Skip to content

Commit a3dcf4d

Browse files
committed
Update SplashScreen to use CsWin32 and shared library
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 dotnet#10023, which leverages dotnet#9914 (the first commit), and will be updated when those are merged. This is an update of dotnet#7929.
1 parent 8e8b2e6 commit a3dcf4d

File tree

15 files changed

+404
-4608
lines changed

15 files changed

+404
-4608
lines changed

eng/Versions.props

+1
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

+12-1
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,11 +119,12 @@
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>
116-
<_WinFormsTargetFrameworkVersion Condition="'$(_WinFormsTargetFrameworkVersion)' == ''">$(TargetFramework)</_WinFormsTargetFrameworkVersion>
127+
<_WinFormsTargetFrameworkVersion Condition="'$(_WinFormsTargetFrameworkVersion)' == ''">$(_targetFrameworkRoot)</_WinFormsTargetFrameworkVersion>
117128
</PropertyGroup>
118129
<ItemGroup>
119130
<Reference Include="$(PkgMicrosoft_Private_Winforms)\lib\$(_WinFormsTargetFrameworkVersion)\%(MicrosoftPrivateWinFormsReference.Identity).dll"

eng/WpfArcadeSdk/tools/WpfProjectReference.targets

+1
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)