Skip to content

Commit

Permalink
This updates SplashScreen to use direct interop built on CsWin32. I…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
JeremyKuhne committed Nov 14, 2024
1 parent cbaeca8 commit 79ae146
Show file tree
Hide file tree
Showing 19 changed files with 540 additions and 4,623 deletions.
35 changes: 35 additions & 0 deletions Microsoft.Dotnet.Wpf.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xaml", "src\Microsoft.DotNet.Wpf\src\System.Xaml\System.Xaml.csproj", "{9AC36357-34B7-40A1-95CA-FE9F46D089A7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "packaging", "packaging", "{0159B0F1-0626-4BED-8D1B-CBFF4F12C369}"
ProjectSection(SolutionItems) = preProject
packaging\Directory.Build.props = packaging\Directory.Build.props
packaging\Directory.Build.targets = packaging\Directory.Build.targets
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Microsoft.DotNet.Wpf.GitHub", "Microsoft.DotNet.Wpf.GitHub", "{BF20132A-191F-4D34-9A1B-831772A6DFCF}"
EndProject
Expand Down Expand Up @@ -257,6 +261,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "eng", "eng", "{92968783-200
.editorconfig = .editorconfig
build.cmd = build.cmd
eng\common\build.ps1 = eng\common\build.ps1
eng\scripts\CIBuild.cmd = eng\scripts\CIBuild.cmd
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
global.json = global.json
Expand Down Expand Up @@ -370,6 +375,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{C70269FA
eng\WpfArcadeSdk\tools\WPF_Generated_Files.txt = eng\WpfArcadeSdk\tools\WPF_Generated_Files.txt
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Windows.Primitives", "src\Microsoft.DotNet.Wpf\src\System.Windows.Primitives\System.Windows.Primitives.csproj", "{5306FA93-178C-4535-ADEE-86B1DE1B68CB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Windows.Primitives-ref", "src\Microsoft.DotNet.Wpf\src\System.Windows.Primitives\ref\System.Windows.Primitives-ref.csproj", "{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|arm64 = Debug|arm64
Expand Down Expand Up @@ -1606,6 +1615,30 @@ Global
{D5A55FFC-E408-4BC5-B633-1CBBE9A94DE1}.Release|x64.Build.0 = Release|x64
{D5A55FFC-E408-4BC5-B633-1CBBE9A94DE1}.Release|x86.ActiveCfg = Release|x86
{D5A55FFC-E408-4BC5-B633-1CBBE9A94DE1}.Release|x86.Build.0 = Release|x86
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Debug|arm64.ActiveCfg = Debug|Any CPU
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Debug|arm64.Build.0 = Debug|Any CPU
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Debug|x64.ActiveCfg = Debug|Any CPU
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Debug|x64.Build.0 = Debug|Any CPU
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Debug|x86.ActiveCfg = Debug|Any CPU
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Debug|x86.Build.0 = Debug|Any CPU
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Release|arm64.ActiveCfg = Release|Any CPU
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Release|arm64.Build.0 = Release|Any CPU
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Release|x64.ActiveCfg = Release|Any CPU
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Release|x64.Build.0 = Release|Any CPU
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Release|x86.ActiveCfg = Release|Any CPU
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Release|x86.Build.0 = Release|Any CPU
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Debug|arm64.ActiveCfg = Debug|Any CPU
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Debug|arm64.Build.0 = Debug|Any CPU
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Debug|x64.ActiveCfg = Debug|Any CPU
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Debug|x64.Build.0 = Debug|Any CPU
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Debug|x86.ActiveCfg = Debug|Any CPU
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Debug|x86.Build.0 = Debug|Any CPU
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Release|arm64.ActiveCfg = Release|Any CPU
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Release|arm64.Build.0 = Release|Any CPU
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Release|x64.ActiveCfg = Release|Any CPU
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Release|x64.Build.0 = Release|Any CPU
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Release|x86.ActiveCfg = Release|Any CPU
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1730,6 +1763,8 @@ Global
{D5A55FFC-E408-4BC5-B633-1CBBE9A94DE1} = {A48B585E-6AB0-4F8D-8484-77F37CB44437}
{8F62A3BF-C618-49B1-8B09-82C32C3427BB} = {92968783-2008-4A16-A823-6737224FEB9E}
{C70269FA-2569-48B7-B246-A263BBC5698F} = {8F62A3BF-C618-49B1-8B09-82C32C3427BB}
{5306FA93-178C-4535-ADEE-86B1DE1B68CB} = {2EE4A2DA-70B3-4767-9D18-618DA0FE3105}
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42} = {D0AED517-9972-41CB-8751-983E4EB8F511}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B4340004-DAC0-497D-B69D-CFA7CD93F567}
Expand Down
1 change: 1 addition & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<!-- These versions are specified in global.json -->
<StrawberryPerlVersion>5.38.0.1</StrawberryPerlVersion>
<NetFramework48RefAssembliesVersion>0.0.0.1</NetFramework48RefAssembliesVersion>
<MicrosoftWindowsCsWin32PackageVersion>0.3.106</MicrosoftWindowsCsWin32PackageVersion>
</PropertyGroup>
<!-- External Analyzers -->
<PropertyGroup>
Expand Down
13 changes: 12 additions & 1 deletion eng/WpfArcadeSdk/tools/SdkReferences.targets
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@
</ItemGroup>
</Target>

<Target Name="SplitTargetFramework">
<PropertyGroup>
<!-- Split out the target framework. "net10.0-windows" is an example. -->
<_targetFrameworkIdentifier>$([MSBuild]::GetTargetFrameworkIdentifier($(TargetFramework)))</_targetFrameworkIdentifier>
<_targetFrameworkIdentifier Condition="'$(_targetFrameworkIdentifier)' == '.NETCoreApp'">net</_targetFrameworkIdentifier>
<_targetFrameworkVersion>$([MSBuild]::GetTargetFrameworkVersion($(TargetFramework)))</_targetFrameworkVersion>
<_targetFrameworkRoot>$(_targetFrameworkIdentifier)$(_targetFrameworkVersion)</_targetFrameworkRoot>
</PropertyGroup>
</Target>

<!--
In your project, Add a references to WinForms transport package like this:
<ItemGroup>
Expand All @@ -109,12 +119,13 @@
</ItemGroup>
-->
<Target Name="ResolveWinFormsReferences"
DependsOnTargets="SplitTargetFramework"
Condition="'@(MicrosoftPrivateWinFormsReference)'!=''
And '$(TargetFrameworkIdentifier)' == '.NETCoreApp'
And $([MSBuild]::VersionGreaterThanOrEquals('$(TargetFrameworkVersion)', '3.0')) ">
<PropertyGroup>
<!-- Use the current TargetFramework if not otherwise specified for WinForms private package -->
<_WinFormsTargetFrameworkVersion Condition="'$(_WinFormsTargetFrameworkVersion)' == ''">$(TargetFramework)</_WinFormsTargetFrameworkVersion>
<_WinFormsTargetFrameworkVersion Condition="'$(_WinFormsTargetFrameworkVersion)' == ''">$(_targetFrameworkRoot)</_WinFormsTargetFrameworkVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="$(PkgMicrosoft_Private_Winforms)\lib\$(_WinFormsTargetFrameworkVersion)\%(MicrosoftPrivateWinFormsReference.Identity).dll"
Expand Down
10 changes: 7 additions & 3 deletions eng/WpfArcadeSdk/tools/ShippingProjects.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
System.Printing;
System.Windows.Controls.Ribbon;
System.Windows.Presentation;
System.Windows.Primitives;
PresentationFramework.Aero;
PresentationFramework.Aero2;
PresentationFramework.AeroLite;
Expand All @@ -40,12 +41,12 @@
$(InternalShippingLibProjects);
bilinearspan
</InternalShippingLibProjects>

<InternalShippingProjects>
$(InternalShippingLibProjects);
PresentationNative;
</InternalShippingProjects>

<ShippingProjects>
$(ExternalShippingProjects);
$(InternalShippingProjects)
Expand Down Expand Up @@ -79,7 +80,7 @@
Reference assembly projects are categorized by what repo they are shipping in.
If this changes, say due to open sourcing, they must move accordingly or they
will not be including in the ref pack.
See: ReferenceAssembly.targets/CopyHandCraftedReferenceProjectsToRefDir
-->
<ExternalHandCraftedReferenceProjects>
Expand All @@ -104,6 +105,7 @@
System.Printing-ref;
System.Windows.Controls.Ribbon-ref;
System.Windows.Presentation-ref;
System.Windows.Primitives-ref;
WindowsFormsIntegration-ref;
</ExternalHandCraftedReferenceProjects>

Expand Down Expand Up @@ -145,6 +147,8 @@
ReachFramework-ref;
System.Printing;
System.Printing-ref;
System.Windows.Primitives;
System.Windows.Primitives-ref;
UIAutomationClient;
UIAutomationClient-ref;
UIAutomationClientsideProviders;
Expand Down
1 change: 1 addition & 0 deletions eng/WpfArcadeSdk/tools/WpfProjectReference.targets
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

</ItemGroup>
<ItemGroup>
<WpfProjectPath Include="System.Windows.Primitives" ProjectPath="$(WpfSourceDir)System.Windows.Primitives\System.Windows.Primitives.csproj" />
<WpfProjectPath Include="System.Xaml" ProjectPath="$(WpfSourceDir)System.Xaml\System.Xaml.csproj" />
<WpfProjectPath Include="WindowsBase" ProjectPath="$(WpfSourceDir)WindowsBase\WindowsBase.csproj" />
<WpfProjectPath Include="DirectWriteForwarder" ProjectPath="$(WpfSourceDir)DirectWriteForwarder\DirectWriteForwarder.vcxproj">
Expand Down
Loading

0 comments on commit 79ae146

Please sign in to comment.