Commit 662b655
Apply dotnet format and harden autogenerated exclusion (#2927)
* Apply dotnet format and harden autogenerated exclusion
Two related changes:
1. src/.editorconfig: Set generated_code = true on the [/**/Autogenerated/**]
section. This is the canonical Roslyn signal so analyzers and dotnet format
skip these files entirely; without it, the existing six 'unset' overrides
only suppress the base settings (charset, EOL, indent) and the C# style
rules still cascade in from [*.cs]. With it, dotnet format leaves all 79
files under src/Sarif/Autogenerated/ and src/Sarif/VersionOne/Autogenerated/
untouched.
2. Repository-wide dotnet format pass against src/Sarif.Sdk.sln, applied
under the unmodified existing .editorconfig style rules. 18 hand-written
files changed. The bulk (647 of 656 whitespace-mode lines) is three files
whose class members had a real 4-space indentation bug inside an 8-space
class scope: Sarif/Visitors/InsertOptionalDataVisitor.cs,
Sarif/Writers/ConsoleLogger.cs, Sarif/EnumeratedArtifact.cs. The
remaining 15 files are small style-rule fixes the existing .editorconfig
already enforces at error/warning severity (csharp_style_var_*,
csharp_prefer_braces, dropping redundant 'public' from interface members,
removing a single trailing blank line in a test file). No public API
changes.
Build clean (0 warnings, 0 errors). All tests pass (1679 passed, 5 skipped).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* CI: modernize check-format job to built-in dotnet format
Replaces the legacy standalone dotnet-format 5.x tool in the check-format
job of .github/workflows/validate.yml with the SDK built-in dotnet format
(added in .NET 6). The two formatters disagree on some C# 12+ constructs,
which caused CI failures that didn't reproduce locally because contributors
use the modern formatter while CI used the legacy one. This closes that gap.
* actions/checkout: v2 -> v4.
* Adds actions/setup-dotnet@v4 with dotnet-version 8.0.x to pin the
formatter version.
* Replaces dotnet-format --folder --check --exclude .\src\Sarif\Autogenerated\
with dotnet format whitespace src\Sarif.Sdk.sln --verify-no-changes
--exclude src/Sarif/Autogenerated/.
The --exclude argument is now belt-and-braces redundant with
generated_code = true in src/.editorconfig (added in the prior commit on
this branch), but keeping it makes the autogen exclusion explicit at the
CI call site for readers of validate.yml.
Subsumes PR #2925.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Small tweaks to remove empty statements
* Fix CI: unused using and trailing whitespace
- SarifEventLogWriterReaderTests.cs: drop unused System.Collections.Generic (became unused when style pass changed List<SarifEvent> to var).
- AggregatingLogger.cs: strip trailing whitespace after 'using (logger as IDisposable)'.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Emit precise drift diagnostic when CweSample fixture mismatches
On hash mismatch the test now prints: total sizes, CRLF/LF-only counts on each side, first divergent byte offset with a hex+ASCII window of context (32B before / 32B after), and the first 5 diverging line pairs after UTF-8 decode. Designed to surface cross-platform fixture drift causes (line endings, Unicode escapes, property-order swaps) directly in the xUnit log so we do not have to spin up a Linux repro to find them.
ComputeSha256 now takes byte[] (we already have the bytes in memory) instead of re-reading the file.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* CweGenerateSample.ps1: switch JSON-bearing hashtables to [ordered]
Bare PowerShell @{} is a .NET Hashtable whose key enumeration order varies across process startups (per-process hash seed). When ConvertTo-Json serialized those hashtables, the resulting JSON property order changed between platforms / runs, which broke the CweGeneratedSampleTests determinism gate on macOS and Ubuntu (the fixture in main was originally generated on Windows where Hashtable happened to enumerate in insertion order).
[ordered]@{} (an OrderedDictionary) preserves insertion order on all platforms, so the script now produces byte-identical CweSample.sarif everywhere. The internal $events array hashtables are NOT serialized to JSON, so they're left as bare @{}; the [pscustomobject]@{} usages in the post-finalize patch block already preserve order natively.
Diagnosed in PR #2926; the script-level fix lands here in PR #2927 so the CweGeneratedSampleTests gate goes green on Linux/macOS without waiting on #2926's validation-rule changes.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 5c692b2 commit 662b655
22 files changed
Lines changed: 859 additions & 696 deletions
File tree
- .github/workflows
- src
- Sarif.Converters
- Sarif.Driver/Sdk
- Sarif.Multitool.Library
- Rules
- Sarif.WorkItems
- Sarif
- Taxonomies
- Visitors
- Writers
- Test.FunctionalTests.Sarif
- Test.UnitTests.Sarif.Multitool.Library/Rules
- Test.UnitTests.Sarif
- Emit
- Readers
- Taxonomies
- Writers
- WorkItems
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | | - | |
53 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
54 | 56 | | |
55 | | - | |
56 | | - | |
| 57 | + | |
| 58 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
| 8 | + | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1546 | 1546 | | |
1547 | 1547 | | |
1548 | 1548 | | |
1549 | | - | |
| 1549 | + | |
| 1550 | + | |
1550 | 1551 | | |
1551 | 1552 | | |
1552 | 1553 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
0 commit comments