Skip to content

Remove InternalsVisibleTo from Aspire.Hosting to Aspire.Hosting.Radius - #20143

Merged
Eric Erhardt (eerhardt) merged 2 commits into
mainfrom
eerhardt-ivt-analysis
Sep 15, 2026
Merged

Eric Erhardt (eerhardt) merged 2 commits into
mainfrom
eerhardt-ivt-analysis

Conversation

@eerhardt

Copy link
Copy Markdown
Member

Description

Aspire.Hosting hands out InternalsVisibleTo to Aspire.Hosting.Radius, which means the entire internal surface of the core hosting assembly is reachable from that integration. Every IVT grant like this makes the internal surface harder to refactor, because a change to any internal member can break a downstream package that was never meant to depend on it.

This removes that grant. It turns out Radius wasn't consuming Aspire.Hosting internals at all in any meaningful sense — it only needed two helpers that live in src/Shared/:

  • EnvironmentVariableNameEncoder (src/Shared/EnvironmentVariableNameEncoder.cs)
  • KnownRelationshipTypes (src/Shared/Model/KnownRelationshipTypes.cs)

These are plain internal source files that get link-compiled into whichever assembly needs them. They are not Aspire.Hosting API. So instead of granting IVT over all of Aspire.Hosting to reach them, Aspire.Hosting.Radius now link-compiles the two files directly, exactly like Aspire.Hosting.DevTunnels already does — and DevTunnels needs no IVT as a result.

Aspire.Hosting.Radius now builds against the public Aspire.Hosting surface only, joining Aspire.Hosting.Java and Aspire.Hosting.Rust, which document that same property in their csproj files.

Stale justification removed

The grant carried this comment:

Radius reads internal members that have no public equivalent, such as
ProjectLaunchDefaultsAnnotation.DefaultHttpsEndpoint, when projecting project
resources into the Bicep it emits.

That is no longer accurate. ProjectLaunchDefaultsAnnotation and DefaultHttpsEndpoint are both public today (behind the ASPIREPROJECTS001 experimental diagnostic), and RadiusServiceDiscovery.cs consumes them through the public surface. The comment was pointing at a reason that had already been designed away.

How the set of required internals was determined

Rather than inferring usage from source searches, the grant was removed and the consumer rebuilt, so the compiler enumerated exactly what was inaccessible. That produced three errors across one file, all in RadiusInfrastructureBuilder.cs, and both offending types were shared-source helpers rather than real hosting API. The same probe was run against the other non-test grants to confirm none of them are in the same situation — Aspire.Hosting.Blazor, Aspire.Hosting.EntityFrameworkCore, Aspire.Hosting.Azure.ContainerRegistry, Aspire.Hosting.Foundry, and Aspire.Hosting.Azure.Kubernetes all consume genuine internal infrastructure with no public equivalent, so they are intentionally left alone here.

Validation

  • Aspire.Hosting.Radius and Aspire.Hosting.Radius.Tests build clean: 0 errors, 0 warnings.
  • Full repository build (build.cmd -build): 0 errors, 0 warnings.
  • Aspire.Hosting.Radius.Tests: 655/655 passing, 0 failed, 0 skipped.

No behavior change is expected or intended: the same helper code is compiled, just sourced by link instead of by IVT.

Fixes # (issue)

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

Radius only needed two `src/Shared/` helpers (`EnvironmentVariableNameEncoder`
and `KnownRelationshipTypes`) from Aspire.Hosting. Those are plain internal
source files, not Aspire.Hosting API, so link-compile them instead of taking an
IVT grant on the whole assembly. Aspire.Hosting.DevTunnels already links these
same two files for the same reason.

The comment justifying the grant was stale: it cited
ProjectLaunchDefaultsAnnotation.DefaultHttpsEndpoint, which is now public
(behind ASPIREPROJECTS001) and no longer requires IVT.

Co-authored-by: Copilot App <[email protected]>
@github-actions

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 -- 20143

Or

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

@github-actions github-actions Bot added the area-integrations Issues pertaining to Aspire Integrations packages label Sep 15, 2026
@aspire-repo-bot
aspire-repo-bot Bot requested a balanced review from Copilot September 15, 2026 15:45
@github-actions

This comment has been minimized.

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.

🟢 Approval recommended

The mechanical dependency change is complete and consistent with the existing DevTunnels pattern.

Pull request overview

Removes Radius’s access to Aspire.Hosting internals while preserving behavior through shared-source compilation.

Changes:

  • Removes the Radius InternalsVisibleTo grant.
  • Link-compiles the two required shared helpers into Radius.
File summaries
File Description
src/Aspire.Hosting/Aspire.Hosting.csproj Removes the Radius IVT grant and stale justification.
src/Aspire.Hosting.Radius/Aspire.Hosting.Radius.csproj Includes the required shared helper sources.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

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.

🟢 Approval recommended

The focused dependency-boundary change preserves the existing helper implementations without introducing unresolved issues.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

50 / 99 PR test projects · 4 PR jobs, from 2 changed files.

Selected PR test projects (50 / 99)

Aspire.Cli.EndToEnd.Tests, Aspire.Hosting.Analyzers.Tests, Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.Azure.Kusto.Tests, Aspire.Hosting.Azure.Tests, Aspire.Hosting.Blazor.Tests, Aspire.Hosting.Browsers.Tests, Aspire.Hosting.CodeGeneration.Go.Tests, Aspire.Hosting.CodeGeneration.Java.Tests, Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.Rust.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Containers.Tests, Aspire.Hosting.DevTunnels.Tests, Aspire.Hosting.Docker.Tests, Aspire.Hosting.Dotnet.Tests, Aspire.Hosting.DotnetTool.Tests, Aspire.Hosting.EntityFrameworkCore.Tests, Aspire.Hosting.Foundry.Tests, Aspire.Hosting.Garnet.Tests, Aspire.Hosting.GitHub.Models.Tests, Aspire.Hosting.Go.Tests, Aspire.Hosting.Java.Tests, Aspire.Hosting.JavaScript.Tests, Aspire.Hosting.Kafka.Tests, Aspire.Hosting.Keycloak.Tests, Aspire.Hosting.Kubernetes.Tests, Aspire.Hosting.Maui.Tests, Aspire.Hosting.Milvus.Tests, Aspire.Hosting.MongoDB.Tests, Aspire.Hosting.MySql.Tests, Aspire.Hosting.Nats.Tests, Aspire.Hosting.OpenAI.Tests, Aspire.Hosting.Oracle.Tests, Aspire.Hosting.Orleans.Tests, Aspire.Hosting.PostgreSQL.Tests, Aspire.Hosting.Python.Tests, Aspire.Hosting.Qdrant.Tests, Aspire.Hosting.RabbitMQ.Tests, Aspire.Hosting.Radius.Tests, Aspire.Hosting.Redis.Tests, Aspire.Hosting.RemoteHost.Tests, Aspire.Hosting.Rust.Tests, Aspire.Hosting.Seq.Tests, Aspire.Hosting.SqlServer.Tests, Aspire.Hosting.Testing.Tests, Aspire.Hosting.Tests, Aspire.Hosting.Valkey.Tests, Aspire.Hosting.Yarp.Tests, Aspire.Playground.Tests

Selected PR jobs (4)

cli-starter-validation, extension-e2e, polyglot, typescript-api-compat


How these were chosen — grouped by what changed

⚠️ 48 of the 50 selected test projects come from a single change — src/Aspire.Hosting/Aspire.Hosting.csproj.

🔧 src/Aspire.Hosting/Aspire.Hosting.csproj (changed source)
→ 48 via the project graph

show 48

Aspire.Hosting.Analyzers.Tests (2 hops), Aspire.Hosting.Azure.Kubernetes.Tests (2 hops), Aspire.Hosting.Azure.Kusto.Tests (2 hops), Aspire.Hosting.Azure.Tests, Aspire.Hosting.Blazor.Tests (2 hops), Aspire.Hosting.Browsers.Tests (2 hops), Aspire.Hosting.CodeGeneration.Go.Tests, Aspire.Hosting.CodeGeneration.Java.Tests, Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.Rust.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Containers.Tests (2 hops), Aspire.Hosting.DevTunnels.Tests (2 hops), Aspire.Hosting.Docker.Tests (2 hops), Aspire.Hosting.Dotnet.Tests (2 hops), Aspire.Hosting.DotnetTool.Tests (2 hops), Aspire.Hosting.EntityFrameworkCore.Tests (2 hops), Aspire.Hosting.Foundry.Tests (2 hops), Aspire.Hosting.Garnet.Tests (2 hops), Aspire.Hosting.GitHub.Models.Tests (2 hops), Aspire.Hosting.Go.Tests (2 hops), Aspire.Hosting.Java.Tests (2 hops), Aspire.Hosting.JavaScript.Tests (2 hops), Aspire.Hosting.Kafka.Tests (2 hops), Aspire.Hosting.Keycloak.Tests (2 hops), Aspire.Hosting.Kubernetes.Tests (2 hops), Aspire.Hosting.Maui.Tests, Aspire.Hosting.Milvus.Tests (2 hops), Aspire.Hosting.MongoDB.Tests (2 hops), Aspire.Hosting.MySql.Tests (2 hops), Aspire.Hosting.Nats.Tests (2 hops), Aspire.Hosting.OpenAI.Tests (2 hops), Aspire.Hosting.Oracle.Tests (2 hops), Aspire.Hosting.Orleans.Tests (2 hops), Aspire.Hosting.PostgreSQL.Tests (2 hops), Aspire.Hosting.Python.Tests (2 hops), Aspire.Hosting.Qdrant.Tests (2 hops), Aspire.Hosting.RabbitMQ.Tests (2 hops), Aspire.Hosting.Redis.Tests (2 hops), Aspire.Hosting.RemoteHost.Tests, Aspire.Hosting.Rust.Tests (2 hops), Aspire.Hosting.Seq.Tests (2 hops), Aspire.Hosting.SqlServer.Tests (2 hops), Aspire.Hosting.Testing.Tests (2 hops), Aspire.Hosting.Tests (2 hops), Aspire.Hosting.Valkey.Tests (2 hops), Aspire.Hosting.Yarp.Tests (2 hops), Aspire.Playground.Tests

📦 affected project Aspire.Hosting.Radius
→ 1 test: Aspire.Cli.EndToEnd.Tests

🔧 src/Aspire.Hosting.Radius/Aspire.Hosting.Radius.csproj (changed source)
→ 1 directly: Aspire.Hosting.Radius.Tests

Job reasons

Job Triggered by
cli-starter-validation affected project Aspire.Hosting.JavaScript
extension-e2e • src/Aspire.Hosting/Aspire.Hosting.csproj
• affected project Aspire.Hosting
polyglot affected project Aspire.Hosting
typescript-api-compat affected project Aspire.Hosting.Radius

Selection computed for commit 3f100f2.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@eerhardt
Eric Erhardt (eerhardt) merged commit 86752cd into main Sep 15, 2026
560 of 564 checks passed
@eerhardt
Eric Erhardt (eerhardt) deleted the eerhardt-ivt-analysis branch September 15, 2026 16:51
@github-actions github-actions Bot added this to the 13.6 milestone Sep 15, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

✅ No documentation update needed.

Step 5 branch taken: docs_optional → internal_refactor

Triggered signals: no signals triggered (signal_count = 0)

Rationale: Only two files changed, both build configuration (no source/API changes):

  • src/Aspire.Hosting.Radius/Aspire.Hosting.Radius.csproj (+2/-0)
  • src/Aspire.Hosting/Aspire.Hosting.csproj (+0/-6)

The change removes an InternalsVisibleTo grant from Aspire.Hosting to Aspire.Hosting.Radius and instead link-compiles two shared internal source files (EnvironmentVariableNameEncoder.cs, KnownRelationshipTypes.cs) directly into Aspire.Hosting.Radius, matching the existing pattern used by Aspire.Hosting.DevTunnels. No public types, methods, options, CLI surface, or documented behavior were added, changed, or removed — this is purely an internal build/assembly-visibility refactor with zero effect on any Aspire user-facing surface. No new or changed environment variables, config keys, connection-string fields, CLI flags, or public API. Matches the internal_refactor allowlist category exactly: touches src/ but introduces no new/changed public surface, and the PR title/body confirm this is purely internal ("internal surface", "not Aspire.Hosting API", removing a stale IVT grant).

@github-actions

Copy link
Copy Markdown
Contributor

🔍 CI Failure Analysis: Transient Infrastructure Failure

The CI build failed due to transient infrastructure issues.

Failed jobs:

  • Tests / No-package tests (regular, Aspire.Hosting.RemoteHost.Tests, Hosting.RemoteHost, Hosting.RemoteHos... / Hosting.RemoteHost (windows-latest) — The job failed at the generic 'Build test project' step with only 'Process completed with exit code 1' as the annotation; no compiler errors, no test failures were extracted, and job logs were unavailable ('Failed to fetch logs for job'). The PR only removes an unused InternalsVisibleTo entry and a stale comment from src/Aspire.Hosting/Aspire.Hosting.csproj, and adds an unrelated entry to Aspire.Hosting.Radius.csproj — neither touches Aspire.Hosting.RemoteHost, Aspire.Hosting.RemoteHost.Tests, or any Radius-related code path that RemoteHost consumes. This matches the known recurring pattern of unrelated 'Build test project' jobs failing with a bare exit code 1 across many unrelated PRs (prior cause build-test-project-widespread-exit1-unrelated, 9 prior occurrences), consistent with a transient CI/runner infrastructure issue rather than a code problem introduced by this PR. (transient-infra)

If a rerun was not already requested automatically, visit the workflow run page to rerun the failed jobs manually.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-integrations Issues pertaining to Aspire Integrations packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants