Skip to content

Commit e455fe3

Browse files
committed
Merge branch 'main' into pr/4340
# Conflicts: # test/IntegrationTests/MSTest.Acceptance.IntegrationTests/NativeAotTests.cs
2 parents fb70d0d + e733620 commit e455fe3

File tree

219 files changed

+3559
-2996
lines changed

Some content is hidden

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

219 files changed

+3559
-2996
lines changed

Directory.Packages.props

+8-6
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
<PropertyGroup Label="Product dependencies">
77
<AspireHostingTestingVersion>8.2.2</AspireHostingTestingVersion>
88
<MicrosoftBuildVersion>17.11.4</MicrosoftBuildVersion>
9-
<MicrosoftCodeAnalysisAnalyzersVersion>3.11.0-beta1.24605.2</MicrosoftCodeAnalysisAnalyzersVersion>
109
<MicrosoftCodeAnalysisVersion>3.11.0</MicrosoftCodeAnalysisVersion>
1110
<MicrosoftCodeAnalysisVersionForTests>4.10.0</MicrosoftCodeAnalysisVersionForTests>
12-
<MicrosoftCodeAnalysisPublicApiAnalyzersVersion>$(MicrosoftCodeAnalysisAnalyzersVersion)</MicrosoftCodeAnalysisPublicApiAnalyzersVersion>
11+
<MicrosoftCodeAnalysisPublicApiAnalyzersVersion>3.11.0-beta1.24605.2</MicrosoftCodeAnalysisPublicApiAnalyzersVersion>
1312
<MicrosoftCodeAnalysisBannedApiAnalyzersVersion>$(MicrosoftCodeAnalysisPublicApiAnalyzersVersion)</MicrosoftCodeAnalysisBannedApiAnalyzersVersion>
1413
<!-- UWP and WinUI dependencies -->
1514
<MicrosoftNETCoreUniversalWindowsPlatformVersion>6.2.14</MicrosoftNETCoreUniversalWindowsPlatformVersion>
@@ -22,9 +21,11 @@
2221
<SystemNetWebSocketsClientVersion>4.3.1</SystemNetWebSocketsClientVersion>
2322
<SystemTextRegularExpressionsVersion>4.3.1</SystemTextRegularExpressionsVersion>
2423
<SystemThreadingTasksExtensionsVersion>4.5.4</SystemThreadingTasksExtensionsVersion>
24+
<SystemValueTupleVersion>4.5.0</SystemValueTupleVersion>
2525
</PropertyGroup>
2626
<PropertyGroup Label="Test dependencies">
2727
<MicrosoftCodeAnalysisAnalyzerTestingVersion>1.1.3-beta1.24423.1</MicrosoftCodeAnalysisAnalyzerTestingVersion>
28+
<MSTestVersion>3.8.0-preview.24616.6</MSTestVersion>
2829
</PropertyGroup>
2930
<ItemGroup Label="Analyzers">
3031
<PackageVersion Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="$(MicrosoftCodeAnalysisBannedApiAnalyzersVersion)" />
@@ -37,7 +38,7 @@
3738
<PackageVersion Include="Microsoft.Build.Framework" Version="$(MicrosoftBuildVersion)" />
3839
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="$(MicrosoftBuildVersion)" />
3940
<PackageVersion Include="Microsoft.CodeAnalysis" Version="$(MicrosoftCodeAnalysisVersion)" />
40-
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="$(MicrosoftCodeAnalysisAnalyzersVersion)" />
41+
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0" />
4142
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="$(MicrosoftCodeAnalysisVersion)" />
4243
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="$(MicrosoftCodeAnalysisVersion)" />
4344
<PackageVersion Include="Microsoft.Diagnostics.NETCore.Client" Version="0.2.553101" />
@@ -53,7 +54,7 @@
5354
<PackageVersion Include="System.Diagnostics.TextWriterTraceListener" Version="4.3.0" />
5455
<!-- CVE-2019-0981, CVE-2019-0980, CVE-2019-0657 -->
5556
<PackageVersion Include="System.Private.Uri" Version="4.3.2" />
56-
<PackageVersion Include="System.ValueTuple" Version="4.5.0" />
57+
<PackageVersion Include="System.ValueTuple" Version="$(SystemValueTupleVersion)" />
5758
</ItemGroup>
5859
<ItemGroup Label="Test dependencies">
5960
<PackageVersion Include="Codecov" Version="1.12.3" />
@@ -65,12 +66,13 @@
6566
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing" Version="$(MicrosoftCodeAnalysisAnalyzerTestingVersion)" />
6667
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeRefactoring.Testing" Version="$(MicrosoftCodeAnalysisAnalyzerTestingVersion)" />
6768
<PackageVersion Include="Microsoft.Extensions.FileSystemGlobbing" Version="9.0.0" />
68-
<PackageVersion Include="Microsoft.Testing.Internal.Framework" Version="$(MicrosoftTestingInternalFrameworkVersion)" />
69-
<PackageVersion Include="Microsoft.Testing.Internal.Framework.SourceGeneration" Version="$(MicrosoftTestingInternalFrameworkVersion)" />
7069
<PackageVersion Include="Microsoft.TestPlatform" Version="$(MicrosoftNETTestSdkVersion)" />
7170
<!-- Pinned to 4.18.4 for security -->
7271
<PackageVersion Include="Moq" Version="4.18.4" />
7372
<PackageVersion Include="MSBuild.StructuredLogger" Version="2.2.386" />
73+
<PackageVersion Include="MSTest.Analyzers" Version="$(MSTestVersion)" />
74+
<PackageVersion Include="MSTest.TestAdapter" Version="$(MSTestVersion)" />
75+
<PackageVersion Include="MSTest.TestFramework" Version="$(MSTestVersion)" />
7476
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
7577
<!-- CVE-2024-0057 / Transitive deps of code analysis testing packages -->
7678
<PackageVersion Include="NuGet.Packaging" Version="6.12.1" />

samples/Playground/DebuggerUtility.cs

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4+
#if NETCOREAPP
45
#pragma warning disable CA1837 // Use 'Environment.ProcessId'
56
#pragma warning disable CA1416 // Validate platform compatibility
67

@@ -356,3 +357,5 @@ private static extern int NtQueryInformationProcess(
356357
[DllImport("ole32.dll")]
357358
private static extern int CreateBindCtx(uint reserved, out IBindCtx ppbc);
358359
}
360+
361+
#endif

samples/Playground/Playground.csproj

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
<NoWarn>$(NoWarn);NETSDK1023</NoWarn>
99
</PropertyGroup>
1010

11+
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
12+
<Compile Remove="ServerMode/**/*.cs" />
13+
</ItemGroup>
14+
1115
<ItemGroup>
1216
<ProjectReference Include="$(RepoRoot)src\Platform\Microsoft.Testing.Platform\Microsoft.Testing.Platform.csproj" />
1317
<ProjectReference Include="$(RepoRoot)src\Adapter\MSTest.TestAdapter\MSTest.TestAdapter.csproj" />

samples/Playground/Program.cs

+9-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
using Microsoft.Testing.Platform.Extensions.TestFramework;
99
using Microsoft.Testing.Platform.Extensions.TestHostControllers;
1010
using Microsoft.Testing.Platform.Messages;
11+
#if NETCOREAPP
1112
using Microsoft.Testing.Platform.ServerMode.IntegrationTests.Messages.V100;
13+
using MSTest.Acceptance.IntegrationTests.Messages.V100;
14+
#endif
1215
using Microsoft.Testing.Platform.TestHost;
1316
using Microsoft.VisualStudio.TestTools.UnitTesting;
1417

15-
using MSTest.Acceptance.IntegrationTests.Messages.V100;
16-
1718
namespace Playground;
1819

1920
public class Program
@@ -25,8 +26,10 @@ public static async Task<int> Main(string[] args)
2526

2627
if (Environment.GetEnvironmentVariable("TESTSERVERMODE") != "1")
2728
{
29+
#if NETCOREAPP
2830
// To attach to the children
2931
Microsoft.Testing.TestInfrastructure.DebuggerUtility.AttachCurrentProcessToParentVSProcess();
32+
#endif
3033

3134
ITestApplicationBuilder testApplicationBuilder = await TestApplication.CreateBuilderAsync(args);
3235

@@ -49,6 +52,9 @@ public static async Task<int> Main(string[] args)
4952
}
5053
else
5154
{
55+
#if NETFRAMEWORK
56+
throw new NotSupportedException("Server mode is not supported on .NET Framework");
57+
#else
5258
Environment.SetEnvironmentVariable("TESTSERVERMODE", "0");
5359
using TestingPlatformClient client = await TestingPlatformClientFactory.StartAsServerAndConnectToTheClientAsync(Environment.ProcessPath!);
5460

@@ -67,6 +73,7 @@ public static async Task<int> Main(string[] args)
6773
await client.ExitAsync();
6874

6975
return 0;
76+
#endif
7077
}
7178
}
7279
}

samples/Playground/Tests.cs

+9-6
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,16 @@ public class TestClass
1515
public TestContext TestContext { get; set; }
1616

1717
[TestMethod]
18-
public void Test() => TestContext.AddResultFile(@"c:\hello2");
18+
[DynamicData(nameof(Data))]
19+
public void Test3(int a, int b)
20+
=> Assert.AreNotEqual(a, b);
1921

20-
[TestMethod]
21-
public void Test2() => Assert.AreEqual(1, 0, "few");
22-
23-
[TestMethod]
24-
public void Test3()
22+
public static IEnumerable<(int A, int B)> Data
2523
{
24+
get
25+
{
26+
yield return (1, 2);
27+
yield return (3, 4);
28+
}
2629
}
2730
}

src/Adapter/MSTest.TestAdapter/DynamicDataOperations.cs

+64-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4-
using Microsoft.VisualStudio.TestTools.UnitTesting;
5-
6-
#if NET471_OR_GREATER || NETCOREAPP
74
using System.Collections;
8-
using System.Runtime.CompilerServices;
9-
#endif
105
using System.Diagnostics.CodeAnalysis;
116
using System.Globalization;
127
using System.Reflection;
8+
#if NET471_OR_GREATER || NETCOREAPP
9+
using System.Runtime.CompilerServices;
10+
#endif
11+
12+
using Microsoft.VisualStudio.TestTools.UnitTesting;
1313

1414
namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter;
1515

@@ -160,12 +160,12 @@ private static bool TryGetData(object dataSource, [NotNullWhen(true)] out IEnume
160160
return true;
161161
}
162162

163-
#if NETCOREAPP || NET471_OR_GREATER
164163
if (dataSource is IEnumerable enumerable)
165164
{
166165
List<object[]> objects = new();
167166
foreach (object? entry in enumerable)
168167
{
168+
#if NET471_OR_GREATER || NETCOREAPP
169169
if (entry is not ITuple tuple
170170
|| (objects.Count > 0 && objects[^1].Length != tuple.Length))
171171
{
@@ -180,14 +180,71 @@ private static bool TryGetData(object dataSource, [NotNullWhen(true)] out IEnume
180180
}
181181

182182
objects.Add(array);
183+
#else
184+
Type type = entry.GetType();
185+
if (!IsTupleOrValueTuple(entry.GetType(), out int tupleSize)
186+
|| (objects.Count > 0 && objects[objects.Count - 1].Length != tupleSize))
187+
{
188+
data = null;
189+
return false;
190+
}
191+
192+
object[] array = new object[tupleSize];
193+
for (int i = 0; i < tupleSize; i++)
194+
{
195+
array[i] = type.GetField($"Item{i + 1}")?.GetValue(entry)!;
196+
}
197+
198+
objects.Add(array);
199+
#endif
183200
}
184201

185202
data = objects;
186203
return true;
187204
}
188-
#endif
189205

190206
data = null;
191207
return false;
192208
}
209+
210+
#if !NET471_OR_GREATER && !NETCOREAPP
211+
private static bool IsTupleOrValueTuple(Type type, out int tupleSize)
212+
{
213+
tupleSize = 0;
214+
if (!type.IsGenericType)
215+
{
216+
return false;
217+
}
218+
219+
Type genericTypeDefinition = type.GetGenericTypeDefinition();
220+
221+
if (genericTypeDefinition == typeof(Tuple<>) ||
222+
genericTypeDefinition == typeof(Tuple<,>) ||
223+
genericTypeDefinition == typeof(Tuple<,,>) ||
224+
genericTypeDefinition == typeof(Tuple<,,,>) ||
225+
genericTypeDefinition == typeof(Tuple<,,,,>) ||
226+
genericTypeDefinition == typeof(Tuple<,,,,,>) ||
227+
genericTypeDefinition == typeof(Tuple<,,,,,,>) ||
228+
genericTypeDefinition == typeof(Tuple<,,,,,,,>))
229+
{
230+
tupleSize = type.GetGenericArguments().Length;
231+
return true;
232+
}
233+
234+
if (genericTypeDefinition == typeof(ValueTuple<>) ||
235+
genericTypeDefinition == typeof(ValueTuple<,>) ||
236+
genericTypeDefinition == typeof(ValueTuple<,,>) ||
237+
genericTypeDefinition == typeof(ValueTuple<,,,>) ||
238+
genericTypeDefinition == typeof(ValueTuple<,,,,>) ||
239+
genericTypeDefinition == typeof(ValueTuple<,,,,,>) ||
240+
genericTypeDefinition == typeof(ValueTuple<,,,,,,>) ||
241+
genericTypeDefinition == typeof(ValueTuple<,,,,,,,>))
242+
{
243+
tupleSize = type.GetGenericArguments().Length;
244+
return true;
245+
}
246+
247+
return false;
248+
}
249+
#endif
193250
}

src/Adapter/MSTest.TestAdapter/Execution/ExceptionHelper.cs

+8-6
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,14 @@ internal static class ExceptionHelper
7777
bool first = true;
7878
while (stackTraces.Count != 0)
7979
{
80-
result.AppendFormat(
81-
CultureInfo.CurrentCulture,
82-
"{0} {1}{2}",
83-
first ? string.Empty : (Resource.UTA_EndOfInnerExceptionTrace + Environment.NewLine),
84-
stackTraces.Pop(),
85-
Environment.NewLine);
80+
if (!first)
81+
{
82+
result.AppendLine(Resource.UTA_EndOfInnerExceptionTrace);
83+
}
84+
85+
result.Append(' ');
86+
result.AppendLine(stackTraces.Pop());
87+
8688
first = false;
8789
}
8890

src/Adapter/MSTest.TestAdapter/Helpers/ReflectHelper.cs

-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ internal static TestIdGenerationStrategy GetTestIdGenerationStrategy(Assembly as
272272
/// Gets TestDataSourceDiscovery assembly level attribute.
273273
/// </summary>
274274
/// <param name="assembly"> The test assembly. </param>
275-
[Obsolete]
276275
internal static TestDataSourceDiscoveryOption? GetTestDataSourceDiscoveryOption(Assembly assembly)
277276
=> PlatformServiceProvider.Instance.ReflectionOperations.GetCustomAttributes(assembly, typeof(TestDataSourceDiscoveryAttribute))
278277
.OfType<TestDataSourceDiscoveryAttribute>()

src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.csproj

+5-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757

5858
<ItemGroup>
5959
<PackageReference Include="Microsoft.TestPlatform.AdapterUtilities" />
60-
<PackageReference Include="System.Threading.Tasks.Extensions" Condition="'$(TargetFramework)'=='netstandard2.0' OR '$(TargetFramework)' == '$(NetFrameworkMinimum)' OR '$(TargetFramework)'=='$(UwpMinimum)'" />
60+
<PackageReference Include="System.Threading.Tasks.Extensions" Condition=" '$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == '$(NetFrameworkMinimum)' OR '$(TargetFramework)' == '$(UwpMinimum)' " />
61+
<PackageReference Include="System.ValueTuple" Condition=" '$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == '$(NetFrameworkMinimum)' OR '$(TargetFramework)' == '$(UwpMinimum)' " />
6162
</ItemGroup>
6263

6364
<ItemGroup>
@@ -81,11 +82,12 @@
8182
</ItemGroup>
8283

8384
<ItemGroup Label="NuGet">
84-
<NuspecProperty Include="RepoRoot=$(RepoRoot)" />
8585
<NuspecProperty Include="ArtifactsBinDir=$(ArtifactsBinDir)" />
8686
<NuspecProperty Include="Configuration=$(Configuration)" />
87-
<NuspecProperty Include="TestingPlatformVersion=$(Version.Replace('$(VersionPrefix)', '$(TestingPlatformVersionPrefix)'))" />
87+
<NuspecProperty Include="RepoRoot=$(RepoRoot)" />
8888
<NuspecProperty Include="SystemThreadingTasksExtensionsVersion=$(SystemThreadingTasksExtensionsVersion)" />
89+
<NuspecProperty Include="SystemValueTupleVersion=$(SystemValueTupleVersion)" />
90+
<NuspecProperty Include="TestingPlatformVersion=$(Version.Replace('$(VersionPrefix)', '$(TestingPlatformVersionPrefix)'))" />
8991
</ItemGroup>
9092

9193
<ItemGroup>

src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.nuspec

+3
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@
77
<dependency id="Microsoft.Testing.Extensions.VSTestBridge" version="$TestingPlatformVersion$" />
88
<dependency id="Microsoft.Testing.Platform.MSBuild" version="$TestingPlatformVersion$" />
99
<dependency id="System.Threading.Tasks.Extensions" version="$SystemThreadingTasksExtensionsVersion$" />
10+
<dependency id="System.ValueTuple" version="$SystemValueTupleVersion$" />
1011
</group>
1112
<group targetFramework="net462">
1213
<dependency id="Microsoft.Testing.Extensions.VSTestBridge" version="$TestingPlatformVersion$" />
1314
<dependency id="Microsoft.Testing.Platform.MSBuild" version="$TestingPlatformVersion$" />
1415
<dependency id="System.Threading.Tasks.Extensions" version="$SystemThreadingTasksExtensionsVersion$" />
16+
<dependency id="System.ValueTuple" version="$SystemValueTupleVersion$" />
1517
</group>
1618
<group targetFramework="uap10.0">
1719
<dependency id="System.Threading.Tasks.Extensions" version="$SystemThreadingTasksExtensionsVersion$" />
20+
<dependency id="System.ValueTuple" version="$SystemValueTupleVersion$" />
1821
</group>
1922
<group targetFramework="netcoreapp3.1">
2023
<dependency id="Microsoft.Testing.Extensions.VSTestBridge" version="$TestingPlatformVersion$" />

0 commit comments

Comments
 (0)