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 4 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
2 changes: 1 addition & 1 deletion eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<Uri>https://github.com/microsoft/testanywhere</Uri>
<Sha>c13e51348015685e1ec9a71377c6e7a2ef52cfd2</Sha>
</Dependency>
<Dependency Name="MSTest.Engine" Version="1.0.0-alpha.24473.2">
<Dependency Name="MSTest.SourceGeneration" Version="1.0.0-alpha.24480.1">
<Uri>https://github.com/microsoft/testanywhere</Uri>
<Sha>aa2fcc8616d988b234bc1d218465b20c56d0b82f</Sha>
nohwnd marked this conversation as resolved.
Show resolved Hide resolved
</Dependency>
Expand Down
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.24476.2</MicrosoftDotNetBuildTasksTemplatingPackageVersion>
<MicrosoftTestingExtensionsCodeCoverageVersion>17.12.5-preview.24477.4</MicrosoftTestingExtensionsCodeCoverageVersion>
<!-- comment to facilitate merge conflicts -->
<MicrosoftTestingInternalFrameworkVersion>1.5.0-preview.24477.3</MicrosoftTestingInternalFrameworkVersion>
<MSTestEngineVersion>1.0.0-alpha.24473.2</MSTestEngineVersion>
<MSTestSourceGenerationVersion>1.0.0-alpha.24480.1</MSTestSourceGenerationVersion>
</PropertyGroup>
</Project>
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
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
Expand Up @@ -22,8 +22,7 @@
<!-- Packages needed for the test assets but that we don't want to reference -->
<ItemGroup>
<PackageDownload Include="Aspire.Hosting.Testing" Version="[$(AspireHostingTestingVersion)]" />
<PackageDownload Include="MSTest.Engine" Version="[$(MSTestEngineVersion)]" />
<PackageDownload Include="MSTest.SourceGeneration" Version="[$(MSTestEngineVersion)]" />
<PackageDownload Include="MSTest.SourceGeneration" Version="[$(MSTestSourceGenerationVersion)]" />
</ItemGroup>

<Target Name="CopyNuGetPackagesForTestAssets" BeforeTargets="BeforeBuild">
Expand All @@ -34,8 +33,7 @@
<Copy SkipUnchangedFiles="true" SourceFiles="@(MicrosoftTestingExtensionsCodeCoveragePackage)" DestinationFiles="$(ArtifactsTmpDir)/packages/%(Filename)%(Extension)" />

<Copy SkipUnchangedFiles="true" SourceFiles="$(NuGetPackageRoot)aspire.hosting.testing\$(AspireHostingTestingVersion)\aspire.hosting.testing.$(AspireHostingTestingVersion).nupkg" DestinationFiles="$(ArtifactsTmpDir)/packages/aspire.hosting.testing.$(AspireHostingTestingVersion).nupkg" />
<Copy SkipUnchangedFiles="true" SourceFiles="$(NuGetPackageRoot)mstest.engine\$(MSTestEngineVersion)\mstest.engine.$(MSTestEngineVersion).nupkg" DestinationFiles="$(ArtifactsTmpDir)/packages/mstest.engine.$(MSTestEngineVersion).nupkg" />
<Copy SkipUnchangedFiles="true" SourceFiles="$(NuGetPackageRoot)mstest.sourcegeneration\$(MSTestEngineVersion)\mstest.sourcegeneration.$(MSTestEngineVersion).nupkg" DestinationFiles="$(ArtifactsTmpDir)/packages/mstest.sourcegeneration.$(MSTestEngineVersion).nupkg" />
<Copy SkipUnchangedFiles="true" SourceFiles="$(NuGetPackageRoot)mstest.sourcegeneration\$(MSTestSourceGenerationVersion)\mstest.sourcegeneration.$(MSTestSourceGenerationVersion).nupkg" DestinationFiles="$(ArtifactsTmpDir)/packages/mstest.sourcegeneration.$(MSTestSourceGenerationVersion).nupkg" />
</Target>

</Project>
Copy link
Member

Choose a reason for hiding this comment

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

Note to self: Combine the tests in a single project so that we do the dotnet publish only once.

Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public class NativeAotTests : AcceptanceTestBase
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Testing.Platform" Version="$MicrosoftTestingPlatformVersion$" />
<PackageReference Include="MSTest.Engine" Version="$MSTestEngineVersion$" />
<PackageReference Include="MSTest.SourceGeneration" Version="$MSTestEngineVersion$" />
<PackageReference Include="MSTest.SourceGeneration" Version="$MSTestSourceGenerationVersion$" />
<PackageReference Include="MSTest.TestFramework" Version="$MSTestVersion$" />
<PackageReference Include="MSTest.TestAdapter" Version="$MSTestVersion$" />
</ItemGroup>
</Project>

Expand Down Expand Up @@ -101,7 +101,7 @@ public async Task NativeAotTests_WillRunWithExitCodeZero()
.PatchCodeWithReplace("$MicrosoftTestingEnterpriseExtensionsVersion$", MicrosoftTestingEnterpriseExtensionsVersion)
.PatchCodeWithReplace("$TargetFramework$", TargetFrameworks.NetCurrent.Arguments)
.PatchCodeWithReplace("$MSTestVersion$", MSTestVersion)
.PatchCodeWithReplace("$MSTestEngineVersion$", MSTestEngineVersion),
.PatchCodeWithReplace("$MSTestSourceGenerationVersion$", MSTestSourceGenerationVersion),
addPublicFeeds: true);

await DotnetCli.RunAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ static AcceptanceTestBase()
MSTestVersion = ExtractVersionFromVersionPropsFile(versionsPropFileDoc, "MSTestVersion");
MicrosoftTestingPlatformVersion = ExtractVersionFromVersionPropsFile(versionsPropFileDoc, "MSTestVersion");
MicrosoftTestingEnterpriseExtensionsVersion = ExtractVersionFromPackage(Constants.ArtifactsPackagesShipping, "Microsoft.Testing.Extensions.");
MSTestEngineVersion = ExtractVersionFromPackage(Constants.ArtifactsPackagesShipping, "MSTest.Engine");
MSTestSourceGenerationVersion = ExtractVersionFromPackage(Constants.ArtifactsPackagesShipping, "MSTest.SourceGeneration");
#else
MSTestVersion = ExtractVersionFromPackage(Constants.ArtifactsPackagesShipping, "MSTest.TestFramework.");
MicrosoftTestingPlatformVersion = ExtractVersionFromPackage(Constants.ArtifactsPackagesShipping, "Microsoft.Testing.Platform.");
MicrosoftTestingEnterpriseExtensionsVersion = ExtractVersionFromVersionPropsFile(versionsPropFileDoc, "MicrosoftTestingInternalFrameworkVersion");
MSTestEngineVersion = ExtractVersionFromVersionPropsFile(versionsPropFileDoc, "MSTestEngineVersion");
MSTestSourceGenerationVersion = ExtractVersionFromVersionPropsFile(versionsPropFileDoc, "MSTestSourceGenerationVersion");
#endif
}

Expand All @@ -80,7 +80,7 @@ protected AcceptanceTestBase(ITestExecutionContext testExecutionContext)

public static string MSTestVersion { get; private set; }

public static string MSTestEngineVersion { get; private set; }
public static string MSTestSourceGenerationVersion { get; private set; }

public static string MicrosoftNETTestSdkVersion { get; private set; }

Expand Down
Loading