Repository navigation
Conversation
Enable EnableNETAnalyzers with AnalysisLevel latest and AnalysisMode Recommended for the projects in src (all built with TreatWarningsAsErrors), and tune .editorconfig severities so the build stays warning-free: public API rules that would require breaking changes are disabled, and the remaining code quality rules are reported as suggestions for now.
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
| Layer / File(s) | Summary |
|---|---|
Enable analyzers and set rule severities .editorconfig, src/NLog/NLog.csproj, src/NLog.OutputDebugString/NLog.OutputDebugString.csproj, src/NLog.RegEx/NLog.RegEx.csproj, src/NLog.Targets.AtomicFile/NLog.Targets.AtomicFile.csproj, src/NLog.Targets.GZipFile/NLog.Targets.GZipFile.csproj, src/NLog.WindowsEventLog/NLog.WindowsEventLog.csproj |
The six projects enable .NET analyzers with the latest analysis level and Recommended mode. .editorconfig assigns severities to selected analyzer rules. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Merge Risk: 
Minimal · previous review 5aada
-
No actionable merge-blocking risk remains in the reviewed analyzer configuration changes.
Pre-merge checks: 
5
-
Full details: Linked Issues check
-
Explanation
Issue
#5916requests enabling .NET analyzers withEnableNETAnalyzers=true,AnalysisLevel=latest, andAnalysisMode=recommended, and permits.editorconfigseverity adjustments. The reviewedsrc/NLog/NLog.csprojandsrc/NLog.RegEx/NLog.RegEx.csprojcontain these settings. The PR summary reports the same changes in all sixsrc/projects..editorconfigincludes the four example rule severities from the issue. The author reports successful Release builds for all six projects.
Full details: Out of Scope Changes check
-
Explanation
The reported changes are limited to analyzer settings in the six
src/projects and.editorconfig. The additional severity settings tune analyzer diagnostics for public APIs, target-framework compatibility, and code quality. They support enabling Recommended analysis underTreatWarningsAsErrors. No unrelated changes appear in the supplied PR summary.
Full details: Docstring Coverage
-
Explanation
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (7 skipped: 7 unsupported.)
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit checks the rules today,
New analyzer settings join the way.
Six projects heed the latest guide,
While severity notes stand beside.
I twitch my nose and hop along,
The config changes make my song.
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
55619a31-c8ba-40b2-8f63-3d3a0c545009
📒 Files selected for processing: 7
-
.editorconfig
src/NLog.OutputDebugString/NLog.OutputDebugString.csproj
src/NLog.RegEx/NLog.RegEx.csproj
src/NLog.Targets.AtomicFile/NLog.Targets.AtomicFile.csproj
src/NLog.Targets.GZipFile/NLog.Targets.GZipFile.csproj
src/NLog.WindowsEventLog/NLog.WindowsEventLog.csproj
src/NLog/NLog.csproj
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
55619a31-c8ba-40b2-8f63-3d3a0c545009
📒 Files selected for processing: 7
-
.editorconfigsrc/NLog.OutputDebugString/NLog.OutputDebugString.csprojsrc/NLog.RegEx/NLog.RegEx.csprojsrc/NLog.Targets.AtomicFile/NLog.Targets.AtomicFile.csprojsrc/NLog.Targets.GZipFile/NLog.Targets.GZipFile.csprojsrc/NLog.WindowsEventLog/NLog.WindowsEventLog.csprojsrc/NLog/NLog.csproj
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
-
|
|
My goal for #5916 is to incrementally fix all relevant issues, and then at the very end put the shackles on (enable the validation by default with minimal suppression) |
|
FYI we renamed dev to main. So if you need to merge with upstream, use main :) The PR has been retargeted to main |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6313 +/- ##
==========================================
- Coverage 73.62% 73.60% -0.02%
==========================================
Files 341 341
Lines 20795 20795
Branches 5282 5282
==========================================
- Hits 15310 15306 -4
- Misses 3829 3831 +2
- Partials 1656 1658 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
FYI the CI has been updated (see #6328) and I added a merge commit to this branch. Also good to know, we gonna move to SonarCloud automatic analysis, and then the Roslyn warnings are not visible in SonarCloud anymore. A possible solution is sending it to GitHub Code Quality, see NLog/NLog.Extensions.Logging#896 |



Requested by winshyon
Description
Enables the built-in .NET code analyzers for the projects in
src/, as proposed in the issue:The properties are added next to
TreatWarningsAsErrorsin all sixsrcprojects (NLog, NLog.OutputDebugString, NLog.RegEx, NLog.Targets.AtomicFile, NLog.Targets.GZipFile, NLog.WindowsEventLog). Since these projects build withTreatWarningsAsErrors, turning the analyzers on without tuning breaks the build (464 errors forsrc/NLogacross its target frameworks)..editorconfigtherefore gets:none, e.g. 46 hits for identifiers likeError/Event/Default) and CA1067, CA1068, CA1725 (suggestion). Fixing them would mean breaking or behavior-relevant API changes.No source code is changed, so the PR only affects build diagnostics. Each
.editorconfigline carries the rule title as a comment, so it's easy to raise individual rules back towarningonce they are fixed. The test projects are not included because they don't build withTreatWarningsAsErrors, and the Recommended mode reports roughly 1000 extra warnings there (mostly CA1707, CA1305, CA2201). I'm happy to add them in a follow-up if you want.Motivation / disclosure: I had some spare AI-assistant quota (Claude Code) and am using it to try to help projects with open good-first-issues. The change was prepared with Claude Code and verified as listed below. If it doesn't fit, isn't up to your bar, or you'd simply rather not take it — please feel free to close it, no hard feelings at all 🙂
Related issue
Closes #5916
Checklist
.editorconfigtuning:dotnet build src/NLog/NLog.csproj -c Releasefails with 464 errors; the other fivesrcprojects fail as well (they build NLog first, and NLog.RegEx / NLog.Targets.AtomicFile additionally hit CA2263 / CA2101).dotnet build src/<project>/<project>.csproj -c Release --no-incrementalsucceeds for all sixsrcprojects with 0 errors and no CA/IDE warnings. The only warning left is NETSDK1210, which also appears ondev. The same holds forsrc/NLogwith/p:targetFrameworks="net46;net45;net35;netstandard2.0;netstandard2.1"as inbuild.ps1.dotnet test ./tests/NLog.UnitTests/ --framework net10.0 --configuration release: Passed 2970, Skipped 8, Failed 0CheckSourceCode, net462/net35 test runs,build.ps1pack).CHANGELOG.mdis updated (if applicable) — n/a (release notes are maintained by the maintainers)🤖 Generated with Claude Code