From 722025ad9701120167501f8cc981d2cb2cc9e1ea Mon Sep 17 00:00:00 2001 From: Jeremy Kuhne Date: Fri, 22 Nov 2024 02:03:28 -0800 Subject: [PATCH] Don't enable transitive references in tests (#10103) Most of the projects include references to ref and cycle breaker projects. This breaks tests as they will pick the wrong assemblies. Create a stub PresentationFramework.Fluent.Tests project to validate. --- Microsoft.Dotnet.Wpf.sln | 15 ++++++++ .../LibraryAssemblyInfo.cs | 6 ++++ .../PresentationFramework.csproj | 1 + .../src/WindowsBase/LibraryAssemblyInfo.cs | 1 - .../tests/Directory.Build.props | 2 +- .../GlobalUsings.cs | 7 ++++ .../PresentationFramework.Fluent.Tests.csproj | 35 +++++++++++++++++++ .../System/Windows/Controls/ButtonTests.cs | 13 +++++++ 8 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 src/Microsoft.DotNet.Wpf/src/PresentationFramework/LibraryAssemblyInfo.cs create mode 100644 src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationFramework.Fluent.Tests/GlobalUsings.cs create mode 100644 src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationFramework.Fluent.Tests/PresentationFramework.Fluent.Tests.csproj create mode 100644 src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationFramework.Fluent.Tests/System/Windows/Controls/ButtonTests.cs diff --git a/Microsoft.Dotnet.Wpf.sln b/Microsoft.Dotnet.Wpf.sln index db740b99344..c3d86130ea5 100644 --- a/Microsoft.Dotnet.Wpf.sln +++ b/Microsoft.Dotnet.Wpf.sln @@ -379,6 +379,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "System.Windows.Primitives", 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 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PresentationFramework.Fluent.Tests", "src\Microsoft.DotNet.Wpf\tests\UnitTests\PresentationFramework.Fluent.Tests\PresentationFramework.Fluent.Tests.csproj", "{56833D74-2D0B-5516-C1D6-B93D4FFF7612}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|arm64 = Debug|arm64 @@ -1639,6 +1641,18 @@ Global {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 + {56833D74-2D0B-5516-C1D6-B93D4FFF7612}.Debug|arm64.ActiveCfg = Debug|arm64 + {56833D74-2D0B-5516-C1D6-B93D4FFF7612}.Debug|arm64.Build.0 = Debug|arm64 + {56833D74-2D0B-5516-C1D6-B93D4FFF7612}.Debug|x64.ActiveCfg = Debug|x64 + {56833D74-2D0B-5516-C1D6-B93D4FFF7612}.Debug|x64.Build.0 = Debug|x64 + {56833D74-2D0B-5516-C1D6-B93D4FFF7612}.Debug|x86.ActiveCfg = Debug|x86 + {56833D74-2D0B-5516-C1D6-B93D4FFF7612}.Debug|x86.Build.0 = Debug|x86 + {56833D74-2D0B-5516-C1D6-B93D4FFF7612}.Release|arm64.ActiveCfg = Release|arm64 + {56833D74-2D0B-5516-C1D6-B93D4FFF7612}.Release|arm64.Build.0 = Release|arm64 + {56833D74-2D0B-5516-C1D6-B93D4FFF7612}.Release|x64.ActiveCfg = Release|x64 + {56833D74-2D0B-5516-C1D6-B93D4FFF7612}.Release|x64.Build.0 = Release|x64 + {56833D74-2D0B-5516-C1D6-B93D4FFF7612}.Release|x86.ActiveCfg = Release|x86 + {56833D74-2D0B-5516-C1D6-B93D4FFF7612}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1765,6 +1779,7 @@ Global {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} + {56833D74-2D0B-5516-C1D6-B93D4FFF7612} = {A48B585E-6AB0-4F8D-8484-77F37CB44437} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {B4340004-DAC0-497D-B69D-CFA7CD93F567} diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/LibraryAssemblyInfo.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/LibraryAssemblyInfo.cs new file mode 100644 index 00000000000..b5df2683b86 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/LibraryAssemblyInfo.cs @@ -0,0 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("PresentationFramework.Fluent.Tests, PublicKey=00000000000000000400000000000000")] diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj index 8e933deb19a..1c7c88d193d 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj @@ -34,6 +34,7 @@ + diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/LibraryAssemblyInfo.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/LibraryAssemblyInfo.cs index ef11e0b67f3..043e9b01263 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/LibraryAssemblyInfo.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/LibraryAssemblyInfo.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("WindowsBase.Tests, PublicKey=00000000000000000400000000000000")] diff --git a/src/Microsoft.DotNet.Wpf/tests/Directory.Build.props b/src/Microsoft.DotNet.Wpf/tests/Directory.Build.props index 650bae4fe33..797955552c5 100644 --- a/src/Microsoft.DotNet.Wpf/tests/Directory.Build.props +++ b/src/Microsoft.DotNet.Wpf/tests/Directory.Build.props @@ -4,6 +4,6 @@ false false true - false + true diff --git a/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationFramework.Fluent.Tests/GlobalUsings.cs b/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationFramework.Fluent.Tests/GlobalUsings.cs new file mode 100644 index 00000000000..6a4deaf1f55 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationFramework.Fluent.Tests/GlobalUsings.cs @@ -0,0 +1,7 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +global using Xunit; +#pragma warning disable IDE0005 // Using directive is unnecessary. New project, this will be used. +global using FluentAssertions; +#pragma warning restore IDE0005 diff --git a/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationFramework.Fluent.Tests/PresentationFramework.Fluent.Tests.csproj b/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationFramework.Fluent.Tests/PresentationFramework.Fluent.Tests.csproj new file mode 100644 index 00000000000..6a36f43d216 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationFramework.Fluent.Tests/PresentationFramework.Fluent.Tests.csproj @@ -0,0 +1,35 @@ + + + true + enable + x64;x86;arm64 + + $(TargetFramework)-windows + true + + + + + + + + + + + + + + + + + + + + TargetFramework;TargetFrameworks + + + + + + + diff --git a/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationFramework.Fluent.Tests/System/Windows/Controls/ButtonTests.cs b/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationFramework.Fluent.Tests/System/Windows/Controls/ButtonTests.cs new file mode 100644 index 00000000000..0b151e08147 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/tests/UnitTests/PresentationFramework.Fluent.Tests/System/Windows/Controls/ButtonTests.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System.Windows.Controls; + +public class ButtonTests +{ + [WpfFact] + public void Button_Create() + { + Button button = new(); + } +}