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

Add ClassName property to ResxSourceGenerator #7226

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

raulsntos
Copy link
Contributor

Allows specifying the fully-qualified class name for the class that will be generated by ResxSourceGenerator.

System.Private.CoreLib specifies the class name System.SR for a resource in Resources\Strings.resx:

https://github.com/dotnet/runtime/blob/8ac30d41d0be7a6de919d765e0143af865371cd4/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj#L32-L37

This allows doing the same with the source generator, the property uses the same name (ClassName):

<EmbeddedResource Update="Resources\Strings.resx">
    <ClassName>System.SR</ClassName>
</EmbeddedResource>

The code for generating with a custom class name already existed, I only exposed it with the ClassName property.

@raulsntos raulsntos requested a review from a team as a code owner March 6, 2024 05:28
@raulsntos
Copy link
Contributor Author

@microsoft-github-policy-service agree

Copy link

codecov bot commented Mar 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.47%. Comparing base (4af0601) to head (7aba2ca).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7226   +/-   ##
=======================================
  Coverage   96.47%   96.47%           
=======================================
  Files        1432     1432           
  Lines      342185   342235   +50     
  Branches    11280    11280           
=======================================
+ Hits       330107   330187   +80     
+ Misses       9227     9199   -28     
+ Partials     2851     2849    -2     

internal static partial class NS2
{
private static global::System.Resources.ResourceManager? s_resourceManager;
public static global::System.Resources.ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new global::System.Resources.ResourceManager(typeof(TestProject.Resources)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Is this correct? Just want to make sure.

Copy link
Contributor Author

@raulsntos raulsntos Mar 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a comment that explains why this empty type is created:

// resource name differs from the access class, need a type for specifying the resources
// this empty type must remain as it is required by the .NETNative toolchain for locating resources
// once assemblies have been merged into the application

I'm not sure why we can't use the other type though (NS1.NS2 in this case).

Copy link
Member

@sharwell sharwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why I omitted this during the initial implementation. 😆

@raulsntos
Copy link
Contributor Author

Is there something else I need to do on my end?

@sharwell
Copy link
Member

I'm not sure why the system hasn't registered your CLA acceptance. Can you try submitting another PR with something small like a test documentation change to see if it works there?

@raulsntos raulsntos mentioned this pull request Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants