Repository navigation
Lower-case generated constructor parameter names with the invariant culture - #1032
Merged
DocSvartz merged 1 commit intoNov 18, 2026
Conversation
…ulture ExpressionTranslator derived a constructor parameter name from the property name with char.ToLower, which uses the current culture. On a machine with the Turkish or Azerbaijani culture a property "Id" produced the parameter "ıd" (dotless i), so code generated by Mapster.Tool depended on the build machine. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
@menes97 Thanks! |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
ExpressionTranslatorwrites a constructor for read-only properties (and the positional parameters of a record) and names each parameterchar.ToLower(parameter.Name[0]) + parameter.Name.Substring(1).char.ToLoweruses the current culture, and in the Turkish and Azerbaijani cultures'I'lower-cases to'ı'(dotless i). So on such a machine a propertyIdgivesIt still compiles, but the generated API (parameter names, named arguments) depends on the culture of the machine that runs Mapster.Tool. Both places now use
char.ToLowerInvariant; output for other cultures is unchanged.Test:
DebugInfoInjectorTest.TestConstructorParameterNamesDoNotDependOnCurrentCulturegenerates a class with a read-onlyIdundertr-TR(restoring the culture afterwards) and checks forpublic MockClass(int id)andthis.Id = id;. It fails without the change (it producedint ıd).ExpressionDebugger.Tests: 40 passed on net6.0, net7.0 and net48 (run withDOTNET_ROLL_FORWARD=Majoron .NET 8+ here).The change and test were written with Claude Code (AI assistance); I reviewed and ran them.
🤖 Generated with Claude Code