Skip to content

feat(TW0007): analyzer for namespace-first file-level usings - #38

Merged
StevenTCramer merged 4 commits into
masterfrom
task/028-tw0007-file-level-usings-must-move-to-kebab-global
Sep 20, 2026
Merged

StevenTCramer merged 4 commits into
masterfrom
task/028-tw0007-file-level-usings-must-move-to-kebab-global

Conversation

@StevenTCramer

Copy link
Copy Markdown
Contributor

Summary

Shipped TW0007 (GlobalUsingsRuleAnalyzer) in TimeWarp.SourceGenerators 1.0.0-beta.11. DiagnosticAnalyzer visits every UsingDirectiveSyntax (compilation unit, file-scoped namespace-first, and block namespace). Skips global using, using static, aliases, generated/build-output paths, the configured global-usings file, and excluded_files. Default filename is kebab global-usings.cs. isEnabledByDefault: false; default severity warning when enabled. No BDSoftware / GlobalUsingsAnalyzer package. Code-fix left out of scope.

Files changed

Path Change
source/timewarp-source-generators/global-usings-rule-analyzer.cs New TW0007 analyzer
source/timewarp-source-generators/AnalyzerReleases.Unshipped.md TW0007 unshipped row
source/Directory.Build.props Version 1.0.0-beta.11
.editorconfig TW0007 keys; removed leftover globalusingsanalyzer000*
tests/timewarp-source-generators-analyzer-tests/** 11 CompilationWithAnalyzers cases
tests/timewarp-source-generators-test-console/** global-usings.cs; TW0007=error smoke
tools/dev-cli/endpoints/test-command.cs Runs analyzer-tests after test-console
readme.md, documentation/** TW0007 docs + how-to
source/timewarp-source-generators/interface-delegation-generator.cs Dropped redundant file-level using

Key decisions

  • DiagnosticAnalyzer, not incremental generator, so FileScopedNamespaceDeclarationSyntax.Usings are not missed.
  • Stay disabled-by-default so existing consumers do not go red on bump.
  • Test-console enables TW0007 as error after moving its file-level using into global-usings.cs.
  • No code-fix (brief: out of scope unless cheap).

Test outcomes

dotnet run --file tools/dev-cli/dev.cs -- test — PASS (test-console + 11/11 TW0007 cases). No BDSoftware package refs.

Test plan

Automated

dotnet run --file tools/dev-cli/dev.cs -- test

Expect: test-console prints kebab/multi-dot/Pascal messages; analyzer-tests prints Passed: 11 Failed: 0 Total: 11; Tests completed successfully!

Smoke

dotnet run --project tests/timewarp-source-generators-analyzer-tests/timewarp-source-generators-analyzer-tests.csproj -c Release

Expect: PASS lines for namespace-first warn, usings-before-namespace warn, and no-warn for global using / using static / alias / global-usings.cs; PascalCase filename configurable.

dotnet pack source/timewarp-source-generators/timewarp-source-generators.csproj -c Release
ls artifacts/packages/TimeWarp.SourceGenerators.1.0.0-beta.11.nupkg

Expect: pack id TimeWarp.SourceGenerators version 1.0.0-beta.11. rg -i 'BDSoftware|GlobalUsingsAnalyzer' Directory.Packages.props is empty.

Not in scope: Ganda 284 audit rewrite; TimeWarp.State using sweep; code-fix.

Kanban task 028
Session: Grok ganda

StevenTCramer and others added 4 commits September 20, 2026 17:21
Replace BDSoftware GlobalUsingsAnalyzer; visit usings after file-scoped
namespace. Default filename kebab global-usings.cs.

Co-Authored-By: grok <noreply@x.ai>
BDSoftware GlobalUsingsAnalyzer only walks compilation-unit usings, so
TimeWarp namespace-first file-scoped files never fire. Ship our own
opt-in TW0007 with kebab global-usings.cs default.

Co-Authored-By: grok <noreply@x.ai>
Keep the implementation-review trail on this host task: effort 1
found no issues, so Results can record a clean disposition.

Co-Authored-By: grok <noreply@x.ai>
@StevenTCramer StevenTCramer changed the title docs(kanban): brief 028 TW0007 namespace-first global usings feat(TW0007): analyzer for namespace-first file-level usings Sep 20, 2026
@StevenTCramer
StevenTCramer merged commit e018595 into master Sep 20, 2026
1 check passed
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