-
-
Notifications
You must be signed in to change notification settings - Fork 34
Support RootNamespaceAttribute #94
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
Conversation
hishamco
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot add two class libraries in the test named ResourcesClassLibraryNoAttribute and ResourcesClassLibraryWithAttribute, then rewrite the unit tests to examine the RootNamespaceAttribute
I've added the two test class libraries as requested:
Both libraries have:
The unit tests have been rewritten to properly examine the
All 37 unit tests pass. Commit: 222ee51 |
Co-authored-by: hishamco <[email protected]>
- Created ResourcesClassLibraryNoAttribute: test library without RootNamespaceAttribute
- Created ResourcesClassLibraryWithAttribute: test library with [assembly: RootNamespace("MyCustomNamespace")]
- Added ResourceLocationAttribute to both libraries for proper resource separation
- Rewrote unit tests to verify RootNamespaceAttribute behavior:
- CreateLocalizerWithType_WithoutRootNamespaceAttribute_UsesAssemblyName
- CreateLocalizerWithType_WithRootNamespaceAttribute_UsesRootNamespace
- CreateLocalizerWithBasenameAndLocation_WithoutRootNamespaceAttribute
- CreateLocalizerWithBasenameAndLocation_WithRootNamespaceAttribute
Co-authored-by: hishamco <[email protected]>
222ee51 to
75ad1c1
Compare
|
@copilot fix the warnings |
JsonStringLocalizerFactorywas using assembly name to calculate resource paths, which fails when root namespace differs from assembly name (configured via<RootNamespace>in csproj).Changes
GetRootNamespace()method that checks forRootNamespaceAttributeon the assembly, falling back to assembly nameCreate(Type resourceSource)to use root namespace instead of assembly name when computing type nameCreate(string baseName, string location)to use root namespace when trimming the base name prefixRootNamespaceAttributeis not present[assembly: RootNamespace("MyCustomNamespace")]where the assembly name differs from the root namespaceThis matches the behavior of
Microsoft.Extensions.Localization.ResourceManagerStringLocalizerFactory.Usage
Testing
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.