Skip to content

Canonical .editorconfig Leaves IDE Style Rules at Hidden, So the Style Gate Checks Almost Nothing #1842

Done

Description

@ptr727

Observed

The canonical root .editorconfig sets every C# code-style option with no :severity suffix and no dotnet_diagnostic.IDExxxx.severity entry, for example csharp_style_var_* = false, csharp_style_namespace_declarations = file_scoped, and the csharp_style_expression_bodied_* options. With nothing raising them, Roslyn reports these IDE rules at their default hidden severity. The fleet clean-compile gate, dotnet format style --verify-no-changes --severity=info, run by the .NET Format task, the Husky hook, and CI, only reports info and above, so it never sees them.

Reproduction

Take a .NET 10 project under the hub's .editorconfig (hub main 92737d1), with AnalysisLevel latest-all. Add a probe file that uses var, a block-scoped namespace, a block-bodied single-expression method, an unused using, and a this. qualifier, then run dotnet format style --verify-no-changes --severity=info.

  • Hub canonical: reports only IDE0130 and IDE0036, and IDE0036 only because csharp_preferred_modifier_order carries an explicit :warning.
  • Same file with dotnet_analyzer_diagnostic.severity = suggestion added under [*.cs]: also reports IDE0003, IDE0005, IDE0008, IDE0022, and IDE0161.

Why it matters

The dotnet-codestyle rules the options encode (no var, file-scoped namespaces, expression bodies) go unenforced wherever the canonical file is carried, and a repo converging onto it silently loses enforcement it had. This surfaced in the MediaTools resync (ptr727/MediaTools#27), whose previous .editorconfig carried the global suggestion line. dotnet-codestyle forbids that line as a blanket relaxation, since it also lowers CA rules from warning to suggestion, so a carrier has no conformant way to restore enforcement locally.

Expected

The canonical file should make the rules it configures visible to the gate, for example with a :suggestion (or stronger) suffix on each style option, or dotnet_diagnostic.IDExxxx.severity entries, without the CA-lowering global line.

🤖 Generated with Claude Code

Activity

  1. ptr727 commented on Nov 1, 2026

    @ptr727
    OwnerAuthor

    Decision needed (decision triage, 2026-11-01)

    Question: Should the canonical root .editorconfig raise the IDE code-style rules it configures (no var, file-scoped namespace, expression bodies, and so on) from hidden so the dotnet format style --severity=info gate sees them, accepting that carrying repos start failing it, or stay as it is?

    Options, recommended first:

    1. A dotnet_diagnostic.IDExxxx.severity = suggestion per rule (recommended): Raises only the rules the file's options configure, so the gate enforces what the file already says, in the per-rule form dotnet-codestyle prescribes. IDE0055 stays none (CSharpier owns formatting), CA severities untouched. Each csharp repo gets failures at its next .editorconfig resync, mostly fixable with dotnet format style. No work in flight.
    2. A :suggestion suffix on each style option: Same coverage, one key per option, but a second severity form beside the documented dotnet_diagnostic one. No work in flight.
    3. Set dotnet_analyzer_diagnostic.category-Style.severity: One line, but switches on every IDE rule the file never configures at defaults nobody chose, close to the blanket line the skill warns against. No work in flight.
    4. Leave the file as it is: No repo fails, but the file's own rules stay unenforced and a resync keeps removing enforcement a repo had (ptr727/MediaTools#27). No work in flight.

    Evidence: .editorconfig [*.cs] from :47: only dotnet_diagnostic.IDE0055.severity = none (:51) and csharp_preferred_modifier_order ...:warning (:71) carry a severity; csharp_style_namespace_declarations (:113) and csharp_style_var_* (:136-138) carry none. dotnet-codestyle SKILL.md:145-150 names dotnet_diagnostic.<RULE>.severity and forbids relaxing with dotnet_analyzer_diagnostic.severity. Nothing sets EnforceCodeStyleInBuild, so a suggestion reaches the format gate, not the build. spec/files.json:22 carries .editorconfig whole to every repo, and 7 registry repos are typed csharp.

    Blocks: none

  2. added
    decision
    on Nov 1, 2026
  3. ptr727 commented on Nov 1, 2026

    @ptr727
    OwnerAuthor

    Maintainer answer (decision triage, 2026-11-01): Option 1: add a dotnet_diagnostic.IDExxxx.severity = suggestion entry for each code-style rule the canonical .editorconfig configures. IDE0055 stays none, and CA severities are untouched. Carrying C# repos fix the new findings at their next resync. This is now work for the next burndown round.

  4. removed
    decision
    on Nov 1, 2026
  5. ptr727 commented on Nov 23, 2026

    @ptr727
    OwnerAuthor

    Backlog burndown claim (round 5, 2026-11-23): branch burndown/editorconfig-ide-severity.

    Predicted files: .editorconfig, .agents/skills/dotnet-codestyle/SKILL.md, .agents/skills/dotnet-codestyle/references/testing.md, .agents/skills/dotnet-codestyle/references/conventions.md (the last three added 2026-11-24 per the maintainer's answer), and their build_dist outputs.

    Group issues: #1842.

  6. ptr727 commented on Nov 24, 2026

    @ptr727
    OwnerAuthor

    Question for the maintainer (backlog burndown round 5, 2026-11-24). The group working this issue stopped before its first push. Branch burndown/editorconfig-ide-severity holds one local commit, which adds 91 dotnet_diagnostic.IDExxxx.severity = suggestion entries taken from the .NET 10.0.404 SDK's own option-to-rule map. A constructed probe shows the gate now reports IDE0003, IDE0008, IDE0022, IDE0025, IDE0032 and IDE0161, which it previously missed.

    Two rules the decision covers conflict with the dotnet-codestyle skill:

    • IDE0058 (an ignored return value) fails builder.Append(part); and the skill's own test example actual.Should().Be(expected);. Its fix rewrites every such call to _ = ... across the C# repos that carry the file.
    • IDE0046 turns a guard clause just before the final return into a ternary. That contradicts the skill's "Guard clauses: prefer early returns".

    A third rule, IDE0079 (unnecessary suppression), does nothing at the gate, and in the IDE it may offer to remove third-party suppressions.

    Options, recommended first:

    1. Leave out IDE0058, IDE0046 and IDE0079, and ship the rest (recommended). The PR body names each and says why. Their fixes would rewrite fleet code against rules the skill already sets.
    2. Leave out IDE0058 and IDE0046, and keep IDE0079.
    3. Keep all three, as the decision literally says. The skill's test example and guard-clause rule then change too, in a separate change.
  7. ptr727 commented on Nov 24, 2026

    @ptr727
    OwnerAuthor

    Maintainer's answer, 2026-11-24: use the strictest, most correct defaults, even where existing code has to be fixed. Keep every rule, IDE0058, IDE0046 and IDE0079 included, at warning severity rather than suggestion. Update the dotnet-codestyle skill to match: the guard-clause rule, and the _ = form in its test example. Carrying C# repositories fix their code at resync.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions