Closed 2A5F closed 11 months ago
The analyzers should support localization, and we use it for this in some other repositories. Can you post a sample project where you encountered this problem? I found that a reference to Microsoft.CodeAnalysis.Analyzers was causing a conflict in one case, but updating it to use the same version as Microsoft.CodeAnalysis.ResxSourceGenerator fixed it: https://github.com/DotNetAnalyzers/StyleCopAnalyzers/commit/271f1d485634951ea3adf60adebbc9f01fe55182
In the sample repository, Microsoft.CodeAnalysis.Analyzers uses version 3.3.4 while Microsoft.CodeAnalysis.ResxSourceGenerator uses 3.11.0-beta1.23525.2. This normally would not be a problem, but there is a bug in Microsoft.CodeAnalysis.Analyzers 3.3.4 that causes it to overwrite the build logic that makes ResxSourceGenerator properly handle culture-specific resources.
Updating Microsoft.CodeAnalysis.Analyzers to 3.11.0-beta1.23525.2 will resolve the problem.
I think I am seeing a similar problem in https://github.com/JustArchiNET/ArchiSteamFarm project
I tried the following:
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0-beta1.24324.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.ResxSourceGenerator" Version="3.11.0-beta1.24324.1" />
and it still generates class no-NO
and class zh-Hant-HK
, producing spammy errors:
Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator\Strings.Designer.cs(9,33,9,40): error CS0101: The namespace 'ArchiSteamFarm.Localization' already contains a definition for 'Strings'
Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator\Strings.no-NO.Designer.cs(11,66,11,83): error CS0116: A namespace cannot directly contain members such as fields, methods or statements
Weirldy it only fails to compile in Visual Studio (version 17.11.2). dotnet build
works fine.
@sharwell can this issue be reopened?
Analyzer source
NuGet Package: Microsoft.CodeAnalysis.ResxSourceGenerator
Version: 3.11.0-beta1.23525.2 (Latest)
Describe the bug