Skip to content

提供选项禁用预处理行删除缩进#8

Merged
lindexi merged 1 commit into
mainfrom
t/walterlv/remove-indent
Nov 25, 2025
Merged

提供选项禁用预处理行删除缩进#8
lindexi merged 1 commit into
mainfrom
t/walterlv/remove-indent

Conversation

@walterlv

Copy link
Copy Markdown
Member

现在,默认不会处理预编译行了

@lindexi lindexi merged commit f88d8c6 into main Nov 25, 2025
7 checks passed
@lindexi lindexi deleted the t/walterlv/remove-indent branch November 25, 2025 08:19

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 introduces an option to disable automatic indent removal for preprocessor directives in C# code generation. The default behavior has been changed from always processing preprocessor lines to requiring explicit opt-in via the new RemoveIndentForPreprocessorLines property. The preprocessor detection logic has also been enhanced to avoid false positives by checking that characters following # are valid preprocessor indicators (letters, !, or :), which handles edge cases like shebang lines and special directives.

Key changes:

  • Added RemoveIndentForPreprocessorLines property (defaults to false) to control preprocessor line processing
  • Enhanced preprocessor detection to validate characters after # symbol
  • Updated line processor assignment to be conditional based on the new property

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
SourceTextBuilder.cs Adds RemoveIndentForPreprocessorLines property with XML documentation and updates ToString() to conditionally apply the CSharp line processor
IndentedStringBuilder.cs Enhances ProcessCSharpCodeLine method with improved preprocessor detection logic and whitespace-only line handling
Comments suppressed due to low confidence (1)

src/dotnetCampus.CodeAnalysisUtils/Generators/Builders/IndentedStringBuilder.cs:439

  • 此行文本与上方列表项(第437行)中的描述重复。建议删除第439行,仅保留列表中的描述即可。
    /// 识别预处理指令行(以 # 开头的行),并确保这些行不进行缩进。

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

3 participants