-
Notifications
You must be signed in to change notification settings - Fork 987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bump up NuGet Packs and apply new Analyzer Rules. #12512
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments. If many/most methods of a struct or class are unsafe we're leaning towards mark the whole type unsafe.
@@ -10,25 +10,25 @@ internal readonly partial struct WPARAM | |||
public static unsafe implicit operator void*(WPARAM value) => (void*)value.Value; | |||
public static unsafe implicit operator WPARAM(void* value) => new((nuint)value); | |||
|
|||
public static explicit operator HWND(WPARAM value) => (HWND)(nint)value.Value; | |||
public static explicit operator WPARAM(HWND value) => new((nuint)value.Value); | |||
public static unsafe explicit operator HWND(WPARAM value) => (HWND)(nint)value.Value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: at this point, should just make the struct itself unsafe
@@ -50,7 +50,7 @@ public unsafe CreateDcScope( | |||
} | |||
|
|||
public static implicit operator HDC(in CreateDcScope scope) => scope.HDC; | |||
public static implicit operator HGDIOBJ(in CreateDcScope scope) => (HGDIOBJ)(scope.HDC.Value); | |||
public static unsafe implicit operator HGDIOBJ(in CreateDcScope scope) => (HGDIOBJ)(scope.HDC.Value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There really should be an implicit operator on HDC
to convert to HGDIOBJ
as that cast is always legit. Then this can just be scope.HDC
.
@@ -30,7 +30,7 @@ public CreatePenScope(Color color, int width = 1) => | |||
HPEN = PInvokeCore.CreatePen(PEN_STYLE.PS_SOLID, width, color); | |||
|
|||
public static implicit operator HPEN(in CreatePenScope scope) => scope.HPEN; | |||
public static implicit operator HGDIOBJ(in CreatePenScope scope) => (HGDIOBJ)scope.HPEN.Value; | |||
public static unsafe implicit operator HGDIOBJ(in CreatePenScope scope) => (HGDIOBJ)scope.HPEN.Value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned above, should have an implicit conversion operator on HPEN
to go to HGDIOBJ
.
src/System.Private.Windows.Core/src/Windows/Win32/Graphics/Gdi/HGDIOBJ.cs
Outdated
Show resolved
Hide resolved
src/System.Private.Windows.Core/src/Windows/Win32/UI/WindowsAndMessaging/HCURSOR.cs
Outdated
Show resolved
Hide resolved
...s.Design/src/System/Windows/Forms/Design/Behavior/BehaviorService.AdornerWindow.MouseHook.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/Input/Cursor.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/NativeWindow.WindowClass.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/ToolTip/ToolTip.cs
Outdated
Show resolved
Hide resolved
@@ -93,15 +93,15 @@ | |||
<PropertyGroup> | |||
<CSharpIsNullAnalyzersVersion>0.1.495</CSharpIsNullAnalyzersVersion> | |||
<DotNetAnalyzersDocumentationAnalyzersVersion>1.0.0-beta.59</DotNetAnalyzersDocumentationAnalyzersVersion> | |||
<MicrosoftCodeAnalysisAnalyzersVersion>3.11.0-beta1.24219.2</MicrosoftCodeAnalysisAnalyzersVersion> | |||
<MicrosoftCodeAnalysisCommonPackageVersion>4.10.0-3.final</MicrosoftCodeAnalysisCommonPackageVersion> | |||
<MicrosoftCodeAnalysisAnalyzersVersion>3.12.0-beta1.24559.1</MicrosoftCodeAnalysisAnalyzersVersion> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll want to update the versions for WPF as well. I'll sync with you on that.
@@ -2318,8 +2318,7 @@ private unsafe void WndProc(ref Message message) | |||
|
|||
using Graphics graphics = paintScope.HDC.CreateGraphics(); | |||
|
|||
IWin32Window? window = GetCurrentToolWindow(); | |||
if (window is not null) | |||
if (GetCurrentToolWindow() is Control window) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this still be IWin32Window? Below code seems to indicate it may not always be a Control
|| (OsVersion.IsWindows10_1607OrGreater() | ||
&& (bool)PInvoke.AreDpiAwarenessContextsEqual(this, dpiContext)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit for readability:
|| (OsVersion.IsWindows10_1607OrGreater() | |
&& (bool)PInvoke.AreDpiAwarenessContextsEqual(this, dpiContext)); | |
|| (OsVersion.IsWindows10_1607OrGreater() | |
&& (bool)PInvoke.AreDpiAwarenessContextsEqual(this, dpiContext)); |
756c4e6
to
e40aa6f
Compare
Updates the NuGet packages to the latest versions and applies the new respective Analyzer Rules.
Microsoft Reviewers: Open in CodeFlow