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

RS0041 cannot be solved for Resources.Designer.cs #5521

Open
bitbonk opened this issue Sep 23, 2021 · 6 comments
Open

RS0041 cannot be solved for Resources.Designer.cs #5521

bitbonk opened this issue Sep 23, 2021 · 6 comments

Comments

@bitbonk
Copy link

bitbonk commented Sep 23, 2021

Analyzer

Diagnostic ID: RS0041: Symbol uses some oblivious reference types

Analyzer source

NuGet Package: Microsoft.CodeAnalysis.PublicApiAnalyzers

Version: 3.3.2 (Latest)

Problem

I get a lot of warnings similar to these on various Resources.Designer.cs files:

Warning RS0041 Symbol 'ResourceManager.get' uses some oblivious reference types

Since this is code generated by PublicResXFileCodeGenerator, I have no way of annotating those generated types. I don't want to turn off RS0041 because everything else is annotated correctly. I don't see a way how to solve this except by turning of RS0041 for the whole project.

@Youssef1313
Copy link
Member

You may want to suppress the diagnostic only for this specific generated file. In editorconfig you can do that like this:

[*.Designer.cs]
dotnet_diagnostic.RS0041.severity = none

@bitbonk
Copy link
Author

bitbonk commented Sep 23, 2021

Is there also a way make the generated code be nullable aware? I saw that Arcade has a Source Generator that probably does this. Is it available in a Nuget package?

@bitbonk
Copy link
Author

bitbonk commented Dec 1, 2021

What would be the official way to make the code generated for resx nullable aware and types in it non-oblivious reference types? This is important to us because it uses the PublicResXFileCodeGenerator which is done for two reasons:

  1. The resources should be usable directly in XAML and therefore must be public.
  2. The resources should be usable by our customers and therefore must be public. But our customers expect that they are nullable annotated.

@sharwell
Copy link
Member

sharwell commented May 4, 2023

ResxSourceGenerator produces files with #nullable enable, which should resolve this.

@bitbonk
Copy link
Author

bitbonk commented May 5, 2023

@sharwell Thanks, where do I find this ResxSourceGenerator?
#6044 seems to suggest that is not yet available in a package or SDK, is this correct?

Also, it seems that that generator cannot produce the needed public resource properties.

@sharwell
Copy link
Member

It's published here:
https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet8/NuGet/Microsoft.CodeAnalysis.ResxSourceGenerator

Also, it seems that that generator cannot produce the needed public resource properties.

Is there a bug for this?

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

3 participants