Skip to content

Add MA0206 for unnecessary braces in type declarations#1191

Merged
meziantou merged 2 commits into
mainfrom
add-ma0206-unnecessary-braces-rule
Jun 20, 2026
Merged

Add MA0206 for unnecessary braces in type declarations#1191
meziantou merged 2 commits into
mainfrom
add-ma0206-unnecessary-braces-rule

Conversation

@meziantou

Copy link
Copy Markdown
Owner

Summary

  • Add MA0206 to flag empty braces on positional records and C# 12 primary-constructor type declarations when the body is empty.
  • Add a code fix that converts the braces to a semicolon while preserving trivia.
  • Update rule docs, analyzer pack defaults, and rule identifiers.
  • Add tests covering compliant and non-compliant cases, including the code fix.

Testing

  • Added unit tests for records, classes, and structs with primary constructors.
  • Document generation and build/test validation were expected as part of the change set; not run in this context.

…y-braces-rule

# Conflicts:
#	README.md
#	docs/README.md
#	src/Meziantou.Analyzer.Pack/configuration/all-errors.editorconfig
#	src/Meziantou.Analyzer.Pack/configuration/all-suggestions.editorconfig
#	src/Meziantou.Analyzer.Pack/configuration/all-warnings.editorconfig
#	src/Meziantou.Analyzer.Pack/configuration/default.editorconfig
#	src/Meziantou.Analyzer.Pack/configuration/none.editorconfig
#	src/Meziantou.Analyzer/RuleIdentifiers.cs
@meziantou meziantou marked this pull request as ready for review June 20, 2026 19:37
@meziantou meziantou merged commit 9c23a3b into main Jun 20, 2026
13 checks passed
@meziantou meziantou deleted the add-ma0206-unnecessary-braces-rule branch June 20, 2026 19:37
This was referenced Jun 20, 2026
IhateTrains pushed a commit to ParadoxGameConverters/ImperatorToCK3 that referenced this pull request Jun 22, 2026
Updated
[Meziantou.Analyzer](https://github.com/meziantou/Meziantou.Analyzer)
from 3.0.104 to 3.0.108.

<details>
<summary>Release notes</summary>

_Sourced from [Meziantou.Analyzer's
releases](https://github.com/meziantou/Meziantou.Analyzer/releases)._

## 3.0.108

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.108>

## What's Changed
* Add MA0206 for unnecessary braces in type declarations by @​meziantou
in meziantou/Meziantou.Analyzer#1191


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.107...3.0.108

## 3.0.107

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.107>

## What's Changed
* Add MA0205 rule to suggest using the XOR operator by @​meziantou in
meziantou/Meziantou.Analyzer#1192


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.106...3.0.107

## 3.0.106

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.106>

## What's Changed
* Add MA0204 to remove unnecessary partial modifiers by @​meziantou in
meziantou/Meziantou.Analyzer#1190


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.105...3.0.106

## 3.0.105

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.105>

## What's Changed
* Add MA0203 to flag `<returns>` tags on `void` methods by @​meziantou
in meziantou/Meziantou.Analyzer#1189


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.104...3.0.105

Commits viewable in [compare
view](meziantou/Meziantou.Analyzer@3.0.104...3.0.108).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=Meziantou.Analyzer&package-manager=nuget&previous-version=3.0.104&new-version=3.0.108)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This was referenced Jun 22, 2026
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.

1 participant