Skip to content

[DRK-73] test(efcore-extensions): Tier-2 arch rule — no System.Console in library code - #323

Merged
baoduy merged 1 commit into
devfrom
arch/dknet-a73-console-enforcement
Aug 5, 2026
Merged

[DRK-73] test(efcore-extensions): Tier-2 arch rule — no System.Console in library code#323
baoduy merged 1 commit into
devfrom
arch/dknet-a73-console-enforcement

Conversation

@baoduy

@baoduy baoduy commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Part of the monthly architecture review DRK-73.

What

Adds a Tier-2 baseline NetArchTest rule to EfCore.Extensions.Tests asserting that no type in the DKNet.EfCore.Extensions assembly depends on System.Console.

  • ProductionTypes_ExceptKnownOffenders_MustNotDependOnSystemConsole — the rule. Passes today because the single known offender (EfCoreExceptionHandler, EfCoreExceptionHandler.cs:61) is on a KnownViolations allow-list. It fails the moment any new Console.* usage appears in the assembly.
  • Rule_CanDetectConsoleUsage_OnTheKnownOffender — a self-check asserting the rule still detects the known offender, so the rule can never silently go blind.

Why

A library primitive that writes to Console bypasses the host's logging configuration entirely — it cannot be filtered, redirected, redacted, or suppressed — and pollutes stdout in production. Diagnostics must go through an injected ILogger. The allow-list must only shrink: when EfCoreExceptionHandler is migrated to ILogger, delete its entry so the rule covers the whole assembly.

Scope

  • Test-only / config-only. No production code is modified.
  • EfCore.Extensions.Tests.csproj: adds the centrally-managed NetArchTest.Rules package reference.
  • New file: Architecture/ConsoleUsageArchitectureTests.cs.

Verification

dotnet test EfCore.Extensions.Tests --filter FullyQualifiedName~ConsoleUsageArchitectureTests
Passed! - Failed: 0, Passed: 2

Full-solution dotnet build DKNet.FW.sln -c Debug is green (0 errors).

🤖 Generated with Claude Code

…Console in library code

Library code must emit diagnostics through an injected ILogger, never
System.Console, so hosts can filter/redirect/redact/suppress them. Adds a
NetArchTest rule over the DKNet.EfCore.Extensions assembly with a KnownViolations
allow-list containing exactly today's single offender (EfCoreExceptionHandler,
EfCoreExceptionHandler.cs:61). The rule fails on any NEW Console usage; the
allow-list must only shrink. A companion self-check asserts the rule can still
detect the known offender, so it can never silently go blind.

Test-only, no production code touched. Part of monthly architecture review DRK-73.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednetarchtest.rules@​1.3.210010090100100

View full report

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

📊 Code Coverage Report

| Metric | Coverage |
|--------|----------|
| **Line Coverage** | 88.6% |
| **Branch Coverage** | 81.1% |
| **Method Coverage** | 86.7% |

**Lines:** 3343/undefined covered
**Branches:** 1255/undefined covered

📈 [View Full Coverage Report](https://github.com/baoduy/DKNet/actions/runs/30881950280)

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.93%. Comparing base (4be0be6) to head (709fcc2).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #323      +/-   ##
==========================================
+ Coverage   84.88%   84.93%   +0.05%     
==========================================
  Files         159      159              
  Lines        3771     3771              
  Branches      591      591              
==========================================
+ Hits         3201     3203       +2     
+ Misses        389      388       -1     
+ Partials      181      180       -1     
Flag Coverage Δ
unittests 84.93% <ø> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@baoduy
baoduy merged commit d17936b into dev Aug 5, 2026
6 checks passed
@baoduy
baoduy deleted the arch/dknet-a73-console-enforcement branch August 5, 2026 05:31
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