Skip to content

源生成器支持生成「表达式」代码,并正确处理相关的换行问题#6

Merged
SeWZC merged 34 commits into
mainfrom
t/walterlv/source-text-builder
Nov 14, 2025
Merged

源生成器支持生成「表达式」代码,并正确处理相关的换行问题#6
SeWZC merged 34 commits into
mainfrom
t/walterlv/source-text-builder

Conversation

@walterlv

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 UseExpressionBody flag to MethodDeclarationSourceTextBuilder to generate methods with expression body syntax
  • Introduced NullableAnnotationContext enum and property to configure nullable directives (#nullable enable/disable/warnings/annotations)
  • Refactored CodeBlockSourceTextBuilder with 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.

Comment thread src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/SourceTextBuilder.g.cs Outdated
Comment thread src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/IndentedStringBuilder.g.cs Outdated
Comment thread src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/SourceTextBuilder.g.cs Outdated
Comment thread src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/SourceTextBuilder.g.cs Outdated
Comment thread src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/SourceTextBuilder.g.cs Outdated
Comment thread src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/SourceTextBuilder.g.cs Outdated
Comment thread src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/SourceTextBuilder.g.cs Outdated
Comment thread src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/SourceTextBuilder.g.cs Outdated
Comment thread src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/SourceTextBuilder.g.cs Outdated

Copilot AI commented Nov 13, 2025

Copy link
Copy Markdown
Contributor

@walterlv I've opened a new pull request, #7, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits November 13, 2025 08:24
Co-authored-by: walterlv <9959623+walterlv@users.noreply.github.com>
Fix multi-character newline handling in IndentedStringBuilder.TrimEnd

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/SourceTextBuilder.g.cs Outdated
Comment thread src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/SourceTextBuilder.g.cs Outdated
Comment thread src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/SourceTextBuilder.g.cs Outdated
Comment thread src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/SourceTextBuilder.g.cs Outdated
Comment thread src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/SourceTextBuilder.g.cs Outdated
Comment thread src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/SourceTextBuilder.g.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/SourceTextBuilder.g.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/SourceTextBuilder.g.cs Outdated
Comment thread src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/SourceTextBuilder.g.cs Outdated
Comment thread src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/SourceTextBuilder.g.cs Outdated
Comment thread src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/SourceTextBuilder.g.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/IndentedStringBuilder.g.cs Outdated
Comment thread src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/IndentedStringBuilder.g.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@SeWZC SeWZC merged commit 6151020 into main Nov 14, 2025
3 checks passed
@SeWZC SeWZC deleted the t/walterlv/source-text-builder branch November 14, 2025 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants