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

Allow specifying access modifier for ResxSourceGenerator generated code #7367

Closed
jeremy-visionaid opened this issue Aug 2, 2024 · 7 comments

Comments

@jeremy-visionaid
Copy link

I'd like to add Microsoft.CodeAnalysis.ResxSourceGenerator to an existing project, but the project is currently using PublicResXFileCodeGenerator, and ResxSourceGenerator appears to be hard-coded to use "internal". Would be great to add a configuration option to specify the desired access modifier.

@jeremy-visionaid
Copy link
Author

Ah, my bad. I missed a duplicate issue (#6827) had been marked as closed.

So, it can be enabled with Public="true", but the Format* methods from EmitFormatMethods="true" are declared internal due to #6579

@alexspirou
Copy link

@jeremy-visionaid hello. I don't get how can I get an autogenerated file as public. Can you please help me?

@jeremy-visionaid
Copy link
Author

@alexspirou Take a look at Andrew Arnott's article here:
https://blog.nerdbank.net/2023/04/get-rid-of-your-designer-cs-code-behind-for-resx
It references the code so you can find the configuration parameters yourself. Just put them on the EmbeddedResource element like so:

<ItemGroup>
    <EmbeddedResource Update="*.resx" GenerateSource="false" />
    <EmbeddedResource Update="Properties/Resources.resx" GenerateSource="true" Public="true" />
</ItemGroup>

@alexspirou
Copy link

alexspirou commented Aug 7, 2024

@jeremy-visionaid Thanks a lot.

One more question. Do you know if there is a way to not generated the file as a static class?

@jeremy-visionaid
Copy link
Author

@alexspirou I don't believe so, but I provided everything you should need to check for yourself.

@jeremy-visionaid
Copy link
Author

@alexspirou Though I thought that sounded familiar: #7332

@alexspirou
Copy link

@alexspirou Take a look at Andrew Arnott's article here: https://blog.nerdbank.net/2023/04/get-rid-of-your-designer-cs-code-behind-for-resx It references the code so you can find the configuration parameters yourself. Just put them on the EmbeddedResource element like so:

<ItemGroup>
    <EmbeddedResource Update="*.resx" GenerateSource="false" />
    <EmbeddedResource Update="Properties/Resources.resx" GenerateSource="true" Public="true" />
</ItemGroup>

<ItemGroup> <EmbeddedResource Update="*.resx" GenerateSource="false" /> <EmbeddedResource Update="Resources\ClientPrivateLocalization.resx" GenerateSource="true" Public="true" /> </ItemGroup>

Here is my setup. Still the file is generated as internal.

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

No branches or pull requests

2 participants