Skip to content

Commit 25dd3ab

Browse files
authored
Enable xunit testing in VS with the dispatcher (#10023)
* Remove NetCoreReference This removes the `NetCoreReference` infrastructure and replaces it with `DefaultReferenceExclusion` to remove the one problematic implicit reference to WindowsBase. Manually picking references was blocking using System.Private.Windows.Core from the WinForms repo. Not having this also greatly simplifies the projects. This also tweaks the solution to add folders docs and eng items. Fixes #9168 * Put back test projects in solution * Enable xunit testing in VS with the dispatcher This change enables writing and debugging unit tests in the Test Explorer in Visual Studio. I added a new test project for WindowsBase that has a unit test that launches the SplashScreen as an example. In order to make this happen I had to reference the xunit.stafact package which introduced a number of challenges to overcome. The package has a reference to the desktop sdk and needs to be used in a project that targets `net10.0-windows`, not `net10.0`. To make everything work seamlessly I had to: - Strip the platform reference - Apply actual versions from the sdk - Get rid of AnyCPU and explictly use x86 (everything has a native dependency) - Enable transitive copying of references for the unit test projects - Target the 10.0 SDK (would get version confusion otherwise) - Add an override setting for WinForms which still targets the 9.0 SDK - Remove other targets that were trying to fixup WindowsBase references from the .NET SDK - * Make PresentationBuildTasks always AnyCPU * Update versions and tweak / simplify some version related stuff * Attempt to turn on the binlog for the CI * Update binlog names for both build and test run * Try 17.12 preview * Move back off of scout image * Update versions * Push back to 9.0 * Uncheck D3DCompiler in ConfigurationManager * Have ref projects only reference ref projects and move ref and cycle breaker projects to AnyCPU. * Normalize ARM64 to arm64. Having multiple casings was causing projects to be built multiple times to the same folder. * Revert RuntimeFrameworkReference.targets changes * Final cleanup pass * Tweak SdkReferences.targets * Respond to feedback
1 parent 0212a4e commit 25dd3ab

File tree

116 files changed

+1290
-1554
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+1290
-1554
lines changed

.editorconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ insert_final_newline = true
1313
indent_style = space
1414
indent_size = 4
1515

16-
[project.json]
16+
[*.json]
1717
indent_size = 2
1818

1919
# C# files
2020
[*.cs]
21+
file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.
22+
2123
# New line preferences
2224
csharp_new_line_before_open_brace = all
2325
csharp_new_line_before_else = true

Microsoft.Dotnet.Wpf.sln

Lines changed: 758 additions & 1166 deletions
Large diffs are not rendered by default.

eng/Versions.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<SystemSecurityCryptographyXmlPackageVersion>10.0.0-alpha.1.24560.1</SystemSecurityCryptographyXmlPackageVersion>
4444
<SystemSecurityPermissionsPackageVersion>10.0.0-alpha.1.24560.1</SystemSecurityPermissionsPackageVersion>
4545
<SystemWindowsExtensionsPackageVersion>10.0.0-alpha.1.24560.1</SystemWindowsExtensionsPackageVersion>
46+
<SystemRuntimeCompilerServicesUnsafePackageVersion>6.0.0</SystemRuntimeCompilerServicesUnsafePackageVersion>
4647
</PropertyGroup>
4748
<!-- Docs / Intellisense -->
4849
<PropertyGroup>

eng/WpfArcadeSdk/Sdk/Sdk.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
-->
2626
<WpfRuntimeIdentifier Condition="('$(Platform)'!='AnyCPU' and '$(Platform)'!='Win32') Or $(Platform.EndsWith('x64'))">win-$(Platform)</WpfRuntimeIdentifier>
2727
<WpfRuntimeIdentifier Condition="'$(Platform)'=='AnyCPU' or '$(Platform)'=='Win32' or '$(Platform)'=='x86'">win-x86</WpfRuntimeIdentifier>
28-
<WpfRuntimeIdentifier Condition="'$(Platform)'=='ARM64'">win-arm64</WpfRuntimeIdentifier>
28+
<WpfRuntimeIdentifier Condition="'$(Platform)'=='arm64'">win-arm64</WpfRuntimeIdentifier>
2929
</PropertyGroup>
3030

3131
<Import Project="$(WpfArcadeSdkToolsDir)RuntimeFrameworkReference.props"/>

eng/WpfArcadeSdk/tools/ApiCompat.targets

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,7 @@
6161
<ResolvedMatchingContract Include="$(OutputPath)$(AssemblyName).dll" Condition="'$(ManagedCxx)'=='true'" />
6262
<!-- Work backwards to find the output for a hand-crafted ref assembly. -->
6363
<ResolvedImplementationAssembly Remove="@(ResolvedImplementationAssembly)" />
64-
<ResolvedImplementationAssembly Include="$(BaseOutputPath)..\$(AssemblyName)-ref\$(Platform)\$(Configuration)\**\$(AssemblyName).dll"
65-
Condition="'$(WpfRuntimeIdentifier)'=='win-x64' or '$(WpfRuntimeIdentifier)'=='win-arm64'"/>
66-
<ResolvedImplementationAssembly Include="$(BaseOutputPath)..\$(AssemblyName)-ref\$(Configuration)\**\$(AssemblyName).dll"
67-
Condition="'$(WpfRuntimeIdentifier)'=='win-x86'"/>
68-
<!-- If building a single project, Platform is used in win-x86. Below handles this case. -->
69-
<ResolvedImplementationAssembly Include="$(BaseOutputPath)..\$(AssemblyName)-ref\$(Platform)\$(Configuration)\**\$(AssemblyName).dll"
70-
Condition="'$(WpfRuntimeIdentifier)'=='win-x86' and @(ResolvedImplementationAssembly->Count()) == 0"/>
71-
64+
<ResolvedImplementationAssembly Include="$(BaseOutputPath)..\$(AssemblyName)-ref\$(Configuration)\**\$(AssemblyName).dll" />
7265
<Error Condition="@(ResolvedImplementationAssembly->Count()) &gt; 1" Text="More than one reference assembly was added to ResolvedImplementationAssembly!" />
7366
</ItemGroup>
7467
</Target>
Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,4 @@
11
<Project>
2-
<!-- This workaround fixes an issue with ResolveAssemblyReferences task where it
3-
removes a reference to *project* WindowsBase.dll because *sdk reference*
4-
WindowsBase.dll exists in the list of references it resolves. -->
5-
<Target Name="FixupProjectReferences" AfterTargets="ResolveAssemblyReferences">
6-
<CallTarget Targets="ResolveProjectReferences" />
7-
<ItemGroup>
8-
<ReferencePath Remove="@(_ResolvedNativeProjectReferencePaths)" />
9-
<ReferencePath Include="@(_ResolvedNativeProjectReferencePaths)" />
10-
11-
<ReferencePath Remove="@(_ResolvedProjectReferencePaths)" />
12-
<ReferencePath Include="@(_ResolvedProjectReferencePaths)" />
13-
</ItemGroup>
14-
<ItemGroup>
15-
<FilteredReferencePath Remove="@(FilteredReferencePath)" />
16-
</ItemGroup>
17-
<RemoveDuplicates Inputs="@(ReferencePath)">
18-
<Output TaskParameter="Filtered" ItemName="FilteredReferencePath"/>
19-
</RemoveDuplicates>
20-
<ItemGroup>
21-
<ReferencePath Remove="@(ReferencePath)" />
22-
<ReferencePath Include="@(FilteredReferencePath)" />
23-
</ItemGroup>
24-
<RemoveDuplicates Inputs="@(ProjectReference)">
25-
<Output TaskParameter="Filtered" ItemName="FilteredProjectReference"/>
26-
</RemoveDuplicates>
27-
<ItemGroup>
28-
<ProjectReference Remove="@(ProjectReference)" />
29-
<ProjectReference Include="@(FilteredProjectReference)" />
30-
</ItemGroup>
31-
</Target>
322
<Target Name="DeDuplicateProjectReferenceWithConfiguration" AfterTargets="AssignProjectConfiguration">
333
<RemoveDuplicates Inputs="@(ProjectReferenceWithConfiguration)">
344
<Output TaskParameter="Filtered" ItemName="_filteredProjectReferenceWithConfiguration"/>
@@ -45,4 +15,4 @@
4515
<_ProjectReferenceWithConfiguration Include="@(_filtered_ProjectReferenceWithConfiguration)" />
4616
</ItemGroup>
4717
</Target>
48-
</Project>
18+
</Project>

eng/WpfArcadeSdk/tools/SdkReferences.targets

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,18 @@
112112
Condition="'@(MicrosoftPrivateWinFormsReference)'!=''
113113
And '$(TargetFrameworkIdentifier)' == '.NETCoreApp'
114114
And $([MSBuild]::VersionGreaterThanOrEquals('$(TargetFrameworkVersion)', '3.0')) ">
115+
<PropertyGroup>
116+
<!-- Use the current TargetFramework if not otherwise specified for WinForms private package -->
117+
<_WinFormsTargetFrameworkVersion Condition="'$(_WinFormsTargetFrameworkVersion)' == ''">$(TargetFramework)</_WinFormsTargetFrameworkVersion>
118+
</PropertyGroup>
115119
<ItemGroup>
116-
<Reference Include="$(PkgMicrosoft_Private_Winforms)\ref\$(TargetFramework)\%(MicrosoftPrivateWinFormsReference.Identity).dll"
117-
Condition="Exists('$(PkgMicrosoft_Private_Winforms)\ref\$(TargetFramework)\%(MicrosoftPrivateWinFormsReference.Identity).dll')">
118-
<NuGetPackageId>Microsoft.Private.Winforms</NuGetPackageId>
119-
</Reference>
120-
<Reference Include="$(PkgMicrosoft_Private_Winforms)\ref\net8.0\%(MicrosoftPrivateWinFormsReference.Identity).dll"
121-
Condition="!Exists('$(PkgMicrosoft_Private_Winforms)\ref\$(TargetFramework)\%(MicrosoftPrivateWinFormsReference.Identity).dll')
122-
And $(TargetFramework) == 'net9.0'
123-
And Exists('$(PkgMicrosoft_Private_Winforms)\ref\net8.0\%(MicrosoftPrivateWinFormsReference.Identity).dll')">
120+
<Reference Include="$(PkgMicrosoft_Private_Winforms)\lib\$(_WinFormsTargetFrameworkVersion)\%(MicrosoftPrivateWinFormsReference.Identity).dll"
121+
Condition="Exists('$(PkgMicrosoft_Private_Winforms)\lib\$(_WinFormsTargetFrameworkVersion)\%(MicrosoftPrivateWinFormsReference.Identity).dll')">
124122
<NuGetPackageId>Microsoft.Private.Winforms</NuGetPackageId>
125123
</Reference>
126124
</ItemGroup>
125+
<Error Condition="!Exists('$(PkgMicrosoft_Private_Winforms)\lib\$(_WinFormsTargetFrameworkVersion)\%(MicrosoftPrivateWinFormsReference.Identity).dll')"
126+
Text="$(PkgMicrosoft_Private_Winforms)\lib\$(_WinFormsTargetFrameworkVersion)\%(MicrosoftPrivateWinFormsReference.Identity).dll could not be found."/>
127127
</Target>
128128

129129
<ItemGroup>
@@ -141,17 +141,16 @@
141141
-->
142142
<Target Name="FilterImplicitAssemblyReferences"
143143
Condition="'@(DefaultReferenceExclusion)' != ''"
144-
DependsOnTargets="ResolveProjectReferences"
145-
AfterTargets="ResolveTargetingPackAssets">
144+
AfterTargets="ResolveTargetingPackAssets"
145+
BeforeTargets="_HandlePackageFileConflicts;ResolveAssemblyReferences">
146146
<ItemGroup>
147147
<_referenceExclusion Include="@(DefaultReferenceExclusion)">
148148
<AssemblyName>%(DefaultReferenceExclusion.Identity)</AssemblyName>
149-
<FrameworkReferenceName>Microsoft.NETCore.App</FrameworkReferenceName>
150149
<ExternallyResolved>true</ExternallyResolved>
151150
</_referenceExclusion>
152151

153152
<Reference Remove="@(_referenceExclusion)"
154-
MatchOnMetadata="AssemblyName;FrameworkReferenceName;ExternallyResolved"/>
153+
MatchOnMetadata="AssemblyName;ExternallyResolved"/>
155154
</ItemGroup>
156155
</Target>
157156
</Project>

eng/WpfArcadeSdk/tools/TestProjects.targets

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -35,71 +35,26 @@
3535
<PackageReference Include="System.Security.AccessControl" Version="$(SystemSecurityAccessControlPackageVersion)" CopyLocal="true" />
3636
<PackageReference Include="System.Security.Principal.Windows" Version="$(SystemSecurityPrincipalWindowsPackageVersion)" CopyLocal="true" />
3737

38-
39-
4038
<!-- These exist to ensure that dependencies (esp. native ones) are binplaced with tests correctly -->
4139
<None Condition="'$(RuntimeIdentifier)'=='win-x64' And '$(Configuration)' != 'Debug'"
4240
Include="$(Pkgruntime_win-x64_Microsoft_DotNet_Wpf_DncEng)\runtimes\$(RuntimeIdentifier)\native\*.dll"
4341
CopyToOutputDirectory="PreserveNewest"/>
4442
<None Condition="'$(RuntimeIdentifier)'=='win-x64' And '$(Configuration)' == 'Debug'"
4543
Include="$(Pkgruntime_win-x64_Microsoft_DotNet_Wpf_DncEng_Debug)\runtimes\$(RuntimeIdentifier)\native\*.dll"
4644
CopyToOutputDirectory="PreserveNewest"/>
47-
48-
45+
4946
<None Condition="'$(RuntimeIdentifier)'=='win-x86' And '$(Configuration)' != 'Debug'"
5047
Include="$(Pkgruntime_win-x86_Microsoft_DotNet_Wpf_DncEng)\runtimes\$(RuntimeIdentifier)\native\*.dll"
5148
CopyToOutputDirectory="PreserveNewest"/>
5249
<None Condition="'$(RuntimeIdentifier)'=='win-x86' And '$(Configuration)' == 'Debug'"
5350
Include="$(Pkgruntime_win-x86_Microsoft_DotNet_Wpf_DncEng_Debug)\runtimes\$(RuntimeIdentifier)\native\*.dll"
5451
CopyToOutputDirectory="PreserveNewest"/>
5552

56-
<_wpfProjectsNotWindowsBase Include="@(WpfProjectPath)" Exclude="WindowsBase" />
57-
<_wpfProjectsWindowsBase Include="@(WpfProjectPath)" Exclude="@(_wpfProjectsWindowsBase)" />
58-
59-
<!--
60-
Do not include WindowsBase. There is a bug in the SDK that will prevent proper deps.json generation when WindowsBase.csproj
61-
and Microsoft.NetCore.App/WindowsBase.dll clash. Part of the problem is due to https://github.com/dotnet/sdk/issues/2674.
62-
63-
Directly referencing DLL's works correctly and generates good deps.json. So instead of reference WindowsBase.csproj, just
64-
obtain the raw path to WindowsBase.dll and add it to @(Reference). This is safe to do since
65-
WindowsBase will be built as a transitive reference via PresentationCore, PresentationFramework etc.
66-
67-
Also make sure that Microsoft.NetCore.App/WindowsBase.dll is removed from @(Reference).
68-
-->
69-
<ProjectReference Include="@(_wpfProjectsNotWindowsBase->'%(ProjectPath)')" >
53+
<ProjectReference Include="@(WpfProjectPath->'%(ProjectPath)')" >
7054
<Private>True</Private>
7155
<OutputItemType>_wpfProjectReferenceLocallyBuildAssemblies</OutputItemType>
7256
</ProjectReference>
73-
74-
<ProjectReference Include="@(_wpfProjectsWindowsBase->'%(ProjectPath)')" >
75-
<Private>True</Private>
76-
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
77-
<OutputItemType>_windowsBaseAssemblyLocallyBuiltPath</OutputItemType>
78-
</ProjectReference>
7957
</ItemGroup>
80-
81-
<PropertyGroup Condition="'$(WpfTest)'=='true' or '$(IsTestProject)'=='true'">
82-
<ResolveAssemblyReferencesDependsOn>
83-
AddWindowsBaseToReferences;
84-
$(ResolveAssemblyReferencesDependsOn)
85-
</ResolveAssemblyReferencesDependsOn>
86-
</PropertyGroup>
87-
88-
<Target Name="AddWindowsBaseToReferences">
89-
<ItemGroup>
90-
<Reference Include="%(_windowsBaseAssemblyLocallyBuiltPath.FullPath)" />
91-
</ItemGroup>
92-
</Target>
93-
94-
<Target Name="RemoveWindowsBaseNetCoreAppReference"
95-
AfterTargets="ResolveTargetingPacks"
96-
Returns="@(Reference)"
97-
Condition="'$(WpfTest)'=='true' or '$(IsTestProject)'=='true'">
98-
<ItemGroup>
99-
<Reference Remove="@(Reference)" Condition="'%(FileName)'=='WindowsBase' and '%(Reference.ResolvedFrom)'=='TargetingPack'" />
100-
</ItemGroup>
101-
</Target>
102-
10358
<!--
10459
This target ensures that Microsoft.DotNet.Wpf.DncEng would not inadvertently over-supply references that
10560
are already satisfied by ProjectReference's from within this repo. This should almost never happen, except
@@ -110,7 +65,7 @@
11065
AfterTargets="ResolveTargetingPacks"
11166
Returns="@(Reference)"
11267
Condition="'$(WpfTest)'=='true' or '$(IsTestProject)'=='true'">
113-
68+
11469
<ItemGroup>
11570
<_microsoftDotNetDncEngRefs Remove="@(_microsoftDotNetDncEngRefs)" />
11671
<_microsoftDotNetDncEngRefs Include="@(Reference)"

eng/WpfArcadeSdk/tools/Wpf.Cpp.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
<Architecture Condition="'$(Architecture)'==''">x64</Architecture>
2222

2323
<!-- This should always use either x86 or x64 -->
24-
<TraceWppArchitecture Condition="'$(Architecture)'=='ARM64'">x64</TraceWppArchitecture>
25-
<TraceWppArchitecture Condition="'$(Architecture)'!='ARM64'">$(Architecture)</TraceWppArchitecture>
24+
<TraceWppArchitecture Condition="'$(Architecture)'=='arm64'">x64</TraceWppArchitecture>
25+
<TraceWppArchitecture Condition="'$(Architecture)'!='arm64'">$(Architecture)</TraceWppArchitecture>
2626
<TraceWpp>$(Windows10SdkPath)bin\$(WindowsTargetPlatformVersion)\$(TraceWppArchitecture)\tracewpp.exe</TraceWpp>
2727

2828
<GenerateAssemblyInfo>$(ManagedCxx)</GenerateAssemblyInfo>

eng/common/tools.sh

100755100644
File mode changed.

0 commit comments

Comments
 (0)