Skip to content

Add tests for the .editorconfig options that were never set by a test - #1419

Merged
meziantou merged 2 commits into
mainfrom
feature/editorconfig-options-coverage-011155
Sep 6, 2026
Merged

meziantou merged 2 commits into
mainfrom
feature/editorconfig-options-coverage-011155

Conversation

@meziantou

@meziantou meziantou commented Sep 6, 2026 •

Copy link
Copy Markdown
Owner

What

Ten documented .editorconfig options were not set by any test in the test assembly. Each now has a test in both directions: the default behavior, and the behavior once the option is set to the other value.

Option Test file
MA0003.excluded_methods NamedParameterAnalyzerTests.cs
MA0011.exclude_tostring_methods UseIFormatProviderAnalyzerTests.cs
MA0045.enable_sqlite_special_cases, MA0045.enable_db_special_cases DoNotUseBlockingCallInAsyncContextAnalyzerTests.cs
MA0053.class_with_virtual_member_should_be_sealed ClassMustBeSealedAnalyzerTests.cs
MA0075.exclude_tostring_methods, MA0075.consider_nullable_types, MA0076.consider_nullable_types DoNotUseImplicitCultureSensitiveToStringAnalyzerTests.cs
MA0104.only_consider_public_symbols DotNotUseNameFromBCLAnalyzerTests.cs
MA0139.allow_non_constant_formats LoggerParameterTypeAnalyzer_SerilogTests.cs

Tests only — no analyzer or documentation changes. dotnet run --project src/DocumentationGenerator exits 0 with no markdown changes.

Why

These options are the documented escape hatch when a rule misfires. With no test setting the key, a rename, a mis-parse, or a flipped default fails silently and only surfaces in users' own repositories.

Two cases were sharper than the rest:

  • MA0053 defines a hidden legacy key with a typo (class_with_virtual_member_shoud_be_sealed) alongside the documented class_with_virtual_member_should_be_sealed. Both existing tests set only the misspelled legacy key, so the spelling users are told to write in docs/Rules/MA0053.md had no coverage at all.
  • MA0045 and MA0139 each duplicate a key owned by a sibling rule (MA0042 and MA0124). Only the sibling's copy was covered.

Notes for the reviewer

  • Where a documented key is paired with another one, the tests also pin the precedence rather than just the on/off behavior: MA0045.enable_*_special_cases overrides the MA0042 key (in both directions), and the documented MA0053 spelling overrides the hidden misspelled one.
  • MA0045.enable_db_special_cases and MA0045.enable_sqlite_special_cases default to true, so the meaningful direction — turning the DB/SQLite special-casing off — had never been taken by a test.
  • main was merged in to resolve a conflict in NamedParameterAnalyzerTests.cs, where both sides added a test at the same place around a shared body. Both are kept: this branch's two MA0003.excluded_methods tests, and Int32_ExcludedMethodWithEmptyRegex_ShouldReportDiagnostic from main.

Verification

Full suite after merging main: 19668 passed, 0 failed, 0 skipped across roslyn4.8 / 4.14 / 5.0 / 5.6 / 5.9.

Ten documented options were not exercised by any test, so a renamed key,
a mis-parsed value, or a flipped default would have gone unnoticed until
users hit it in their own repositories. Each option now has a test for
both directions: the default behavior and the behavior once the option is
set to the other value.

- MA0003.excluded_methods
- MA0011.exclude_tostring_methods
- MA0045.enable_db_special_cases
- MA0045.enable_sqlite_special_cases
- MA0053.class_with_virtual_member_should_be_sealed
- MA0075.consider_nullable_types
- MA0075.exclude_tostring_methods
- MA0076.consider_nullable_types
- MA0104.only_consider_public_symbols
- MA0139.allow_non_constant_formats

MA0045 and MA0053 pair a documented key with another one, so their tests
also pin the precedence: MA0045.enable_*_special_cases overrides the
MA0042 key, and the documented class_with_virtual_member_should_be_sealed
overrides the hidden misspelled class_with_virtual_member_shoud_be_sealed.
Both sides added a test at the same place in NamedParameterAnalyzerTests,
around a shared body. Kept both: the two MA0003.excluded_methods tests of
this branch and Int32_ExcludedMethodWithEmptyRegex_ShouldReportDiagnostic
from main.
@meziantou
meziantou merged commit c9bbcfc into main Sep 6, 2026
13 checks passed
@meziantou
meziantou deleted the feature/editorconfig-options-coverage-011155 branch September 6, 2026 05:35
This was referenced Sep 6, 2026
This was referenced Oct 1, 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