Adjust for culture name normalization in AssemblyNameInfoFuzzer#114231
Merged
jkotas merged 4 commits intodotnet:mainfrom Apr 5, 2025
Merged
Adjust for culture name normalization in AssemblyNameInfoFuzzer#114231jkotas merged 4 commits intodotnet:mainfrom
jkotas merged 4 commits intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adjusts tests to account for the culture name normalization behavior when converting AssemblyNameInfo to AssemblyName.
- Added a new test in AssemblyNameInfoTests.cs to verify that the CultureInfo constructor lower-cases the culture name.
- Updated the fuzzer in AssemblyNameInfoFuzzer.cs to conditionally verify the lower-cased culture name.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/libraries/System.Reflection.Metadata/tests/Metadata/AssemblyNameInfoTests.cs | Added a test validating the normalization of the culture name when converting to AssemblyName. |
| src/libraries/Fuzzing/DotnetFuzzing/Fuzzers/AssemblyNameInfoFuzzer.cs | Modified assertions to verify culture name normalization based on whether the culture name is null or not. |
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-reflection-metadata |
jkotas
approved these changes
Apr 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The fuzzer has discovered something that I was not aware of when authoring the fuzz tests.
When
AssemblyNameInfo.ToAssemblyNamesets theAssemblyName.CultureInfo:runtime/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/AssemblyNameInfo.cs
Line 160 in 778427c
A
CultureInfois being allocated:runtime/src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs
Lines 82 to 85 in 778427c
Which calls
CultureData.GetCultureDatawith the provided name and consumes the returned result:runtime/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureInfo.cs
Lines 167 to 169 in 778427c
Which internally performs
ToLoweron the provided name, just to be able to cache it:runtime/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs
Line 683 in 778427c
and later normalizes the name also by lowering it:
runtime/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs
Lines 741 to 746 in 778427c