Skip to content

Remove (non-functional) outer class support entirely - #326

Merged
viceroypenguin merged 2 commits into
mainfrom
outer-classes
Jul 28, 2026
Merged

Remove (non-functional) outer class support entirely#326
viceroypenguin merged 2 commits into
mainfrom
outer-classes

Conversation

@viceroypenguin

@viceroypenguin viceroypenguin commented Jul 28, 2026

Copy link
Copy Markdown
Member

Fixes #322

Summary by CodeRabbit

  • New Features

    • Added validation to prevent route groups from being nested inside non-route-group classes.
    • Added diagnostic IAPI0014 with an error severity for invalid nesting.
  • Bug Fixes

    • Corrected generated route-group filenames by removing an extra period.
    • Simplified generated route-group code for nested class scenarios.
  • Tests

    • Added coverage for valid and invalid route-group nesting.
    • Updated generator snapshots to reflect corrected filenames.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds analyzer rule IAPI0014 to reject route groups nested inside non-route-group types. The generator removes outer-class wrapper handling and emits simplified generated filenames, with analyzer and generator tests updated accordingly.

Changes

Route group nesting

Layer / File(s) Summary
Nested route group analyzer
src/Immediate.Apis.Analyzers/..., tests/Immediate.Apis.Tests/AnalyzerTests/...
Adds and registers diagnostic IAPI0014, reports invalid nested route groups, records the shipped rule, and tests nested and non-nested scenarios.
Route group generator output
src/Immediate.Apis.Generators/..., tests/Immediate.Apis.Tests/GeneratorTests/...
Removes outer-class data and template wrappers, simplifies generated source filenames, and updates generator expectations and snapshots.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RoslynCompiler
  participant RouteGroupClassAnalyzer
  participant Diagnostic
  RoslynCompiler->>RouteGroupClassAnalyzer: Analyze named type symbol
  RouteGroupClassAnalyzer->>RouteGroupClassAnalyzer: Check route-group attribute and containing type
  RouteGroupClassAnalyzer->>Diagnostic: Report IAPI0014 at nested type
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: removing outer class support from route-group generation.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch outer-classes

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/Immediate.Apis.Tests/AnalyzerTests/RouteGroupClassAnalyzerTests.cs (1)

26-44: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Align the test name with the case it covers.

Inner is nested inside Outer, so this verifies that route groups may nest inside other route groups—not a non-nested route group. Rename the test accordingly and add a separate top-level case if you intend to cover the ContainingType is null path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/Immediate.Apis.Tests/AnalyzerTests/RouteGroupClassAnalyzerTests.cs`
around lines 26 - 44, Rename NonNestedRouteGroupShouldNotError to reflect that
it verifies nested route groups are accepted. Add a separate analyzer test with
a top-level route group if coverage of the ContainingType-null path is required.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Immediate.Apis.Analyzers/AnalyzerReleases.Shipped.md`:
- Around line 52-55: Insert a blank line between the “### New Rules” heading and
the rules table in AnalyzerReleases.Shipped.md so the markdown satisfies MD058.
Keep the table contents unchanged.

In `@src/Immediate.Apis.Generators/ImmediateApisGenerator.Render.cs`:
- Around line 81-82: Update the source filename construction in the generator
method containing context.AddSource so a null or absent
group.Definition.Namespace omits the namespace separator, producing IA.Root.g.cs
for global-namespace route groups while preserving the existing
namespace-qualified naming.

---

Nitpick comments:
In `@tests/Immediate.Apis.Tests/AnalyzerTests/RouteGroupClassAnalyzerTests.cs`:
- Around line 26-44: Rename NonNestedRouteGroupShouldNotError to reflect that it
verifies nested route groups are accepted. Add a separate analyzer test with a
top-level route group if coverage of the ContainingType-null path is required.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9f572d62-1364-4947-8dc5-f8bf02472ff9

📥 Commits

Reviewing files that changed from the base of the PR and between 63afbf5 and 2f68c6b.

📒 Files selected for processing (11)
  • src/Immediate.Apis.Analyzers/AnalyzerReleases.Shipped.md
  • src/Immediate.Apis.Analyzers/DiagnosticIds.cs
  • src/Immediate.Apis.Analyzers/RouteGroupClassAnalyzer.cs
  • src/Immediate.Apis.Generators/ImmediateApisGenerator.Models.cs
  • src/Immediate.Apis.Generators/ImmediateApisGenerator.Render.cs
  • src/Immediate.Apis.Generators/ImmediateApisGenerator.Transform.cs
  • src/Immediate.Apis.Generators/Templates/RouteGroup.sbntxt
  • tests/Immediate.Apis.Tests/AnalyzerTests/RouteGroupClassAnalyzerTests.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/RouteGroupTests.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/RouteGroupTests.SimpleRouteGroupTest#IA.Dummy.Root.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/RouteGroupTests.TaggedRouteGroupTest_framework=net10.0#IA.Dummy.Root.g.verified.cs
💤 Files with no reviewable changes (3)
  • src/Immediate.Apis.Generators/ImmediateApisGenerator.Models.cs
  • src/Immediate.Apis.Generators/ImmediateApisGenerator.Transform.cs
  • src/Immediate.Apis.Generators/Templates/RouteGroup.sbntxt

Comment thread src/Immediate.Apis.Analyzers/AnalyzerReleases.Shipped.md
Comment thread src/Immediate.Apis.Generators/ImmediateApisGenerator.Render.cs
@viceroypenguin

Copy link
Copy Markdown
Member Author

@coderabbitai pause

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews paused.

@viceroypenguin
viceroypenguin merged commit a9f60cd into main Jul 28, 2026
3 checks passed
@viceroypenguin
viceroypenguin deleted the outer-classes branch July 28, 2026 16:00
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.

[RouteGroup] nested in a plain outer class is silently dropped, producing an unreachable endpoint

1 participant