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

Update SplashScreen to use CsWin32 and shared library #10047

Merged
merged 2 commits into from
Nov 15, 2024

Conversation

JeremyKuhne
Copy link
Member

@JeremyKuhne JeremyKuhne commented Nov 10, 2024

This updates SplashScreen to use direct interop built on CsWin32. It also uses the shared System.Private.Windows.Core library built in Windows Forms.

This makes SplashScreen trim-friendly and improves the performance as it will no longer need to generate the rather extensive interop it used to at startup.

This also introduces a bottom level assembly for WPF: System.Windows.Primitives where there are no other dependencies other than the WinForms/WPF base assembly: System.Private.Windows.Core.

PInvokeCore is the static class that comes from System.Private.Windows.Core. PInvoke is the static class from System.Windows.Primitives. When C# adds something akin to extension types (currently in the design phase) we'll be able to unify to a single PInvoke. Generated types (such as HWND) are in the namespaces as specified by the Windows metdata and don't have the same problem with conflicts as CsWin32 won't generate types that already exist.

CsWin32 uses System.Drawing types where they match Win32 types. Point is an example of this. These interchange System.Drawing types are in-box with .NET.

System.Private.Windows.Core provides a lot of useful support functionality, particularly when it comes to interop. The various scope types in this PR are an example. OLE code will come from this assembly after the new APIs are merged in WinForms.

I've also deleted a large swath of unused interop.

It leverages #10023, which leverages #9914 (the first commit), and will be updated when those are merged.

This is an update of #7929.

Microsoft Reviewers: Open in CodeFlow

@JeremyKuhne JeremyKuhne requested review from a team as code owners November 10, 2024 19:39
@dotnet-policy-service dotnet-policy-service bot added the PR metadata: Label to tag PRs, to facilitate with triage label Nov 10, 2024
@JeremyKuhne JeremyKuhne force-pushed the newsplash branch 2 times, most recently from 877f249 to f1987f5 Compare November 11, 2024 20:14
Copy link
Member

@lonitra lonitra left a comment

Choose a reason for hiding this comment

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

Overall 👍

@lonitra
Copy link
Member

lonitra commented Nov 12, 2024

Changes LGTM!

@lindexi
Copy link
Member

lindexi commented Nov 13, 2024

Good job. And I want to bring the some more feature to SplashScreen. See #2031

@JeremyKuhne
Copy link
Member Author

@lindexi it should be significantly faster now that it doesn't have to generate all of the interop at start

Copy link
Contributor

@h3xds1nz h3xds1nz left a comment

Choose a reason for hiding this comment

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

Mostly nits, hope that's alright; I've cleared up the catch for myself, didn't notice the logic got altered for the cleanup.

Kuldeep-MS
Kuldeep-MS previously approved these changes Nov 14, 2024
…t also uses the shared `System.Private.Windows.Core` library built in Windows Forms.

This makes `SplashScreen` trim-friendly and improves the performance as it will no longer need to generate the rather extensive interop it used to at startup.

This also introduces a bottom level assembly for WPF: `System.Windows.Primitives` where there are no other dependencies other than the WinForms/WPF base assembly: `System.Private.Windows.Core`.

`PInvokeCore` is the static class that comes from `System.Private.Windows.Core`. `PInvoke` is the static class from `System.Windows.Primitives`. When C# adds something akin to extension types (currently in the design phase) we'll be able to unify to a single `PInvoke`. Generated types (such as `HWND`) are in the namespaces as specified by the Windows metdata and don't have the same problem with conflicts as CsWin32 won't generate types that already exist.

CsWin32 uses `System.Drawing` types where they match Win32 types. `Point` is an example of this. These interchange `System.Drawing` types are in-box with .NET.

`System.Private.Windows.Core` provides a lot of useful support functionality, particularly when it comes to interop. The various scope types in this PR are an example. OLE code will come from this assembly after the new APIs are merged in WinForms.

I've also deleted a large swath of unused interop.

It builds on dotnet#10023, which leverages dotnet#9914.

This is an update of dotnet#7929.
@h3xds1nz
Copy link
Contributor

h3xds1nz commented Nov 14, 2024

LGTM, really happy to see this. ❤️

@lonitra
Copy link
Member

lonitra commented Nov 14, 2024

Did another pass, changes look good 👍

@Kuldeep-MS Kuldeep-MS merged commit d4bb347 into dotnet:main Nov 15, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants