Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sourcegen #3880

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
cc0d3be
Update source gen
nohwnd Sep 27, 2024
990d154
Get assembly
nohwnd Sep 30, 2024
0969391
Update source generation to latest
nohwnd Sep 30, 2024
45cb700
Merge branch 'main' into update-sourcegen
nohwnd Sep 30, 2024
acec139
down to just trim and aot warnings from libs
nohwnd Oct 1, 2024
b21bf50
revert proj
nohwnd Oct 1, 2024
2b6ee6c
fixes
nohwnd Oct 1, 2024
8294a2d
fixes
nohwnd Oct 1, 2024
b546d0c
Merge branch 'main' into update-sourcegen
Evangelink Oct 31, 2024
0f8c9cb
Merge branch 'main' into update-sourcegen
Evangelink Nov 1, 2024
c4a2bb8
Extend test with different init/cleanup attributes
Nov 5, 2024
2520e34
Fix cleanup methods in test
Nov 5, 2024
0b651fa
Revert VersionPrefix change and update source gen
Youssef1313 Nov 6, 2024
91414af
Merge branch 'main' into update-sourcegen
Youssef1313 Nov 6, 2024
e89c7d3
Update Version.Details.xml as well
Youssef1313 Nov 6, 2024
b0ead66
Revert launchSettings.json change
Youssef1313 Nov 6, 2024
e298e0a
Add more tests for native AOT
Youssef1313 Nov 6, 2024
def4e8b
Refactor tests, add more tests
Youssef1313 Nov 6, 2024
ad94d29
Fix typo
Youssef1313 Nov 6, 2024
88ff2bc
Address analyzer warning
Youssef1313 Nov 6, 2024
9477851
More tests
Youssef1313 Nov 6, 2024
873bd97
Formatting error
Youssef1313 Nov 8, 2024
5e41dba
Move to UnconditionalSuppressMessage attribute
Youssef1313 Nov 8, 2024
430bb08
Suppress
Youssef1313 Nov 12, 2024
31001ac
Avoid using #pragma warning disable ILxxxx
Youssef1313 Nov 19, 2024
ce4198b
Merge branch 'main' into update-sourcegen
Youssef1313 Nov 21, 2024
04f6470
Adjust
Youssef1313 Nov 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
<Uri>https://github.com/microsoft/testanywhere</Uri>
<Sha>0ec8a6c01c5f0f6fa70e857b75cc0916bd433bae</Sha>
</Dependency>
<Dependency Name="MSTest.Engine" Version="1.0.0-alpha.24473.2">
<Dependency Name="MSTest.SourceGeneration" Version="1.0.0-alpha.24501.1">
<Uri>https://github.com/microsoft/testanywhere</Uri>
<Sha>aa2fcc8616d988b234bc1d218465b20c56d0b82f</Sha>
<Sha>aef1b181cc47377cf9c381f650be704b5a8dfc44</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>
6 changes: 3 additions & 3 deletions eng/Versions.props
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project>
<PropertyGroup Label="Version settings">
<!-- MSTest version -->
<VersionPrefix>3.7.0</VersionPrefix>
Youssef1313 marked this conversation as resolved.
Show resolved Hide resolved
<VersionPrefix>3.8.0</VersionPrefix>
<!-- Testing Platform version -->
<TestingPlatformVersionPrefix>1.5.0</TestingPlatformVersionPrefix>
<TestingPlatformVersionPrefix>1.6.0</TestingPlatformVersionPrefix>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be reset

Suggested change
<TestingPlatformVersionPrefix>1.6.0</TestingPlatformVersionPrefix>
<TestingPlatformVersionPrefix>1.5.0</TestingPlatformVersionPrefix>

<PreReleaseVersionLabel>preview</PreReleaseVersionLabel>
</PropertyGroup>
<PropertyGroup Label="MSTest prod dependencies - darc updated">
<MicrosoftDotNetBuildTasksTemplatingPackageVersion>10.0.0-beta.24531.2</MicrosoftDotNetBuildTasksTemplatingPackageVersion>
<MicrosoftTestingExtensionsCodeCoverageVersion>17.13.0-preview.24551.1</MicrosoftTestingExtensionsCodeCoverageVersion>
<!-- comment to facilitate merge conflicts -->
<MicrosoftTestingInternalFrameworkVersion>1.5.0-preview.24531.1</MicrosoftTestingInternalFrameworkVersion>
<MSTestEngineVersion>1.0.0-alpha.24473.2</MSTestEngineVersion>
<MSTestSourceGenerationVersion>1.0.0-alpha.24501.1</MSTestSourceGenerationVersion>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion samples/Playground/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static async Task<int> Main(string[] args)
if (Environment.GetEnvironmentVariable("TESTSERVERMODE") != "1")
{
// To attach to the children
Microsoft.Testing.TestInfrastructure.DebuggerUtility.AttachCurrentProcessToParentVSProcess();
// Microsoft.Testing.TestInfrastructure.DebuggerUtility.AttachCurrentProcessToParentVSProcess();
ITestApplicationBuilder testApplicationBuilder = await TestApplication.CreateBuilderAsync(args);

// Test MSTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution;
using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Helpers;
using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel;
#if NET8_0_OR_GREATER
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter;
#endif
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting.Internal;
Expand Down Expand Up @@ -300,8 +303,13 @@ private static bool DynamicDataAttached(UnitTestElement test, Lazy<TestMethodInf
return testMethodInfo.Value != null && TryProcessTestDataSourceTests(test, testMethodInfo.Value, tests);
}

[UnconditionalSuppressMessage("Aot", "IL3000:DoNotUseLocation", Justification = "Fixture tests are not supported in NativeAOT mode.")]

private static void AddFixtureTests(TestMethodInfo testMethodInfo, List<UnitTestElement> tests, HashSet<string> fixtureTests)
{
#if NET8_0_OR_GREATER
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be NETCOREAPP or NET7_0_OR_GREATER if we want to link it specifically to native aot.

ApplicationStateGuard.Ensure(System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported, "Fixture tests are not supported in NativeAOT mode.");
#endif
string assemblyName = testMethodInfo.Parent.Parent.Assembly.GetName().Name!;
string assemblyLocation = testMethodInfo.Parent.Parent.Assembly.Location;
string className = testMethodInfo.Parent.ClassType.Name;
Expand Down
1 change: 1 addition & 0 deletions src/Adapter/MSTest.TestAdapter/Execution/TypeCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ private static bool TryGetUnescapedManagedTypeName(TestMethod testMethod, [NotNu
/// <param name="classType"> The class Type. </param>
/// <param name="testMethod"> The test Method. </param>
/// <returns> The <see cref="TestClassInfo"/>. </returns>
[UnconditionalSuppressMessage("Aot", "IL2070:DoNotUseGetConstructor", Justification = "We access all the types we need in metadata, so this is preserved and works.")]
private TestClassInfo CreateClassInfo(Type classType, TestMethod testMethod)
{
IEnumerable<ConstructorInfo> constructors = PlatformServiceProvider.Instance.ReflectionOperations.GetDeclaredConstructors(classType);
Expand Down
2 changes: 1 addition & 1 deletion src/Adapter/MSTest.TestAdapter/MSTest.TestAdapter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<PropertyGroup>
<!-- Enable AOT analyzer warnings to make sure we don't call APIs that would fail when we use source generator mode together with NativeAOT. -->
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">$(EnableIotAnalyzers)</IsAotCompatible>
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">true</IsAotCompatible>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/Adapter/MSTest.TestAdapter/TestMethodFilter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Diagnostics.CodeAnalysis;
using System.Reflection;

using Microsoft.VisualStudio.TestPlatform.ObjectModel;
Expand Down Expand Up @@ -118,6 +119,7 @@ internal TestProperty PropertyProvider(string propertyName)
/// <param name="context">Discovery context.</param>
/// <param name="logger">The logger to log exception messages too.</param>
/// <returns>Filter expression.</returns>
[UnconditionalSuppressMessage("Aot", "IL2072:DoNotUseDynamicMembers", Justification = "Tested it, it works.")]
private ITestCaseFilterExpression? GetTestCaseFilterFromDiscoveryContext(IDiscoveryContext context, IMessageLogger logger)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ namespace Microsoft.VisualStudio.TestTools.UnitTesting;
public static class TestingPlatformBuilderHook
{
#pragma warning disable IDE0060 // Remove unused parameter
public static void AddExtensions(ITestApplicationBuilder testApplicationBuilder, string[] arguments) => testApplicationBuilder.AddMSTest(() => [Assembly.GetEntryAssembly()!]);
public static void AddExtensions(ITestApplicationBuilder testApplicationBuilder, string[] arguments)
{
#if NET8_0_OR_GREATER
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be NETCOREAPP or NET7_0_OR_GREATER if we want to link it specifically to native aot.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC it did not build with just netcoreapp, and net7 is out of life and rest of the platform used net8 so I used net8

if (!System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported)
{
// We don't have a reliable way to get reference to the entry dll when compiled as NativeAOT. So instead we do the same registration
// in source generator.
return;
}
#endif
testApplicationBuilder.AddMSTest(() => [Assembly.GetEntryAssembly()!]);
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#if NETFRAMEWORK || NET
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
#if NETFRAMEWORK
using System.Runtime.InteropServices.WindowsRuntime;
Expand Down Expand Up @@ -291,16 +292,14 @@ private static
#endif
bool DoesFileExist(string filePath) => File.Exists(filePath);

[UnconditionalSuppressMessage("Aot", "IL2026:DoNotUseGetDefinedTypes", Justification = "The whole class is not used in source generator mode.")]

#if NETFRAMEWORK
protected virtual
#else
private static
#endif

// This whole class is not used in source generator mode.
#pragma warning disable IL2026 // Members attributed with RequiresUnreferencedCode may break when trimming
Assembly LoadAssemblyFrom(string path) => Assembly.LoadFrom(path);
#pragma warning restore IL2026 // Members attributed with RequiresUnreferencedCode may break when trimming

#if NETFRAMEWORK
protected virtual Assembly ReflectionOnlyLoadAssemblyFrom(string path) => Assembly.ReflectionOnlyLoadFrom(path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Collections.Concurrent;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;

#if WIN_UI
Expand Down Expand Up @@ -81,12 +82,10 @@ public Assembly LoadAssembly(string assemblyName, bool isReflectionOnly)
/// </summary>
/// <param name="assembly">The assembly.</param>
/// <returns>Path to the .DLL of the assembly.</returns>
[UnconditionalSuppressMessage("Aot", "IL3000:DoNotUseLocation", Justification = "This method will never be called in source generator mode, we are providing a different provider for file operations.")]
public string? GetAssemblyPath(Assembly assembly)
#if NETSTANDARD || NETCOREAPP || NETFRAMEWORK
// This method will never be called in source generator mode, we are providing a different provider for file operations.
#pragma warning disable IL3000 // Avoid accessing Assembly file path when publishing as a single file
=> assembly.Location;
#pragma warning disable IL3000 // Avoid accessing Assembly file path when publishing as a single file
#elif WINDOWS_UWP
=> null; // TODO: what are the options here?
#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Diagnostics.CodeAnalysis;
using System.Reflection;

using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface;
Expand Down Expand Up @@ -38,6 +39,8 @@ public IEnumerable<PropertyInfo> GetDeclaredProperties(Type type)
public PropertyInfo? GetDeclaredProperty(Type type, string propertyName)
=> type.GetTypeInfo().GetDeclaredProperty(propertyName);

[UnconditionalSuppressMessage("Aot", "IL2026:DoNotUseGetDefinedTypes", Justification = "We access all the types we need in metadata, so this is preserved and works.")]

public Type[] GetDefinedTypes(Assembly assembly)
=> assembly.DefinedTypes.ToArray();

Expand All @@ -50,9 +53,11 @@ public IEnumerable<MethodInfo> GetRuntimeMethods(Type type)
public PropertyInfo? GetRuntimeProperty(Type classType, string testContextPropertyName)
=> classType.GetProperty(testContextPropertyName);

[UnconditionalSuppressMessage("Aot", "IL2026:DoNotUseGetDefinedTypes", Justification = "We access all the types we need in metadata, so this is preserved and works.")]
public Type? GetType(string typeName)
=> Type.GetType(typeName);

[UnconditionalSuppressMessage("Aot", "IL2026:DoNotUseGetDefinedTypes", Justification = "We access all the types we need in metadata, so this is preserved and works.")]
public Type? GetType(Assembly assembly, string typeName)
=> assembly.GetType(typeName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ internal virtual string GetTargetFrameworkVersionString(string sourceFileName)
/// <returns>
/// A list of path.
/// </returns>
[UnconditionalSuppressMessage("Aot", "IL3000:DoNotUseLocation", Justification = " We check for the empty path, and in single file mode, or on source gen mode we allow loading dependencies only from the current folder, which is what the default loader handles by itself.")]
internal virtual List<string> GetResolutionPaths(string sourceFileName, bool isPortableMode)
{
List<string> resolutionPaths =
Expand Down Expand Up @@ -388,9 +389,6 @@ internal virtual List<string> GetResolutionPaths(string sourceFileName, bool isP
#endif
}

// We check for the empty path, and in single file mode, or on source gen mode we don't allow
// loading dependencies than from the current folder, which is what the default loader handles by itself.
#pragma warning disable IL3000 // Avoid accessing Assembly file path when publishing as a single file
if (!string.IsNullOrEmpty(typeof(TestSourceHost).Assembly.Location))
{
// Adding adapter folder to resolution paths
Expand All @@ -408,7 +406,6 @@ internal virtual List<string> GetResolutionPaths(string sourceFileName, bool isP
resolutionPaths.Add(Path.GetDirectoryName(typeof(AssemblyHelper).Assembly.Location)!);
}
}
#pragma warning restore IL3000 // Avoid accessing Assembly file path when publishing as a single file

return resolutionPaths;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public static string GetTestResultsDirectory(IRunContext? runContext) => !String
/// <param name="deploymentDirectory">The deployment directory.</param>
/// <param name="resultsDirectory">Root results directory.</param>
/// <returns>Returns a list of deployment warnings.</returns>
[UnconditionalSuppressMessage("Aot", "IL3000:DoNotUseLocation", Justification = "Deployment feature is not available in native.")]
protected IEnumerable<string> Deploy(IList<DeploymentItem> deploymentItems, string testSource, string deploymentDirectory, string resultsDirectory)
{
Guard.NotNullOrWhiteSpace(deploymentDirectory);
Expand Down Expand Up @@ -186,10 +187,7 @@ protected IEnumerable<string> Deploy(IList<DeploymentItem> deploymentItems, stri

// Ignore the test platform files.
string tempFile = Path.GetFileName(fileToDeploy);
// We throw when we run in source gen mode.
#pragma warning disable IL3000 // Avoid accessing Assembly file path when publishing as a single file
string assemblyName = Path.GetFileName(GetType().Assembly.Location);
#pragma warning restore IL3000 // Avoid accessing Assembly file path when publishing as a single file
if (tempFile.Equals(assemblyName, StringComparison.OrdinalIgnoreCase))
{
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/Package/MSTest.Sdk/MSTest.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</ItemGroup>
<Target Name="GenerateTemplates" AfterTargets="PrepareForBuild">
<PropertyGroup>
<_TemplateProperties>MSTestEngineVersion=$(MSTestEngineVersion);MSTestVersion=$(Version);MicrosoftTestingPlatformVersion=$(Version.Replace('$(VersionPrefix)', '$(TestingPlatformVersionPrefix)'));MicrosoftTestingEntrepriseExtensionsVersion=$(MicrosoftTestingInternalFrameworkVersion);MicrosoftNETTestSdkVersion=$(MicrosoftNETTestSdkVersion);MicrosoftTestingExtensionsCodeCoverageVersion=$(MicrosoftTestingExtensionsCodeCoverageVersion);MicrosoftPlaywrightVersion=$(MicrosoftPlaywrightVersion);AspireHostingTestingVersion=$(AspireHostingTestingVersion)</_TemplateProperties>
<_TemplateProperties>MSTestSourceGenerationVersion=$(MSTestSourceGenerationVersion);MSTestVersion=$(Version);MicrosoftTestingPlatformVersion=$(Version.Replace('$(VersionPrefix)', '$(TestingPlatformVersionPrefix)'));MicrosoftTestingEntrepriseExtensionsVersion=$(MicrosoftTestingInternalFrameworkVersion);MicrosoftNETTestSdkVersion=$(MicrosoftNETTestSdkVersion);MicrosoftTestingExtensionsCodeCoverageVersion=$(MicrosoftTestingExtensionsCodeCoverageVersion);MicrosoftPlaywrightVersion=$(MicrosoftPlaywrightVersion);AspireHostingTestingVersion=$(AspireHostingTestingVersion)</_TemplateProperties>
</PropertyGroup>

<!--
Expand Down
12 changes: 7 additions & 5 deletions src/Package/MSTest.Sdk/Sdk/Runner/NativeAOT.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

<Import Project="$(MSBuildThisFileDirectory)Common.targets"/>

<PropertyGroup Condition=" '$(IsTestApplication)' == 'true' ">
<EnableMSTestRunner>true</EnableMSTestRunner>
</PropertyGroup>

Comment on lines +6 to +9
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

<Target Name="_MSTestSDKValidateFeatures" BeforeTargets="Build">
<Error Condition=" '$(EnableAspireTesting)' == 'true' " Text="Aspire MSTest currently doesn't support NativeAOT mode." />
<Error Condition=" '$(EnablePlaywright)' == 'true' " Text="Playwright MSTest currently doesn't support NativeAOT mode." />
Expand All @@ -15,14 +19,12 @@

<!-- Core -->
<ItemGroup>
<PackageReference Include="Microsoft.Testing.Platform.MSBuild" Sdk="MSTest"
Version="$(MicrosoftTestingPlatformVersion)" VersionOverride="$(MicrosoftTestingPlatformVersion)" />
<PackageReference Include="MSTest.TestFramework" Sdk="MSTest"
Version="$(MSTestVersion)" VersionOverride="$(MSTestVersion)" />
<PackageReference Include="MSTest.Engine" Sdk="MSTest"
Version="$(MSTestEngineVersion)" VersionOverride="$(MSTestEngineVersion)" />
<PackageReference Include="MSTest.TestAdapter" Sdk="MSTest"
Version="$(MSTestVersion)" VersionOverride="$(MSTestVersion)" />
<PackageReference Include="MSTest.SourceGeneration" Sdk="MSTest"
Version="$(MSTestEngineVersion)" VersionOverride="$(MSTestEngineVersion)" />
Version="$(MSTestSourceGenerationVersion)" VersionOverride="$(MSTestSourceGenerationVersion)" />
<!--
Most of the times this dependency is not required but we leave the opportunity to align the version of the platform being used.
At the moment this is mainly used for our acceptance tests because the locally/CI built version ends with -dev or -ci which is
Expand Down
2 changes: 1 addition & 1 deletion src/Package/MSTest.Sdk/Sdk/Sdk.props.template
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<AspireHostingTestingVersion Condition=" '$(AspireHostingTestingVersion)' == '' ">${AspireHostingTestingVersion}</AspireHostingTestingVersion>
<MSTestVersion Condition=" '$(MSTestVersion)' == '' ">${MSTestVersion}</MSTestVersion>
<MSTestEngineVersion Condition=" '$(MSTestEngineVersion)' == '' ">${MSTestEngineVersion}</MSTestEngineVersion>
<MSTestSourceGenerationVersion Condition=" '$(MSTestSourceGenerationVersion)' == '' ">${MSTestSourceGenerationVersion}</MSTestSourceGenerationVersion>
<MicrosoftNETTestSdkVersion Condition=" '$(MicrosoftNETTestSdkVersion)' == '' ">${MicrosoftNETTestSdkVersion}</MicrosoftNETTestSdkVersion>
<MicrosoftPlaywrightVersion Condition=" '$(MicrosoftPlaywrightVersion)' == '' ">${MicrosoftPlaywrightVersion}</MicrosoftPlaywrightVersion>
<MicrosoftTestingExtensionsCodeCoverageVersion Condition=" '$(MicrosoftTestingExtensionsCodeCoverageVersion)' == '' " >${MicrosoftTestingExtensionsCodeCoverageVersion}</MicrosoftTestingExtensionsCodeCoverageVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Reflection;

Expand Down Expand Up @@ -103,13 +104,12 @@ protected sealed override Task RunTestsAsync(VSTestRunTestExecutionRequest reque
protected abstract Task SynchronizedRunTestsAsync(VSTestRunTestExecutionRequest request, IMessageBus messageBus,
CancellationToken cancellationToken);

[UnconditionalSuppressMessage("Aot", "IL3000:DoNotUseLocation", Justification = "We are passing our own class that derives from Assembly and sets the Location.")]
protected sealed override Task ExecuteRequestAsync(TestExecutionRequest request, IMessageBus messageBus,
CancellationToken cancellationToken)
=> ExecuteRequestWithRequestCountGuardAsync(async () =>
{
#pragma warning disable IL3000 // Avoid accessing Assembly file path when publishing as a single file
string[] testAssemblyPaths = _getTestAssemblies().Select(x => x.Location).ToArray();
#pragma warning restore IL3000 // Avoid accessing Assembly file path when publishing as a single file
switch (request)
{
case DiscoverTestExecutionRequest discoverRequest:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public DynamicDataAttribute(string dynamicDataSourceName, Type dynamicDataDeclar
public IEnumerable<object[]> GetData(MethodInfo methodInfo) => DynamicDataProvider.Instance.GetData(_dynamicDataDeclaringType, _dynamicDataSourceType, _dynamicDataSourceName, methodInfo);

/// <inheritdoc />
[UnconditionalSuppressMessage("Aot", "IL2075:DoNotUseGetDefinedMethod", Justification = "We access all the types we need in metadata, so this is preserved and works.")]
public string? GetDisplayName(MethodInfo methodInfo, object?[]? data)
{
if (DynamicDataDisplayName != null)
Expand Down
2 changes: 1 addition & 1 deletion src/TestFramework/TestFramework/TestFramework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<PropertyGroup>
<!-- Enable AOT analyzer warnings to make sure we don't call APIs that would fail when we use source generator mode together with NativeAOT. -->
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">$(EnableIotAnalyzers)</IsAotCompatible>
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">true</IsAotCompatible>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading
Loading