Repository navigation
Strip trivia from enclosing type parameter lists in Options validation generator - #136881
Closed
Manish-1kumar wants to merge 2 commits into
Closed
Manish-1kumar wants to merge 2 commits into
Manish-1kumar wants to merge 2 commits into
Conversation
…n generator When an enclosing generic type declaration contains conditional compilation directives across its generic parameter list, stringifying parent.TypeParameterList captures internal preprocessor directives without capturing matching closing directives outside the span. This emitted unmatched preprocessor directives into Validators.g.cs, causing error CS1027. Format type parameter lists cleanly by joining variance keywords and identifiers without trivia. Fixes dotnet#133455
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/area-extensions-options |
This was referenced Nov 3, 2026
…on generator Restore parent.ConstraintClauses and spacing in Parser.cs so generic constraints on enclosing classes are retained in generated code and trailing whitespace matches generator expectations.
Contributor
Author
Member
|
@Manish-1kumar Thanks for understanding that we didn't take this PR. For future reference, if an issue has an assignee, it's best to ask before working on it (even if it looks like it hasn't been touched in months). |
Contributor
Author
|
Thanks @svick, understood. I'll check for assignees and ask on the issue first from now on. |
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.
Fixes #133455
Description
When an enclosing generic type declaration contains conditional compilation directives crossing its generic parameter list:
csharp public partial class OptionsOuterTypeParameters< #if TRIVIA_BRANCH T> #else T> #endif { [OptionsValidator] public sealed partial class Validator : IValidateOptions<OptionsOuterTypeParametersModel> { } }parent.TypeParameterList.ToString() captured the opening #if TRIVIA_BRANCH while dropping the matching #endif that lay outside the <...> syntax span. This emitted unmatched preprocessor directives into Validators.g.cs, causing compiler error CS1027: #endif directive expected.
Changes