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

Microsoft.CodeAnalysis.ResxSourceGenerator does not support i18n #7041

Open
2A5F opened this issue Nov 19, 2023 · 10 comments
Open

Microsoft.CodeAnalysis.ResxSourceGenerator does not support i18n #7041

2A5F opened this issue Nov 19, 2023 · 10 comments

Comments

@2A5F
Copy link

2A5F commented Nov 19, 2023

Analyzer source

NuGet Package: Microsoft.CodeAnalysis.ResxSourceGenerator

Version: 3.11.0-beta1.23525.2 (Latest)

Describe the bug

image
image

@sharwell
Copy link
Member

sharwell commented Dec 19, 2023

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:
DotNetAnalyzers/StyleCopAnalyzers@271f1d4

@2A5F
Copy link
Author

2A5F commented Dec 20, 2023

@sharwell
Copy link
Member

sharwell commented Dec 20, 2023

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.

@xPaw
Copy link

xPaw commented Aug 19, 2024

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.

@xPaw
Copy link

xPaw commented Sep 2, 2024

@sharwell can this issue be reopened?

@DevSplash
Copy link

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.

It also happens in version 17.12.3.

@xPaw
Copy link

xPaw commented Jan 6, 2025

@DevSplash want to open a new issue since this one wasn't reopened?

@2A5F 2A5F reopened this Jan 6, 2025
@DevSplash
Copy link

#7523

@chr233
Copy link

chr233 commented Jan 28, 2025

#7523

这个问题居然这么久了吗

@DevSplash
Copy link

#7523

这个问题居然这么久了吗

似乎是在.net9版本之后出现的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants