-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Move common dialogs to CsWin32 and clean printing #10471
Conversation
We can't (yet) directly use CsWin32 directly for the common dialogs due to packing differences between 32 and 64 bit. We target AnyCPU and CsWin32 doesn't have the ability to force a particular platform definition. For now, I'm copying in CsWin32 defines from a platform targetted project. Hopefully we'll eventually get .NET support for specifying packing per platform. Also investigating getting a feature added to CsWin32 to mitigate this for us. This does a pass through all of the print code to clean to style guides. Plan is to follow up with an attempt to update System.Drawing to CsWin32 code.
CsWin32 related issue: .NET Runtime related issues: |
if (text.Length == 0) | ||
return null; | ||
} | ||
else |
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.
else
can be removed because we are returning from the if
clause
{ | ||
if (destinationType == typeof(InstanceDescriptor)) | ||
if (value is not string strValue) |
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.
strValue->stringValue
/// </summary> | ||
public int RawKind | ||
{ | ||
get => unchecked((int)_kind); | ||
set => _kind = unchecked((PaperSourceKind)value); | ||
get => (int)_kind; |
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 are more unchecked
keywords that can be removed, but this is an iterative process.
@@ -1033,18 +917,25 @@ internal unsafe PaperSize[] Get_PaperSizes() | |||
|
|||
int count = FastDeviceCapabilities(SafeNativeMethods.DC_PAPERNAMES, IntPtr.Zero, -1, printerName); | |||
if (count == -1) | |||
return Array.Empty<PaperSize>(); | |||
{ | |||
return []; |
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.
Nice!
Thanks, @Tanya-Solyanik. I'll catch your comments in the next PR. |
We can't (yet) directly use CsWin32 directly for the common dialogs due to packing differences between 32 and 64 bit. We target AnyCPU and CsWin32 doesn't have the ability to force a particular platform definition. For now, I'm copying in CsWin32 defines from a platform targetted project.
Hopefully we'll eventually get .NET support for specifying packing per platform. Also investigating getting a feature added to CsWin32 to mitigate this for us.
This does a pass through all of the print code to clean to style guides.
Plan is to follow up with an attempt to update System.Drawing to CsWin32 code.
Microsoft Reviewers: Open in CodeFlow