Skip to content

Add strict C# formatting rules to .editorconfig#80

Merged
LittleLittleCloud merged 4 commits intomainfrom
copilot/update-editorconfig-white-space-rule
Nov 1, 2025
Merged

Add strict C# formatting rules to .editorconfig#80
LittleLittleCloud merged 4 commits intomainfrom
copilot/update-editorconfig-white-space-rule

Conversation

Copy link
Contributor

Copilot AI commented Oct 31, 2025

  • Explore repository structure and current .editorconfig
  • Verify current build and test status (passing)
  • Research common strict whitespace/newline/brace rules for C#
  • Add comprehensive strict spacing rules to .editorconfig
  • Add comprehensive strict newline rules for control flow statements
  • Add comprehensive strict brace rules
  • Add indentation and wrapping rules
  • Apply dotnet format to fix code according to new rules
  • Verify that dotnet format passes with new rules
  • Build and test to ensure no breaking changes (all 176 tests pass)
  • Request code review (no issues found)
  • Run security check (no vulnerabilities found)
  • Re-apply formatting after merge to CanvasElementTranslator

Summary

Successfully added strict whitespace, newline, and brace rules to .editorconfig to enforce consistent C# code formatting across the RazorConsole repository.

Latest Update

After merging changes from main (SpectreCanvas component PR #78), re-ran dotnet format to apply the strict rules to the new CanvasElementTranslator.cs file:

  • Added braces to 5 single-line if/else statements per csharp_prefer_braces rule

Added Rules (30+ total)

New Line Settings (6 rules)

  • Braces for else, catch, finally clauses on new lines
  • Members in object initializers and anonymous types on new lines
  • Query expression clauses on separate lines

Spacing Settings (19 rules)

  • No space after cast
  • Space after control flow keywords
  • No spaces in parentheses or brackets
  • Spaces around binary operators
  • Space after comma and semicolon
  • And 14 more spacing rules

Indentation Settings (3 rules)

  • Braces not indented
  • Block contents indented
  • Case contents in blocks not double-indented

Brace & Wrapping Settings (3 rules)

  • Braces required for single-line statements (warning)
  • Single-line statements broken across lines
  • Single-line blocks preserved

Code Changes

Formatted 5 files total to comply with new rules:

  • Initial commit: MeasuredAlign.cs, ConsoleRenderer.cs, HtmlVdomConverter.cs, FigletElementTranslator.cs
  • After merge: CanvasElementTranslator.cs

Verification

✅ All 176 tests pass
✅ Build succeeds
dotnet format --verify-no-changes passes
✅ Code review: no issues
✅ Security scan: no vulnerabilities

Security Summary

No security vulnerabilities were found in the changes.

Original prompt

This section details on the original issue you should resolve

<issue_title>.editorconfig: More strict rule on white space / newline in brace/ etc</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>
Copilot AI changed the title [WIP] Update .editorconfig for stricter whitespace rules Add strict C# formatting rules to .editorconfig Oct 31, 2025
@LittleLittleCloud LittleLittleCloud marked this pull request as ready for review October 31, 2025 23:47
@LittleLittleCloud
Copy link
Member

@copilot rerun formatting

Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 1, 2025

@copilot rerun formatting

Formatting reapplied to CanvasElementTranslator.cs after merge. Added braces to 5 single-line if/else statements per the strict rules. (8a01d37)

@LittleLittleCloud LittleLittleCloud enabled auto-merge (squash) November 1, 2025 00:25
@LittleLittleCloud LittleLittleCloud merged commit 6267aeb into main Nov 1, 2025
5 checks passed
@LittleLittleCloud LittleLittleCloud deleted the copilot/update-editorconfig-white-space-rule branch November 1, 2025 00:27
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.

.editorconfig: More strict rule on white space / newline in brace/ etc

2 participants