Skip to content
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

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

JeremyKuhne
Copy link
Member

@JeremyKuhne JeremyKuhne commented Dec 13, 2023

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

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.
@JeremyKuhne JeremyKuhne requested a review from a team as a code owner December 13, 2023 01:13
@ghost ghost assigned JeremyKuhne Dec 13, 2023
if (text.Length == 0)
return null;
}
else
Copy link
Member

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)
Copy link
Member

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;
Copy link
Member

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 [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@JeremyKuhne
Copy link
Member Author

Thanks, @Tanya-Solyanik. I'll catch your comments in the next PR.

@JeremyKuhne JeremyKuhne merged commit fc705dc into dotnet:main Dec 13, 2023
9 checks passed
@ghost ghost added this to the 9.0 Preview1 milestone Dec 13, 2023
@JeremyKuhne JeremyKuhne deleted the printclean branch December 13, 2023 19:41
@github-actions github-actions bot locked and limited conversation to collaborators Jan 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants