Skip to content

Commit

Permalink
fixup! Update tests and breaking change documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sharwell committed Jan 19, 2024
1 parent 3a21023 commit b869ea5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
16 changes: 9 additions & 7 deletions docs/compilers/CSharp/Compiler Breaking Changes - DotNet 9.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

## .editorconfig values no longer support trailing comments

***Introduced in Visual Studio 2022 version [TBD]***
***Introduced in Visual Studio 2022 version 17.[TBD]***

The compiler is updated based on the EditorConfig specification clarification in
[editorconfig/specification#31](https://github.com/editorconfig/specification/pull/31). This changes the way values are
passed to analyzers for lines with the following form:
[editorconfig/specification#31](https://github.com/editorconfig/specification/pull/31). Following this change, comments
in **.editorconfig** and **.globalconfig** files must now appear on their own line. Comments which appear at the end of
a property value are now treated as part of the property value itself. This changes the way values are passed to
analyzers for lines with the following form:

```ini
[*.cs]
Expand All @@ -16,7 +18,7 @@ key2 = value2 ; text2

The following table shows how this change affects values passed to analyzers:

| EditorConfig line | New compiler interpretation | Old interpretation |
| ----------------- | --------------------------- | ------------------ |
| `key = value # text` | `value # text` | `value` |
| `key2 = value2 ; text2` | `value2 ; text2` | `value2` |
| EditorConfig line | New compiler interpretation | Old interpretation |
| ----------------------- | --------------------------- | ------------------ |
| `key = value # text` | `value # text` | `value` |
| `key2 = value2 ; text2` | `value2 ; text2` | `value2` |
Original file line number Diff line number Diff line change
Expand Up @@ -1003,12 +1003,13 @@ public void EditorConfigToDiagnosticsIgnoresCommentLikeText(string delimiter)
configs.Add(Parse($@"
[*.cs]
dotnet_diagnostic.cs000.severity = error {delimiter} ignored text
dotnet_diagnostic.cs001.severity = warning {delimiter} ignored text
", "/.editorconfig"));

var options = GetAnalyzerConfigOptions(["/test.cs"], configs);
configs.Free();

Assert.Equal([CreateImmutableDictionary(("cs000", ReportDiagnostic.Error))], Array.ConvertAll(options, o => o.TreeOptions));
Assert.Equal([CreateImmutableDictionary(("cs000", ReportDiagnostic.Error), ("cs001", ReportDiagnostic.Warn))], Array.ConvertAll(options, o => o.TreeOptions));
}

[Fact]
Expand Down

0 comments on commit b869ea5

Please sign in to comment.