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

Fix analyzer messages not localized #4434

Merged
merged 5 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion eng/verify-nupkgs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function Confirm-NugetPackages {
"MSTest.TestFramework" = 148;
"MSTest.TestAdapter" = 74;
"MSTest" = 6;
"MSTest.Analyzers" = 10;
"MSTest.Analyzers" = 50;
}

$packageDirectory = Resolve-Path "$PSScriptRoot/../artifacts/packages/$configuration"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@

<Target Name="_AddAnalyzersToOutput">
<ItemGroup>
<!-- Analyzer works for both C# and VB.NET -->
<TfmSpecificPackageFile Include="$(OutputPath)\MSTest.Analyzers.dll" PackagePath="analyzers/dotnet" />
<!-- This code fix is C# specific -->
<TfmSpecificPackageFile Include="$(OutputPath)\MSTest.Analyzers.dll" PackagePath="analyzers/dotnet/cs" />
<TfmSpecificPackageFile Include="$(OutputPath)\MSTest.Analyzers.CodeFixes.dll" PackagePath="analyzers/dotnet/cs" />
<TfmSpecificPackageFile Include="$(OutputPath)\**\MSTest.Analyzers.resources.dll" PackagePath="analyzers/dotnet/cs/" />
<TfmSpecificPackageFile Include="$(OutputPath)\**\MSTest.Analyzers.CodeFixes.resources.dll" PackagePath="analyzers/dotnet/cs/" />

<!-- NOTE: Currently, code fixes are C# only. -->
<TfmSpecificPackageFile Include="$(OutputPath)\MSTest.Analyzers.dll" PackagePath="analyzers/dotnet/vb" />
<TfmSpecificPackageFile Include="$(OutputPath)\**\MSTest.Analyzers.resources.dll" PackagePath="analyzers/dotnet/vb/" />
</ItemGroup>
</Target>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.Testing.Platform.Acceptance.IntegrationTests;
using Microsoft.Testing.Platform.Acceptance.IntegrationTests.Helpers;

namespace MSTest.Acceptance.IntegrationTests;

[TestClass]
public sealed class AnalyzersTests : AcceptanceTestBase<AnalyzersTests.TestAssetFixture>
{
[TestMethod]
public async Task AnalyzerMessagesShouldBeLocalized()
{
var testHost = TestHost.LocateFrom(AssetFixture.ProjectPath, TestAssetFixture.ProjectName, TargetFrameworks.NetCurrent);
TestHostResult testHostResult = await testHost.ExecuteAsync(environmentVariables: new()
{
// This is fr-FR
["VSLang"] = "1036",
});

testHostResult.AssertOutputContains("DataRow ne doit être défini que sur une méthode de test");
}

public sealed class TestAssetFixture() : TestAssetFixtureBase(AcceptanceFixture.NuGetGlobalPackagesFolder)
Youssef1313 marked this conversation as resolved.
Show resolved Hide resolved
{
public const string ProjectName = "Analyzers";

public string ProjectPath => GetAssetPath(ProjectName);

public override IEnumerable<(string ID, string Name, string Code)> GetAssetsToGenerate()
{
yield return (ProjectName, ProjectName,
SourceCode
.PatchTargetFrameworks(TargetFrameworks.NetCurrent)
.PatchCodeWithReplace("$MSTestVersion$", MSTestVersion));
}

private const string SourceCode = """
#file Analyzers.csproj
<Project Sdk="MSTest.Sdk/$MSTestVersion$">

<PropertyGroup>
<TargetFrameworks>$TargetFrameworks$</TargetFrameworks>
</PropertyGroup>

</Project>

#file UnitTest1.cs
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
public class UnitTest1
{
[DataRow(0)]
public void TestMethod()
{
}
}
""";
}
}
Loading