-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Harden handling for generic type arguments in source generator #61145
base: main
Are you sure you want to change the base?
Conversation
...upportsXmlCommentsOnOperationsFromMinimalApis#OpenApiXmlCommentSupport.generated.verified.cs
Outdated
Show resolved
Hide resolved
27568b2
to
afede74
Compare
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/CompletenessTests.cs
Show resolved
Hide resolved
3f2b6b3
to
a49c0b8
Compare
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/CompletenessTests.cs
Show resolved
Hide resolved
@BrennanConroy @martincostello I talked with both of you online about the notion of switching to a string-based key and what the key would be. Turns out that I dusted off an old idea around reusing the DocumentationIds that exist in the XML doc comment to support this. We know emit a helper method that emits a documentation ID from Worst case scenario: the failure mode here is a lot nicer since we won't emit any compiler errors for invalid keys. In the event that happens, the implementation will no-op and fail to apply a doc comment but it shouldn't impact users builds. |
if (!omitGenericArity) | ||
{ | ||
int arity = genericDef.GetGenericArguments().Length; | ||
defName += "`" + arity; |
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.
I would err on the side of caution here and format the arity explicitly with CultureInfo.InvariantCulture
so that users on systems configured for non-English won't potentially get incorrect number formatting (e.g. scenario of 1000
becoming 1,000
or 1.000
). Might be some other occurrences of this elsewhere too.
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.
Closes #61035.