Skip to content

Detect duplicate polyglot capability IDs - #16530

Merged
Sébastien Ros (sebastienros) merged 3 commits into
microsoft:mainfrom
sebastienros:sebastienros/sebros-polyglot-collisions
Apr 28, 2026
Merged

Sébastien Ros (sebastienros) merged 3 commits into
microsoft:mainfrom
sebastienros:sebastienros/sebros-polyglot-collisions

Conversation

@sebastienros

Copy link
Copy Markdown
Contributor

Description

Polyglot capability IDs must be unique within an assembly, but the existing analyzer only caught duplicate export IDs for the same target type. This adds ASPIREEXPORT013 to detect assembly-wide generated capability ID collisions, including static exports and members exposed from [AspireExport(ExposeMethods/ExposeProperties)] context types.

The analyzer now mirrors the capability ID shapes used by the ATS scanner closely enough to catch collisions like differently targeted static exports with the same generated ID and overloaded context-type methods that produce the same capability ID. This PR intentionally does not change the Kubernetes exports themselves; that fix is handled separately.

Fixes # (issue)
N/A

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Copilot AI review requested due to automatic review settings April 28, 2026 16:25
@github-actions

github-actions Bot commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16530

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16530"

@sebastienros

Copy link
Copy Markdown
Contributor Author

This PR is supposed to fail until #16498 is merged

@sebastienros

Copy link
Copy Markdown
Contributor Author

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 extends AspireExportAnalyzer with a new warning rule (ASPIREEXPORT013) to detect assembly-wide polyglot capability ID collisions, including collisions arising from static exports and context-type exports (via ExposeMethods / ExposeProperties). This aligns analyzer behavior more closely with the runtime ATS capability scanner so collisions are caught at build time.

Changes:

  • Added ASPIREEXPORT013 diagnostic descriptor and release-tracking entry.
  • Implemented compilation-wide capability ID collection and duplicate reporting (new compilation-end pass).
  • Updated analyzer unit tests to cover duplicate capability IDs across target types, non-extension exports, and exposed context-type overloads.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
tests/Aspire.Hosting.Analyzers.Tests/AspireExportAnalyzerTests.cs Adds/updates test cases to validate ASPIREEXPORT013 warnings for several collision scenarios.
src/Aspire.Hosting.Integration.Analyzers/AspireExportAnalyzer.Diagnostics.cs Introduces ASPIREEXPORT013 descriptor and adds it to supported diagnostics.
src/Aspire.Hosting.Integration.Analyzers/AspireExportAnalyzer.cs Implements capability-ID tracking across the compilation and reports duplicates at compilation end.
src/Aspire.Hosting.Integration.Analyzers/AnalyzerReleases.Unshipped.md Documents the new analyzer rule in the unshipped release notes.

Add ASPIREEXPORT013 to flag assembly-wide polyglot capability ID collisions, including static exports and context type members exposed through AspireExport.

Co-authored-by: Copilot <[email protected]>
Handle assembly-level context exports, generic context type names, and runtime-filtered methods when tracking ASPIREEXPORT013 capability IDs.

Co-authored-by: Copilot <[email protected]>
Give Gateway and Ingress hostname and TLS exports unique capability IDs while preserving generated polyglot method names, and cover them in the polyglot apphosts.

Co-authored-by: Copilot <[email protected]>
@sebastienros
Sébastien Ros (sebastienros) merged commit 69584b8 into microsoft:main Apr 28, 2026
564 of 567 checks passed
@sebastienros
Sébastien Ros (sebastienros) deleted the sebastienros/sebros-polyglot-collisions branch April 28, 2026 20:01
@github-actions github-actions Bot added this to the 13.3 milestone Apr 28, 2026
Nell Shamrell-Harrington (nellshamrell) pushed a commit to nellshamrell/aspire that referenced this pull request May 18, 2026
* Detect duplicate polyglot capability IDs

Add ASPIREEXPORT013 to flag assembly-wide polyglot capability ID collisions, including static exports and context type members exposed through AspireExport.

Co-authored-by: Copilot <[email protected]>

* Align capability collision analyzer with scanner

Handle assembly-level context exports, generic context type names, and runtime-filtered methods when tracking ASPIREEXPORT013 capability IDs.

Co-authored-by: Copilot <[email protected]>

* Disambiguate Kubernetes gateway and ingress exports

Give Gateway and Ingress hostname and TLS exports unique capability IDs while preserving generated polyglot method names, and cover them in the polyglot apphosts.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
@github-actions github-actions Bot locked and limited conversation to collaborators May 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants