Skip to content

Commit

Permalink
Build targeting net9.0 (#4167)
Browse files Browse the repository at this point in the history
  • Loading branch information
Evangelink authored Nov 26, 2024
1 parent b97678d commit 2e89f20
Show file tree
Hide file tree
Showing 27 changed files with 140 additions and 36 deletions.
6 changes: 3 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
<NetFrameworkMinimum>net462</NetFrameworkMinimum>
<UwpMinimum>uap10.0.16299</UwpMinimum>
<WinUiMinimum>net6.0-windows10.0.18362.0</WinUiMinimum>
<NetCurrent>net8.0</NetCurrent>
<NetCurrent>net9.0</NetCurrent>

<SupportedNetFrameworks>netcoreapp3.1;net6.0;net7.0;net8.0</SupportedNetFrameworks>
<MicrosoftTestingTargetFrameworks>net6.0;net7.0;net8.0</MicrosoftTestingTargetFrameworks>
<MicrosoftTestingTargetFrameworks>net6.0;net7.0;net8.0;net9.0</MicrosoftTestingTargetFrameworks>
<SupportedNetFrameworks>netcoreapp3.1;net6.0;net7.0;net8.0;net9.0</SupportedNetFrameworks>
</PropertyGroup>

<!-- Build config -->
Expand Down
4 changes: 2 additions & 2 deletions eng/verify-nupkgs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ function Confirm-NugetPackages {
$expectedNumOfFiles = @{
"MSTest.Sdk" = 15;
"MSTest.Internal.TestFx.Documentation" = 10;
"MSTest.TestFramework" = 130;
"MSTest.TestAdapter" = 76;
"MSTest.TestFramework" = 148;
"MSTest.TestAdapter" = 82;
"MSTest" = 6;
"MSTest.Analyzers" = 10;
}
Expand Down
7 changes: 4 additions & 3 deletions global.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
"3.1.32",
"6.0.35",
"7.0.20",
"8.0.10"
"8.0.11",
"9.0.0"
],
"dotnet/x86": [
"8.0.10"
"9.0.0"
],
"aspnetcore": [
"8.0.10"
"9.0.0"
]
},
"vs": {
Expand Down
2 changes: 1 addition & 1 deletion samples/Playground/Playground.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<GenerateProgramFile>false</GenerateProgramFile>
<NoWarn>$(NoWarn);NETSDK1023</NoWarn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution;
/// </summary>
public class LogMessageListener : IDisposable
{
private static readonly object TraceLock = new();
private static readonly Lock TraceLock = new();
private static int s_listenerCount;
private static ThreadSafeStringWriter? s_redirectedDebugTrace;

Expand Down
7 changes: 2 additions & 5 deletions src/Adapter/MSTest.TestAdapter/Execution/TestAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,14 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution;
/// </summary>
public class TestAssemblyInfo
{
private readonly object _assemblyInfoExecuteSyncObject;
private readonly Lock _assemblyInfoExecuteSyncObject = new();

/// <summary>
/// Initializes a new instance of the <see cref="TestAssemblyInfo"/> class.
/// </summary>
/// <param name="assembly">Sets the <see cref="Assembly"/> this class is representing. </param>
internal TestAssemblyInfo(Assembly assembly)
{
_assemblyInfoExecuteSyncObject = new object();
Assembly = assembly;
}
=> Assembly = assembly;

/// <summary>
/// Gets <c>AssemblyInitialize</c> method for the assembly.
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/MSTest.TestAdapter/Execution/TestClassInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution;
/// </summary>
public class TestClassInfo
{
private readonly object _testClassExecuteSyncObject = new();
private readonly Lock _testClassExecuteSyncObject = new();

/// <summary>
/// Initializes a new instance of the <see cref="TestClassInfo"/> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
<dependency id="Microsoft.Testing.Extensions.VSTestBridge" version="$TestingPlatformVersion$" />
<dependency id="Microsoft.Testing.Platform.MSBuild" version="$TestingPlatformVersion$" />
</group>
<group targetFramework="net9.0">
<dependency id="Microsoft.Testing.Extensions.VSTestBridge" version="$TestingPlatformVersion$" />
<dependency id="Microsoft.Testing.Platform.MSBuild" version="$TestingPlatformVersion$" />
</group>
</dependencies>
<readme>PACKAGE.md</readme>
</metadata>
Expand Down Expand Up @@ -70,6 +74,14 @@
<file src="net8.0\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll" target="build\net8.0\" />
<file src="net8.0\Microsoft.TestPlatform.AdapterUtilities.dll" target="build\net8.0\" />

<!-- net9.0 -->
<file src="net9.0\build\common\MSTest.TestAdapter.props" target="build\net9.0\MSTest.TestAdapter.props" />
<file src="net9.0\build\net\MSTest.TestAdapter.targets" target="build\net9.0\MSTest.TestAdapter.targets" />
<file src="net9.0\Microsoft.VisualStudio.TestPlatform.TestFramework.dll" target="build\net9.0\" />
<file src="net9.0\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll" target="build\net9.0\" />
<file src="net9.0\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll" target="build\net9.0\" />
<file src="net9.0\Microsoft.TestPlatform.AdapterUtilities.dll" target="build\net9.0\" />

<!-- Localization -->
<!-- All TFMs share the same resx + TestAdapter depends on PlatformServices + TestFramework so all resources are available -->
<file src="net6.0\**\*.resources.dll" target="\build\_localization\" />
Expand Down
12 changes: 12 additions & 0 deletions src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
<dependency id="Microsoft.Testing.Extensions.VSTestBridge" version="$TestingPlatformVersion$" />
<dependency id="Microsoft.Testing.Platform.MSBuild" version="$TestingPlatformVersion$" />
</group>
<group targetFramework="net9.0">
<dependency id="Microsoft.Testing.Extensions.VSTestBridge" version="$TestingPlatformVersion$" />
<dependency id="Microsoft.Testing.Platform.MSBuild" version="$TestingPlatformVersion$" />
</group>
</dependencies>
<readme>PACKAGE.md</readme>
</metadata>
Expand Down Expand Up @@ -88,6 +92,14 @@
<file src="net8.0\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll" target="build\net8.0\" />
<file src="net8.0\Microsoft.TestPlatform.AdapterUtilities.dll" target="build\net8.0\" />

<!-- net9.0 -->
<file src="net9.0\build\common\MSTest.TestAdapter.props" target="build\net9.0\MSTest.TestAdapter.props" />
<file src="net9.0\build\net\MSTest.TestAdapter.targets" target="build\net9.0\MSTest.TestAdapter.targets" />
<file src="net9.0\Microsoft.VisualStudio.TestPlatform.TestFramework.dll" target="build\net9.0\" />
<file src="net9.0\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll" target="build\net9.0\" />
<file src="net9.0\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll" target="build\net9.0\" />
<file src="net9.0\Microsoft.TestPlatform.AdapterUtilities.dll" target="build\net9.0\" />

<!-- net462 -->
<file src="net462\build\common\MSTest.TestAdapter.props" target="build\net462\" />
<file src="net462\build\netfx-netcore-netstandard\MSTest.TestAdapter.targets" target="build\net462\" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class AssemblyResolver :
/// <summary>
/// lock for the loaded assemblies cache.
/// </summary>
private readonly object _syncLock = new();
private readonly Lock _syncLock = new();

private static List<string>? s_currentlyLoading;
private bool _disposed;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#nullable enable
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.TestRunDirectories
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.TestRunDirectories.InDirectory.get -> string!
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.TestRunDirectories.InMachineNameDirectory.get -> string!
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.TestRunDirectories.OutDirectory.get -> string!
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.TestRunDirectories.RootDeploymentDirectory.get -> string!
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.TestRunDirectories.RootDeploymentDirectory.set -> void
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.TestRunDirectories.TestRunDirectories(string! rootDirectory) -> void
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.MSTestAdapterSettings
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.MSTestAdapterSettings.DeleteDeploymentDirectoryAfterTestRunIsComplete.get -> bool
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.MSTestAdapterSettings.DeploymentEnabled.get -> bool
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.MSTestAdapterSettings.DeployTestSourceDependencies.get -> bool
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.MSTestAdapterSettings.GetDirectoryListWithRecursiveProperty(string! baseDirectory) -> System.Collections.Generic.List<Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.RecursiveDirectoryPath!>!
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.MSTestAdapterSettings.MSTestAdapterSettings() -> void
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.MSTestAdapterSettings.SearchDirectories.get -> System.Collections.Generic.List<Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.RecursiveDirectoryPath!>!
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.RecursiveDirectoryPath
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.RecursiveDirectoryPath.DirectoryPath.get -> string!
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.RecursiveDirectoryPath.IncludeSubDirectories.get -> bool
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.RecursiveDirectoryPath.RecursiveDirectoryPath(string! dirPath, bool includeSubDirectories) -> void
override Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.RecursiveDirectoryPath.InitializeLifetimeService() -> object!
override Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.TestContextImplementation.DeploymentDirectory.get -> string?
override Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.TestContextImplementation.FullyQualifiedTestClassName.get -> string!
override Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.TestContextImplementation.ResultsDirectory.get -> string?
override Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.TestContextImplementation.TestName.get -> string!
override Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.TestContextImplementation.TestResultsDirectory.get -> string?
override Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.TestContextImplementation.TestRunDirectory.get -> string?
override Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.TestContextImplementation.TestRunResultsDirectory.get -> string?
static Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.MSTestAdapterSettings.IsAppDomainCreationDisabled(string? settingsXml) -> bool
static Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.MSTestAdapterSettings.ToSettings(System.Xml.XmlReader! reader) -> Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.MSTestAdapterSettings!
static Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.MSTestSettingsProvider.Reset() -> void
static Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.MSTestSettingsProvider.Settings.get -> Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.MSTestAdapterSettings!
virtual Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.MSTestAdapterSettings.DoesDirectoryExist(string! path) -> bool
virtual Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.MSTestAdapterSettings.ExpandEnvironmentVariables(string! path) -> string!
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#nullable enable
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ThreadSafeStringWriter : StringWriter
// This static lock guards access to the state and getting values from dictionary. There can be multiple different instances of ThreadSafeStringWriter
// accessing the state at the same time, and we need to give them the correct state for their async context. Non-concurrent dictionary is used to store the
// state because we need to lock around it anyway, to ensure that the State is populated, but not overwritten by every new instance of ThreadSafeStringWriter.
private static readonly object StaticLockObject = new();
private static readonly Lock StaticLockObject = new();
private readonly string _outputType;

/// <summary>
Expand Down Expand Up @@ -175,7 +175,7 @@ private ThreadSafeStringBuilder GetOrAddStringBuilder()
private class ThreadSafeStringBuilder
{
private readonly StringBuilder _stringBuilder = new();
private readonly object _instanceLockObject = new();
private readonly Lock _instanceLockObject = new();

public void Append(string? value)
{
Expand Down
7 changes: 7 additions & 0 deletions src/Package/MSTest/MSTest.NonWindows.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
<dependency id="MSTest.Analyzers" version="[$version$]" />
<dependency id="Microsoft.NET.Test.Sdk" version="$TestPlatformVersion$" />
</group>

<group targetFramework="net9.0">
<dependency id="MSTest.TestAdapter" version="[$version$]" />
<dependency id="MSTest.TestFramework" version="[$version$]" />
<dependency id="MSTest.Analyzers" version="[$version$]" />
<dependency id="Microsoft.NET.Test.Sdk" version="$TestPlatformVersion$" />
</group>
</dependencies>
</metadata>
<files>
Expand Down
7 changes: 7 additions & 0 deletions src/Package/MSTest/MSTest.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@
<dependency id="MSTest.Analyzers" version="[$version$]" />
<dependency id="Microsoft.NET.Test.Sdk" version="$TestPlatformVersion$" />
</group>

<group targetFramework="net9.0">
<dependency id="MSTest.TestAdapter" version="[$version$]" />
<dependency id="MSTest.TestFramework" version="[$version$]" />
<dependency id="MSTest.Analyzers" version="[$version$]" />
<dependency id="Microsoft.NET.Test.Sdk" version="$TestPlatformVersion$" />
</group>
</dependencies>
<readme>PACKAGE.md</readme>
</metadata>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class InvokeTestingPlatformTask : Build.Utilities.ToolTask, IDisposable
private readonly CancellationTokenSource _waitForConnections = new();
private readonly List<NamedPipeServer> _connections = new();
private readonly StringBuilder _output = new();
private readonly object _initLock = new();
private readonly Lock _initLock = new();
private readonly Process _currentProcess = Process.GetCurrentProcess();
private readonly Architecture _currentProcessArchitecture = RuntimeInformation.ProcessArchitecture;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ internal ObjectPool(Factory factory)

internal ObjectPool(Factory factory, int size)
{
#pragma warning disable SA1405 // Debug.Assert should provide message text
Debug.Assert(size >= 1);
#pragma warning restore SA1405 // Debug.Assert should provide message text
RoslynDebug.Assert(size >= 1);
_factory = factory;
_items = new Element[size - 1];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<group targetFramework="net6.0" />
<group targetFramework="net7.0" />
<group targetFramework="net8.0" />
<group targetFramework="net9.0" />
</dependencies>
<readme>PACKAGE.md</readme>
</metadata>
Expand Down Expand Up @@ -52,6 +53,14 @@
<file src="net8.0/Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll" target="build/net8.0/" />
<file src="net8.0/Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.xml" target="build/net8.0/" />

<!-- net9.0 -->
<file src="net9.0/build/winui/MSTest.TestFramework.targets" target="build/net9.0/" />
<file src="net9.0/Microsoft.VisualStudio.TestPlatform.TestFramework.dll" target="lib/net9.0/" />
<file src="net9.0/Microsoft.VisualStudio.TestPlatform.TestFramework.xml" target="lib/net9.0/" />
<file src="net9.0/**/Microsoft.VisualStudio.TestPlatform.TestFramework.resources.dll" target="lib/net9.0/" />
<file src="net9.0/Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll" target="build/net9.0/" />
<file src="net9.0/Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.xml" target="build/net9.0/" />

<!-- Source code -->
<file src="$srcroot$/**/*.cs" target="src" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<group targetFramework="net6.0" />
<group targetFramework="net7.0" />
<group targetFramework="net8.0" />
<group targetFramework="net9.0" />
</dependencies>
<readme>PACKAGE.md</readme>
</metadata>
Expand Down Expand Up @@ -70,6 +71,14 @@
<file src="net8.0\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll" target="build\net8.0\" />
<file src="net8.0\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.xml" target="build\net8.0\" />

<!-- net9.0 -->
<file src="net9.0\build\winui\MSTest.TestFramework.targets" target="build\net9.0\" />
<file src="net9.0\Microsoft.VisualStudio.TestPlatform.TestFramework.dll" target="lib\net9.0\" />
<file src="net9.0\Microsoft.VisualStudio.TestPlatform.TestFramework.xml" target="lib\net9.0\" />
<file src="net9.0\**\Microsoft.VisualStudio.TestPlatform.TestFramework.resources.dll" target="lib\net9.0\" />
<file src="net9.0\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll" target="build\net9.0\" />
<file src="net9.0\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.xml" target="build\net9.0\" />

<!-- Source code -->
<file src="$srcroot$\**\*.cs" target="src" />

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#nullable enable
Microsoft.VisualStudio.TestTools.UnitTesting.DeploymentItemAttribute
Microsoft.VisualStudio.TestTools.UnitTesting.DeploymentItemAttribute.DeploymentItemAttribute(string? path) -> void
Microsoft.VisualStudio.TestTools.UnitTesting.DeploymentItemAttribute.DeploymentItemAttribute(string? path, string? outputDirectory) -> void
Microsoft.VisualStudio.TestTools.UnitTesting.DeploymentItemAttribute.OutputDirectory.get -> string?
Microsoft.VisualStudio.TestTools.UnitTesting.DeploymentItemAttribute.Path.get -> string?
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.DeploymentDirectory.get -> string?
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.ResultsDirectory.get -> string?
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestDeploymentDir.get -> string?
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestDir.get -> string?
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestLogsDir.get -> string?
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestResultsDirectory.get -> string?
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestRunDirectory.get -> string?
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestRunResultsDirectory.get -> string?
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#nullable enable
Loading

0 comments on commit 2e89f20

Please sign in to comment.