before_code
stringlengths
30
149k
reviewer_comment
stringlengths
16
20.6k
after_code
stringlengths
30
163k
diff_context
stringlengths
0
22.4k
file_path
stringlengths
6
155
comment_line
int64
0
26
language
stringclasses
19 values
quality_score
float64
0.07
1
comment_type
stringclasses
9 values
comment_length
int64
16
20.6k
before_lines
int64
2
4.61k
after_lines
int64
2
4.4k
is_negative
bool
2 classes
pr_title
stringlengths
7
140
pr_number
int64
18
61.2k
repo_name
stringclasses
29 values
repo_stars
int64
321
56k
repo_language
stringclasses
14 values
reviewer_username
stringclasses
378 values
author_username
stringclasses
739 values
user
stringlengths
361
200k
assistant
stringlengths
16
20.6k
system
stringclasses
1 value
protected override string? GetNameCore() { var result = AutomationProperties.GetName(Owner); if (string.IsNullOrWhiteSpace(result) && GetLabeledBy() is AutomationPeer labeledBy) { result = labeledBy.GetName(); } return result...
Use Environment.Newline instead.
protected override string? GetNameCore() { var result = AutomationProperties.GetName(Owner); if (string.IsNullOrWhiteSpace(result) && GetLabeledBy() is AutomationPeer labeledBy) { result = labeledBy.GetName(); } return result...
@@ -117,15 +117,22 @@ protected override IReadOnlyList<AutomationPeer> GetOrCreateChildrenCore() return result; } protected override string? GetHelpTextCore() - { + { var result = AutomationProperties.GetHelpText(Owner); if (string.IsNul...
src/Avalonia.Controls/Automation/Peers/ControlAutomationPeer.cs
26
C#
0.143
suggestion
32
51
51
false
Feat/19059 add automation for validation error
19,161
AvaloniaUI/Avalonia
24,333
C#
robloo
longbuibao
Review this pull request change. Language: C# File: src/Avalonia.Controls/Automation/Peers/ControlAutomationPeer.cs PR Title: Feat/19059 add automation for validation error BEFORE CODE: protected override string? GetNameCore() { var result = AutomationProperties.GetName(Owner); ...
Use Environment.Newline instead.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
using System; using System.Collections.Generic; using System.Linq; using Avalonia.Reactive; using Avalonia.Controls.Metadata; using Avalonia.Controls.Templates; using Avalonia.Data; namespace Avalonia.Controls { /// <summary> /// A control which displays an error notifier when there is a DataValidationError. ...
You shouldn't remove the newline here... @maxkatz6 since formatting only changes aren't allowed we should be much stricter on stuff like this. Still hoping we can get editorconfig rules setup at some point.
using System; using System.Collections.Generic; using System.Linq; using Avalonia.Reactive; using Avalonia.Controls.Metadata; using Avalonia.Controls.Templates; using Avalonia.Data; namespace Avalonia.Controls { /// <summary> /// A control which displays an error notifier when there is a DataValidationError. ...
@@ -5,7 +5,6 @@ using Avalonia.Controls.Metadata; using Avalonia.Controls.Templates; using Avalonia.Data; -
src/Avalonia.Controls/DataValidationErrors.cs
8
C#
0.5
suggestion
208
33
33
false
Feat/19059 add automation for validation error
19,161
AvaloniaUI/Avalonia
24,333
C#
robloo
longbuibao
Review this pull request change. Language: C# File: src/Avalonia.Controls/DataValidationErrors.cs PR Title: Feat/19059 add automation for validation error BEFORE CODE: using System; using System.Collections.Generic; using System.Linq; using Avalonia.Reactive; using Avalonia.Controls.Metadata; using Avalonia.Control...
You shouldn't remove the newline here... @maxkatz6 since formatting only changes aren't allowed we should be much stricter on stuff like this. Still hoping we can get editorconfig rules setup at some point.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
internal bool IsQueued => Chain != null; private EventHandler? _aborted; private EventHandler? _completed; private DispatcherPriority _priority; private ExecutionContext? _executionContext; internal DispatcherOperation(Dispatcher dispatcher, DispatcherPriority priority, Action callback, bool ...
WPF checks for ExecutionContext.IsFlowSuppressed() - https://github.com/dotnet/wpf/blob/main/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/CulturePreservingExecutionContext.cs#L85
internal DispatcherOperation? SequentialPrev { get; set; } internal DispatcherOperation? SequentialNext { get; set; } internal DispatcherOperation? PriorityPrev { get; set; } internal DispatcherOperation? PriorityNext { get; set; } internal PriorityChain? Chain { get; set; } internal bool IsQu...
@@ -52,6 +53,7 @@ private protected DispatcherOperation(Dispatcher dispatcher, DispatcherPriority ThrowOnUiThread = throwOnUiThread; Priority = priority; Dispatcher = dispatcher; + _executionContext = ExecutionContext.Capture();
src/Avalonia.Base/Threading/DispatcherOperation.cs
26
C#
0.357
suggestion
181
51
51
false
Capture ExecutionContext for Dispatcher.InvokeAsync
19,163
AvaloniaUI/Avalonia
24,333
C#
kekekeks
walterlv
Review this pull request change. Language: C# File: src/Avalonia.Base/Threading/DispatcherOperation.cs PR Title: Capture ExecutionContext for Dispatcher.InvokeAsync BEFORE CODE: internal bool IsQueued => Chain != null; private EventHandler? _aborted; private EventHandler? _completed; private Dispa...
WPF checks for ExecutionContext.IsFlowSuppressed() - https://github.com/dotnet/wpf/blob/main/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/CulturePreservingExecutionContext.cs#L85
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
{ return null; } var context = ExecutionContext.Capture(); if (context == null) return null; return new CulturePreservingExecutionContext(context); } /// <summary> /// Runs the specified callback in the captured execution context while prese...
Since this version is "modernized", might as well make ContextCallback to be typed `ContextCallback<T>` to save on that cast later.
/// </summary> /// <returns>A new CulturePreservingExecutionContext instance, or null if no context needs to be captured.</returns> public static CulturePreservingExecutionContext? Capture() { // ExecutionContext.SuppressFlow had been called. // We expect ExecutionContext.Capture() to re...
@@ -0,0 +1,151 @@ +using System; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.Globalization; +using System.Threading; + +namespace Avalonia.Threading; + +/// <summary> +/// An ExecutionContext that preserves culture information across async operations. +/// This is a modernized vers...
src/Avalonia.Base/Threading/CulturePreservingExecutionContext.cs
26
C#
0.643
suggestion
131
51
51
false
Capture ExecutionContext for Dispatcher.InvokeAsync
19,163
AvaloniaUI/Avalonia
24,333
C#
kekekeks
walterlv
Review this pull request change. Language: C# File: src/Avalonia.Base/Threading/CulturePreservingExecutionContext.cs PR Title: Capture ExecutionContext for Dispatcher.InvokeAsync BEFORE CODE: { return null; } var context = ExecutionContext.Capture(); if (context == null)...
Since this version is "modernized", might as well make ContextCallback to be typed `ContextCallback<T>` to save on that cast later.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
using System; using System.Collections.Generic; using System.Text; using Avalonia.Media.TextFormatting; using Avalonia.Metadata; namespace Avalonia.Controls.Documents { /// <summary> /// Span element used for grouping other Inline elements. /// </summary> public class Span : Inline, IAddChild { ...
Can we use the typed IAddChild<T> instead?
using System; using System.Collections.Generic; using System.Text; using Avalonia.Media.TextFormatting; using Avalonia.Metadata; namespace Avalonia.Controls.Documents { /// <summary> /// Span element used for grouping other Inline elements. /// </summary> public class Span : Inline, IAddChild<Inline>, ...
@@ -9,7 +9,7 @@ namespace Avalonia.Controls.Documents /// <summary> /// Span element used for grouping other Inline elements. /// </summary> - public class Span : Inline + public class Span : Inline, IAddChild
src/Avalonia.Controls/Documents/Span.cs
12
C#
0.286
question
42
37
37
false
Share Avalonia.Controls with Avalonia.Controls.Documents
19,191
AvaloniaUI/Avalonia
24,333
C#
kekekeks
Gillibald
Review this pull request change. Language: C# File: src/Avalonia.Controls/Documents/Span.cs PR Title: Share Avalonia.Controls with Avalonia.Controls.Documents BEFORE CODE: using System; using System.Collections.Generic; using System.Text; using Avalonia.Media.TextFormatting; using Avalonia.Metadata; namespace Aval...
Can we use the typed IAddChild<T> instead?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
default: resizeBehavior = GridResizeBehavior.PreviousAndNext; break; } } } return resizeBehavior; } /// <summary> /// Removes preview adorner from the gri...
Nit: this can be added to the `switch` below as a `case Grid`.
default: resizeBehavior = GridResizeBehavior.PreviousAndNext; break; } } } return resizeBehavior; } /// <summary> /// Removes preview adorner from the gri...
@@ -205,13 +206,50 @@ private void RemovePreviewAdorner() } } + private Grid? GetParentGrid() + { + var grid = Parent as Grid; + if (grid is not null)
src/Avalonia.Controls/GridSplitter.cs
26
C#
0.357
nitpick
62
51
51
false
Fix usage of GridSplitter inside ItemsControl as ItemsPanel
19,200
AvaloniaUI/Avalonia
24,333
C#
MrJul
wieslawsoltes
Review this pull request change. Language: C# File: src/Avalonia.Controls/GridSplitter.cs PR Title: Fix usage of GridSplitter inside ItemsControl as ItemsPanel BEFORE CODE: default: resizeBehavior = GridResizeBehavior.PreviousAndNext; b...
Nit: this can be added to the `switch` below as a `case Grid`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
layer.Children.Remove(_resizeData.Adorner); } } private Grid? GetParentGrid() { var grid = Parent as Grid; if (grid is not null) { return grid; } // When GridSplitter is used inside an Items...
I'm not sure I like having such a specialization here. It seems a bit odd to have `GridSplitter` know about every possible hierarchy it could be in. That said, introducing some abstraction just for this purpose sounds like over engineering...
layer.Children.Remove(_resizeData.Adorner); } } /// <summary> /// Initialize the data needed for resizing. /// </summary> private void InitializeData(bool showsPreview) { // If not in a grid or can't resize, do nothing. ...
@@ -205,13 +206,50 @@ private void RemovePreviewAdorner() } } + private Grid? GetParentGrid() + { + var grid = Parent as Grid; + if (grid is not null) + { + return grid; + } + + // When GridSplitter is used insid...
src/Avalonia.Controls/GridSplitter.cs
26
C#
0.643
refactor
245
51
51
false
Fix usage of GridSplitter inside ItemsControl as ItemsPanel
19,200
AvaloniaUI/Avalonia
24,333
C#
MrJul
wieslawsoltes
Review this pull request change. Language: C# File: src/Avalonia.Controls/GridSplitter.cs PR Title: Fix usage of GridSplitter inside ItemsControl as ItemsPanel BEFORE CODE: layer.Children.Remove(_resizeData.Adorner); } } private Grid? GetParentGrid() { ...
I'm not sure I like having such a specialization here. It seems a bit odd to have `GridSplitter` know about every possible hierarchy it could be in. That said, introducing some abstraction just for this purpose sounds like over engineering...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/// <summary> /// Gets or sets the curent selection range within current surrounding text. /// </summary> public abstract TextSelection Selection { get; set; } /// <summary> /// Sets the non-committed input string /// </summary> public virtual void SetPre...
Add `//TODO12: remove`. Maybe forward the call to `RaiseInputPaneActivationRequested`?
/// <summary> /// Gets or sets the curent selection range within current surrounding text. /// </summary> public abstract TextSelection Selection { get; set; } /// <summary> /// Sets the non-committed input string /// </summary> public virtual void SetPre...
@@ -78,6 +83,7 @@ public virtual void SetPreeditText(string? preeditText, int? cursorPos) SetPreeditText(preeditText); } + [Obsolete] public virtual void ShowInputPanel() { }
src/Avalonia.Base/Input/TextInput/TextInputMethodClient.cs
26
C#
0.429
question
93
51
51
false
Revert 15603, add InputPaneActivationRequested in TextInputMethodClient
19,225
AvaloniaUI/Avalonia
24,333
C#
kekekeks
emmauss
Review this pull request change. Language: C# File: src/Avalonia.Base/Input/TextInput/TextInputMethodClient.cs PR Title: Revert 15603, add InputPaneActivationRequested in TextInputMethodClient BEFORE CODE: /// <summary> /// Gets or sets the curent selection range within current surrounding text. ...
Add `//TODO12: remove`. Maybe forward the call to `RaiseInputPaneActivationRequested`?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
[parent->View otherMouseDragged:event]; break; case NSEventTypeMouseMoved: [parent->View mouseMoved:event]; break; default: break; } } - (void)sendEvent:(NSEvent *_Nonnull)event { // Event-tracking loop for thick titlebar mouse events ...
Not calling `[NSApp sendEvent:ev];` for unknown events can and **will** break other things in the framework.
[parent->View otherMouseDragged:event]; break; case NSEventTypeMouseMoved: [parent->View mouseMoved:event]; break; default: break; } } - (void)sendEvent:(NSEvent *_Nonnull)event { // Event-tracking loop for thick titlebar mouse events ...
@@ -476,8 +476,93 @@ - (NSView*) findRootView:(NSView*)view } } +- (BOOL)isPointInTitlebar:(NSPoint)windowPoint +{ + auto parent = _parent.tryGetWithCast<WindowImpl>(); + if (!parent || !_isExtended) { + return NO; + } + + AvnView* view = parent->View; + NSPoint viewPoint = [view conve...
native/Avalonia.Native/src/OSX/AvnWindow.mm
26
Objective-C++
0.5
suggestion
108
51
51
false
Fixes/osx thick titlebar pointer events streaming, (tabs interface) #15696
19,320
AvaloniaUI/Avalonia
24,333
C#
kekekeks
ErtyHackward
Review this pull request change. Language: Objective-C++ File: native/Avalonia.Native/src/OSX/AvnWindow.mm PR Title: Fixes/osx thick titlebar pointer events streaming, (tabs interface) #15696 BEFORE CODE: [parent->View otherMouseDragged:event]; break; case NSEventTypeMouseMoved: ...
Not calling `[NSApp sendEvent:ev];` for unknown events can and **will** break other things in the framework.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} private void UpdateInertiaScrolling() { #if !TVOS _momentumVelocityX *= DecelerationRate; _momentumVelocityY *= DecelerationRate; var currentMagnitude = Math.Sqrt(_momentumVelocityX * _momentumVelocityX + _momentumVelocityY * _momentumVelocityY); if (currentMagnitude < 0...
Maybe instead check for `_cachedScrollLocation` being `null` and not fire the event? The field being `null` means that StopMomentumScrolling was called, so we don't want to keep sending updates (and shouldn't be in this method anyway).
} private void UpdateInertiaScrolling() { #if !TVOS _momentumVelocityX *= DecelerationRate; _momentumVelocityY *= DecelerationRate; var currentMagnitude = Math.Sqrt(_momentumVelocityX * _momentumVelocityX + _momentumVelocityY * _momentumVelocityY); if (currentMagnitude < 0...
@@ -249,6 +260,127 @@ private static RawInputModifiers ConvertModifierKeys(UIKeyModifierFlags? uiModif return modifier; } + public void HandleScrollWheel(UIPanGestureRecognizer recognizer) + { + switch (recognizer.State) + { + case UIGestureRecognizerState.Began: + ...
src/iOS/Avalonia.iOS/InputHandler.cs
26
C#
0.786
performance
235
51
51
false
[iOS] Enable Pointer/Trackpad scrolling
19,342
AvaloniaUI/Avalonia
24,333
C#
kekekeks
drasticactions
Review this pull request change. Language: C# File: src/iOS/Avalonia.iOS/InputHandler.cs PR Title: [iOS] Enable Pointer/Trackpad scrolling BEFORE CODE: } private void UpdateInertiaScrolling() { #if !TVOS _momentumVelocityX *= DecelerationRate; _momentumVelocityY *= DecelerationRate; ...
Maybe instead check for `_cachedScrollLocation` being `null` and not fire the event? The field being `null` means that StopMomentumScrolling was called, so we don't want to keep sending updates (and shouldn't be in this method anyway).
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
{ base.OnGotFocus(e); FocusChanged(IsKeyboardFocusWithin); } /// <inheritdoc /> protected override void OnLostFocus(RoutedEventArgs e) { CommitInput(true); base.OnLostFocus(e); FocusChanged(IsKeyboardFocusWithin); ...
We can revert all the changes and just add one line ```csharp TextBox[!TabIndexProperty] = this[!TabIndexProperty]; ```
{ base.OnGotFocus(e); FocusChanged(IsKeyboardFocusWithin); } /// <inheritdoc /> protected override void OnLostFocus(RoutedEventArgs e) { CommitInput(true); base.OnLostFocus(e); FocusChanged(IsKeyboardFocusWithin); ...
@@ -408,6 +409,7 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e) if (TextBox != null) { TextBox.Text = Text; + TextBox.TabIndex = TabIndex;
src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs
26
C#
0.786
suggestion
135
51
51
false
Track TabIndex value in NumericUpDown
19,348
AvaloniaUI/Avalonia
24,333
C#
rabbitism
drasticactions
Review this pull request change. Language: C# File: src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs PR Title: Track TabIndex value in NumericUpDown BEFORE CODE: { base.OnGotFocus(e); FocusChanged(IsKeyboardFocusWithin); } /// <inheritdoc /> protected ove...
We can revert all the changes and just add one line ```csharp TextBox[!TabIndexProperty] = this[!TabIndexProperty]; ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
base.OnGotFocus(e); FocusChanged(IsKeyboardFocusWithin); } /// <inheritdoc /> protected override void OnLostFocus(RoutedEventArgs e) { CommitInput(true); base.OnLostFocus(e); FocusChanged(IsKeyboardFocusWithin); } ...
Can't we use the new focus redirection capability introduced in #18373? There are probably other ways than `TabIndex` to have the focus not properly reach the `TextBox`?
{ base.OnGotFocus(e); FocusChanged(IsKeyboardFocusWithin); } /// <inheritdoc /> protected override void OnLostFocus(RoutedEventArgs e) { CommitInput(true); base.OnLostFocus(e); FocusChanged(IsKeyboardFocusWithin); ...
@@ -408,6 +408,7 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e) if (TextBox != null) { TextBox.Text = Text; + TextBox[!TabIndexProperty] = this[!TabIndexProperty];
src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs
26
C#
0.571
question
171
51
51
false
Track TabIndex value in NumericUpDown
19,348
AvaloniaUI/Avalonia
24,333
C#
MrJul
drasticactions
Review this pull request change. Language: C# File: src/Avalonia.Controls/NumericUpDown/NumericUpDown.cs PR Title: Track TabIndex value in NumericUpDown BEFORE CODE: base.OnGotFocus(e); FocusChanged(IsKeyboardFocusWithin); } /// <inheritdoc /> protected override void...
Can't we use the new focus redirection capability introduced in #18373? There are probably other ways than `TabIndex` to have the focus not properly reach the `TextBox`?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
if (OperatingSystem.IsIOSVersionAtLeast(14)) { documentPicker = new UIDocumentPickerViewController(new[] { tempFileUrl }, asCopy: true); } else { #pragma warning disable CA1422 documentPicker = new UIDocumentPickerViewController(tempFileUrl, UIDocumentPick...
In addition to the file, shouldn't the temporary directory be deleted?
{ #pragma warning disable CA1422 documentPicker = new UIDocumentPickerViewController(tempFileUrl, UIDocumentPickerMode.ExportToService); #pragma warning restore CA1422 } using (documentPicker) { if (OperatingSystem.IsIOSVersionAtLeast(13)) { ...
@@ -161,10 +161,77 @@ private async Task<IReadOnlyList<IStorageFile>> OpenDocumentsPickerAsync(FilePic return Task.FromResult<IStorageFolder?>(new IOSStorageFolder(uri, wellKnownFolder)); } - public Task<IStorageFile?> SaveFilePickerAsync(FilePickerSaveOptions options) + public async Task<IStorage...
src/iOS/Avalonia.iOS/Storage/IOSStorageProvider.cs
26
C#
0.286
question
70
51
51
false
[iOS] Implement Save File Picker Support
19,364
AvaloniaUI/Avalonia
24,333
C#
MrJul
drasticactions
Review this pull request change. Language: C# File: src/iOS/Avalonia.iOS/Storage/IOSStorageProvider.cs PR Title: [iOS] Implement Save File Picker Support BEFORE CODE: if (OperatingSystem.IsIOSVersionAtLeast(14)) { documentPicker = new UIDocumentPickerViewController(new[] { tempFileUrl },...
In addition to the file, shouldn't the temporary directory be deleted?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
if (uri is null) { return Task.FromResult<IStorageFolder?>(null); } return Task.FromResult<IStorageFolder?>(new IOSStorageFolder(uri, wellKnownFolder)); } public async Task<IStorageFile?> SaveFilePickerAsync(FilePickerSaveOptions options) { /* ...
You can use NameWithExtension helper method https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Base/Platform/Storage/FileIO/StorageProviderHelpers.cs#L65
if (uri is null) { return Task.FromResult<IStorageFolder?>(null); } return Task.FromResult<IStorageFolder?>(new IOSStorageFolder(uri, wellKnownFolder)); } public async Task<IStorageFile?> SaveFilePickerAsync(FilePickerSaveOptions options) { /* ...
@@ -161,10 +161,77 @@ private async Task<IReadOnlyList<IStorageFile>> OpenDocumentsPickerAsync(FilePic return Task.FromResult<IStorageFolder?>(new IOSStorageFolder(uri, wellKnownFolder)); } - public Task<IStorageFile?> SaveFilePickerAsync(FilePickerSaveOptions options) + public async Task<IStorage...
src/iOS/Avalonia.iOS/Storage/IOSStorageProvider.cs
26
C#
0.429
refactor
166
51
51
false
[iOS] Implement Save File Picker Support
19,364
AvaloniaUI/Avalonia
24,333
C#
maxkatz6
drasticactions
Review this pull request change. Language: C# File: src/iOS/Avalonia.iOS/Storage/IOSStorageProvider.cs PR Title: [iOS] Implement Save File Picker Support BEFORE CODE: if (uri is null) { return Task.FromResult<IStorageFolder?>(null); } return Task.FromResult<IStorageFolde...
You can use NameWithExtension helper method https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Base/Platform/Storage/FileIO/StorageProviderHelpers.cs#L65
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
using Avalonia.Platform; using Avalonia.Win32.Interop; using static Avalonia.Win32.Interop.UnmanagedMethods; namespace Avalonia.Win32 { internal class TrayIconImpl : ITrayIconImpl { private static readonly Win32Icon s_emptyIcon; private readonly int _uniqueId; private static int s_nextU...
[`ChangeWindowMessageFilter`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-changewindowmessagefilter) is deprecated: [`ChangeWindowMessageFilterEx`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-changewindowmessagefilterex) is recommended instead. Please use it in `Win...
using Avalonia.Platform; using Avalonia.Win32.Interop; using static Avalonia.Win32.Interop.UnmanagedMethods; namespace Avalonia.Win32 { internal class TrayIconImpl : ITrayIconImpl { private static readonly Win32Icon s_emptyIcon; private readonly int _uniqueId; private static int s_nextU...
@@ -33,6 +33,7 @@ internal class TrayIconImpl : ITrayIconImpl static TrayIconImpl() { + ChangeWindowMessageFilter(WM_TASKBARCREATED, MessageFilterFlag.MSGFLT_ADD);
src/Windows/Avalonia.Win32/TrayIconImpl.cs
26
C#
0.643
suggestion
352
51
51
false
Enable tray icon creation in all circumstances when running as an admin
19,382
AvaloniaUI/Avalonia
24,333
C#
MrJul
Wesley-Lin-coder
Review this pull request change. Language: C# File: src/Windows/Avalonia.Win32/TrayIconImpl.cs PR Title: Enable tray icon creation in all circumstances when running as an admin BEFORE CODE: using Avalonia.Platform; using Avalonia.Win32.Interop; using static Avalonia.Win32.Interop.UnmanagedMethods; namespace Avalon...
[`ChangeWindowMessageFilter`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-changewindowmessagefilter) is deprecated: [`ChangeWindowMessageFilterEx`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-changewindowmessagefilterex) is recommended instead. Please use it in `Win...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
GCLP_MENUNAME = -8, GCLP_HBRBACKGROUND = -10, GCLP_HCURSOR = -12, GCLP_HICON = -14, GCLP_HMODULE = -16, GCL_CBWNDEXTRA = -18, GCL_CBCLSEXTRA = -20, GCLP_WNDPROC = -24, GCL_STYLE = -26, GCLP_HICONSM = ...
Change the enum to `MSGFLT_RESET/MSGFLT_ALLOW/MSGFLT_DISALLOW`, matching the documentation of `ChangeWindowMessageFilterEx`.
GCLP_MENUNAME = -8, GCLP_HBRBACKGROUND = -10, GCLP_HCURSOR = -12, GCLP_HICON = -14, GCLP_HMODULE = -16, GCL_CBWNDEXTRA = -18, GCL_CBCLSEXTRA = -20, GCLP_WNDPROC = -24, GCL_STYLE = -26, GCLP_HICONSM = ...
@@ -1502,6 +1502,19 @@ public enum ClassLongIndex : int [DllImport("shell32", CharSet = CharSet.Auto)] public static extern int Shell_NotifyIcon(NIM dwMessage, NOTIFYICONDATA lpData); + [DllImport("user32.dll", SetLastError = true)] + public static extern bool ChangeWindowMessageFilter...
src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs
26
C#
0.571
suggestion
124
51
51
false
Enable tray icon creation in all circumstances when running as an admin
19,382
AvaloniaUI/Avalonia
24,333
C#
MrJul
Wesley-Lin-coder
Review this pull request change. Language: C# File: src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs PR Title: Enable tray icon creation in all circumstances when running as an admin BEFORE CODE: GCLP_MENUNAME = -8, GCLP_HBRBACKGROUND = -10, GCLP_HCURSOR = -12, ...
Change the enum to `MSGFLT_RESET/MSGFLT_ALLOW/MSGFLT_DISALLOW`, matching the documentation of `ChangeWindowMessageFilterEx`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
{ private static readonly Win32Icon s_emptyIcon; private readonly int _uniqueId; private static int s_nextUniqueId; private static nint s_taskBarMonitor; private bool _iconAdded; private IconImpl? _iconImpl; private bool _iconStale; private Win32Icon?...
Nit: a space is missing before `MessageFilterFlag`.
{ private static readonly Win32Icon s_emptyIcon; private readonly int _uniqueId; private static int s_nextUniqueId; private static nint s_taskBarMonitor; private bool _iconAdded; private IconImpl? _iconImpl; private bool _iconStale; private Win32Icon?...
@@ -37,7 +37,12 @@ static TrayIconImpl() new PixelSize(32, 32), new Vector(96, 96), PixelFormats.Bgra8888, AlphaFormat.Unpremul); s_emptyIcon = new Win32Icon(bitmap); } - + + internal static void ChangeWindowMessageFilter(IntPtr hWnd) + { + ChangeW...
src/Windows/Avalonia.Win32/TrayIconImpl.cs
26
C#
0.357
nitpick
51
51
51
false
Enable tray icon creation in all circumstances when running as an admin
19,382
AvaloniaUI/Avalonia
24,333
C#
MrJul
Wesley-Lin-coder
Review this pull request change. Language: C# File: src/Windows/Avalonia.Win32/TrayIconImpl.cs PR Title: Enable tray icon creation in all circumstances when running as an admin BEFORE CODE: { private static readonly Win32Icon s_emptyIcon; private readonly int _uniqueId; private static in...
Nit: a space is missing before `MessageFilterFlag`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/// </summary> public sealed class WeakEvent<TSender, TEventArgs> : WeakEvent where TSender : class { private readonly Func<TSender, EventHandler<TEventArgs>, Action> _subscribe; private readonly ConditionalWeakTable<object, Subscription> _subscriptions = new(); internal WeakEvent( Action<TSender,...
This isn't correct, the `SpinWait` returned from `Nullable<SpinWait>` is a copy, meaning no state gets persisted. You might as well initialize the `SpinWait` directly here, it's a single int in size.
/// </summary> public sealed class WeakEvent<TSender, TEventArgs> : WeakEvent where TSender : class { private readonly Func<TSender, EventHandler<TEventArgs>, Action> _subscribe; private readonly ConditionalWeakTable<TSender, Subscription> _subscriptions = new(); private readonly ConditionalWeakTable<TSende...
@@ -23,22 +25,27 @@ internal WeakEvent( return () => unsubscribe(t, s); }; } - + internal WeakEvent(Func<TSender, EventHandler<TEventArgs>, Action> subscribe) { _subscribe = subscribe; } - + public void Subscribe(TSender target, IWeakEventSubscriber<TEvent...
src/Avalonia.Base/Utilities/WeakEvent.cs
26
C#
0.643
suggestion
199
51
51
false
WeakEvent subscription management thread race condition fix
19,383
AvaloniaUI/Avalonia
24,333
C#
MrJul
11v1
Review this pull request change. Language: C# File: src/Avalonia.Base/Utilities/WeakEvent.cs PR Title: WeakEvent subscription management thread race condition fix BEFORE CODE: /// </summary> public sealed class WeakEvent<TSender, TEventArgs> : WeakEvent where TSender : class { private readonly Func<TSender, Eve...
This isn't correct, the `SpinWait` returned from `Nullable<SpinWait>` is a copy, meaning no state gets persisted. You might as well initialize the `SpinWait` directly here, it's a single int in size.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
private readonly Func<TSender, EventHandler<TEventArgs>, Action> _subscribe; private readonly ConditionalWeakTable<object, Subscription> _subscriptions = new(); internal WeakEvent( Action<TSender, EventHandler<TEventArgs>> subscribe, Action<TSender, EventHandler<TEventArgs>> unsubscribe) ...
To avoid an additional delegate creation here, consider using the parameter instead of capturing `target`. Then cache the delegate instance. Example: ```csharp private ConditionalWeakTable<object, Subscription>.CreateValueCallback? _createSubscription; public void Subscribe(...) { _createSubscription ??= CreateS...
private readonly Func<TSender, EventHandler<TEventArgs>, Action> _subscribe; private readonly ConditionalWeakTable<TSender, Subscription> _subscriptions = new(); private readonly ConditionalWeakTable<TSender, Subscription>.CreateValueCallback _createSubscription; internal WeakEvent( Action<TSen...
@@ -23,22 +25,27 @@ internal WeakEvent( return () => unsubscribe(t, s); }; } - + internal WeakEvent(Func<TSender, EventHandler<TEventArgs>, Action> subscribe) { _subscribe = subscribe; } - + public void Subscribe(TSender target, IWeakEventSubscriber<TEvent...
src/Avalonia.Base/Utilities/WeakEvent.cs
26
C#
0.857
performance
513
51
51
false
WeakEvent subscription management thread race condition fix
19,383
AvaloniaUI/Avalonia
24,333
C#
MrJul
11v1
Review this pull request change. Language: C# File: src/Avalonia.Base/Utilities/WeakEvent.cs PR Title: WeakEvent subscription management thread race condition fix BEFORE CODE: private readonly Func<TSender, EventHandler<TEventArgs>, Action> _subscribe; private readonly ConditionalWeakTable<object, Subscrip...
To avoid an additional delegate creation here, consider using the parameter instead of capturing `target`. Then cache the delegate instance. Example: ```csharp private ConditionalWeakTable<object, Subscription>.CreateValueCallback? _createSubscription; public void Subscribe(...) { _createSubscription ??= CreateS...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
[Export("enablesReturnKeyAutomatically")] public bool EnablesReturnKeyAutomatically { get; set; } [Export("isSecureTextEntry")] public bool IsSecureEntry => _view._options?.ContentType is TextInputContentType.Password or TextInputContentType.Pin || (_view._options?.IsS...
`UITextInputPasswordRules.PasswordRules` is a nullable value for iOS and Catalyst. I'm not sure why it wasn't breaking for iOS normally, but adding Catalyst would break the build to complain about it not being nullable here. Adding the nullable flag fixes it.
[Export("enablesReturnKeyAutomatically")] public bool EnablesReturnKeyAutomatically { get; set; } [Export("isSecureTextEntry")] public bool IsSecureEntry => _view._options?.ContentType is TextInputContentType.Password or TextInputContentType.Pin || (_view._options?.IsS...
@@ -81,7 +81,7 @@ public UIReturnKeyType ReturnKeyType [Export("smartInsertDeleteType")] public UITextSmartInsertDeleteType SmartInsertDeleteType { get; set; } = UITextSmartInsertDeleteType.Default; - [Export("passwordRules")] public UITextInputPasswordRules PasswordRules { get; set; } = null...
src/iOS/Avalonia.iOS/TextInputResponder.Properties.cs
26
C#
0.714
suggestion
259
38
38
false
[v12] Enable Mac Catalyst in Avalonia.iOS
19,415
AvaloniaUI/Avalonia
24,333
C#
drasticactions
drasticactions
Review this pull request change. Language: C# File: src/iOS/Avalonia.iOS/TextInputResponder.Properties.cs PR Title: [v12] Enable Mac Catalyst in Avalonia.iOS BEFORE CODE: [Export("enablesReturnKeyAutomatically")] public bool EnablesReturnKeyAutomatically { get; set; } [Export("isSecureText...
`UITextInputPasswordRules.PasswordRules` is a nullable value for iOS and Catalyst. I'm not sure why it wasn't breaking for iOS normally, but adding Catalyst would break the build to complain about it not being nullable here. Adding the nullable flag fixes it.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
{ if (!string.IsNullOrEmpty(_lastPlacementPseudoclass)) { PseudoClasses.Remove(_lastPlacementPseudoclass); } _lastPlacementPseudoclass = GetPseudoClass(newValue); PseudoClasses.Add(_lastPlacementPseudoclass); } private...
The condition `if (_pointerDisposable == null)` prevents re-subscribing to events when the subscription already exists. This could cause issues if the subscription becomes invalid but the disposable reference still exists. Consider disposing the existing subscription before creating a new one, or add additional checks ...
private void UpdateVisualStateForPanePlacementProperty(SplitViewPanePlacement newValue) { if (!string.IsNullOrEmpty(_lastPlacementPseudoclass)) { PseudoClasses.Remove(_lastPlacementPseudoclass); } _lastPlacementPseudoclass = GetPseudoClass...
@@ -541,27 +543,34 @@ private void UpdateVisualStateForPanePlacementProperty(SplitViewPanePlacement ne PseudoClasses.Add(_lastPlacementPseudoclass); } - private void EnableLightDismiss() + private void InvalidateLightDismissSubscription() { if (_pane == null) ...
src/Avalonia.Controls/SplitView/SplitView.cs
26
C#
0.786
suggestion
362
51
51
false
Fix SplitView incorrectly closing when the user changes DisplayMode to inline when IsPaneOpen is already true
19,460
AvaloniaUI/Avalonia
24,333
C#
Copilot
danwalmsley
Review this pull request change. Language: C# File: src/Avalonia.Controls/SplitView/SplitView.cs PR Title: Fix SplitView incorrectly closing when the user changes DisplayMode to inline when IsPaneOpen is already true BEFORE CODE: { if (!string.IsNullOrEmpty(_lastPlacementPseudoclass)) ...
The condition `if (_pointerDisposable == null)` prevents re-subscribing to events when the subscription already exists. This could cause issues if the subscription becomes invalid but the disposable reference still exists. Consider disposing the existing subscription before creating a new one, or add additional checks ...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
for (var i = 0; i < glyphIndex; i++) { distance += _glyphInfos[i].GlyphAdvance; } return distance; } else { distance = Bounds.Width; //RightToLeft va...
Why the change? The complexity is now `O(N)`. Using the existing `glyphIndex` (the variable is now unused) which was retrieved using binary search in `FindGlyphIndex` was `O(log(N))`. (Also, the LTR and RTL algorithms were symmetric before and aren't anymore). Reverting this completely still makes the two new tests ...
for (var i = 0; i < glyphIndex; i++) { distance += _glyphInfos[i].GlyphAdvance; } return distance; } else { //RightToLeft var glyphIndex = FindGlyphIndex(characterInd...
@@ -293,12 +295,19 @@ public double GetDistanceFromCharacterHit(CharacterHit characterHit) return Bounds.Width; } - for (var i = glyphIndex + 1; i < _glyphInfos.Count; i++) + for (var i = _glyphInfos.Count - 1; i >= 0; i--)
src/Avalonia.Base/Media/GlyphRun.cs
26
C#
0.643
performance
416
51
51
false
Fix zero width space handling
19,488
AvaloniaUI/Avalonia
24,333
C#
MrJul
Gillibald
Review this pull request change. Language: C# File: src/Avalonia.Base/Media/GlyphRun.cs PR Title: Fix zero width space handling BEFORE CODE: for (var i = 0; i < glyphIndex; i++) { distance += _glyphInfos[i].GlyphAdvance; } return ...
Why the change? The complexity is now `O(N)`. Using the existing `glyphIndex` (the variable is now unused) which was retrieved using binary search in `FindGlyphIndex` was `O(log(N))`. (Also, the LTR and RTL algorithms were symmetric before and aren't anymore). Reverting this completely still makes the two new tests ...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} //Detect null terminator if (count > 0) { return new UnshapedTextRun(new string(ZeroWidthSpace, count).AsMemory(), defaultProperties, biDiLevel); } if (TryGetShapeableLength(textSpan, defaultGlyphTypeface, null, out count)) ...
Nit: rename the variable to `graphemeEnumerator`.
} //Detect null terminator if (count > 0) { return new UnshapedTextRun(new string(ZeroWidthSpace, count).AsMemory(), defaultProperties, biDiLevel); } if (TryGetShapeableLength(textSpan, defaultGlyphTypeface, null, out count)) ...
@@ -115,16 +115,11 @@ private static UnshapedTextRun CreateShapeableRun(ReadOnlyMemory<char> text, var codepoint = Codepoint.ReplacementCodepoint; - var codepointEnumerator = new CodepointEnumerator(text.Slice(count).Span); + var codepointEnumerator = new GraphemeEnumerator(text.S...
src/Avalonia.Base/Media/TextFormatting/TextCharacters.cs
26
C#
0.286
nitpick
49
51
51
false
Do not treat combining marks as whitespace
19,498
AvaloniaUI/Avalonia
24,333
C#
MrJul
Gillibald
Review this pull request change. Language: C# File: src/Avalonia.Base/Media/TextFormatting/TextCharacters.cs PR Title: Do not treat combining marks as whitespace BEFORE CODE: } //Detect null terminator if (count > 0) { return new UnshapedTextRun(new s...
Nit: rename the variable to `graphemeEnumerator`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
//Detect null terminator if (count > 0) { return new UnshapedTextRun(new string(ZeroWidthSpace, count).AsMemory(), defaultProperties, biDiLevel); } if (TryGetShapeableLength(textSpan, defaultGlyphTypeface, null, out count)) { ...
This isn't a loop anymore (the `break` is unconditional) and can be simplified to a single `if`.
//Detect null terminator if (count > 0) { return new UnshapedTextRun(new string(ZeroWidthSpace, count).AsMemory(), defaultProperties, biDiLevel); } if (TryGetShapeableLength(textSpan, defaultGlyphTypeface, null, out count)) { ...
@@ -115,16 +115,11 @@ private static UnshapedTextRun CreateShapeableRun(ReadOnlyMemory<char> text, var codepoint = Codepoint.ReplacementCodepoint; - var codepointEnumerator = new CodepointEnumerator(text.Slice(count).Span); + var codepointEnumerator = new GraphemeEnumerator(text.S...
src/Avalonia.Base/Media/TextFormatting/TextCharacters.cs
26
C#
0.357
suggestion
96
51
51
false
Do not treat combining marks as whitespace
19,498
AvaloniaUI/Avalonia
24,333
C#
MrJul
Gillibald
Review this pull request change. Language: C# File: src/Avalonia.Base/Media/TextFormatting/TextCharacters.cs PR Title: Do not treat combining marks as whitespace BEFORE CODE: //Detect null terminator if (count > 0) { return new UnshapedTextRun(new string(ZeroWidth...
This isn't a loop anymore (the `break` is unconditional) and can be simplified to a single `if`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
set => SetValue(TransformProperty, value); } /// <summary> /// Gets or sets the origin of the brush <see cref="Transform"/> /// </summary> public RelativePoint TransformOrigin { get => GetValue(TransformOriginProperty); set => SetValue...
This is now redundant. I actually think we should remove `KnownColors.GetKnownBrush()` completely here and mark as obsolete in v12. It doesn't do anything special for brush that color doesn't already provide.
set => SetValue(TransformProperty, value); } /// <summary> /// Gets or sets the origin of the brush <see cref="Transform"/> /// </summary> public RelativePoint TransformOrigin { get => GetValue(TransformOriginProperty); set => SetValue...
@@ -73,9 +71,9 @@ public static IBrush Parse(string s) if (s.Length > 0) { - if (s[0] == '#') + if (Color.TryParse(s, out Color color)) { - return new ImmutableSolidColorBrush(Color.Parse(s)); + return new I...
src/Avalonia.Base/Media/Brush.cs
26
C#
0.643
suggestion
208
51
51
false
Update Brush.Parse() to Handle all Color Formats
19,526
AvaloniaUI/Avalonia
24,333
C#
robloo
robloo
Review this pull request change. Language: C# File: src/Avalonia.Base/Media/Brush.cs PR Title: Update Brush.Parse() to Handle all Color Formats BEFORE CODE: set => SetValue(TransformProperty, value); } /// <summary> /// Gets or sets the origin of the brush <see cref="Transform"/...
This is now redundant. I actually think we should remove `KnownColors.GetKnownBrush()` completely here and mark as obsolete in v12. It doesn't do anything special for brush that color doesn't already provide.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
private IDisposable EnsureApplication() { var scope = AvaloniaLocator.EnterScope(); try { Dispatcher.ResetForUnitTests(); _appBuilder.SetupUnsafe(); } catch { scope.Dispose(); throw; } return Dispos...
Also reordered operations here to match https://github.com/AvaloniaUI/Avalonia/blob/22f3c026dfb16f68808235cee01176f590ca4cf8/tests/Avalonia.UnitTests/UnitTestApplication.cs#L40-L61
return tcs.Task; } private IDisposable EnsureApplication() { var scope = AvaloniaLocator.EnterScope(); var oldContext = SynchronizationContext.Current; try { Dispatcher.ResetBeforeUnitTests(); _appBuilder.SetupUnsafe(); } catch...
@@ -137,9 +140,12 @@ private IDisposable EnsureApplication() return Disposable.Create(() => { - scope.Dispose(); + ((ToolTipService?)AvaloniaLocator.Current.GetService<IToolTipService>())?.Dispose(); + (AvaloniaLocator.Current.GetService<FontManager>() as IDisposable...
src/Headless/Avalonia.Headless/HeadlessUnitTestSession.cs
26
C#
0.357
suggestion
180
51
51
false
Fix headless FontManager leak
19,599
AvaloniaUI/Avalonia
24,333
C#
maxkatz6
maxkatz6
Review this pull request change. Language: C# File: src/Headless/Avalonia.Headless/HeadlessUnitTestSession.cs PR Title: Fix headless FontManager leak BEFORE CODE: private IDisposable EnsureApplication() { var scope = AvaloniaLocator.EnterScope(); try { Dispatcher.ResetFo...
Also reordered operations here to match https://github.com/AvaloniaUI/Avalonia/blob/22f3c026dfb16f68808235cee01176f590ca4cf8/tests/Avalonia.UnitTests/UnitTestApplication.cs#L40-L61
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
Assert.NotNull(textLine); var textBounds = textLine.GetTextBounds(10, 1); Assert.Equal(1, textBounds.Count); var firstBounds = textBounds[0]; Assert.NotEmpty(firstBounds.TextRunBounds); var firstRunBounds = firstBounds...
```suggestion var text = "a\u202C\u202C\u202C\u202Cb"; ```
Assert.NotNull(textLine); var textBounds = textLine.GetTextBounds(10, 1); Assert.Equal(1, textBounds.Count); var firstBounds = textBounds[0]; Assert.NotEmpty(firstBounds.TextRunBounds); var firstRunBounds = firstBounds...
@@ -2011,6 +2011,42 @@ public void Should_Get_TextBounds_With_Mixed_Runs_Within_Cluster() } } + [Fact] + public void Should_Get_TextBounds_With_Glue() + { + using (Start()) + { + var typeface = Typeface.Default; + + var def...
tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextLineTests.cs
26
C#
0.571
suggestion
74
51
51
false
TextLine.GetTextBounds zero width run fixes
19,602
AvaloniaUI/Avalonia
24,333
C#
miloush
Gillibald
Review this pull request change. Language: C# File: tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextLineTests.cs PR Title: TextLine.GetTextBounds zero width run fixes BEFORE CODE: Assert.NotNull(textLine); var textBounds = textLine.GetTextBounds(10, 1); Asse...
```suggestion var text = "a\u202C\u202C\u202C\u202Cb"; ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
var shaperOption = new TextShaperOptions(typeface.GlyphTypeface); var textSource = new SingleBufferTextSource(text, defaultProperties); var formatter = new TextFormatterImpl(); var textLine = formatter.FormatLine(textSource, 0, doubl...
An assert of the correct bounds should probably be added here if it's possible?
var shaperOption = new TextShaperOptions(typeface.GlyphTypeface); var textSource = new SingleBufferTextSource(text, defaultProperties); var formatter = new TextFormatterImpl(); var textLine = formatter.FormatLine(textSource, 0, doubl...
@@ -2135,6 +2135,32 @@ public void Should_Get_TextBounds_Tamil() } } + [Fact] + public void Should_GetTextBounds_Trailing_ZeroWidth() + { + var text = "dasdsad\r\n"; + + using (Start()) + { + var typeface = Typeface.Default; + ...
tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextLineTests.cs
26
C#
0.286
question
79
51
51
false
Fixes TextLineImpl.GetTextBounds with trailing zero width
19,616
AvaloniaUI/Avalonia
24,333
C#
MrJul
Gillibald
Review this pull request change. Language: C# File: tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextLineTests.cs PR Title: Fixes TextLineImpl.GetTextBounds with trailing zero width BEFORE CODE: var shaperOption = new TextShaperOptions(typeface.GlyphTypeface); var textSource =...
An assert of the correct bounds should probably be added here if it's possible?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
return false; s = _arr[_index]; _index++; return true; } public string ReadString() { if(!TryReadString(out var rv)) throw new FormatException(); return rv; ...
Unrelated to this PR, this seems to be missing `IsInset`.
/// <summary> /// Gets or sets a value indicating whether the shadow is inset and drawn within the element rather than outside of it. /// </summary> /// <remarks> /// Inset changes the shadow to inside the element (as if the content was depressed inside the box). /// If ...
@@ -6,25 +6,90 @@ namespace Avalonia.Media { + /// <summary> + /// Represents a box shadow which can be attached to an element or control. + /// </summary> public struct BoxShadow { + private readonly static char[] s_Separator = new char[] { ' ', '\t' }; + + /// <summary> + /...
src/Avalonia.Base/Media/BoxShadow.cs
26
C#
0.357
suggestion
57
51
51
false
Add Boxshadow(s) Documentation Comments
19,644
AvaloniaUI/Avalonia
24,333
C#
MrJul
robloo
Review this pull request change. Language: C# File: src/Avalonia.Base/Media/BoxShadow.cs PR Title: Add Boxshadow(s) Documentation Comments BEFORE CODE: return false; s = _arr[_index]; _index++; return true; } public string ...
Unrelated to this PR, this seems to be missing `IsInset`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} case WindowsMessage.WM_MOUSELEAVE: { if (IsMouseInPointerEnabled) { break; } _trackingMouse = false; e = new RawP...
There's a different instance of `IMouseDevice` (and associated `IPointer`) per window. Consequently, we should probably not check other windows, or pointers from them will keep the capture even though they don't have it anymore. (Note that having a mouse device per window causes other problems but this isn't the ri...
case WindowsMessage.WM_MOUSELEAVE: { if (IsMouseInPointerEnabled) { break; } _trackingMouse = false; e = new RawPointerEventArgs( ...
@@ -394,6 +395,26 @@ protected virtual unsafe IntPtr AppWndProc(IntPtr hWnd, uint msg, IntPtr wParam, break; } + case WindowsMessage.WM_CAPTURECHANGED: + { + if (IsMouseInPointerEnabled) + { +...
src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs
26
C#
0.643
suggestion
343
51
51
false
Respond to WM_CAPTURECHANGED
19,685
AvaloniaUI/Avalonia
24,333
C#
MrJul
miloush
Review this pull request change. Language: C# File: src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs PR Title: Respond to WM_CAPTURECHANGED BEFORE CODE: } case WindowsMessage.WM_MOUSELEAVE: { if (IsMouseInPointerEnabled) ...
There's a different instance of `IMouseDevice` (and associated `IPointer`) per window. Consequently, we should probably not check other windows, or pointers from them will keep the capture even though they don't have it anymore. (Note that having a mouse device per window causes other problems but this isn't the ri...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
private Size _savedLogicalSize; private double _savedScaling; private WindowTransparencyLevel _transparencyLevel = WindowTransparencyLevel.None; protected MacOSTopLevelHandle? _handle; private object _syncRoot = new object(); private IEnumerable<object>? _surfaces; public TopLevelImpl(IA...
```suggestion _savedScaling = Native?.Scaling ?? 1; ```
private Size _savedLogicalSize; private double _savedScaling; private WindowTransparencyLevel _transparencyLevel = WindowTransparencyLevel.None; protected MacOSTopLevelHandle? _handle; private object _syncRoot = new object(); private IEnumerable<object>? _surfaces; public TopLevelImpl(IA...
@@ -98,13 +98,19 @@ internal virtual void Init(MacOSTopLevelHandle handle) { _handle = handle; _savedLogicalSize = ClientSize; - _savedScaling = Native?.Scaling ?? 1;; + _savedScaling = Native?.Scaling ?? 1; + ;
src/Avalonia.Native/TopLevelImpl.cs
26
C#
0.571
suggestion
65
51
51
false
[OSX] Move Drag and Drop logic to TopLevelImpl
19,731
AvaloniaUI/Avalonia
24,333
C#
maxkatz6
drasticactions
Review this pull request change. Language: C# File: src/Avalonia.Native/TopLevelImpl.cs PR Title: [OSX] Move Drag and Drop logic to TopLevelImpl BEFORE CODE: private Size _savedLogicalSize; private double _savedScaling; private WindowTransparencyLevel _transparencyLevel = WindowTransparencyLevel.None; ...
```suggestion _savedScaling = Native?.Scaling ?? 1; ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
private MARGINS UpdateExtendMargins() { RECT borderThickness = new RECT(); RECT borderCaptionThickness = new RECT(); var scaling = (uint)(RenderScaling * StandardDpi); var relativeScaling = RenderScaling / PrimaryScreenRenderScaling; if (Win3...
Use the `scaling` variable (currently unused) here and on the line below.
private MARGINS UpdateExtendMargins() { RECT borderThickness = new RECT(); RECT borderCaptionThickness = new RECT(); var scaling = (uint)(RenderScaling * StandardDpi); var relativeScaling = RenderScaling / PrimaryScreenRenderScaling; if (Win3...
@@ -1100,8 +1100,30 @@ private MARGINS UpdateExtendMargins() RECT borderThickness = new RECT(); RECT borderCaptionThickness = new RECT(); - AdjustWindowRectEx(ref borderCaptionThickness, (uint)(GetStyle()), false, 0); - AdjustWindowRectEx(ref borderThickness, (uint)(Get...
src/Windows/Avalonia.Win32/WindowImpl.cs
26
C#
0.429
suggestion
73
51
51
false
Win32 - Fix margins and nc hit test for caption buttons in extend to client windows
19,773
AvaloniaUI/Avalonia
24,333
C#
MrJul
emmauss
Review this pull request change. Language: C# File: src/Windows/Avalonia.Win32/WindowImpl.cs PR Title: Win32 - Fix margins and nc hit test for caption buttons in extend to client windows BEFORE CODE: private MARGINS UpdateExtendMargins() { RECT borderThickness = new RECT(); ...
Use the `scaling` variable (currently unused) here and on the line below.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
switch (NotificationType) { case NotificationType.Error: PseudoClasses.Add(":error"); break; case NotificationType.Information: PseudoClasses.Add(":information"); break; ...
Please remove this new public API member. Use `Equals(Content, o.Content)` directly in the single caller.
using System; using System.Linq; using Avalonia.Controls.Metadata; using Avalonia.Interactivity; using Avalonia.LogicalTree; namespace Avalonia.Controls.Notifications { /// <summary> /// Control that represents and displays a notification. /// </summary> [PseudoClasses(":error", ":information", ":succe...
@@ -190,5 +189,12 @@ private void UpdateNotificationType() break; } } + + /// <summary> + /// Determines whether the <see cref="NotificationCard"/>'s content is equal to the specified object. + /// </summary> + /// <param name="o">The object with wh...
src/Avalonia.Controls/Notifications/NotificationCard.cs
26
C#
0.571
refactor
105
29
194
false
Fixed ArgumentException when showing multiple notifications with the same content
19,774
AvaloniaUI/Avalonia
24,333
C#
MrJul
fgsfds
Review this pull request change. Language: C# File: src/Avalonia.Controls/Notifications/NotificationCard.cs PR Title: Fixed ArgumentException when showing multiple notifications with the same content BEFORE CODE: switch (NotificationType) { case NotificationType.Error: ...
Please remove this new public API member. Use `Equals(Content, o.Content)` directly in the single caller.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using Avalonia.Controls.Metadata; using Avalonia.Controls.Primitives; using Avalonia.Threading; using Avalonia.VisualTree; namespace Avalonia.Controls.Notifications { /// <summary> /// An <see cref="INotificationManage...
Nitpicking here, but this is only for unit tests and copies the collection on each access, which is a bit unusual for properties. Consider refactoring this to a `IEnumerable<NotificationCard> GetNotifications()` method that doesn't copy, and do the copy manually in tests if needed. Then, you'll be able to re-use this...
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using Avalonia.Controls.Metadata; using Avalonia.Controls.Primitives; using Avalonia.Threading; using Avalonia.VisualTree; namespace Avalonia.Controls.Notifications { /// <summary> /// An <see cref="INotificationManage...
@@ -17,8 +16,13 @@ namespace Avalonia.Controls.Notifications [PseudoClasses(":topleft", ":topright", ":bottomleft", ":bottomright", ":topcenter", ":bottomcenter")] public class WindowNotificationManager : TemplatedControl, IManagedNotificationManager { - private IList? _items; - private rea...
src/Avalonia.Controls/Notifications/WindowNotificationManager.cs
24
C#
0.786
refactor
412
49
49
false
Fixed ArgumentException when showing multiple notifications with the same content
19,774
AvaloniaUI/Avalonia
24,333
C#
MrJul
fgsfds
Review this pull request change. Language: C# File: src/Avalonia.Controls/Notifications/WindowNotificationManager.cs PR Title: Fixed ArgumentException when showing multiple notifications with the same content BEFORE CODE: using System; using System.Collections; using System.Collections.Generic; using System.Linq; u...
Nitpicking here, but this is only for unit tests and copies the collection on each access, which is a bit unusual for properties. Consider refactoring this to a `IEnumerable<NotificationCard> GetNotifications()` method that doesn't copy, and do the copy manually in tests if needed. Then, you'll be able to re-use this...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
VerticalAlignmentProperty.OverrideDefaultValue<WindowNotificationManager>(Layout.VerticalAlignment.Stretch); } /// <inheritdoc/> protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { base.OnApplyTemplate(e); var itemsControl = e.NameS...
Why did you remove the existing condition here? This changes the behavior when called with a `INotification` object.
VerticalAlignmentProperty.OverrideDefaultValue<WindowNotificationManager>(Layout.VerticalAlignment.Stretch); } /// <inheritdoc/> protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { base.OnApplyTemplate(e); var itemsControl = e.NameS...
@@ -95,14 +102,7 @@ public void Show(INotification content) /// <inheritdoc/> public void Show(object content) { - if (content is INotification notification) - { - Show(notification, notification.Type, notification.Expiration, notification.OnClick, notific...
src/Avalonia.Controls/Notifications/WindowNotificationManager.cs
26
C#
0.571
question
116
51
51
false
Fixed ArgumentException when showing multiple notifications with the same content
19,774
AvaloniaUI/Avalonia
24,333
C#
MrJul
fgsfds
Review this pull request change. Language: C# File: src/Avalonia.Controls/Notifications/WindowNotificationManager.cs PR Title: Fixed ArgumentException when showing multiple notifications with the same content BEFORE CODE: VerticalAlignmentProperty.OverrideDefaultValue<WindowNotificationManager>(Layout.V...
Why did you remove the existing condition here? This changes the behavior when called with a `INotification` object.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
if (e is not null) { tsc.TrySetException(e); } else { if (x.Results.TryGetValue("current_filter", out var currentFilter)) { var name = currentFilter.GetItem...
We can fallback to `new FilePickerFileType` here, assuming input choices didn't include one was actually selected. It won't help for XPF, but just for completion.
if (e is not null) { tsc.TrySetException(e); } else { if (x.Results.TryGetValue("current_filter", out var currentFilter)) { var name = currentFilter.GetItem...
@@ -113,35 +131,38 @@ public override async Task<IReadOnlyList<IStorageFile>> OpenFilePickerAsync(File if (x.Results.TryGetValue("current_filter", out var currentFilter)) { var name = currentFilter.GetItem(0).GetString(); - select...
src/Avalonia.FreeDesktop/DBusSystemDialog.cs
26
C#
0.643
suggestion
163
51
51
false
Add Impl for SaveFilePickerWithResultAsync API
19,783
AvaloniaUI/Avalonia
24,333
C#
maxkatz6
jmacato
Review this pull request change. Language: C# File: src/Avalonia.FreeDesktop/DBusSystemDialog.cs PR Title: Add Impl for SaveFilePickerWithResultAsync API BEFORE CODE: if (e is not null) { tsc.TrySetException(e); } else ...
We can fallback to `new FilePickerFileType` here, assuming input choices didn't include one was actually selected. It won't help for XPF, but just for completion.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
if (e is not null) { tsc.TrySetException(e); } else { if (x.Results.TryGetValue("current_filter", out var currentFilter)) { var name = currentFilter.GetItem...
We probably should change `nameCondition || mimeCondition || patternCondition` into `nameCondition && (mimeCondition || patternCondition)`
if (e is not null) { tsc.TrySetException(e); } else { if (x.Results.TryGetValue("current_filter", out var currentFilter)) { var name = currentFilter.GetItem...
@@ -113,35 +131,38 @@ public override async Task<IReadOnlyList<IStorageFile>> OpenFilePickerAsync(File if (x.Results.TryGetValue("current_filter", out var currentFilter)) { var name = currentFilter.GetItem(0).GetString(); - select...
src/Avalonia.FreeDesktop/DBusSystemDialog.cs
26
C#
0.571
suggestion
138
51
51
false
Add Impl for SaveFilePickerWithResultAsync API
19,783
AvaloniaUI/Avalonia
24,333
C#
maxkatz6
jmacato
Review this pull request change. Language: C# File: src/Avalonia.FreeDesktop/DBusSystemDialog.cs PR Title: Add Impl for SaveFilePickerWithResultAsync API BEFORE CODE: if (e is not null) { tsc.TrySetException(e); } else ...
We probably should change `nameCondition || mimeCondition || patternCondition` into `nameCondition && (mimeCondition || patternCondition)`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
{ tsc.TrySetException(e); } else { if (x.Results.TryGetValue("current_filter", out var currentFilter)) { var name = currentFilter.GetItem(0).GetString(); ...
Missing patterns/mime assignment
{ tsc.TrySetException(e); } else { if (x.Results.TryGetValue("current_filter", out var currentFilter)) { var name = currentFilter.GetItem(0).GetString(); ...
@@ -147,7 +147,8 @@ public override async Task<SaveFilePickerResult> SaveFilePickerWithResultAsync(F // file type selected instead of spawning one. selectedType = options.FileTypeChoices?.FirstOrDefault(type => type.Name == name && ( (type.M...
src/Avalonia.FreeDesktop/DBusSystemDialog.cs
26
C#
0.071
suggestion
33
51
51
false
Add Impl for SaveFilePickerWithResultAsync API
19,783
AvaloniaUI/Avalonia
24,333
C#
maxkatz6
jmacato
Review this pull request change. Language: C# File: src/Avalonia.FreeDesktop/DBusSystemDialog.cs PR Title: Add Impl for SaveFilePickerWithResultAsync API BEFORE CODE: { tsc.TrySetException(e); } else { if (x.Resu...
Missing patterns/mime assignment
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
namespace Avalonia.Platform.Storage; /// <summary> /// Extended result of the <see cref="IStorageProvider.SaveFilePickerWithResultAsync(FilePickerSaveOptions)"/> operation. /// </summary> public readonly struct SaveFilePickerResult { internal SaveFilePickerResult(IStorageFile? file) { File = file; ...
The original API specified `File { get; init; }`. Internal constructors on public structs don't prevent the user from constructing a default instance so it's a bit odd that they can't construct one with a value. More generally, I don't think we gain anything here by preventing users from creating such simple data ty...
namespace Avalonia.Platform.Storage; /// <summary> /// Extended result of the <see cref="IStorageProvider.SaveFilePickerWithResultAsync(FilePickerSaveOptions)"/> operation. /// </summary> public readonly struct SaveFilePickerResult { internal SaveFilePickerResult(IStorageFile? file) { File = file; ...
@@ -0,0 +1,22 @@ +namespace Avalonia.Platform.Storage; + +/// <summary> +/// Extended result of the <see cref="IStorageProvider.SaveFilePickerWithResultAsync(FilePickerSaveOptions)"/> operation. +/// </summary> +public readonly struct SaveFilePickerResult +{ + internal SaveFilePickerResult(IStorageFile? file) + {...
src/Avalonia.Base/Platform/Storage/SaveFilePickerResult.cs
16
C#
0.786
suggestion
390
23
23
false
Add Impl for SaveFilePickerWithResultAsync API
19,783
AvaloniaUI/Avalonia
24,333
C#
MrJul
jmacato
Review this pull request change. Language: C# File: src/Avalonia.Base/Platform/Storage/SaveFilePickerResult.cs PR Title: Add Impl for SaveFilePickerWithResultAsync API BEFORE CODE: namespace Avalonia.Platform.Storage; /// <summary> /// Extended result of the <see cref="IStorageProvider.SaveFilePickerWithResultAsyn...
The original API specified `File { get; init; }`. Internal constructors on public structs don't prevent the user from constructing a default instance so it's a bit odd that they can't construct one with a value. More generally, I don't think we gain anything here by preventing users from creating such simple data ty...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
using System.Linq; using System.Text.RegularExpressions; using Avalonia.Platform.Storage; namespace Avalonia.Dialogs.Internal { public class ManagedFileChooserFilterViewModel : AvaloniaDialogsInternalViewModelBase { private readonly Regex[]? _patterns; public string Name { get; } intern...
I know that this VM is supposed to be internal, but contrary to our interfaces marked as `NotClientImplementable`, this constructor was part of the public API, even if it shouldn't have. We can revisit for v12, but if we want to backport this to v11, please revert this. Either add a new overload or just keep the prope...
using System.Linq; using System.Text.RegularExpressions; using Avalonia.Platform.Storage; namespace Avalonia.Dialogs.Internal { public class ManagedFileChooserFilterViewModel : AvaloniaDialogsInternalViewModelBase { private readonly Regex[]? _patterns; public string Name { get; } intern...
@@ -8,9 +8,11 @@ public class ManagedFileChooserFilterViewModel : AvaloniaDialogsInternalViewMode { private readonly Regex[]? _patterns; public string Name { get; } + internal int Index { get; } - public ManagedFileChooserFilterViewModel(FilePickerFileType filter) + public ...
src/Avalonia.Dialogs/Internal/ManagedFileChooserFilterViewModel.cs
17
C#
0.643
suggestion
356
36
40
false
Add Impl for SaveFilePickerWithResultAsync API
19,783
AvaloniaUI/Avalonia
24,333
C#
MrJul
jmacato
Review this pull request change. Language: C# File: src/Avalonia.Dialogs/Internal/ManagedFileChooserFilterViewModel.cs PR Title: Add Impl for SaveFilePickerWithResultAsync API BEFORE CODE: using System.Linq; using System.Text.RegularExpressions; using Avalonia.Platform.Storage; namespace Avalonia.Dialogs.Internal ...
I know that this VM is supposed to be internal, but contrary to our interfaces marked as `NotClientImplementable`, this constructor was part of the public API, even if it shouldn't have. We can revisit for v12, but if we want to backport this to v11, please revert this. Either add a new overload or just keep the prope...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
internal void Capture(IInputElement? control, CaptureSource source) { var oldCapture = Captured; if (oldCapture == control) return; var oldVisual = oldCapture as Visual; IInputElement? commonParent = null; if (oldVisual != nu...
`PlatformCapture()` is now called before detaching from the event, is that intended? I think we should detach from the event as soon as possible (like it was before) to avoid side effects where `OnCaptureDetached` could be inadvertently called as a result of the platform capture.
internal void Capture(IInputElement? control, CaptureSource source) { var oldCapture = Captured; if (oldCapture == control) return; var oldVisual = oldCapture as Visual; IInputElement? commonParent = null; if (oldVisual != nu...
@@ -30,46 +37,61 @@ public Pointer(int id, PointerType type, bool isPrimary) protected virtual void PlatformCapture(IInputElement? element) { - + } internal void PlatformCaptureLost() { if (Captured != null) - Capture(null, platfor...
src/Avalonia.Base/Input/Pointer.cs
26
C#
0.643
suggestion
280
51
51
false
Internal PointerCaptureChanging event
19,833
AvaloniaUI/Avalonia
24,333
C#
MrJul
miloush
Review this pull request change. Language: C# File: src/Avalonia.Base/Input/Pointer.cs PR Title: Internal PointerCaptureChanging event BEFORE CODE: internal void Capture(IInputElement? control, CaptureSource source) { var oldCapture = Captured; if (oldCapture == control) ...
`PlatformCapture()` is now called before detaching from the event, is that intended? I think we should detach from the event as soon as possible (like it was before) to avoid side effects where `OnCaptureDetached` could be inadvertently called as a result of the platform capture.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
using System; using System.Collections.Generic; using Avalonia.Reactive; using Avalonia.Input.Raw; using Avalonia.Interactivity; using Avalonia.Metadata; using Avalonia.Platform; using Avalonia.Utilities; using Avalonia.VisualTree; using Avalonia.Input.GestureRecognizers; #pragma warning disable CS0618 namespace Avalo...
This should probably be `??=` to reuse the same instance, or use `GetOrCreatePrimary()`.
using System; using System.Collections.Generic; using Avalonia.Reactive; using Avalonia.Input.Raw; using Avalonia.Interactivity; using Avalonia.Metadata; using Avalonia.Platform; using Avalonia.Utilities; using Avalonia.VisualTree; using Avalonia.Input.GestureRecognizers; #pragma warning disable CS0618 namespace Avalo...
@@ -18,6 +18,9 @@ namespace Avalonia.Input [PrivateApi] public class MouseDevice : IMouseDevice, IDisposable { + private static MouseDevice? _primary; + internal static MouseDevice Primary => _primary ?? new MouseDevice();
src/Avalonia.Base/Input/MouseDevice.cs
22
C#
0.429
suggestion
88
47
47
false
Primary mouse device
19,898
AvaloniaUI/Avalonia
24,333
C#
MrJul
miloush
Review this pull request change. Language: C# File: src/Avalonia.Base/Input/MouseDevice.cs PR Title: Primary mouse device BEFORE CODE: using System; using System.Collections.Generic; using Avalonia.Reactive; using Avalonia.Input.Raw; using Avalonia.Interactivity; using Avalonia.Metadata; using Avalonia.Platform; us...
This should probably be `??=` to reuse the same instance, or use `GetOrCreatePrimary()`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
else if (xiValuatorClassInfo.Label == touchMajorAtom) { TouchMajorXIValuatorClassInfo = xiValuatorClassInfo; } else if (xiValuatorClassInfo.Label == touchMinorAtom) { Touch...
Nit: this also works for touch. I understand that it's used only to distinguish between mouse and pen but this isn't obvious at first glance. Rename to something like `HasPressureValuator` (or remove completely and check for `PressureXIValuatorClassInfo` directly since it's public).
TouchMinorXIValuatorClassInfo = null; foreach (var xiValuatorClassInfo in Valuators) { if (xiValuatorClassInfo.Label == pressureAtom || xiValuatorClassInfo.Label == pressureAtomPen) { ...
@@ -119,6 +126,11 @@ public override void Update(XIAnyClassInfo** classes, int num) UpdateKnownValuator(); } + public bool HasPenEvaluators()
src/Avalonia.X11/XI2Manager.cs
26
C#
0.643
nitpick
283
51
51
false
Added basic Pen support for X11
19,910
AvaloniaUI/Avalonia
24,333
C#
MrJul
flabbet
Review this pull request change. Language: C# File: src/Avalonia.X11/XI2Manager.cs PR Title: Added basic Pen support for X11 BEFORE CODE: else if (xiValuatorClassInfo.Label == touchMajorAtom) { TouchMajorXIValuatorClassInfo = xiValuatorClassInfo; ...
Nit: this also works for touch. I understand that it's used only to distinguish between mouse and pen but this isn't obvious at first glance. Rename to something like `HasPressureValuator` (or remove completely and check for `PressureXIValuatorClassInfo` directly since it's public).
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
// https://www.kernel.org/doc/html/latest/input/multi-touch-protocol.html var touchMajorAtom = XInternAtom(_x11.Display, "Abs MT Touch Major", false); var touchMinorAtom = XInternAtom(_x11.Display, "Abs MT Touch Minor", false); var pressureAtom = XInternA...
Is it possible for a device to have both `Abs Pressure` and `Abs MT Pressure`? I don't think so, but if that's the case we should probably prefer the second one.
UpdateKnownValuator(); } private readonly X11Info _x11; private void UpdateKnownValuator() { // ABS_MT_TOUCH_MAJOR ABS_MT_TOUCH_MINOR // https://www.kernel.org/doc/html/latest/input/multi-touch-protocol.html ...
@@ -91,14 +86,18 @@ private void UpdateKnownValuator() var touchMinorAtom = XInternAtom(_x11.Display, "Abs MT Touch Minor", false); var pressureAtom = XInternAtom(_x11.Display, "Abs MT Pressure", false); + var pressureAtomPen = XInternAtom(_x11.Display, "Abs Pressure",...
src/Avalonia.X11/XI2Manager.cs
26
C#
0.571
suggestion
161
51
51
false
Added basic Pen support for X11
19,910
AvaloniaUI/Avalonia
24,333
C#
MrJul
flabbet
Review this pull request change. Language: C# File: src/Avalonia.X11/XI2Manager.cs PR Title: Added basic Pen support for X11 BEFORE CODE: // https://www.kernel.org/doc/html/latest/input/multi-touch-protocol.html var touchMajorAtom = XInternAtom(_x11.Display, "Abs MT Touch Major", fal...
Is it possible for a device to have both `Abs Pressure` and `Abs MT Pressure`? I don't think so, but if that's the case we should probably prefer the second one.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
using System; using System.Collections.Generic; using System.Linq; using Avalonia.Input; using Avalonia.Input.Raw; using static Avalonia.X11.XLib; namespace Avalonia.X11 { internal unsafe class XI2Manager { private static readonly XiEventType[] DefaultEventTypes = new XiEventType[] { ...
Please revert the formatting changes here and on the field below.
using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using Avalonia.Input; using Avalonia.Input.Raw; using static Avalonia.X11.XLib; namespace Avalonia.X11 { internal unsafe class XI2Manager { private static readonly XiEventType[] DefaultEventTypes = ...
@@ -11,19 +11,13 @@ internal unsafe class XI2Manager { private static readonly XiEventType[] DefaultEventTypes = new XiEventType[] { - XiEventType.XI_Motion, - XiEventType.XI_ButtonPress, - XiEventType.XI_ButtonRelease, - XiEventType.XI_Leave, + ...
src/Avalonia.X11/XI2Manager.cs
14
C#
0.286
style
65
39
39
false
Added basic Pen support for X11
19,910
AvaloniaUI/Avalonia
24,333
C#
MrJul
flabbet
Review this pull request change. Language: C# File: src/Avalonia.X11/XI2Manager.cs PR Title: Added basic Pen support for X11 BEFORE CODE: using System; using System.Collections.Generic; using System.Linq; using Avalonia.Input; using Avalonia.Input.Raw; using static Avalonia.X11.XLib; namespace Avalonia.X11 { i...
Please revert the formatting changes here and on the field below.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
/// A general purpose <see cref="IValueConverter"/> that uses a <see cref="Func{TIn, TParam, TOut}"/> /// to provide the converter logic. /// </summary> /// <typeparam name="TIn">The input type.</typeparam> /// <typeparam name="TParam">The param type.</typeparam> /// <typeparam name="TOut">The o...
This constructor still breaks API, there should be a second copy without convertBack for these generics.
/// A general purpose <see cref="IValueConverter"/> that uses a <see cref="Func{TIn, TParam, TOut}"/> /// to provide the converter logic. /// </summary> /// <typeparam name="TIn">The input type.</typeparam> /// <typeparam name="TParam">The param type.</typeparam> /// <typeparam name="TOut">The o...
@@ -53,14 +77,17 @@ public FuncValueConverter(Func<TIn?, TOut> convert) public class FuncValueConverter<TIn, TParam, TOut> : IValueConverter { private readonly Func<TIn?, TParam?, TOut> _convert; + private readonly Func<TOut?, TParam?, TIn>? _convertBack; /// <summary> /// ...
src/Avalonia.Base/Data/Converters/FuncValueConverter.cs
26
C#
0.429
suggestion
104
51
51
false
Added an optional "ConvertBack" method to FuncValueConverter
19,920
AvaloniaUI/Avalonia
24,333
C#
maxkatz6
zacfromaustinpowder
Review this pull request change. Language: C# File: src/Avalonia.Base/Data/Converters/FuncValueConverter.cs PR Title: Added an optional "ConvertBack" method to FuncValueConverter BEFORE CODE: /// A general purpose <see cref="IValueConverter"/> that uses a <see cref="Func{TIn, TParam, TOut}"/> /// to provide...
This constructor still breaks API, there should be a second copy without convertBack for these generics.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
callDwp = false; } } break; // Normally, Avalonia doesn't handles non-client input as a special NonClientLeftButtonDown, ignoring move and up events. // What makes it a problem, Avalonia has to m...
Nit: we usually define these constants explicitly, you can add them to `UnmanagedMethods.cs`.
callDwp = false; } } break; // Normally, Avalonia doesn't handles non-client input as a special NonClientLeftButtonDown, ignoring move and up events. // What makes it a problem, Avalonia has to m...
@@ -141,24 +142,64 @@ protected virtual IntPtr CustomCaptionProc(IntPtr hWnd, uint msg, IntPtr wParam, case WindowsMessage.WM_NCMOUSEMOVE when !IsMouseInPointerEnabled: case WindowsMessage.WM_NCLBUTTONDOWN when !IsMouseInPointerEnabled: case WindowsMessage.WM_NCLBUTTON...
src/Windows/Avalonia.Win32/WindowImpl.CustomCaptionProc.cs
26
C#
0.357
suggestion
93
51
51
false
[Win] Handle mouse movement in non-client areas of window.
19,922
AvaloniaUI/Avalonia
24,333
C#
MrJul
drasticactions
Review this pull request change. Language: C# File: src/Windows/Avalonia.Win32/WindowImpl.CustomCaptionProc.cs PR Title: [Win] Handle mouse movement in non-client areas of window. BEFORE CODE: callDwp = false; } } break; ...
Nit: we usually define these constants explicitly, you can add them to `UnmanagedMethods.cs`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
// Normally, Avalonia doesn't handles non-client input as a special NonClientLeftButtonDown, ignoring move and up events. // What makes it a problem, Avalonia has to mark templated caption buttons as a non-client area. // Meaning, these buttons no longer can accept norma...
Shouldn't `TrackMouseEvent` be called with `TME_CANCEL` at the same time we're setting `_trackingNonClientMouse` to false?
// Normally, Avalonia doesn't handles non-client input as a special NonClientLeftButtonDown, ignoring move and up events. // What makes it a problem, Avalonia has to mark templated caption buttons as a non-client area. // Meaning, these buttons no longer can accept norma...
@@ -141,24 +142,64 @@ protected virtual IntPtr CustomCaptionProc(IntPtr hWnd, uint msg, IntPtr wParam, case WindowsMessage.WM_NCMOUSEMOVE when !IsMouseInPointerEnabled: case WindowsMessage.WM_NCLBUTTONDOWN when !IsMouseInPointerEnabled: case WindowsMessage.WM_NCLBUTTON...
src/Windows/Avalonia.Win32/WindowImpl.CustomCaptionProc.cs
26
C#
0.571
question
122
51
51
false
[Win] Handle mouse movement in non-client areas of window.
19,922
AvaloniaUI/Avalonia
24,333
C#
MrJul
drasticactions
Review this pull request change. Language: C# File: src/Windows/Avalonia.Win32/WindowImpl.CustomCaptionProc.cs PR Title: [Win] Handle mouse movement in non-client areas of window. BEFORE CODE: // Normally, Avalonia doesn't handles non-client input as a special NonClientLeftButtonDown, ignoring move...
Shouldn't `TrackMouseEvent` be called with `TME_CANCEL` at the same time we're setting `_trackingNonClientMouse` to false?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
_ => throw new ArgumentOutOfRangeException() }; var fileName = options.AvaloniaNameGeneratorViewFileNamingStrategy switch { ViewFileNamingStrategy.ClassName => $"{view.ClassName}.g.cs", ViewFileNamingStrategy.Nam...
I am surprised here, as it felt backwards to fallback to XDocument. Because I thought we use more reliable [GuiLabs.Language.Xml](https://www.nuget.org/packages/GuiLabs.Language.Xml) for generator here (see [GuiLabsXamlParser.cs](https://github.com/kekekeks/XamlX/blob/master/src/XamlX.Parser.GuiLabs/GuiLabsXamlParser.c...
var fileName = options.AvaloniaNameGeneratorViewFileNamingStrategy switch { ViewFileNamingStrategy.ClassName => $"{view.ClassName}.g.cs", ViewFileNamingStrategy.NamespaceAndClassName => $"{view.Namespace}.{view.ClassName}.g.cs", ...
@@ -200,12 +227,40 @@ public void Initialize(IncrementalGeneratorInitializationContext context) }); } + /// <summary> + /// Fallback in case XAML parsing fails. Extracts just the class name and namespace of the root element. + /// </summary> + private static ResolvedXmlView? TryExtractTypeFr...
src/tools/Avalonia.Generators/NameGenerator/AvaloniaNameIncrementalGenerator.cs
26
C#
0.5
suggestion
620
51
51
false
Improve `AvaloniaNameIncrementalGenerator` error handling
19,934
AvaloniaUI/Avalonia
24,333
C#
maxkatz6
TomEdwardsEnscape
Review this pull request change. Language: C# File: src/tools/Avalonia.Generators/NameGenerator/AvaloniaNameIncrementalGenerator.cs PR Title: Improve `AvaloniaNameIncrementalGenerator` error handling BEFORE CODE: _ => throw new ArgumentOutOfRangeException() }; var...
I am surprised here, as it felt backwards to fallback to XDocument. Because I thought we use more reliable [GuiLabs.Language.Xml](https://www.nuget.org/packages/GuiLabs.Language.Xml) for generator here (see [GuiLabsXamlParser.cs](https://github.com/kekekeks/XamlX/blob/master/src/XamlX.Parser.GuiLabs/GuiLabsXamlParser.c...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
using System.Diagnostics.CodeAnalysis; using Microsoft.CodeAnalysis; namespace Avalonia.Generators.NameGenerator; internal static class NameGeneratorDiagnostics { private const string Category = "Avalonia.NameGenerator"; private const string BugReportLink = "https://github.com/AvaloniaUI/Avalonia/issues/new/...
This doesn't work. The output is trimmed to one single line and all information about the exception is lost.
using System.Diagnostics.CodeAnalysis; using Microsoft.CodeAnalysis; namespace Avalonia.Generators.NameGenerator; internal static class NameGeneratorDiagnostics { private const string Category = "Avalonia.NameGenerator"; private const string BugReportLink = "https://github.com/AvaloniaUI/Avalonia/issues/new/...
@@ -0,0 +1,39 @@ +using System.Diagnostics.CodeAnalysis; +using Microsoft.CodeAnalysis; + +namespace Avalonia.Generators.NameGenerator; + +internal static class NameGeneratorDiagnostics +{ + private const string Category = "Avalonia.NameGenerator"; + private const string BugReportLink = "https://github.com/Avalo...
src/tools/Avalonia.Generators/NameGenerator/NameGeneratorDiagnostics.cs
25
C#
0.5
style
108
40
40
false
Improve `AvaloniaNameIncrementalGenerator` error handling
19,934
AvaloniaUI/Avalonia
24,333
C#
TomEdwardsEnscape
TomEdwardsEnscape
Review this pull request change. Language: C# File: src/tools/Avalonia.Generators/NameGenerator/NameGeneratorDiagnostics.cs PR Title: Improve `AvaloniaNameIncrementalGenerator` error handling BEFORE CODE: using System.Diagnostics.CodeAnalysis; using Microsoft.CodeAnalysis; namespace Avalonia.Generators.NameGenera...
This doesn't work. The output is trimmed to one single line and all information about the exception is lost.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
using System.Diagnostics.CodeAnalysis; using Microsoft.CodeAnalysis; namespace Avalonia.Generators.NameGenerator; internal static class NameGeneratorDiagnostics { private const string Category = "Avalonia.NameGenerator"; private const string BugReportLink = "https://github.com/AvaloniaUI/Avalonia/issues/new/...
``` NameGeneratorDiagnostics.cs(16,9,16,18): warning RS2008: Enable analyzer release tracking for the analyzer project containing rule 'AXN0001' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md) ``` [Are we going to do this?](https://github...
using System.Diagnostics.CodeAnalysis; using Microsoft.CodeAnalysis; namespace Avalonia.Generators.NameGenerator; internal static class NameGeneratorDiagnostics { private const string Category = "Avalonia.NameGenerator"; private const string BugReportLink = "https://github.com/AvaloniaUI/Avalonia/issues/new/...
@@ -0,0 +1,39 @@ +using System.Diagnostics.CodeAnalysis; +using Microsoft.CodeAnalysis; + +namespace Avalonia.Generators.NameGenerator; + +internal static class NameGeneratorDiagnostics +{ + private const string Category = "Avalonia.NameGenerator"; + private const string BugReportLink = "https://github.com/Avalo...
src/tools/Avalonia.Generators/NameGenerator/NameGeneratorDiagnostics.cs
16
C#
0.786
suggestion
435
40
40
false
Improve `AvaloniaNameIncrementalGenerator` error handling
19,934
AvaloniaUI/Avalonia
24,333
C#
TomEdwardsEnscape
TomEdwardsEnscape
Review this pull request change. Language: C# File: src/tools/Avalonia.Generators/NameGenerator/NameGeneratorDiagnostics.cs PR Title: Improve `AvaloniaNameIncrementalGenerator` error handling BEFORE CODE: using System.Diagnostics.CodeAnalysis; using Microsoft.CodeAnalysis; namespace Avalonia.Generators.NameGenera...
``` NameGeneratorDiagnostics.cs(16,9,16,18): warning RS2008: Enable analyzer release tracking for the analyzer project containing rule 'AXN0001' (https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md) ``` [Are we going to do this?](https://github...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
try { var document = XDocument.Parse(xaml); var classValue = document.Root.Attribute(XName.Get("Class", XamlNamespaces.Xaml2006))?.Value; if (classValue?.LastIndexOf('.') is { } lastDotIndex && lastDotIndex != -1) { return new(classValue.Su...
`Diagnostic` shouldn't be part of the record. Even though it's equatable, two different diagnostics from two different compilations won't be because their `Location` is different, breaking caching. The [usual solution](https://andrewlock.net/creating-a-source-generator-part-9-avoiding-performance-pitfalls-in-incrementa...
{ var document = XDocument.Parse(xaml); var classValue = document.Root.Attribute(XName.Get("Class", XamlNamespaces.Xaml2006))?.Value; if (classValue?.LastIndexOf('.') is { } lastDotIndex && lastDotIndex != -1) { return new(classValue.Substring(last...
@@ -200,12 +226,43 @@ public void Initialize(IncrementalGeneratorInitializationContext context) }); } + private static Diagnostic GetInternalErrorDiagnostic(Location location, Exception ex) => + Diagnostic.Create(NameGeneratorDiagnostics.InternalError, location, ex.ToString().Replace('\n', '*'...
src/tools/Avalonia.Generators/NameGenerator/AvaloniaNameIncrementalGenerator.cs
26
C#
0.786
performance
421
33
42
false
Improve `AvaloniaNameIncrementalGenerator` error handling
19,934
AvaloniaUI/Avalonia
24,333
C#
MrJul
TomEdwardsEnscape
Review this pull request change. Language: C# File: src/tools/Avalonia.Generators/NameGenerator/AvaloniaNameIncrementalGenerator.cs PR Title: Improve `AvaloniaNameIncrementalGenerator` error handling BEFORE CODE: try { var document = XDocument.Parse(xaml); var classValue = do...
`Diagnostic` shouldn't be part of the record. Even though it's equatable, two different diagnostics from two different compilations won't be because their `Location` is different, breaking caching. The [usual solution](https://andrewlock.net/creating-a-source-generator-part-9-avoiding-performance-pitfalls-in-incrementa...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
public ChildSelector(Selector parent) { if (parent == null) { throw new InvalidOperationException("Child selector must be preceeded by a selector."); } _parent = parent; } /// <inheritdoc/> internal override bool ...
Note: all selectors have been modified to add parenthesis around `OrSelector`, why not add this directly to `OrSelector.ToString()`? You could add an internal override taking a flag to avoid adding parenthesis around an `OrSelector` being placed at the root level.
public ChildSelector(Selector parent) { if (parent == null) { throw new InvalidOperationException("Child selector must be preceeded by a selector."); } _parent = parent; } /// <inheritdoc/> internal override bool ...
@@ -31,7 +31,9 @@ public override string ToString(Style? owner) { if (_selectorString == null) { - _selectorString = _parent.ToString(owner) + " > "; + _selectorString = _parent is OrSelector ? + $"({_parent.ToString(owner)}) > " :
src/Avalonia.Base/Styling/ChildSelector.cs
26
C#
0.643
suggestion
264
51
51
false
Fixed Selector.ValidateNestingSelector not calling overrides when iterating up through parent selectors
19,947
AvaloniaUI/Avalonia
24,333
C#
MrJul
zacfromaustinpowder
Review this pull request change. Language: C# File: src/Avalonia.Base/Styling/ChildSelector.cs PR Title: Fixed Selector.ValidateNestingSelector not calling overrides when iterating up through parent selectors BEFORE CODE: public ChildSelector(Selector parent) { if (parent == null) ...
Note: all selectors have been modified to add parenthesis around `OrSelector`, why not add this directly to `OrSelector.ToString()`? You could add an internal override taking a flag to avoid adding parenthesis around an `OrSelector` being placed at the root level.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
{ var directory = new DirectoryInfo(path); if (directory.Exists) { return new BclStorageFolder(directory); } var file = new FileInfo(path); if (file.Exists) { return new BclStorageFile(file); ...
Pass `StringComparison.Ordinal` as the second argument.
{ var directory = new DirectoryInfo(path); if (directory.Exists) { return new BclStorageFolder(directory); } var file = new FileInfo(path); if (file.Exists) { return new BclStorageFile(file); ...
@@ -36,11 +36,15 @@ internal static class StorageProviderHelpers public static Uri UriFromFilePath(string path, bool isDirectory) { - var uriPath = new StringBuilder(path) - .Replace("%", $"%{(int)'%':X2}") - .Replace("[", $"%{(int)'[':X2}") - .Replace("]", $"%{(int)'...
src/Avalonia.Base/Platform/Storage/FileIO/StorageProviderHelpers.cs
26
C#
0.357
suggestion
56
51
51
false
Handle long file paths in UriFromFilePath
19,955
AvaloniaUI/Avalonia
24,333
C#
MrJul
startewho
Review this pull request change. Language: C# File: src/Avalonia.Base/Platform/Storage/FileIO/StorageProviderHelpers.cs PR Title: Handle long file paths in UriFromFilePath BEFORE CODE: { var directory = new DirectoryInfo(path); if (directory.Exists) { retu...
Pass `StringComparison.Ordinal` as the second argument.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
{ return new BclStorageFolder(directory); } var file = new FileInfo(path); if (file.Exists) { return new BclStorageFile(file); } } return null; } public static string? TryGetPathFromFileUri...
Perf nit: we're already using a `StringBuilder` below, consider using `StringBuilder.Append(path, 4, path.Length - 4)` to avoid an extra string allocation.
{ return new BclStorageFolder(directory); } var file = new FileInfo(path); if (file.Exists) { return new BclStorageFile(file); } } return null; } public static string? TryGetPathFromFileUri...
@@ -36,11 +36,15 @@ internal static class StorageProviderHelpers public static Uri UriFromFilePath(string path, bool isDirectory) { - var uriPath = new StringBuilder(path) - .Replace("%", $"%{(int)'%':X2}") - .Replace("[", $"%{(int)'[':X2}") - .Replace("]", $"%{(int)'...
src/Avalonia.Base/Platform/Storage/FileIO/StorageProviderHelpers.cs
26
C#
0.571
suggestion
155
51
51
false
Handle long file paths in UriFromFilePath
19,955
AvaloniaUI/Avalonia
24,333
C#
MrJul
startewho
Review this pull request change. Language: C# File: src/Avalonia.Base/Platform/Storage/FileIO/StorageProviderHelpers.cs PR Title: Handle long file paths in UriFromFilePath BEFORE CODE: { return new BclStorageFolder(directory); } var file = new FileInfo(path); ...
Perf nit: we're already using a `StringBuilder` below, consider using `StringBuilder.Append(path, 4, path.Length - 4)` to avoid an extra string allocation.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
{ var directory = new DirectoryInfo(path); if (directory.Exists) { return new BclStorageFolder(directory); } var file = new FileInfo(path); if (file.Exists) { return new BclStorageFile(file); ...
Naming: `isLongPatah` ⇒ `isLongPath`
{ var directory = new DirectoryInfo(path); if (directory.Exists) { return new BclStorageFolder(directory); } var file = new FileInfo(path); if (file.Exists) { return new BclStorageFile(file); ...
@@ -36,11 +36,15 @@ internal static class StorageProviderHelpers public static Uri UriFromFilePath(string path, bool isDirectory) { - var uriPath = new StringBuilder(path) - .Replace("%", $"%{(int)'%':X2}") - .Replace("[", $"%{(int)'[':X2}") - .Replace("]", $"%{(int)'...
src/Avalonia.Base/Platform/Storage/FileIO/StorageProviderHelpers.cs
26
C#
0.214
style
36
51
51
false
Handle long file paths in UriFromFilePath
19,955
AvaloniaUI/Avalonia
24,333
C#
MrJul
startewho
Review this pull request change. Language: C# File: src/Avalonia.Base/Platform/Storage/FileIO/StorageProviderHelpers.cs PR Title: Handle long file paths in UriFromFilePath BEFORE CODE: { var directory = new DirectoryInfo(path); if (directory.Exists) { retu...
Naming: `isLongPatah` ⇒ `isLongPath`
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
using Avalonia.Media; namespace Avalonia.Rendering.Composition.Server; internal partial class ServerCompositionSimplePen : IPen { IDashStyle? IPen.DashStyle => DashStyle; /// <inheritdoc/> public override void Dispose() { // Dispose of the brush resource, this will remove the pen from the bru...
The property change will cause the pen to be queued for invalidation, which isn't needed since the object is being disposed. I think a better fix would be to call `RemoveObserversFromProperty(ref _brush)`.
using Avalonia.Media; namespace Avalonia.Rendering.Composition.Server; internal partial class ServerCompositionSimplePen : IPen { IDashStyle? IPen.DashStyle => DashStyle; /// <inheritdoc/> public override void Dispose() { // Remove the pen from the brush observers. // Without this, th...
@@ -1,12 +1,18 @@ -using System; using Avalonia.Media; -using Avalonia.Media.Immutable; -using Avalonia.Rendering.Composition.Server; -using Avalonia.Rendering.Composition.Transport; namespace Avalonia.Rendering.Composition.Server; internal partial class ServerCompositionSimplePen : IPen { IDashStyle? IPen...
src/Avalonia.Base/Rendering/Composition/Drawing/ServerCompositionSimplePen.cs
15
C#
0.643
suggestion
205
19
20
false
Fix ServerCompositionSimplePen memory leak
19,958
AvaloniaUI/Avalonia
24,333
C#
MrJul
aguahombre
Review this pull request change. Language: C# File: src/Avalonia.Base/Rendering/Composition/Drawing/ServerCompositionSimplePen.cs PR Title: Fix ServerCompositionSimplePen memory leak BEFORE CODE: using Avalonia.Media; namespace Avalonia.Rendering.Composition.Server; internal partial class ServerCompositionSimpleP...
The property change will cause the pen to be queued for invalidation, which isn't needed since the object is being disposed. I think a better fix would be to call `RemoveObserversFromProperty(ref _brush)`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
var childAvailableSize = new Size( (availableSize.Width - (_columns - 1) * ColumnSpacing) / _columns, (availableSize.Height - (_rows - 1) * RowSpacing) / _rows); foreach (var child in Children) { child.Measure(childAvailableSize); ...
Nit: use `!MathUtilities.IsFinite()` instead (I'm leaving this once, but this applies to the 4 added `if` conditions).
var maxWidth = 0d; var maxHeight = 0d; var childAvailableSize = new Size( (availableSize.Width - (_columns - 1) * ColumnSpacing) / _columns, (availableSize.Height - (_rows - 1) * RowSpacing) / _rows); foreach (var child in Children) ...
@@ -116,6 +116,22 @@ protected override Size MeasureOverride(Size availableSize) } } + // If layout rounding is enabled, round the measured per-cell unit size (maxWidth/maxHeight). + // We round the measured max sizes instead of the childAvailableSize to avoid chang...
src/Avalonia.Controls/Primitives/UniformGrid.cs
26
C#
0.571
suggestion
118
51
51
false
UniformGrid: Round measured cell sizes when UseLayoutRounding is enabled
19,959
AvaloniaUI/Avalonia
24,333
C#
MrJul
Soar360
Review this pull request change. Language: C# File: src/Avalonia.Controls/Primitives/UniformGrid.cs PR Title: UniformGrid: Round measured cell sizes when UseLayoutRounding is enabled BEFORE CODE: var childAvailableSize = new Size( (availableSize.Width - (_columns - 1) * ColumnSpacing) /...
Nit: use `!MathUtilities.IsFinite()` instead (I'm leaving this once, but this applies to the 4 added `if` conditions).
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
(availableSize.Width - (_columns - 1) * ColumnSpacing) / _columns, (availableSize.Height - (_rows - 1) * RowSpacing) / _rows); foreach (var child in Children) { child.Measure(childAvailableSize); if (child.DesiredSize.Width > maxW...
This doesn't seem right, we normally use `LayoutHelper.RoundLayoutXxx` methods with a scale to adjust for the current DPI.
var childAvailableSize = new Size( (availableSize.Width - (_columns - 1) * ColumnSpacing) / _columns, (availableSize.Height - (_rows - 1) * RowSpacing) / _rows); foreach (var child in Children) { child.Measure(childAvailableSize); ...
@@ -116,6 +116,22 @@ protected override Size MeasureOverride(Size availableSize) } } + // If layout rounding is enabled, round the measured per-cell unit size (maxWidth/maxHeight). + // We round the measured max sizes instead of the childAvailableSize to avoid chang...
src/Avalonia.Controls/Primitives/UniformGrid.cs
26
C#
0.571
refactor
122
51
51
false
UniformGrid: Round measured cell sizes when UseLayoutRounding is enabled
19,959
AvaloniaUI/Avalonia
24,333
C#
MrJul
Soar360
Review this pull request change. Language: C# File: src/Avalonia.Controls/Primitives/UniformGrid.cs PR Title: UniformGrid: Round measured cell sizes when UseLayoutRounding is enabled BEFORE CODE: (availableSize.Width - (_columns - 1) * ColumnSpacing) / _columns, (availableSize.Height...
This doesn't seem right, we normally use `LayoutHelper.RoundLayoutXxx` methods with a scale to adjust for the current DPI.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
{ UpdateRowsAndColumns(); var maxWidth = 0d; var maxHeight = 0d; var childAvailableSize = new Size( (availableSize.Width - (_columns - 1) * ColumnSpacing) / _columns, (availableSize.Height - (_rows - 1) * RowSpacing) / _rows); ...
Reading the comment, I understand that it's now possible for the child control size not to match the grid, which would be unexpected (controls won't be uniform anymore). Could you please provide a sample to compare the before and after behaviors? Plus, a matching unit test is needed.
protected override Size MeasureOverride(Size availableSize) { UpdateRowsAndColumns(); var maxWidth = 0d; var maxHeight = 0d; var childAvailableSize = new Size( (availableSize.Width - (_columns - 1) * ColumnSpacing) / _columns, ...
@@ -116,6 +116,22 @@ protected override Size MeasureOverride(Size availableSize) } } + // If layout rounding is enabled, round the measured per-cell unit size (maxWidth/maxHeight).
src/Avalonia.Controls/Primitives/UniformGrid.cs
26
C#
0.5
nitpick
285
51
51
false
UniformGrid: Round measured cell sizes when UseLayoutRounding is enabled
19,959
AvaloniaUI/Avalonia
24,333
C#
MrJul
Soar360
Review this pull request change. Language: C# File: src/Avalonia.Controls/Primitives/UniformGrid.cs PR Title: UniformGrid: Round measured cell sizes when UseLayoutRounding is enabled BEFORE CODE: { UpdateRowsAndColumns(); var maxWidth = 0d; var maxHeight = 0d; ...
Reading the comment, I understand that it's now possible for the child control size not to match the grid, which would be unexpected (controls won't be uniform anymore). Could you please provide a sample to compare the before and after behaviors? Plus, a matching unit test is needed.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} public override bool TryMatchCharacter(int codepoint, FontStyle style, FontWeight weight, FontStretch stretch, string? familyName, CultureInfo? culture, out Typeface match) { match = default; if (_fontManager.PlatformImpl.TryMatchCharacter(code...
This was already the case before this PR, but the value factory [can be executed multiple times](https://learn.microsoft.com/en-us/dotnet/api/system.collections.concurrent.concurrentdictionary-2.getoradd?view=netstandard-2.0#system-collections-concurrent-concurrentdictionary-2-getoradd(-0-system-func((-0-1)))), effecti...
} public override bool TryMatchCharacter(int codepoint, FontStyle style, FontWeight weight, FontStretch stretch, string? familyName, CultureInfo? culture, out Typeface match) { //TODO12: Think about removing familyName parameter match = default; ...
@@ -172,5 +158,38 @@ public bool TryGetFamilyTypefaces(string familyName, [NotNullWhen(true)] out IRe return false; } + + public override bool TryMatchCharacter(int codepoint, FontStyle style, FontWeight weight, FontStretch stretch, string? familyName, + CultureInfo? culture, o...
src/Avalonia.Base/Media/Fonts/SystemFontCollection.cs
26
C#
0.643
suggestion
1,005
37
48
false
Cache platform font manager TryMatchCharacter result
19,987
AvaloniaUI/Avalonia
24,333
C#
MrJul
Gillibald
Review this pull request change. Language: C# File: src/Avalonia.Base/Media/Fonts/SystemFontCollection.cs PR Title: Cache platform font manager TryMatchCharacter result BEFORE CODE: } public override bool TryMatchCharacter(int codepoint, FontStyle style, FontWeight weight, FontStretch stretch, stri...
This was already the case before this PR, but the value factory [can be executed multiple times](https://learn.microsoft.com/en-us/dotnet/api/system.collections.concurrent.concurrentdictionary-2.getoradd?view=netstandard-2.0#system-collections-concurrent-concurrentdictionary-2-getoradd(-0-system-func((-0-1)))), effecti...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
{ /// <summary> /// Gets the system's default font family's name. /// </summary> string GetDefaultFontFamilyName(); /// <summary> /// Get all installed fonts in the system. /// <param name="checkForUpdates">If <c>true</c> the font collection is update...
I'm well aware that this interface is marked as unstable, but any mismatched versions between `Avalonia` and `Avalonia.Skia` (e.g. 11.3.8 and 11.3.9) will throw at runtime. Can we keep the old overload just so that we don't introduce this issue, and add the new one to `IFontManagerImpl2`?
{ /// <summary> /// Gets the system's default font family's name. /// </summary> string GetDefaultFontFamilyName(); /// <summary> /// Get all installed fonts in the system. /// <param name="checkForUpdates">If <c>true</c> the font collection is update...
@@ -35,7 +35,7 @@ public interface IFontManagerImpl /// <c>True</c>, if the <see cref="IFontManagerImpl"/> could match the character to specified parameters, <c>False</c> otherwise. /// </returns> bool TryMatchCharacter(int codepoint, FontStyle fontStyle, - FontWeight fontWeigh...
src/Avalonia.Base/Platform/IFontManagerImpl.cs
26
C#
0.571
question
292
51
51
false
Cache platform font manager TryMatchCharacter result
19,987
AvaloniaUI/Avalonia
24,333
C#
MrJul
Gillibald
Review this pull request change. Language: C# File: src/Avalonia.Base/Platform/IFontManagerImpl.cs PR Title: Cache platform font manager TryMatchCharacter result BEFORE CODE: { /// <summary> /// Gets the system's default font family's name. /// </summary> string GetDefaultFon...
I'm well aware that this interface is marked as unstable, but any mismatched versions between `Avalonia` and `Avalonia.Skia` (e.g. 11.3.8 and 11.3.9) will throw at runtime. Can we keep the old overload just so that we don't introduce this issue, and add the new one to `IFontManagerImpl2`?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using Avalonia.Platform; namespace Avalonia.Media.Fonts { internal class SystemFontCollection : FontCollectionBase, IFontCollection2 { private readonly FontMan...
Note: this isn't really thread-safe, but also isn't worse than before. Considering that everything related to font matching happens in practice on the UI thread, it's very, very unlikely for this code to really be concurrent. Since it's going to be rewritten for v12 anyways, it's good for now.
AddGlyphTypefaceByFamilyName(glyphTypeface.FamilyName, glyphTypeface); match = new Typeface(glyphTypeface.FamilyName, glyphTypeface.Style, glyphTypeface.Weight, glyphTypeface.Stretch); return true; } r...
@@ -172,5 +158,49 @@ public bool TryGetFamilyTypefaces(string familyName, [NotNullWhen(true)] out IRe return false; } + + public override bool TryMatchCharacter(int codepoint, FontStyle style, FontWeight weight, FontStretch stretch, string? familyName, + CultureInfo? culture, o...
src/Avalonia.Base/Media/Fonts/SystemFontCollection.cs
26
C#
0.643
suggestion
295
177
36
false
Cache platform font manager TryMatchCharacter result
19,987
AvaloniaUI/Avalonia
24,333
C#
MrJul
Gillibald
Review this pull request change. Language: C# File: src/Avalonia.Base/Media/Fonts/SystemFontCollection.cs PR Title: Cache platform font manager TryMatchCharacter result BEFORE CODE: using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using Sys...
Note: this isn't really thread-safe, but also isn't worse than before. Considering that everything related to font matching happens in practice on the UI thread, it's very, very unlikely for this code to really be concurrent. Since it's going to be rewritten for v12 anyways, it's good for now.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
using (_gpu.EnsureCurrent()) { wait.Semaphore.WaitTimelineSemaphore(_image, waitForValue); try { return TakeSnapshot(); } finally { signal.Semaphore.SignalTimelineSemaphore(_image, signalValue); ...
Note that having a lingering surface will consume not only it's color attachment but a depth buffer too.
{ using (_gpu.EnsureCurrent()) return TakeSnapshot(); } private int CopyToNewTexture(int textureType, int sourceTextureId, int internalFormat, int width, int height) { var gl = _gpu.GlContext.GlInterface; using var _ = _gpu.EnsureCurrent(); // Snapshot curr...
@@ -240,4 +277,15 @@ public IBitmapImpl SnapshotWithAutomaticSync() using (_gpu.EnsureCurrent()) return TakeSnapshot(); } + + private sealed class SnapshotBuffer(int width, int height, SKSurface surface) + : IDisposable + { + public int Width { get; } = width; + pub...
src/Skia/Avalonia.Skia/Gpu/OpenGl/GlSkiaExternalObjectsFeature.cs
26
C#
0.357
suggestion
104
32
41
false
Properly snapshot GlSkiaImportedImage
20,053
AvaloniaUI/Avalonia
24,333
C#
kekekeks
MrJul
Review this pull request change. Language: C# File: src/Skia/Avalonia.Skia/Gpu/OpenGl/GlSkiaExternalObjectsFeature.cs PR Title: Properly snapshot GlSkiaImportedImage BEFORE CODE: using (_gpu.EnsureCurrent()) { wait.Semaphore.WaitTimelineSemaphore(_image, waitForValue); try ...
Note that having a lingering surface will consume not only it's color attachment but a depth buffer too.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
=> _feature?.GetSynchronizationCapabilities(imageHandleType) ?? default; public byte[]? DeviceUuid => _feature?.DeviceUuid; public byte[]? DeviceLuid => _feature?.DeviceLuid; } internal class GlSkiaImportedSemaphore : IPlatformRenderInterfaceImportedSemaphore { private readonly GlSkiaGpu _gpu; ...
FBO can be reused by the entire GlSkiaExternalObjectsFeature
public CompositionGpuImportedImageSynchronizationCapabilities GetSynchronizationCapabilities(string imageHandleType) => _feature?.GetSynchronizationCapabilities(imageHandleType) ?? default; public int Fbo { get { if (_fbo == 0) _fbo = _gpu.GlContext.GlInt...
@@ -82,6 +82,7 @@ internal class GlSkiaImportedImage : IPlatformRenderInterfaceImportedImage private readonly GlSkiaSharedTextureForComposition? _sharedTexture; private readonly GlSkiaGpu _gpu; private readonly IGlExternalImageTexture? _image; + private int _fbo;
src/Skia/Avalonia.Skia/Gpu/OpenGl/GlSkiaExternalObjectsFeature.cs
26
C#
0.286
suggestion
60
51
51
false
Properly snapshot GlSkiaImportedImage
20,053
AvaloniaUI/Avalonia
24,333
C#
kekekeks
MrJul
Review this pull request change. Language: C# File: src/Skia/Avalonia.Skia/Gpu/OpenGl/GlSkiaExternalObjectsFeature.cs PR Title: Properly snapshot GlSkiaImportedImage BEFORE CODE: => _feature?.GetSynchronizationCapabilities(imageHandleType) ?? default; public byte[]? DeviceUuid => _feature?.DeviceUuid; ...
FBO can be reused by the entire GlSkiaExternalObjectsFeature
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
var internalFormat = _image?.InternalFormat ?? _sharedTexture!.InternalFormat; var textureId = _image?.TextureId ?? _sharedTexture!.TextureId; var topLeft = _image?.Properties.TopLeftOrigin ?? false; var textureType = _image?.TextureType ?? GL_TEXTURE_2D; var snapshotTextureId =...
Need to delete `snapshotTextureId` here since texture ownership wasn't transferred to Skia
if (image is not null) return image; using var unformatted = new GRBackendTexture(width, height, false, new GRGlTextureInfo((uint)target, (uint)textureId)); return SKImage.FromAdoptedTexture(_gpu.GrContext, unformatted, origin, SKColorType.Rgba8888); } IBitmapI...
@@ -109,63 +116,63 @@ SKColorType ConvertColorType(PlatformGraphicsExternalImageFormat format) => _ => SKColorType.Rgba8888 }; - SKSurface? TryCreateSurface(int target, int textureId, int format, int width, int height, bool topLeft) + SKImage? TryCreateImage(int target, int textureId, int ...
src/Skia/Avalonia.Skia/Gpu/OpenGl/GlSkiaExternalObjectsFeature.cs
26
C#
0.357
suggestion
90
51
51
false
Properly snapshot GlSkiaImportedImage
20,053
AvaloniaUI/Avalonia
24,333
C#
kekekeks
MrJul
Review this pull request change. Language: C# File: src/Skia/Avalonia.Skia/Gpu/OpenGl/GlSkiaExternalObjectsFeature.cs PR Title: Properly snapshot GlSkiaImportedImage BEFORE CODE: var internalFormat = _image?.InternalFormat ?? _sharedTexture!.InternalFormat; var textureId = _image?.TextureId ?? _shar...
Need to delete `snapshotTextureId` here since texture ownership wasn't transferred to Skia
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
using System; using System.Collections.Generic; using Avalonia.OpenGL; using Avalonia.Platform; using Avalonia.Rendering.Composition; using SkiaSharp; using static Avalonia.OpenGL.GlConsts; namespace Avalonia.Skia; internal class GlSkiaExternalObjectsFeature : IExternalObjectsRenderInterfaceContextFeature { priva...
Make sure to call `glDisable(GL_SCISSOR_TEST)`. It might be left ON by Skia previously and it will clip the operation. It took a while to figure last time...
using (_gpu.EnsureCurrent()) return TakeSnapshot(); } private int CopyToNewTexture(int textureType, int sourceTextureId, int internalFormat, int width, int height) { var gl = _gpu.GlContext.GlInterface; using var _ = _gpu.EnsureCurrent(); // Snapshot current va...
@@ -240,4 +247,31 @@ public IBitmapImpl SnapshotWithAutomaticSync() using (_gpu.EnsureCurrent()) return TakeSnapshot(); } + + private int CopyToNewTexture(int textureType, int sourceTextureId, int internalFormat, int width, int height) + { + var gl = _gpu.GlContext.GlInterface; +...
src/Skia/Avalonia.Skia/Gpu/OpenGl/GlSkiaExternalObjectsFeature.cs
26
C#
0.5
suggestion
158
278
40
false
Properly snapshot GlSkiaImportedImage
20,053
AvaloniaUI/Avalonia
24,333
C#
kekekeks
MrJul
Review this pull request change. Language: C# File: src/Skia/Avalonia.Skia/Gpu/OpenGl/GlSkiaExternalObjectsFeature.cs PR Title: Properly snapshot GlSkiaImportedImage BEFORE CODE: using System; using System.Collections.Generic; using Avalonia.OpenGL; using Avalonia.Platform; using Avalonia.Rendering.Composition; usi...
Make sure to call `glDisable(GL_SCISSOR_TEST)`. It might be left ON by Skia previously and it will clip the operation. It took a while to figure last time...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
public IBitmapImpl SnapshotWithAutomaticSync() { using (_gpu.EnsureCurrent()) return TakeSnapshot(); } private int CopyToNewTexture(int textureType, int sourceTextureId, int internalFormat, int width, int height) { var gl = _gpu.GlContext.GlInterface; using var ...
Note that `GL_READ_FRAMEBUFFER` is not Available with OpenGLES 2.0. Using `GL_FRAMEBUFFER` is safe since it affects both read and write framebuffers.
var signal = (GlSkiaImportedSemaphore)signalSemaphore; using (_gpu.EnsureCurrent()) { wait.Semaphore.WaitTimelineSemaphore(_image, waitForValue); try { return TakeSnapshot(); } finally { signa...
@@ -240,4 +247,31 @@ public IBitmapImpl SnapshotWithAutomaticSync() using (_gpu.EnsureCurrent()) return TakeSnapshot(); } + + private int CopyToNewTexture(int textureType, int sourceTextureId, int internalFormat, int width, int height) + { + var gl = _gpu.GlContext.GlInterface; +...
src/Skia/Avalonia.Skia/Gpu/OpenGl/GlSkiaExternalObjectsFeature.cs
26
C#
0.5
suggestion
149
34
51
false
Properly snapshot GlSkiaImportedImage
20,053
AvaloniaUI/Avalonia
24,333
C#
kekekeks
MrJul
Review this pull request change. Language: C# File: src/Skia/Avalonia.Skia/Gpu/OpenGl/GlSkiaExternalObjectsFeature.cs PR Title: Properly snapshot GlSkiaImportedImage BEFORE CODE: public IBitmapImpl SnapshotWithAutomaticSync() { using (_gpu.EnsureCurrent()) return TakeSnapshot(); } ...
Note that `GL_READ_FRAMEBUFFER` is not Available with OpenGLES 2.0. Using `GL_FRAMEBUFFER` is safe since it affects both read and write framebuffers.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
using System; using System.Collections.Generic; using Avalonia.OpenGL; using Avalonia.Platform; using Avalonia.Rendering.Composition; using SkiaSharp; using static Avalonia.OpenGL.GlConsts; namespace Avalonia.Skia; internal class GlSkiaExternalObjectsFeature : IExternalObjectsRenderInterfaceContextFeature { priva...
Unbind the texture from the color attachment once you are done with it (i. e. before glFlush)
{ signal.Semaphore.SignalTimelineSemaphore(_image, signalValue); } } } public IBitmapImpl SnapshotWithAutomaticSync() { using (_gpu.EnsureCurrent()) return TakeSnapshot(); } private int CopyToNewTexture(int textureType, int source...
@@ -240,4 +247,31 @@ public IBitmapImpl SnapshotWithAutomaticSync() using (_gpu.EnsureCurrent()) return TakeSnapshot(); } + + private int CopyToNewTexture(int textureType, int sourceTextureId, int internalFormat, int width, int height) + { + var gl = _gpu.GlContext.GlInterface; +...
src/Skia/Avalonia.Skia/Gpu/OpenGl/GlSkiaExternalObjectsFeature.cs
26
C#
0.214
suggestion
93
278
48
false
Properly snapshot GlSkiaImportedImage
20,053
AvaloniaUI/Avalonia
24,333
C#
kekekeks
MrJul
Review this pull request change. Language: C# File: src/Skia/Avalonia.Skia/Gpu/OpenGl/GlSkiaExternalObjectsFeature.cs PR Title: Properly snapshot GlSkiaImportedImage BEFORE CODE: using System; using System.Collections.Generic; using Avalonia.OpenGL; using Avalonia.Platform; using Avalonia.Rendering.Composition; usi...
Unbind the texture from the color attachment once you are done with it (i. e. before glFlush)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
return TakeSnapshot(); } finally { signal.Semaphore.SignalTimelineSemaphore(_image, signalValue); } } } public IBitmapImpl SnapshotWithAutomaticSync() { using (_gpu.EnsureCurrent()) return TakeSnapsh...
It _might_ be a good idea to save previous `GL_FRAMEBUFFER`(`_BINDING`) / `GL_READ_FRAMEBUFFER`(`_BINDING`) and `GL_SCISSOR_TEST` values and restore those afterwards. Not necessary right now since the entire texture import operation currently happens before Skia calls, but it could save us a `GrContext.Reset()` call...
public IBitmapImpl SnapshotWithTimelineSemaphores(IPlatformRenderInterfaceImportedSemaphore waitForSemaphore, ulong waitForValue, IPlatformRenderInterfaceImportedSemaphore signalSemaphore, ulong signalValue) { if (_image is null) { throw new NotSupportedException("Only suppor...
@@ -240,4 +247,31 @@ public IBitmapImpl SnapshotWithAutomaticSync() using (_gpu.EnsureCurrent()) return TakeSnapshot(); } + + private int CopyToNewTexture(int textureType, int sourceTextureId, int internalFormat, int width, int height) + { + var gl = _gpu.GlContext.GlInterface; +...
src/Skia/Avalonia.Skia/Gpu/OpenGl/GlSkiaExternalObjectsFeature.cs
26
C#
0.643
suggestion
326
43
51
false
Properly snapshot GlSkiaImportedImage
20,053
AvaloniaUI/Avalonia
24,333
C#
kekekeks
MrJul
Review this pull request change. Language: C# File: src/Skia/Avalonia.Skia/Gpu/OpenGl/GlSkiaExternalObjectsFeature.cs PR Title: Properly snapshot GlSkiaImportedImage BEFORE CODE: return TakeSnapshot(); } finally { signal.Semaphore.SignalTimelineSem...
It _might_ be a good idea to save previous `GL_FRAMEBUFFER`(`_BINDING`) / `GL_READ_FRAMEBUFFER`(`_BINDING`) and `GL_SCISSOR_TEST` values and restore those afterwards. Not necessary right now since the entire texture import operation currently happens before Skia calls, but it could save us a `GrContext.Reset()` call...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
var root = new TestRoot() { Child = sp }; target1.SelectionStart = 0; target1.SelectionEnd = 4; target1.Focus(); Assert.True(target1.IsFocused); Assert.Equal("1234", target1.SelectedText); t...
The test should probably not use platform specific line endings, as the code being tested does not. Have a test for \n, \r\n and \r?
var root = new TestRoot() { Child = sp }; target1.SelectionStart = 0; target1.SelectionEnd = 4; target1.Focus(); Assert.True(target1.IsFocused); Assert.Equal("1234", target1.SelectedText); t...
@@ -2129,6 +2129,25 @@ public void Losing_Focus_Should_Not_Reset_Selection() } } + [Fact] + public void Backspace_Should_Delete_Newline_Character_At_Once() + { + using var _ = UnitTestApplication.Start(Services); + var target = new TextBox + ...
tests/Avalonia.Controls.UnitTests/TextBoxTests.cs
26
C#
0.429
question
132
51
51
false
Fixed the issue where a newline character required two backspaces to be deleted in Windows.
20,073
AvaloniaUI/Avalonia
24,333
C#
miloush
Linlccc
Review this pull request change. Language: C# File: tests/Avalonia.Controls.UnitTests/TextBoxTests.cs PR Title: Fixed the issue where a newline character required two backspaces to be deleted in Windows. BEFORE CODE: var root = new TestRoot() { Child = sp }; target1.SelectionStart ...
The test should probably not use platform specific line endings, as the code being tested does not. Have a test for \n, \r\n and \r?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
s_intermediatePointsPooledList.Clear(); s_sortedPoints.Clear(); s_sortedPoints.Capacity = pointsCount; for (int i = 0; i < pointsCount; i++) { var mp = movePoints[i]; var x = mp.x > 32767 ? mp.x - ...
Unless I'm missing something, considering that the points are sorted by time, all further points will also be `> movePoint.Time` so we can `break` out of the loop instead. That said, it might simply be easier (and more performant) to avoid adding points that aren't between `prevModePoint.time` and `movePoint.time` to ...
s_intermediatePointsPooledList.Clear(); s_sortedPoints.Clear(); s_sortedPoints.Capacity = pointsCount; for (int i = 0; i < pointsCount; i++) { var mp = movePoints[i]; var x = mp.x > 32767 ? mp.x - ...
@@ -994,54 +996,59 @@ private unsafe IReadOnlyList<RawPointerPoint> CreateIntermediatePoints(MOUSEMOVE { var movePointCopy = movePoint; movePointCopy.time = 0; // empty "time" as otherwise WinAPI will always fail + int pointsCount = GetMouseMovePointsEx( ...
src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs
26
C#
0.643
suggestion
352
51
51
false
Fixed intermediate points order for windows
20,075
AvaloniaUI/Avalonia
24,333
C#
MrJul
flabbet
Review this pull request change. Language: C# File: src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs PR Title: Fixed intermediate points order for windows BEFORE CODE: s_intermediatePointsPooledList.Clear(); s_sortedPoints.Clear(); s_sortedPoints.Capacity = points...
Unless I'm missing something, considering that the points are sorted by time, all further points will also be `> movePoint.Time` so we can `break` out of the loop instead. That said, it might simply be easier (and more performant) to avoid adding points that aren't between `prevModePoint.time` and `movePoint.time` to ...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
movePointCopy.time = 0; // empty "time" as otherwise WinAPI will always fail int pointsCount = GetMouseMovePointsEx( (uint)(Marshal.SizeOf(movePointCopy)), &movePointCopy, movePoints, s_mouseHistoryInfos.Length, 1); ...
Note: the previous and current point are now ignored. This matches what we do in `WM_POINTER` so that's good.
{ var movePointCopy = movePoint; movePointCopy.time = 0; // empty "time" as otherwise WinAPI will always fail int pointsCount = GetMouseMovePointsEx( (uint)(Marshal.SizeOf(movePointCopy)), &movePointCopy, movePoints, s_...
@@ -994,54 +996,54 @@ private unsafe IReadOnlyList<RawPointerPoint> CreateIntermediatePoints(MOUSEMOVE { var movePointCopy = movePoint; movePointCopy.time = 0; // empty "time" as otherwise WinAPI will always fail + int pointsCount = GetMouseMovePointsEx( ...
src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs
26
C#
0.5
suggestion
109
51
51
false
Fixed intermediate points order for windows
20,075
AvaloniaUI/Avalonia
24,333
C#
MrJul
flabbet
Review this pull request change. Language: C# File: src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs PR Title: Fixed intermediate points order for windows BEFORE CODE: movePointCopy.time = 0; // empty "time" as otherwise WinAPI will always fail int pointsCount = GetMouseMovePoints...
Note: the previous and current point are now ignored. This matches what we do in `WM_POINTER` so that's good.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
using System; using ControlCatalog; using Avalonia; namespace WindowsInteropTest { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { System.Windows.Forms.Application.Ena...
Nit: this is a Windows only project, we already have `UseWin32()` above.
using System; using ControlCatalog; using Avalonia; namespace WindowsInteropTest { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { System.Windows.Forms.Application.Ena...
@@ -17,6 +17,7 @@ static void Main() AppBuilder.Configure<App>() .UseWin32() .UseSkia() + .UsePlatformDetect()
samples/interop/WindowsInteropTest/Program.cs
20
C#
0.429
nitpick
72
26
25
false
Fix popups not closing when using WinForms Host
20,090
AvaloniaUI/Avalonia
24,333
C#
MrJul
emmauss
Review this pull request change. Language: C# File: samples/interop/WindowsInteropTest/Program.cs PR Title: Fix popups not closing when using WinForms Host BEFORE CODE: using System; using ControlCatalog; using Avalonia; namespace WindowsInteropTest { static class Program { /// <summary> /...
Nit: this is a Windows only project, we already have `UseWin32()` above.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} /// <inheritdoc /> protected override void OnPaint(PaintEventArgs e) { if (DesignMode) { const string message = "Avalonia control is disabled in design mode."; using var pen = new Pen(SystemBrushes.ControlDark); var outline = ClientSize - new SizeF...
For performance, check the message first. If we're not interested in it, you can return immediately, avoiding all the further checks. `IsOurWindow` takes a lock and iterates through all windows (granted, we aren't expecting many of those).
} /// <inheritdoc /> protected override void OnPaint(PaintEventArgs e) { if (DesignMode) { const string message = "Avalonia control is disabled in design mode."; using var pen = new Pen(SystemBrushes.ControlDark); var outline = ClientSize - new SizeF...
@@ -135,4 +138,26 @@ protected override void OnPaint(PaintEventArgs e) e.Graphics.DrawString(message, Font, SystemBrushes.ControlText, messageArea); } } + + public bool PreFilterMessage(ref Message m) + { + if (_root?.PlatformImpl is WindowImpl impl && !impl.IsOurWindow(m.HWnd))
src/Windows/Avalonia.Win32.Interoperability/WinForms/WinFormsAvaloniaControlHost.cs
26
C#
0.786
performance
239
46
46
false
Fix popups not closing when using WinForms Host
20,090
AvaloniaUI/Avalonia
24,333
C#
MrJul
emmauss
Review this pull request change. Language: C# File: src/Windows/Avalonia.Win32.Interoperability/WinForms/WinFormsAvaloniaControlHost.cs PR Title: Fix popups not closing when using WinForms Host BEFORE CODE: } /// <inheritdoc /> protected override void OnPaint(PaintEventArgs e) { if (DesignM...
For performance, check the message first. If we're not interested in it, you can return immediately, avoiding all the further checks. `IsOurWindow` takes a lock and iterates through all windows (granted, we aren't expecting many of those).
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
using WinFormsControl = System.Windows.Forms.Control; namespace Avalonia.Win32.Interoperability; /// <summary> /// An element that allows you to host a Avalonia control on a Windows Forms page. /// </summary> [ToolboxItem(true)] public class WinFormsAvaloniaControlHost : WinFormsControl { private AvControl? _cont...
`inputManager` can't be null here, `GetRequiredService()` would have thrown. Use `AvaloniaLocator.Current.GetService()` instead.
using WinFormsControl = System.Windows.Forms.Control; namespace Avalonia.Win32.Interoperability; /// <summary> /// An element that allows you to host a Avalonia control on a Windows Forms page. /// </summary> [ToolboxItem(true)] public class WinFormsAvaloniaControlHost : WinFormsControl, IMessageFilter { private ...
@@ -27,6 +31,29 @@ public class WinFormsAvaloniaControlHost : WinFormsControl public WinFormsAvaloniaControlHost() { SetStyle(ControlStyles.AllPaintingInWmPaint, true); + + var inputManager = AvaloniaLocator.Current.GetRequiredService<IInputManager>(); + + if(inputManager != null )
src/Windows/Avalonia.Win32.Interoperability/WinForms/WinFormsAvaloniaControlHost.cs
26
C#
0.714
suggestion
128
51
51
false
Fix winforms mnemonic handler being called when textbox is focused.
20,091
AvaloniaUI/Avalonia
24,333
C#
MrJul
emmauss
Review this pull request change. Language: C# File: src/Windows/Avalonia.Win32.Interoperability/WinForms/WinFormsAvaloniaControlHost.cs PR Title: Fix winforms mnemonic handler being called when textbox is focused. BEFORE CODE: using WinFormsControl = System.Windows.Forms.Control; namespace Avalonia.Win32.Interoper...
`inputManager` can't be null here, `GetRequiredService()` would have thrown. Use `AvaloniaLocator.Current.GetService()` instead.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
using System; using System.Runtime.InteropServices; using System.Runtime.Versioning; using Android.Runtime; using Android.Views; using Avalonia.Platform; namespace Avalonia.Android.Platform.SkiaPlatform { unsafe class AndroidFramebuffer : ILockedFramebuffer { private IntPtr _window; public And...
`InvalidationAwareSurfaceView.HandleDescriptor` should return `ANativeWindow` instead of `SurfaceView` to make it consistent with the actual handle content. But it is technically a silent breaking change.
using System; using System.Runtime.InteropServices; using System.Runtime.Versioning; using Avalonia.Platform; namespace Avalonia.Android.Platform.SkiaPlatform { unsafe class AndroidFramebuffer : ILockedFramebuffer { private IntPtr _window; public AndroidFramebuffer(InvalidationAwareSurfaceView...
@@ -11,11 +9,11 @@ unsafe class AndroidFramebuffer : ILockedFramebuffer { private IntPtr _window; - public AndroidFramebuffer(Surface surface, double scaling) + public AndroidFramebuffer(InvalidationAwareSurfaceView surface, double scaling) { if(surface == null) ...
src/Android/Avalonia.Android/Platform/SkiaPlatform/AndroidFramebuffer.cs
16
C#
0.786
suggestion
204
41
41
false
Android - Directly use the surface window handle cached in InvalidationAwareSurfaceView instead of requesting new handles
20,093
AvaloniaUI/Avalonia
24,333
C#
maxkatz6
emmauss
Review this pull request change. Language: C# File: src/Android/Avalonia.Android/Platform/SkiaPlatform/AndroidFramebuffer.cs PR Title: Android - Directly use the surface window handle cached in InvalidationAwareSurfaceView instead of requesting new handles BEFORE CODE: using System; using System.Runtime.InteropServ...
`InvalidationAwareSurfaceView.HandleDescriptor` should return `ANativeWindow` instead of `SurfaceView` to make it consistent with the actual handle content. But it is technically a silent breaking change.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} protected override TextLayout CreateTextLayout(string? text) { var typeface = new Typeface(FontFamily, FontStyle, FontWeight, FontStretch); var defaultProperties = new GenericTextRunProperties( typeface, FontFeatures, Fo...
By default, we should apply the old logic; only if `_textRuns` is not null should we apply the new logic.
} protected override TextLayout CreateTextLayout(string? text) { var typeface = new Typeface(FontFamily, FontStyle, FontWeight, FontStretch); var defaultProperties = new GenericTextRunProperties( typeface, FontFeatures, Fo...
@@ -197,20 +197,48 @@ protected override TextLayout CreateTextLayout(string? text) LineSpacing = LineSpacing }; - IReadOnlyList<ValueSpan<TextRunProperties>>? textStyleOverrides = null; + List<ValueSpan<TextRunProperties>>? textStyleOverrides = null; va...
src/Avalonia.Controls/SelectableTextBlock.cs
26
C#
0.714
suggestion
105
51
51
false
Preserve run formatting when applying SelectionForegroundBrush in SelectableTextBlock
20,110
AvaloniaUI/Avalonia
24,333
C#
Gillibald
AuroraZiling
Review this pull request change. Language: C# File: src/Avalonia.Controls/SelectableTextBlock.cs PR Title: Preserve run formatting when applying SelectionForegroundBrush in SelectableTextBlock BEFORE CODE: } protected override TextLayout CreateTextLayout(string? text) { var type...
By default, we should apply the old logic; only if `_textRuns` is not null should we apply the new logic.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} var orientation = displayContext.Resources?.Configuration?.Orientation; if (orientation == AndroidOrientation.Square) naturalOrientation = ScreenOrientation.None; else if (rotation is global::Android.Views.SurfaceOrientation.Rotation0 or global::Android...
Add an alias instead, like it's done for `AndroidOrientation`.
Scaling = config.DensityDpi / (float)global::Android.Util.DisplayMetricsDensity.Default; } var orientation = displayContext.Resources?.Configuration?.Orientation; if (orientation == AndroidOrientation.Square) naturalOrientation = ScreenOrientation.Non...
@@ -73,14 +73,14 @@ public void Refresh(Context context) CurrentOrientation = (display.Rotation, naturalOrientation) switch { (_, ScreenOrientation.None) => ScreenOrientation.None, - (SurfaceOrientation.Rotation0, ScreenOrientation.Landscape) => ScreenOrientation.Landscape, - ...
src/Android/Avalonia.Android/Platform/AndroidScreens.cs
26
C#
0.429
suggestion
62
51
51
false
Add screen orientation support for Linux DRM
20,154
AvaloniaUI/Avalonia
24,333
C#
MrJul
ThadHouse
Review this pull request change. Language: C# File: src/Android/Avalonia.Android/Platform/AndroidScreens.cs PR Title: Add screen orientation support for Linux DRM BEFORE CODE: } var orientation = displayContext.Resources?.Configuration?.Orientation; if (orientation == AndroidOri...
Add an alias instead, like it's done for `AndroidOrientation`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
if (res != 0) throw new Win32Exception(res, "drmModeSetCrtc failed"); _mode = mode; _currentBo = bo; // Initialize FBO for rotation if needed var needsRotation = _outputOptions.Orientation != SurfaceOrientation.Rotation0; ...
You can simplify this with the `gl.GenTexture()` helper method.
if (res != 0) throw new Win32Exception(res, "drmModeSetCrtc failed"); _mode = mode; _currentBo = bo; // Initialize FBO for rotation if needed var needsRotation = _outputOptions.Orientation != SurfaceOrientation.Rotation0; ...
@@ -236,6 +249,143 @@ uint GetCrtc() _mode = mode; _currentBo = bo; + + // Initialize FBO for rotation if needed + var needsRotation = _outputOptions.Orientation != SurfaceOrientation.Rotation0; + if (needsRotation) + { + ...
src/Linux/Avalonia.LinuxFramebuffer/Output/DrmOutput.cs
26
C#
0.429
refactor
63
51
51
false
Add screen orientation support for Linux DRM
20,154
AvaloniaUI/Avalonia
24,333
C#
MrJul
ThadHouse
Review this pull request change. Language: C# File: src/Linux/Avalonia.LinuxFramebuffer/Output/DrmOutput.cs PR Title: Add screen orientation support for Linux DRM BEFORE CODE: if (res != 0) throw new Win32Exception(res, "drmModeSetCrtc failed"); _mode = mode; _cu...
You can simplify this with the `gl.GenTexture()` helper method.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
-1.0f, -1.0f, 1.0f, 1.0f, // Bottom-left -> Top-right of texture 1.0f, -1.0f, 0.0f, 1.0f, // Bottom-right -> Top-left of texture 1.0f, 1.0f, 0.0f, 0.0f, // Top-right -> Bottom-left of texture ...
You can simplify this with the `gl.GenBuffer()` helper method.
// 270° clockwise (90° counter-clockwise) rotation -1.0f, -1.0f, 0.0f, 1.0f, // Bottom-left -> Top-left of texture 1.0f, -1.0f, 0.0f, 0.0f, // Bottom-right -> Bottom-left of texture 1.0f, 1...
@@ -236,6 +249,143 @@ uint GetCrtc() _mode = mode; _currentBo = bo; + + // Initialize FBO for rotation if needed + var needsRotation = _outputOptions.Orientation != SurfaceOrientation.Rotation0; + if (needsRotation) + { + ...
src/Linux/Avalonia.LinuxFramebuffer/Output/DrmOutput.cs
26
C#
0.429
refactor
62
51
51
false
Add screen orientation support for Linux DRM
20,154
AvaloniaUI/Avalonia
24,333
C#
MrJul
ThadHouse
Review this pull request change. Language: C# File: src/Linux/Avalonia.LinuxFramebuffer/Output/DrmOutput.cs PR Title: Add screen orientation support for Linux DRM BEFORE CODE: -1.0f, -1.0f, 1.0f, 1.0f, // Bottom-left -> Top-right of texture 1.0f, -1.0...
You can simplify this with the `gl.GenBuffer()` helper method.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
}, SurfaceOrientation.Rotation270 => new float[] { // 270° clockwise (90° counter-clockwise) rotation -1.0f, -1.0f, 0.0f, 1.0f, // Bottom-left -> Top-left of texture 1.0f, -1.0f, ...
You can simplify this with the `gl.GenVertexArray()` helper method.
-1.0f, 1.0f, 1.0f, 1.0f // Top-left -> Top-right of texture }, _ => new float[] { // No rotation (shouldn't reach here but fallback) -1.0f, -1.0f, 0.0f, 0.0f, ...
@@ -236,6 +249,143 @@ uint GetCrtc() _mode = mode; _currentBo = bo; + + // Initialize FBO for rotation if needed + var needsRotation = _outputOptions.Orientation != SurfaceOrientation.Rotation0; + if (needsRotation) + { + ...
src/Linux/Avalonia.LinuxFramebuffer/Output/DrmOutput.cs
26
C#
0.429
refactor
67
51
51
false
Add screen orientation support for Linux DRM
20,154
AvaloniaUI/Avalonia
24,333
C#
MrJul
ThadHouse
Review this pull request change. Language: C# File: src/Linux/Avalonia.LinuxFramebuffer/Output/DrmOutput.cs PR Title: Add screen orientation support for Linux DRM BEFORE CODE: }, SurfaceOrientation.Rotation270 => new float[] { // 270° clock...
You can simplify this with the `gl.GenVertexArray()` helper method.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
break; } } var builder = BuildAvaloniaApp(); double GetScaling() { var idx = Array.IndexOf(args, "--scaling"); if (idx != 0 && args.Length > idx + 1 && double.TryParse(args[idx +...
Should be `idx >= 0`, otherwise that's parsing the first argument instead. (I'm aware that this bug was already present before and several times in this file.)
break; } } var builder = BuildAvaloniaApp(); double GetScaling() { var idx = Array.IndexOf(args, "--scaling"); if (idx != 0 && args.Length > idx + 1 && double.TryParse(args[idx +...
@@ -50,7 +45,22 @@ double GetScaling() return scaling; return 1; } - if (s_useFramebuffer) + SurfaceOrientation GetOrientation() + { + var idx = Array.IndexOf(args, "--orientation"); + if (idx != 0 && args....
samples/ControlCatalog.Desktop/Program.cs
26
C#
0.714
bug
159
51
51
false
Add screen orientation support for Linux DRM
20,154
AvaloniaUI/Avalonia
24,333
C#
MrJul
ThadHouse
Review this pull request change. Language: C# File: samples/ControlCatalog.Desktop/Program.cs PR Title: Add screen orientation support for Linux DRM BEFORE CODE: break; } } var builder = BuildAvaloniaApp(); double GetScaling() ...
Should be `idx >= 0`, otherwise that's parsing the first argument instead. (I'm aware that this bug was already present before and several times in this file.)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
namespace Avalonia.Controls.UnitTests.Shapes; public class PolygonTests : ScopedTestBase { [Fact] public void Polygon_Will_Update_Geometry_On_Shapes_Collection_Content_Change() { using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface); var points = new Observabl...
Note: Tested in the Gallery already but there is not a specific Shapes Page. Should include it?
namespace Avalonia.Controls.UnitTests.Shapes; public class PolygonTests : ScopedTestBase { [Fact] public void Polygon_Will_Update_Geometry_On_Shapes_Collection_Content_Change() { using var app = UnitTestApplication.Start(TestServices.MockPlatformRenderInterface); var points = new Observabl...
@@ -25,4 +26,21 @@ public void Polygon_Will_Update_Geometry_On_Shapes_Collection_Content_Change() root.Child = null; } + + [Fact] + public void FillRule_On_Polygon_Is_Applied_To_DefiningGeometry()
tests/Avalonia.Controls.UnitTests/Shapes/PolygonTests.cs
26
C#
0.286
question
95
42
51
false
[Feature] Add FillRule property for Polyline/Polygon
20,159
AvaloniaUI/Avalonia
24,333
C#
jsuarezruiz
jsuarezruiz
Review this pull request change. Language: C# File: tests/Avalonia.Controls.UnitTests/Shapes/PolygonTests.cs PR Title: [Feature] Add FillRule property for Polyline/Polygon BEFORE CODE: namespace Avalonia.Controls.UnitTests.Shapes; public class PolygonTests : ScopedTestBase { [Fact] public void Polygon_Wil...
Note: Tested in the Gallery already but there is not a specific Shapes Page. Should include it?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
using System.Collections.Generic; using System.Linq; using Avalonia.Media; using Avalonia.VisualTree; namespace Avalonia.Rendering; /// <summary> /// This class is used to render the visual tree into a DrawingContext by doing /// a simple tree traversal. /// It's currently used mostly for RenderTargetBitmap.Render a...
Can we change the order of parameters to match the other overloads?
using System.Collections.Generic; using System.Linq; using Avalonia.Media; using Avalonia.VisualTree; namespace Avalonia.Rendering; /// <summary> /// This class is used to render the visual tree into a DrawingContext by doing /// a simple tree traversal. /// It's currently used mostly for RenderTargetBitmap.Render a...
@@ -1,124 +1,89 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; -using Avalonia.Logging; using Avalonia.Media; -using Avalonia.Platform; using Avalonia.VisualTree; -namespace Avalonia.Rendering +namespace Avalonia.Rendering...
src/Avalonia.Base/Rendering/ImmediateRenderer.cs
20
C#
0.286
question
67
45
45
false
[Fix] ImmediateRenderer
20,174
AvaloniaUI/Avalonia
24,333
C#
Gillibald
ds1709
Review this pull request change. Language: C# File: src/Avalonia.Base/Rendering/ImmediateRenderer.cs PR Title: [Fix] ImmediateRenderer BEFORE CODE: using System.Collections.Generic; using System.Linq; using Avalonia.Media; using Avalonia.VisualTree; namespace Avalonia.Rendering; /// <summary> /// This class is u...
Can we change the order of parameters to match the other overloads?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
//--------------------------------------------------------------------------------------------------- // <auto-generated> // This code was generated by UnicodeDataGenerator. // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. // </auto-generated>" //----------------...
As discussed in the comments, please revert the changes in all `*.trie.cs` files. Or Use collection expressions (`[ ]`) since they are now available, they will be more obvious than `=> new`.
//--------------------------------------------------------------------------------------------------- // <auto-generated> // This code was generated by UnicodeDataGenerator. // Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. // </auto-generated>" //----------------...
@@ -18,7 +18,7 @@ public static UnicodeTrie Trie get => new(Data, 0x00100000, 0x00000000); } - private static ReadOnlySpan<uint> Data => new uint[]
src/Avalonia.Base/Media/TextFormatting/Unicode/BiDi.trie.cs
21
C#
0.571
suggestion
190
46
46
false
Reduce Allocations in Text Rendering
20,175
AvaloniaUI/Avalonia
24,333
C#
MrJul
Washi1337
Review this pull request change. Language: C# File: src/Avalonia.Base/Media/TextFormatting/Unicode/BiDi.trie.cs PR Title: Reduce Allocations in Text Rendering BEFORE CODE: //--------------------------------------------------------------------------------------------------- // <auto-generated> // This code was g...
As discussed in the comments, please revert the changes in all `*.trie.cs` files. Or Use collection expressions (`[ ]`) since they are now available, they will be more obvious than `=> new`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
new DBusInputMethodFactory<FcitxX11TextInputMethod>(_ => new FcitxX11TextInputMethod(conn)), ["fcitx5"] = static conn => new DBusInputMethodFactory<FcitxX11TextInputMethod>(_ => new FcitxX11TextInputMethod(conn)), ["ibus"] = static conn => ...
Can we parse this properly instead please? Currently, this code will match partial strings such as `@im=ibusabcdef` (ok, unlikely to happen, but let's be strict), and according to https://linux.die.net/man/3/xsetlocalemodifiers the order matters, with the first one winning.
new DBusInputMethodFactory<FcitxX11TextInputMethod>(_ => new FcitxX11TextInputMethod(conn)), ["fcitx5"] = static conn => new DBusInputMethodFactory<FcitxX11TextInputMethod>(_ => new FcitxX11TextInputMethod(conn)), ["ibus"] = static conn => ...
@@ -31,6 +31,18 @@ internal class X11DBusImeHelper return factory; } + var modifiers = Environment.GetEnvironmentVariable("XMODIFIERS"); + if (modifiers is not null && modifiers.Contains("@im=")) + { + foreach (var pair in KnownMethods)...
src/Avalonia.FreeDesktop/DBusIme/X11DBusImeHelper.cs
26
C#
0.643
question
276
51
51
false
[X11] Clean up IME inconsistencies
20,201
AvaloniaUI/Avalonia
24,333
C#
MrJul
AlanIWBFT
Review this pull request change. Language: C# File: src/Avalonia.FreeDesktop/DBusIme/X11DBusImeHelper.cs PR Title: [X11] Clean up IME inconsistencies BEFORE CODE: new DBusInputMethodFactory<FcitxX11TextInputMethod>(_ => new FcitxX11TextInputMethod(conn)), ["fcitx5"] = static conn...
Can we parse this properly instead please? Currently, this code will match partial strings such as `@im=ibusabcdef` (ok, unlikely to happen, but let's be strict), and according to https://linux.die.net/man/3/xsetlocalemodifiers the order matters, with the first one winning.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
if (format is DataFormat<byte[]> bytesFormat) { return dataTransfer.TryGetValue(bytesFormat) is { } bytes ? WriteBytesToHGlobal(ref hGlobal, bytes.AsSpan()) : DV_E_FORMATETC; } Logger.TryGet(LogEventLevel.Warning, LogArea.Win32Platform) ...
we could probably do here without a copy, there is MemoryStream.GetBuffer(), but it might be larger than you need, so you need to use Length
infoHeader.Init(); var imageData = new byte[infoHeader.bV5Size + infoHeader.bV5SizeImage]; fixed (byte* image = imageData) { Marshal.StructureToPtr(infoHeader, (IntPtr)image, false); ...
@@ -363,6 +362,20 @@ public unsafe static uint WriteDataToHGlobal(IDataTransfer dataTransfer, DataFor } } + if (ClipboardFormatRegistry.PngSystemDataFormat.Equals(format) + || ClipboardFormatRegistry.PngDataFormat.Equals(format)) + { + var bitmap = dataTransfe...
src/Windows/Avalonia.Win32/OleDataObjectHelper.cs
26
C#
0.571
suggestion
140
51
51
false
Win32 - export bitmap in more clipboard formats
20,209
AvaloniaUI/Avalonia
24,333
C#
miloush
emmauss
Review this pull request change. Language: C# File: src/Windows/Avalonia.Win32/OleDataObjectHelper.cs PR Title: Win32 - export bitmap in more clipboard formats BEFORE CODE: if (format is DataFormat<byte[]> bytesFormat) { return dataTransfer.TryGetValue(bytesFormat) is { } bytes ? ...
we could probably do here without a copy, there is MemoryStream.GetBuffer(), but it might be larger than you need, so you need to use Length
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
IntPtr hdc = IntPtr.Zero, compatDc = IntPtr.Zero, hbitmap = IntPtr.Zero; try { hdc = GetDC(IntPtr.Zero); if (hdc == IntPtr.Zero) return DV_E_FORMATETC; compat...
You are assuming pixel is 4 bytes here but use any BitsPerPixel value you get from the bitmap. These should be made to match (and match the reality). Some of the formats, and especially the ones with transparency cannot be supported using BITMAPINFOHEADER, you need V5 header. The main benefit of using HBITMAP is that i...
return DV_E_FORMATETC; } if (format is DataFormat<string> stringFormat) { return dataTransfer.TryGetValue(stringFormat) is { } stringValue ? WriteStringToHGlobal(ref hGlobal, stringValue) : DV_E_FORMATETC; } if (format is ...
@@ -383,6 +396,76 @@ public unsafe static uint WriteDataToHGlobal(IDataTransfer dataTransfer, DataFor return DV_E_FORMATETC; } + public unsafe static uint WriteDataToGdi(IDataTransfer dataTransfer, DataFormat format, ref IntPtr hGlobalBitmap) + { + if (ClipboardFormatRegistry.HBitmapDataFor...
src/Windows/Avalonia.Win32/OleDataObjectHelper.cs
26
C#
0.5
suggestion
365
51
51
false
Win32 - export bitmap in more clipboard formats
20,209
AvaloniaUI/Avalonia
24,333
C#
miloush
emmauss
Review this pull request change. Language: C# File: src/Windows/Avalonia.Win32/OleDataObjectHelper.cs PR Title: Win32 - export bitmap in more clipboard formats BEFORE CODE: IntPtr hdc = IntPtr.Zero, compatDc = IntPtr.Zero, hbitmap = IntPtr.Zero; try { ...
You are assuming pixel is 4 bytes here but use any BitsPerPixel value you get from the bitmap. These should be made to match (and match the reality). Some of the formats, and especially the ones with transparency cannot be supported using BITMAPINFOHEADER, you need V5 header. The main benefit of using HBITMAP is that i...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
public static extern bool GetPointerPenInfoHistory(uint pointerId, ref int entriesCount, [MarshalAs(UnmanagedType.LPArray), In, Out] POINTER_PEN_INFO[] penInfos); [DllImport("user32.dll", SetLastError = true)] public static extern bool GetPointerTouchInfo(uint pointerId, out POINTER_TOUCH_INFO ...
instead of `[In] ref` you can just do `in` (and pass it without a qualifier at callsite)
} [StructLayout(LayoutKind.Sequential)] public struct BITMAPINFO { // C# cannot inlay structs in structs so must expand directly here // //[StructLayout(LayoutKind.Sequential)] //public struct BITMAPINFOHEADER //{ p...
@@ -1200,6 +1200,12 @@ public static extern int SetDIBitsToDevice(IntPtr hdc, int XDest, int YDest, uint uStartScan, uint cScanLines, IntPtr lpvBits, [In] ref BITMAPINFO lpbmi, uint fuColorUse); + [DllImport("gdi32.dll")] + public static extern int SetDIBits(IntPtr hdc, IntPtr h...
src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs
26
C#
0.429
suggestion
88
51
51
false
Win32 - export bitmap in more clipboard formats
20,209
AvaloniaUI/Avalonia
24,333
C#
miloush
emmauss
Review this pull request change. Language: C# File: src/Windows/Avalonia.Win32/Interop/UnmanagedMethods.cs PR Title: Win32 - export bitmap in more clipboard formats BEFORE CODE: public static extern bool GetPointerPenInfoHistory(uint pointerId, ref int entriesCount, [MarshalAs(UnmanagedType.LPArray), In, Ou...
instead of `[In] ref` you can just do `in` (and pass it without a qualifier at callsite)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
using System; using System.Collections.Generic; using System.ComponentModel; using Avalonia.Input; using Avalonia.Media.Imaging; using Avalonia.Utilities; using Avalonia.Win32.Interop; namespace Avalonia.Win32 { internal static class ClipboardFormatRegistry { private const int MaxFormatNameLength = 26...
The names are not too helpful, would prefer `PngDataFormat` for PNG and `PngMimeDataFormat` for image/png.
using System; using System.Collections.Generic; using System.ComponentModel; using Avalonia.Input; using Avalonia.Media.Imaging; using Avalonia.Utilities; using Avalonia.Win32.Interop; namespace Avalonia.Win32 { internal static class ClipboardFormatRegistry { private const int MaxFormatNameLength = 26...
@@ -12,17 +13,24 @@ internal static class ClipboardFormatRegistry private const int MaxFormatNameLength = 260; private const string AppPrefix = "avn-app-fmt:"; public const string PngFormatMimeType = "image/png"; - public const string JpegFormatMimeType = "image/jpeg"; public ...
src/Windows/Avalonia.Win32/ClipboardFormatRegistry.cs
21
C#
0.571
suggestion
106
46
46
false
Win32 - export bitmap in more clipboard formats
20,209
AvaloniaUI/Avalonia
24,333
C#
miloush
emmauss
Review this pull request change. Language: C# File: src/Windows/Avalonia.Win32/ClipboardFormatRegistry.cs PR Title: Win32 - export bitmap in more clipboard formats BEFORE CODE: using System; using System.Collections.Generic; using System.ComponentModel; using Avalonia.Input; using Avalonia.Media.Imaging; using Ava...
The names are not too helpful, would prefer `PngDataFormat` for PNG and `PngMimeDataFormat` for image/png.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
using System; using System.Collections.Generic; using System.ComponentModel; using Avalonia.Input; using Avalonia.Media.Imaging; using Avalonia.Utilities; using Avalonia.Win32.Interop; namespace Avalonia.Win32 { internal static class ClipboardFormatRegistry { private const int MaxFormatNameLength = 26...
why is `image/png` format extracted into const and `PNG` not?
using System; using System.Collections.Generic; using System.ComponentModel; using Avalonia.Input; using Avalonia.Media.Imaging; using Avalonia.Utilities; using Avalonia.Win32.Interop; namespace Avalonia.Win32 { internal static class ClipboardFormatRegistry { private const int MaxFormatNameLength = 26...
@@ -12,17 +13,24 @@ internal static class ClipboardFormatRegistry private const int MaxFormatNameLength = 260; private const string AppPrefix = "avn-app-fmt:"; public const string PngFormatMimeType = "image/png"; - public const string JpegFormatMimeType = "image/jpeg"; public ...
src/Windows/Avalonia.Win32/ClipboardFormatRegistry.cs
20
C#
0.429
refactor
61
45
45
false
Win32 - export bitmap in more clipboard formats
20,209
AvaloniaUI/Avalonia
24,333
C#
miloush
emmauss
Review this pull request change. Language: C# File: src/Windows/Avalonia.Win32/ClipboardFormatRegistry.cs PR Title: Win32 - export bitmap in more clipboard formats BEFORE CODE: using System; using System.Collections.Generic; using System.ComponentModel; using Avalonia.Input; using Avalonia.Media.Imaging; using Ava...
why is `image/png` format extracted into const and `PNG` not?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
if (DataFormat.File.Equals(format)) { var files = dataTransfer.TryGetValues(DataFormat.File) ?? []; IEnumerable<string> fileNames = files .Select(StorageProviderExtensions.TryGetLocalPath) .Where(path => path is not null)!; return Wri...
it is not V5 you would need to ensure the bitmap is one of the supported formats
{ var files = dataTransfer.TryGetValues(DataFormat.File) ?? []; IEnumerable<string> fileNames = files .Select(StorageProviderExtensions.TryGetLocalPath) .Where(path => path is not null)!; return WriteFileNamesToHGlobal(ref hGlobal, fileNames)...
@@ -326,44 +328,79 @@ public unsafe static uint WriteDataToHGlobal(IDataTransfer dataTransfer, DataFor return WriteFileNamesToHGlobal(ref hGlobal, fileNames); } - if (ClipboardFormatRegistry.DibDataFormat.Equals(format)) + if (ClipboardFormatRegistry.DibDataFormat.Equals(format) +...
src/Windows/Avalonia.Win32/OleDataObjectHelper.cs
26
C#
0.214
style
80
51
51
false
Win32 - export bitmap in more clipboard formats
20,209
AvaloniaUI/Avalonia
24,333
C#
miloush
emmauss
Review this pull request change. Language: C# File: src/Windows/Avalonia.Win32/OleDataObjectHelper.cs PR Title: Win32 - export bitmap in more clipboard formats BEFORE CODE: if (DataFormat.File.Equals(format)) { var files = dataTransfer.TryGetValues(DataFormat.File) ?? []; IE...
it is not V5 you would need to ensure the bitmap is one of the supported formats
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
biHeight = -pixelSize.Height, biBitCount = (ushort)bpp, biPlanes = 1, biCompression = BitmapCompressionMode.BI_RGB, }; infoHeader.Init(); ...
only valid for 16bpp and 32bpp, must be BI_RGB otherwise
biBitCount = (ushort)bpp, biPlanes = 1, biCompression = BitmapCompressionMode.BI_RGB, }; infoHeader.Init(); var imageData = new byte[infoHeader.biSize + infoHeader...
@@ -326,44 +328,79 @@ public unsafe static uint WriteDataToHGlobal(IDataTransfer dataTransfer, DataFor return WriteFileNamesToHGlobal(ref hGlobal, fileNames); } - if (ClipboardFormatRegistry.DibDataFormat.Equals(format)) + if (ClipboardFormatRegistry.DibDataFormat.Equals(format) +...
src/Windows/Avalonia.Win32/OleDataObjectHelper.cs
26
C#
0.214
suggestion
56
51
51
false
Win32 - export bitmap in more clipboard formats
20,209
AvaloniaUI/Avalonia
24,333
C#
miloush
emmauss
Review this pull request change. Language: C# File: src/Windows/Avalonia.Win32/OleDataObjectHelper.cs PR Title: Win32 - export bitmap in more clipboard formats BEFORE CODE: biHeight = -pixelSize.Height, biBitCount = (ushort)bpp, biP...
only valid for 16bpp and 32bpp, must be BI_RGB otherwise
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
IntPtr hdc = IntPtr.Zero, compatDc = IntPtr.Zero, hbitmap = IntPtr.Zero; try { hdc = GetDC(IntPtr.Zero); if (hdc == IntPtr.Zero) return DV_E_FORMATETC; compat...
why business here but colorimetric for dib?
IntPtr hdc = IntPtr.Zero, compatDc = IntPtr.Zero, desDc = IntPtr.Zero, hbitmap = IntPtr.Zero, section = IntPtr.Zero; try { hdc = GetDC(IntPtr.Zero); if (hdc == IntPtr.Zero) return DV_E...
@@ -421,32 +503,44 @@ public unsafe static uint WriteDataToGdi(IDataTransfer dataTransfer, DataFormat if (compatDc == IntPtr.Zero) return DV_E_FORMATETC; - hbitmap = CreateCompatibleBitmap(compatDc, pixelSize.Width, pixelSize.Height); - ...
src/Windows/Avalonia.Win32/OleDataObjectHelper.cs
26
C#
0.071
question
43
51
51
false
Win32 - export bitmap in more clipboard formats
20,209
AvaloniaUI/Avalonia
24,333
C#
miloush
emmauss
Review this pull request change. Language: C# File: src/Windows/Avalonia.Win32/OleDataObjectHelper.cs PR Title: Win32 - export bitmap in more clipboard formats BEFORE CODE: IntPtr hdc = IntPtr.Zero, compatDc = IntPtr.Zero, hbitmap = IntPtr.Zero; try { ...
why business here but colorimetric for dib?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
bool removeEmptyEntries = options.HasFlag(StringSplitOptions.RemoveEmptyEntries); bool trimEntries = options.HasFlag(StringSplitOptions.TrimEntries); for (int i = 0; i < span.Length; i++) { char ch = span[i]; if (ch == openingBracket) depth++; ...
The method doesn't check if there are unmatched opening brackets at the end of parsing. If the string ends with a depth greater than 0 (unclosed opening brackets), this should throw a FormatException similar to how unmatched closing brackets are handled. Currently, such input would be silently accepted. ```suggestion ...
int depth = 0; int segStart = 0; bool removeEmptyEntries = options.HasFlag(StringSplitOptions.RemoveEmptyEntries); bool trimEntries = options.HasFlag(StringSplitOptions.TrimEntries); for (int i = 0; i < span.Length; i++) { char ch = span[i]; if (...
@@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; + +namespace Avalonia.Utilities; + +/// <summary> +/// Helpers for splitting strings. +/// </summary> +internal static class StringSplitter +{ + private const char DefaultOpeningParenthesis = '('; + private const char DefaultClosingParenthesis =...
src/Avalonia.Base/Utilities/StringSplitter.cs
26
C#
1
suggestion
452
51
51
false
Add support for parsing BoxShadows with color functions
20,321
AvaloniaUI/Avalonia
24,333
C#
Copilot
gehongyan
Review this pull request change. Language: C# File: src/Avalonia.Base/Utilities/StringSplitter.cs PR Title: Add support for parsing BoxShadows with color functions BEFORE CODE: bool removeEmptyEntries = options.HasFlag(StringSplitOptions.RemoveEmptyEntries); bool trimEntries = options.HasFlag(String...
The method doesn't check if there are unmatched opening brackets at the end of parsing. If the string ends with a depth greater than 0 (unclosed opening brackets), this should throw a FormatException similar to how unmatched closing brackets are handled. Currently, such input would be silently accepted. ```suggestion ...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
var result = new string[ranges.Count]; for (int i = 0; i < ranges.Count; i++) { var r = ranges[i]; #if NET6_0_OR_GREATER result[i] = new string(span.Slice(r.start, r.length)); #else result[i] = span.Slice(r.start, r.length).ToString(); #endif } ...
The condition logic appears incorrect. When length is 0, you want to add it only if removeEmptyEntries is false. The current condition "length == 0 && !removeEmptyEntries" is correct, but it should be combined with the first condition using OR, not written as "length > 0 || length == 0 && !removeEmptyEntries". The curr...
// last segment ProcessSegment(segStart, span.Length - 1); if (ranges.Count == 0) return []; var result = new string[ranges.Count]; for (int i = 0; i < ranges.Count; i++) { var r = ranges[i]; #if NET6_0_OR_GREATER result[i] = new stri...
@@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; + +namespace Avalonia.Utilities; + +/// <summary> +/// Helpers for splitting strings. +/// </summary> +internal static class StringSplitter +{ + private const char DefaultOpeningParenthesis = '('; + private const char DefaultClosingParenthesis =...
src/Avalonia.Base/Utilities/StringSplitter.cs
26
C#
0.857
bug
478
31
36
false
Add support for parsing BoxShadows with color functions
20,321
AvaloniaUI/Avalonia
24,333
C#
Copilot
gehongyan
Review this pull request change. Language: C# File: src/Avalonia.Base/Utilities/StringSplitter.cs PR Title: Add support for parsing BoxShadows with color functions BEFORE CODE: var result = new string[ranges.Count]; for (int i = 0; i < ranges.Count; i++) { var r = ranges[i]; #if...
The condition logic appears incorrect. When length is 0, you want to add it only if removeEmptyEntries is false. The current condition "length == 0 && !removeEmptyEntries" is correct, but it should be combined with the first condition using OR, not written as "length > 0 || length == 0 && !removeEmptyEntries". The curr...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
DotNetBuild(c => ApplySetting(c) .SetProjectFile(Parameters.MSBuildSolution) ); }); Target OutputVersion => _ => _ .Requires(() => VersionOutputDir) .Executes(() => { var versionFile = Path.Combine(Parameters.VersionOutputDir, "ver...
I filed https://github.com/nuke-build/nuke/issues/1584. Meanwhile, I'm not very familiar with Nuke. Is there a way here to pass the full `dotnet test` command to be executed?
.DependsOn(Clean, CompileNative, InitDnx) .Executes(() => { DotNetBuild(c => ApplySetting(c) .SetProjectFile(Parameters.MSBuildSolution) ); }); Target OutputVersion => _ => _ .Requires(() => VersionOutputDir) .Executes(() => ...
@@ -182,6 +182,8 @@ void RunCoreTest(string projectName) { RunCoreTest(projectName, (project, tfm) => { + // TODO: Looks like this might be only supporting VSTest. + // Figure out how to fix this to run with Microsoft.Testing.Platform.
nukebuild/Build.cs
26
C#
0.5
question
177
51
51
false
Update to xunit.v3
20,331
AvaloniaUI/Avalonia
24,333
C#
Youssef1313
Youssef1313
Review this pull request change. Language: C# File: nukebuild/Build.cs PR Title: Update to xunit.v3 BEFORE CODE: DotNetBuild(c => ApplySetting(c) .SetProjectFile(Parameters.MSBuildSolution) ); }); Target OutputVersion => _ => _ .Requires(() => VersionOutp...
I filed https://github.com/nuke-build/nuke/issues/1584. Meanwhile, I'm not very familiar with Nuke. Is there a way here to pass the full `dotnet test` command to be executed?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
if (_fillMode is FillMode.Forward or FillMode.Both) _targetControl.SetValue(_animator.Property, _lastInterpValue); } private void DoComplete() { ApplyFinalFill(); _onCompleteAction?.Invoke(); PublishCompleted(); } ...
As discussed internally, we should probably fall back to the neutral value, since that's what the animator does for other key frames. This value is only used for the initial delay, if any.
if (_fillMode is FillMode.Forward or FillMode.Both) _targetControl.SetValue(_animator.Property, _lastInterpValue); } private void DoComplete() { ApplyFinalFill(); _onCompleteAction?.Invoke(); PublishCompleted(); } ...
@@ -137,7 +137,16 @@ private void DoPlayStates() if (!_gotFirstKFValue) { - _firstKFValue = (T)_animator.First().Value!; + var firstKeyFrame = _animator.First(); + if (firstKeyFrame.Value is null)
src/Avalonia.Base/Animation/AnimationInstance`1.cs
26
C#
0.429
suggestion
188
51
51
false
Null Reference Check for Animation keyframes
20,422
AvaloniaUI/Avalonia
24,333
C#
MrJul
drasticactions
Review this pull request change. Language: C# File: src/Avalonia.Base/Animation/AnimationInstance`1.cs PR Title: Null Reference Check for Animation keyframes BEFORE CODE: if (_fillMode is FillMode.Forward or FillMode.Both) _targetControl.SetValue(_animator.Property, _lastInterpValue); ...
As discussed internally, we should probably fall back to the neutral value, since that's what the animator does for other key frames. This value is only used for the initial delay, if any.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
} } - (NSString *)accessibilityRoleDescription { auto landmarkType = _peer->GetLandmarkType(); switch (landmarkType) { case LandmarkBanner: return @"banner"; case LandmarkComplementary: return @"complementary"; case LandmarkContentInfo: return @"content"; case LandmarkRegion...
Use the `kAXARIALiveAttribute` constant instead.
} } - (NSString *)accessibilityRoleDescription { auto landmarkType = _peer->GetLandmarkType(); switch (landmarkType) { case LandmarkBanner: return @"banner"; case LandmarkComplementary: return @"complementary"; case LandmarkContentInfo: return @"content"; case LandmarkRegion...
@@ -166,6 +167,32 @@ - (NSString *)accessibilityRoleDescription return NSAccessibilityRoleDescription([self accessibilityRole], [self accessibilitySubrole]); } +// Note: Apple has deprecated this API, but it's still used to set attributes not supported by NSAccessibility +- (NSArray<NSString *> *)accessibilityA...
native/Avalonia.Native/src/OSX/automation.mm
26
Objective-C++
0.286
suggestion
48
51
51
false
Implemented AutomationProperties.LiveSetting
20,473
AvaloniaUI/Avalonia
24,333
C#
MrJul
codecat
Review this pull request change. Language: Objective-C++ File: native/Avalonia.Native/src/OSX/automation.mm PR Title: Implemented AutomationProperties.LiveSetting BEFORE CODE: } } - (NSString *)accessibilityRoleDescription { auto landmarkType = _peer->GetLandmarkType(); switch (landmarkType) { ...
Use the `kAXARIALiveAttribute` constant instead.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.