Skip to content

Bump MSTest + VSTest and use MSTest.Sdk #203

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="MSTest.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<LangVersion>preview</LangVersion>
<UseVSTest>true</UseVSTest>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.3" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.3" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 8 additions & 0 deletions CommunityToolkit.Tooling.SampleGen.Tests/MSTestConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.VisualStudio.TestTools.UnitTesting;

[assembly: Parallelize(Scope = ExecutionScope.MethodLevel, Workers = 0)]
[assembly: ClassCleanupExecution(ClassCleanupBehavior.EndOfClass)]
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

using CommunityToolkit.Tooling.SampleGen.Diagnostics;
using CommunityToolkit.Tooling.SampleGen.Tests.Helpers;
using Microsoft.CodeAnalysis;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;

namespace CommunityToolkit.Tooling.SampleGen.Tests;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ Which is valid.

result.AssertNoCompilationErrors();

Assert.AreEqual(result.Compilation.GetFileContentsByName("ToolkitDocumentRegistry.g.cs"), """
Assert.AreEqual("""
#nullable enable
namespace CommunityToolkit.Tooling.SampleGen;

Expand All @@ -311,6 +311,6 @@ public static class ToolkitDocumentRegistry
yield return new CommunityToolkit.Tooling.SampleGen.Metadata.ToolkitFrontMatter() { ComponentName = "Primitives", Title = "Canvas Layout", Author = "mhawker", Description = "A canvas-like VirtualizingLayout for use in an ItemsRepeater", Keywords = "CanvasLayout, ItemsRepeater, VirtualizingLayout, Canvas, Layout, Panel, Arrange", Category = ToolkitSampleCategory.Controls, Subcategory = ToolkitSampleSubcategory.Layout, DiscussionId = 0, IssueId = 0, Icon = @"assets/icon.png", FilePath = @"experiment\samples\documentation.md", SampleIdReferences = new string[] { "Sample" }, IsExperimental = true, CsProjName = @"componentname.csproj" };
}
}
""", "Unexpected code generated");
""", result.Compilation.GetFileContentsByName("ToolkitDocumentRegistry.g.cs"), "Unexpected code generated");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
using CommunityToolkit.Tooling.SampleGen.Diagnostics;
using CommunityToolkit.Tooling.SampleGen.Tests.Helpers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Immutable;
using System.ComponentModel.DataAnnotations;

namespace CommunityToolkit.Tooling.SampleGen.Tests;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="MSTest.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<UseVSTest>true</UseVSTest>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 8 additions & 0 deletions CommunityToolkit.Tooling.TestGen.Tests/MSTestConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.VisualStudio.TestTools.UnitTesting;

[assembly: Parallelize(Scope = ExecutionScope.MethodLevel, Workers = 0)]
[assembly: ClassCleanupExecution(ClassCleanupBehavior.EndOfClass)]
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,10 @@ from assembly in AppDomain.CurrentDomain.GetAssemblies()
driver = driver.RunGeneratorsAndUpdateCompilation(compilation, out Compilation outputCompilation, out ImmutableArray<Diagnostic> diagnostics);

HashSet<string> resultingIds = diagnostics.Select(diagnostic => diagnostic.Id).ToHashSet();
var generatedCompilationDiaghostics = outputCompilation.GetDiagnostics();
var generatedCompilationDiagnostics = outputCompilation.GetDiagnostics();

Assert.IsTrue(resultingIds.SetEquals(diagnosticsIds), $"Expected one of [{string.Join(", ", diagnosticsIds)}] diagnostic Ids. Got [{string.Join(", ", resultingIds)}]");
Assert.IsTrue(generatedCompilationDiaghostics.All(x => x.Severity != DiagnosticSeverity.Error), $"Expected no generated compilation errors. Got: \n{string.Join("\n", generatedCompilationDiaghostics.Where(x => x.Severity == DiagnosticSeverity.Error).Select(x => $"[{x.Id}: {x.GetMessage()}]"))}");
Assert.IsTrue(generatedCompilationDiagnostics.All(x => x.Severity != DiagnosticSeverity.Error), $"Expected no generated compilation errors. Got: \n{string.Join("\n", generatedCompilationDiagnostics.Where(x => x.Severity == DiagnosticSeverity.Error).Select(x => $"[{x.Id}: {x.GetMessage()}]"))}");

GC.KeepAlive(attributeType);

Expand Down
2 changes: 1 addition & 1 deletion ProjectHeads/Tests.Head.WinAppSdk.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Import Project="$(MSBuildThisFileDirectory)\Head.WinAppSdk.props"/>

<ItemGroup>
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="17.11.1">
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="17.13.0">
<ExcludeAssets>build</ExcludeAssets>
</PackageReference>
</ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions ProjectHeads/Tests.Head.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

<!-- Test Dependencies -->
<ItemGroup>
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10"/>
<PackageReference Include="MSTest.TestFramework" Version="2.2.10"/>
<PackageReference Include="MSTest" Version="3.7.3"/>

<ProjectReference Include="$(ToolingDirectory)\CommunityToolkit.Tooling.TestGen\CommunityToolkit.Tooling.TestGen.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="True" />
</ItemGroup>
Expand Down
5 changes: 3 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"version": "9.0.101",
"rollForward": "latestFeature"
},
"msbuild-sdks":
"msbuild-sdks":
{
"MSBuild.Sdk.Extras":"3.0.23"
"MSBuild.Sdk.Extras":"3.0.23",
"MSTest.Sdk": "3.7.3"
}
}
Loading