Skip to content

Commit d4bb347

Browse files
authored
Update SplashScreen to use CsWin32 and shared library (#10047)
* 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 builds on #10023, which leverages #9914. This is an update of #7929. * Make anonymous method static and remove orphaned file.
1 parent cbaeca8 commit d4bb347

File tree

18 files changed

+469
-4623
lines changed

18 files changed

+469
-4623
lines changed

Microsoft.Dotnet.Wpf.sln

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.Xaml", "src\Microsoft.DotNet.Wpf\src\System.Xaml\System.Xaml.csproj", "{9AC36357-34B7-40A1-95CA-FE9F46D089A7}"
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "packaging", "packaging", "{0159B0F1-0626-4BED-8D1B-CBFF4F12C369}"
9+
ProjectSection(SolutionItems) = preProject
10+
packaging\Directory.Build.props = packaging\Directory.Build.props
11+
packaging\Directory.Build.targets = packaging\Directory.Build.targets
12+
EndProjectSection
913
EndProject
1014
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Microsoft.DotNet.Wpf.GitHub", "Microsoft.DotNet.Wpf.GitHub", "{BF20132A-191F-4D34-9A1B-831772A6DFCF}"
1115
EndProject
@@ -257,6 +261,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "eng", "eng", "{92968783-200
257261
.editorconfig = .editorconfig
258262
build.cmd = build.cmd
259263
eng\common\build.ps1 = eng\common\build.ps1
264+
eng\scripts\CIBuild.cmd = eng\scripts\CIBuild.cmd
260265
Directory.Build.props = Directory.Build.props
261266
Directory.Build.targets = Directory.Build.targets
262267
global.json = global.json
@@ -370,6 +375,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{C70269FA
370375
eng\WpfArcadeSdk\tools\WPF_Generated_Files.txt = eng\WpfArcadeSdk\tools\WPF_Generated_Files.txt
371376
EndProjectSection
372377
EndProject
378+
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}"
379+
EndProject
380+
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}"
381+
EndProject
373382
Global
374383
GlobalSection(SolutionConfigurationPlatforms) = preSolution
375384
Debug|arm64 = Debug|arm64
@@ -1606,6 +1615,30 @@ Global
16061615
{D5A55FFC-E408-4BC5-B633-1CBBE9A94DE1}.Release|x64.Build.0 = Release|x64
16071616
{D5A55FFC-E408-4BC5-B633-1CBBE9A94DE1}.Release|x86.ActiveCfg = Release|x86
16081617
{D5A55FFC-E408-4BC5-B633-1CBBE9A94DE1}.Release|x86.Build.0 = Release|x86
1618+
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Debug|arm64.ActiveCfg = Debug|Any CPU
1619+
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Debug|arm64.Build.0 = Debug|Any CPU
1620+
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Debug|x64.ActiveCfg = Debug|Any CPU
1621+
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Debug|x64.Build.0 = Debug|Any CPU
1622+
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Debug|x86.ActiveCfg = Debug|Any CPU
1623+
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Debug|x86.Build.0 = Debug|Any CPU
1624+
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Release|arm64.ActiveCfg = Release|Any CPU
1625+
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Release|arm64.Build.0 = Release|Any CPU
1626+
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Release|x64.ActiveCfg = Release|Any CPU
1627+
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Release|x64.Build.0 = Release|Any CPU
1628+
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Release|x86.ActiveCfg = Release|Any CPU
1629+
{5306FA93-178C-4535-ADEE-86B1DE1B68CB}.Release|x86.Build.0 = Release|Any CPU
1630+
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Debug|arm64.ActiveCfg = Debug|Any CPU
1631+
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Debug|arm64.Build.0 = Debug|Any CPU
1632+
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Debug|x64.ActiveCfg = Debug|Any CPU
1633+
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Debug|x64.Build.0 = Debug|Any CPU
1634+
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Debug|x86.ActiveCfg = Debug|Any CPU
1635+
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Debug|x86.Build.0 = Debug|Any CPU
1636+
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Release|arm64.ActiveCfg = Release|Any CPU
1637+
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Release|arm64.Build.0 = Release|Any CPU
1638+
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Release|x64.ActiveCfg = Release|Any CPU
1639+
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Release|x64.Build.0 = Release|Any CPU
1640+
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Release|x86.ActiveCfg = Release|Any CPU
1641+
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42}.Release|x86.Build.0 = Release|Any CPU
16091642
EndGlobalSection
16101643
GlobalSection(SolutionProperties) = preSolution
16111644
HideSolutionNode = FALSE
@@ -1730,6 +1763,8 @@ Global
17301763
{D5A55FFC-E408-4BC5-B633-1CBBE9A94DE1} = {A48B585E-6AB0-4F8D-8484-77F37CB44437}
17311764
{8F62A3BF-C618-49B1-8B09-82C32C3427BB} = {92968783-2008-4A16-A823-6737224FEB9E}
17321765
{C70269FA-2569-48B7-B246-A263BBC5698F} = {8F62A3BF-C618-49B1-8B09-82C32C3427BB}
1766+
{5306FA93-178C-4535-ADEE-86B1DE1B68CB} = {2EE4A2DA-70B3-4767-9D18-618DA0FE3105}
1767+
{0EFFC7C4-B486-4852-8CED-EDEB46E02C42} = {D0AED517-9972-41CB-8751-983E4EB8F511}
17331768
EndGlobalSection
17341769
GlobalSection(ExtensibilityGlobals) = postSolution
17351770
SolutionGuid = {B4340004-DAC0-497D-B69D-CFA7CD93F567}

eng/Versions.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
<!-- These versions are specified in global.json -->
8282
<StrawberryPerlVersion>5.38.0.1</StrawberryPerlVersion>
8383
<NetFramework48RefAssembliesVersion>0.0.0.1</NetFramework48RefAssembliesVersion>
84+
<MicrosoftWindowsCsWin32PackageVersion>0.3.106</MicrosoftWindowsCsWin32PackageVersion>
8485
</PropertyGroup>
8586
<!-- External Analyzers -->
8687
<PropertyGroup>

eng/WpfArcadeSdk/tools/SdkReferences.targets

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,16 @@
9797
</ItemGroup>
9898
</Target>
9999

100+
<Target Name="SplitTargetFramework">
101+
<PropertyGroup>
102+
<!-- Split out the target framework. "net10.0-windows" is an example. -->
103+
<_targetFrameworkIdentifier>$([MSBuild]::GetTargetFrameworkIdentifier($(TargetFramework)))</_targetFrameworkIdentifier>
104+
<_targetFrameworkIdentifier Condition="'$(_targetFrameworkIdentifier)' == '.NETCoreApp'">net</_targetFrameworkIdentifier>
105+
<_targetFrameworkVersion>$([MSBuild]::GetTargetFrameworkVersion($(TargetFramework)))</_targetFrameworkVersion>
106+
<_targetFrameworkRoot>$(_targetFrameworkIdentifier)$(_targetFrameworkVersion)</_targetFrameworkRoot>
107+
</PropertyGroup>
108+
</Target>
109+
100110
<!--
101111
In your project, Add a references to WinForms transport package like this:
102112
<ItemGroup>
@@ -109,12 +119,13 @@
109119
</ItemGroup>
110120
-->
111121
<Target Name="ResolveWinFormsReferences"
122+
DependsOnTargets="SplitTargetFramework"
112123
Condition="'@(MicrosoftPrivateWinFormsReference)'!=''
113124
And '$(TargetFrameworkIdentifier)' == '.NETCoreApp'
114125
And $([MSBuild]::VersionGreaterThanOrEquals('$(TargetFrameworkVersion)', '3.0')) ">
115126
<PropertyGroup>
116127
<!-- Use the current TargetFramework if not otherwise specified for WinForms private package -->
117-
<_WinFormsTargetFrameworkVersion Condition="'$(_WinFormsTargetFrameworkVersion)' == ''">$(TargetFramework)</_WinFormsTargetFrameworkVersion>
128+
<_WinFormsTargetFrameworkVersion Condition="'$(_WinFormsTargetFrameworkVersion)' == ''">$(_targetFrameworkRoot)</_WinFormsTargetFrameworkVersion>
118129
</PropertyGroup>
119130
<ItemGroup>
120131
<Reference Include="$(PkgMicrosoft_Private_Winforms)\lib\$(_WinFormsTargetFrameworkVersion)\%(MicrosoftPrivateWinFormsReference.Identity).dll"

eng/WpfArcadeSdk/tools/ShippingProjects.props

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
System.Printing;
2323
System.Windows.Controls.Ribbon;
2424
System.Windows.Presentation;
25+
System.Windows.Primitives;
2526
PresentationFramework.Aero;
2627
PresentationFramework.Aero2;
2728
PresentationFramework.AeroLite;
@@ -40,12 +41,12 @@
4041
$(InternalShippingLibProjects);
4142
bilinearspan
4243
</InternalShippingLibProjects>
43-
44+
4445
<InternalShippingProjects>
4546
$(InternalShippingLibProjects);
4647
PresentationNative;
4748
</InternalShippingProjects>
48-
49+
4950
<ShippingProjects>
5051
$(ExternalShippingProjects);
5152
$(InternalShippingProjects)
@@ -79,7 +80,7 @@
7980
Reference assembly projects are categorized by what repo they are shipping in.
8081
If this changes, say due to open sourcing, they must move accordingly or they
8182
will not be including in the ref pack.
82-
83+
8384
See: ReferenceAssembly.targets/CopyHandCraftedReferenceProjectsToRefDir
8485
-->
8586
<ExternalHandCraftedReferenceProjects>
@@ -104,6 +105,7 @@
104105
System.Printing-ref;
105106
System.Windows.Controls.Ribbon-ref;
106107
System.Windows.Presentation-ref;
108+
System.Windows.Primitives-ref;
107109
WindowsFormsIntegration-ref;
108110
</ExternalHandCraftedReferenceProjects>
109111

@@ -145,6 +147,8 @@
145147
ReachFramework-ref;
146148
System.Printing;
147149
System.Printing-ref;
150+
System.Windows.Primitives;
151+
System.Windows.Primitives-ref;
148152
UIAutomationClient;
149153
UIAutomationClient-ref;
150154
UIAutomationClientsideProviders;

eng/WpfArcadeSdk/tools/WpfProjectReference.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
</ItemGroup>
2323
<ItemGroup>
24+
<WpfProjectPath Include="System.Windows.Primitives" ProjectPath="$(WpfSourceDir)System.Windows.Primitives\System.Windows.Primitives.csproj" />
2425
<WpfProjectPath Include="System.Xaml" ProjectPath="$(WpfSourceDir)System.Xaml\System.Xaml.csproj" />
2526
<WpfProjectPath Include="WindowsBase" ProjectPath="$(WpfSourceDir)WindowsBase\WindowsBase.csproj" />
2627
<WpfProjectPath Include="DirectWriteForwarder" ProjectPath="$(WpfSourceDir)DirectWriteForwarder\DirectWriteForwarder.vcxproj">

0 commit comments

Comments
 (0)