源生成器支持生成「表达式」代码,并正确处理相关的换行问题#6
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for expression-bodied members (using => syntax) in the source code generator, with proper handling of newline formatting for expression contexts. It also introduces configurable nullable annotation contexts.
Key Changes:
- Added
UseExpressionBodyflag toMethodDeclarationSourceTextBuilderto generate methods with expression body syntax - Introduced
NullableAnnotationContextenum and property to configure nullable directives (#nullable enable/disable/warnings/annotations) - Refactored
CodeBlockSourceTextBuilderwith new properties (IsExpression,IsPartExpression,IsBracketBlock) to handle complex expression formatting scenarios
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 12 comments.
| File | Description |
|---|---|
| SourceTextBuilder.g.cs | Renamed IAllowStatements to IAllowStatement; added nullable context configuration; implemented expression-bodied member support with proper newline handling; refactored code block builder with expression-aware formatting |
| SourceTextBuilder.Builder.g.cs | Updated extension class and interface names; added new extension methods for statements and expression bodies; added overload for creating expression-bodied method declarations |
| IndentedStringBuilder.g.cs | Enhanced TrimEnd() method to handle line buffer and preserve last line content without indentation; updated ToString() to include pending line buffer content |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: walterlv <9959623+walterlv@users.noreply.github.com>
Fix multi-character newline handling in IndentedStringBuilder.TrimEnd
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 9 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.