Skip to content

Add namespace to MapXxxEndpoints - #327

Merged
viceroypenguin merged 2 commits into
mainfrom
namespace
Jul 31, 2026
Merged

Add namespace to MapXxxEndpoints#327
viceroypenguin merged 2 commits into
mainfrom
namespace

Conversation

@viceroypenguin

@viceroypenguin viceroypenguin commented Jul 31, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Generated API endpoints and service extensions now use the project’s configured root namespace automatically.
    • Generated code is placed in the appropriate namespace, improving integration with existing application code.
  • Bug Fixes

    • Prevented generated types from unintentionally appearing in the global namespace.
  • Tests

    • Updated generator validation across supported framework versions to verify namespace-aware output.

@viceroypenguin
viceroypenguin requested a review from Copilot July 31, 2026 18:16
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9db73c85-4797-46b0-b232-e6bdd8f82fdc

📥 Commits

Reviewing files that changed from the base of the PR and between dffb149 and 929a7ca.

📒 Files selected for processing (27)
  • src/Immediate.Apis.Generators/ImmediateApisGenerator.Render.cs
  • src/Immediate.Apis.Generators/ImmediateApisGenerator.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/GeneratorTestHelper.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/MapEndpointsTests.ValidAddServicesMethod_framework=net10.0#IA.MapEndpoints.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/MapEndpointsTests.ValidAddServicesMethod_framework=net10.0#IH.ServiceCollectionExtensions.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/MapEndpointsTests.ValidAddServicesMethod_framework=net11.0#IA.MapEndpoints.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/MapEndpointsTests.ValidAddServicesMethod_framework=net11.0#IH.ServiceCollectionExtensions.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/MapEndpointsTests.ValidAddServicesMethod_framework=net8.0#IA.MapEndpoints.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/MapEndpointsTests.ValidAddServicesMethod_framework=net8.0#IH.ServiceCollectionExtensions.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/MapEndpointsTests.ValidAddServicesMethod_framework=net9.0#IA.MapEndpoints.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/MapEndpointsTests.ValidAddServicesMethod_framework=net9.0#IH.ServiceCollectionExtensions.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/RouteGroupTests.TaggedRouteGroupTest_framework=net10.0#IA.MapEndpoints.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/RouteGroupTests.TaggedRouteGroupTest_framework=net10.0#IH.ServiceCollectionExtensions.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/RouteGroupTests.TaggedRouteGroupTest_framework=net11.0#IA.MapEndpoints.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/RouteGroupTests.TaggedRouteGroupTest_framework=net11.0#IH.ServiceCollectionExtensions.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/RouteGroupTests.TaggedRouteGroupTest_framework=net8.0#IA.MapEndpoints.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/RouteGroupTests.TaggedRouteGroupTest_framework=net8.0#IH.ServiceCollectionExtensions.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/RouteGroupTests.TaggedRouteGroupTest_framework=net9.0#IA.MapEndpoints.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/RouteGroupTests.TaggedRouteGroupTest_framework=net9.0#IH.ServiceCollectionExtensions.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/SimpleApiTests.MapMethodTagsTest_framework=net10.0#IA.MapEndpoints.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/SimpleApiTests.MapMethodTagsTest_framework=net10.0#IH.ServiceCollectionExtensions.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/SimpleApiTests.MapMethodTagsTest_framework=net11.0#IA.MapEndpoints.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/SimpleApiTests.MapMethodTagsTest_framework=net11.0#IH.ServiceCollectionExtensions.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/SimpleApiTests.MapMethodTagsTest_framework=net8.0#IA.MapEndpoints.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/SimpleApiTests.MapMethodTagsTest_framework=net8.0#IH.ServiceCollectionExtensions.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/SimpleApiTests.MapMethodTagsTest_framework=net9.0#IA.MapEndpoints.g.verified.cs
  • tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/SimpleApiTests.MapMethodTagsTest_framework=net9.0#IH.ServiceCollectionExtensions.g.verified.cs

📝 Walkthrough

Walkthrough

The generator now reads build_property.rootnamespace, combines it with assembly defaults, and passes it to map-endpoint rendering. Generator tests provide the analyzer configuration, track the new incremental step, and update snapshots with the generated namespace.

Changes

Root Namespace Generation

Layer / File(s) Summary
Namespace input and rendering
src/Immediate.Apis.Generators/ImmediateApisGenerator.cs, src/Immediate.Apis.Generators/ImmediateApisGenerator.Render.cs
The generator reads rootnamespace, combines it with assembly defaults, and passes the resulting namespace to the endpoint-map template.
Generator test support and snapshots
tests/Immediate.Apis.Tests/GeneratorTests/GeneratorTestHelper.cs, tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/*
The test helper supplies and tracks the root namespace configuration. Generated snapshots now declare Immediate.Apis.Testing.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: copilot

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding a namespace to generated MapXxxEndpoints code.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch namespace

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

Copilot AI 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.

Pull request overview

This PR updates the Immediate.Apis source generator so the generated MapXxxEndpoints extension class can be emitted into a configured root namespace (instead of the global namespace), and aligns the generator tests/snapshots accordingly.

Changes:

  • Read build_property.rootnamespace from AnalyzerConfigOptionsProvider.GlobalOptions and pass it into the MapEndpoints template as Namespace.
  • Update generator test harness to provide a root namespace via an AnalyzerConfigOptionsProvider, and track the new incremental step (RootNamespace).
  • Refresh verified generator snapshots (net8/net9/net10/net11) to include the new generated namespace Immediate.Apis.Testing; header.

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/SimpleApiTests.MapMethodTagsTest_framework=net9.0#IH.ServiceCollectionExtensions.g.verified.cs Snapshot updated to include generated namespace header.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/SimpleApiTests.MapMethodTagsTest_framework=net9.0#IA.MapEndpoints.g.verified.cs Snapshot updated to include generated namespace header for MapEndpoints output.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/SimpleApiTests.MapMethodTagsTest_framework=net8.0#IH.ServiceCollectionExtensions.g.verified.cs Snapshot updated to include generated namespace header.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/SimpleApiTests.MapMethodTagsTest_framework=net8.0#IA.MapEndpoints.g.verified.cs Snapshot updated to include generated namespace header for MapEndpoints output.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/SimpleApiTests.MapMethodTagsTest_framework=net11.0#IH.ServiceCollectionExtensions.g.verified.cs Snapshot updated to include generated namespace header.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/SimpleApiTests.MapMethodTagsTest_framework=net11.0#IA.MapEndpoints.g.verified.cs Snapshot updated to include generated namespace header for MapEndpoints output.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/SimpleApiTests.MapMethodTagsTest_framework=net10.0#IH.ServiceCollectionExtensions.g.verified.cs Snapshot updated to include generated namespace header.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/SimpleApiTests.MapMethodTagsTest_framework=net10.0#IA.MapEndpoints.g.verified.cs Snapshot updated to include generated namespace header for MapEndpoints output.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/RouteGroupTests.TaggedRouteGroupTest_framework=net9.0#IH.ServiceCollectionExtensions.g.verified.cs Snapshot updated to include generated namespace header.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/RouteGroupTests.TaggedRouteGroupTest_framework=net9.0#IA.MapEndpoints.g.verified.cs Snapshot updated to include generated namespace header for MapEndpoints output.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/RouteGroupTests.TaggedRouteGroupTest_framework=net8.0#IH.ServiceCollectionExtensions.g.verified.cs Snapshot updated to include generated namespace header.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/RouteGroupTests.TaggedRouteGroupTest_framework=net8.0#IA.MapEndpoints.g.verified.cs Snapshot updated to include generated namespace header for MapEndpoints output.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/RouteGroupTests.TaggedRouteGroupTest_framework=net11.0#IH.ServiceCollectionExtensions.g.verified.cs Snapshot updated to include generated namespace header.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/RouteGroupTests.TaggedRouteGroupTest_framework=net11.0#IA.MapEndpoints.g.verified.cs Snapshot updated to include generated namespace header for MapEndpoints output.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/RouteGroupTests.TaggedRouteGroupTest_framework=net10.0#IH.ServiceCollectionExtensions.g.verified.cs Snapshot updated to include generated namespace header.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/RouteGroupTests.TaggedRouteGroupTest_framework=net10.0#IA.MapEndpoints.g.verified.cs Snapshot updated to include generated namespace header for MapEndpoints output.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/MapEndpointsTests.ValidAddServicesMethod_framework=net9.0#IH.ServiceCollectionExtensions.g.verified.cs Snapshot updated to include generated namespace header.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/MapEndpointsTests.ValidAddServicesMethod_framework=net9.0#IA.MapEndpoints.g.verified.cs Snapshot updated to include generated namespace header for MapEndpoints output.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/MapEndpointsTests.ValidAddServicesMethod_framework=net8.0#IH.ServiceCollectionExtensions.g.verified.cs Snapshot updated to include generated namespace header.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/MapEndpointsTests.ValidAddServicesMethod_framework=net8.0#IA.MapEndpoints.g.verified.cs Snapshot updated to include generated namespace header for MapEndpoints output.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/MapEndpointsTests.ValidAddServicesMethod_framework=net11.0#IH.ServiceCollectionExtensions.g.verified.cs Snapshot updated to include generated namespace header.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/MapEndpointsTests.ValidAddServicesMethod_framework=net11.0#IA.MapEndpoints.g.verified.cs Snapshot updated to include generated namespace header for MapEndpoints output.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/MapEndpointsTests.ValidAddServicesMethod_framework=net10.0#IH.ServiceCollectionExtensions.g.verified.cs Snapshot updated to include generated namespace header.
tests/Immediate.Apis.Tests/GeneratorTests/Snapshots/MapEndpointsTests.ValidAddServicesMethod_framework=net10.0#IA.MapEndpoints.g.verified.cs Snapshot updated to include generated namespace header for MapEndpoints output.
tests/Immediate.Apis.Tests/GeneratorTests/GeneratorTestHelper.cs Test harness now provides RootNamespace via analyzer config options and tracks the new step.
src/Immediate.Apis.Generators/ImmediateApisGenerator.Render.cs MapEndpoints rendering now receives a namespace and forwards it into the template model.
src/Immediate.Apis.Generators/ImmediateApisGenerator.cs Generator now reads build_property.rootnamespace and combines it into the MapEndpoints pipeline.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 30654525199

Coverage increased (+0.02%) to 96.348%

Details

  • Coverage increased (+0.02%) from the base build.
  • Patch coverage: 11 of 11 lines across 2 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 1506
Covered Lines: 1451
Line Coverage: 96.35%
Coverage Strength: 3.85 hits per line

💛 - Coveralls

@viceroypenguin
viceroypenguin merged commit a5e0904 into main Jul 31, 2026
4 checks passed
@viceroypenguin
viceroypenguin deleted the namespace branch July 31, 2026 18:30
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.

3 participants