Fix static analysis errors in Example6-ReducingDuplicateCode (Net8.0)#66
Merged
Chris-Wolfgang merged 6 commits intoMar 10, 2026
Merged
Conversation
Co-authored-by: Chris-Wolfgang <210299580+Chris-Wolfgang@users.noreply.github.com>
Co-authored-by: Chris-Wolfgang <210299580+Chris-Wolfgang@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix static analysis errors for PR checks in Example6-ReducingDuplicateCode
Fix static analysis errors in Example6-ReducingDuplicateCode (Net8.0)
Mar 9, 2026
Chris-Wolfgang
approved these changes
Mar 9, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR resolves 47+ static analyzer violations in examples/Net8.0/Example6-ReducingDuplicateCode/ that cause CI failures when TreatWarningsAsErrors=true is active in Release builds. The changes address SonarSource (S3236), Meziantou (MA0003, MA0040, MA0048), and Microsoft (CA2007, CA2016) analyzer rules across the example project.
Changes:
- Removed redundant
nameof()arguments fromArgumentNullException.ThrowIfNull(), named literal arguments, and added.ConfigureAwait(false)to all awaited expressions across ETL classes andProgram.cs - Extracted
EtlProgressrecord andConsoleColorsclass fromProgram.csinto their own files to satisfy MA0048 - Added
CancellationTokenforwarding to allTask.Delaycalls and added.nuget/nuget.exeto.gitignore
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
examples/.../Program.cs |
Added .ConfigureAwait(false) to all awaited calls; removed EtlProgress and ConsoleColors inline definitions |
examples/.../EtlProgress.cs |
New file containing the extracted EtlProgress record (MA0048) |
examples/.../ConsoleColors.cs |
New file containing the extracted ConsoleColors class (MA0048) |
examples/.../ETL/ConsoleLoader.cs |
Removed nameof() from ThrowIfNull, named null literal, added state: null, .ConfigureAwait(false), forwarded token to Task.Delay |
examples/.../ETL/IntToStringTransformer.cs |
Same analyzer fixes as ConsoleLoader.cs; forwarded token to Task.Delay |
examples/.../ETL/FibonacciExtractor.cs |
Same analyzer fixes; forwarded token to Task.Delay, named null arguments |
.gitignore |
Added .nuget/nuget.exe entry |
…tractor.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…Transformer.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves 47+ analyzer violations (SonarSource S3236, Meziantou MA0003/MA0040/MA0048, Microsoft CA2007/CA2016) in
examples/Net8.0/Example6-ReducingDuplicateCode/that cause CI to fail in Release builds (TreatWarningsAsErrors=true).Changes
S3236 — Removed redundant
nameof()second argument from allArgumentNullException.ThrowIfNull()calls inConsoleLoader.cs,IntToStringTransformer.cs,FibonacciExtractor.csMA0003 — Named
nullliteral arguments at call sites for readabilityCA2016 / MA0040 — Forwarded
CancellationTokento allTask.Delay()callsCA2007 — Added
.ConfigureAwait(false)to all awaited expressions (await using var timer,await Task.Delay(), and allawaitcalls inProgram.cs)MA0048 — Extracted
EtlProgressandConsoleColorsfromProgram.csinto their own files (EtlProgress.cs,ConsoleColors.cs)Type of change
How Has This Been Tested?
dotnet buildofExample6-ReducingDuplicateCodereports 0 warnings, 0 errors in Debug configuration (confirming all flagged rules are resolved)Checklist
Screenshots (if applicable)
Additional context
Only
examples/Net8.0/Example6-ReducingDuplicateCode/is modified. The Net4.8 counterpart uses legacy null-check patterns and is not subject to these rules.Original prompt
This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.