Skip to content

Filter Aspire.Hosting bits out of sdk dump command#15291

Open
IEvangelist wants to merge 6 commits intorelease/13.2from
dapine/sdk-dump-filtering
Open

Filter Aspire.Hosting bits out of sdk dump command#15291
IEvangelist wants to merge 6 commits intorelease/13.2from
dapine/sdk-dump-filtering

Conversation

@IEvangelist
Copy link
Member

Filter Aspire.Hosting bits out of sdk dump command

  • Introduced IntegrationAssemblyNameResolver to resolve assembly names from project files.
  • Updated SdkDumpCommand and SdkGenerateCommand to utilize the new resolver.
  • Enhanced AppHostRpcClient and IAppHostRpcClient to support assembly name parameters.
  • Implemented AtsContextFilter for filtering ATS contexts based on exporting assemblies.
  • Added comprehensive unit tests for IntegrationAssemblyNameResolver and AtsContextFilter.

Fixes #14822

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?

…blies

When running 'aspire sdk dump MyIntegration.csproj', the output now only
shows capabilities, handle types, DTO types, and enums from the specified
integration assembly instead of including the entire Aspire.Hosting surface.

Changes:
- Add assemblyNames parameter to getCapabilities RPC method
- Add assemblyName parameter to generateCode RPC method
- Apply AtsContextFilter.FilterByExportingAssembliesWithReferences on
  the server side to scope output to specified assemblies while including
  referenced supporting types
- Add IntegrationAssemblyNameResolver to read AssemblyName from .csproj
- Add end-to-end test scanning real assemblies and verifying filtering
- Fix test assertion to check actual context entries, not phantom IDs

Fixes #14822
Copilot AI review requested due to automatic review settings March 16, 2026 21:03
@github-actions
Copy link
Contributor

github-actions bot commented Mar 16, 2026

🚀 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/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15291

Or

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the aspire sdk dump / aspire sdk generate flows to scope ATS output to the user-specified integration assembly (instead of always dumping the full Aspire.Hosting surface), by resolving the integration’s assembly name and filtering the ATS context server-side.

Changes:

  • Added IntegrationAssemblyNameResolver and updated SDK commands to use assembly name (vs. project file name) when wiring project integrations.
  • Extended the AppHost JSON-RPC surface (getCapabilities, generateCode) to accept optional assembly-scoping parameters and applied ATS context filtering in CodeGenerationService.
  • Introduced AtsContextFilter (strict + “include referenced types” modes) and added unit tests covering the filtering and assembly-name resolution.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/Aspire.Hosting.RemoteHost.Tests/AtsContextFilterTests.cs Adds coverage for strict filtering and “with references” behavior, including an end-to-end scan + filter scenario.
tests/Aspire.Cli.Tests/Commands/IntegrationAssemblyNameResolverTests.cs Tests project-file AssemblyName resolution and fallback behavior.
src/Aspire.Hosting.RemoteHost/CodeGeneration/CodeGenerationService.cs Adds optional assembly scoping parameters to RPC methods and applies ATS context filtering before returning data / generating code.
src/Aspire.Hosting.RemoteHost/AtsContextFilter.cs New internal helper that filters ATS contexts by exporting assembly, optionally retaining referenced types needed by selected exports.
src/Aspire.Cli/Scaffolding/ScaffoldingService.cs Updates GenerateCodeAsync call-site to use named arguments after RPC signature change.
src/Aspire.Cli/Projects/IAppHostRpcClient.cs Extends typed RPC interface to accept optional assembly scoping parameters.
src/Aspire.Cli/Projects/GuestAppHostProject.cs Updates GenerateCodeAsync call-site to avoid positional ambiguity after signature change.
src/Aspire.Cli/Projects/AppHostRpcClient.cs Implements the new typed RPC parameters for getCapabilities / generateCode.
src/Aspire.Cli/Commands/Sdk/SdkGenerateCommand.cs Resolves integration assembly name from .csproj and scopes code generation to it.
src/Aspire.Cli/Commands/Sdk/SdkDumpCommand.cs Uses resolved assembly name for project integrations and passes selected assembly names to the RPC call for filtering.
src/Aspire.Cli/Commands/Sdk/IntegrationAssemblyNameResolver.cs New resolver that reads <AssemblyName> from SDK-style project files (with fallback).

You can also share your feedback on Copilot code review. Take the survey.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 16, 2026

🎬 CLI E2E Test Recordings

The following terminal recordings are available for commit f3e27d0:

Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndDeployToDockerCompose ▶️ View Recording
CreateAndDeployToDockerComposeInteractive ▶️ View Recording
CreateAndPublishToKubernetes ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RunWithMissingAwaitShowsHelpfulError ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ❌ Upload failed
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
TypeScriptAppHostWithProjectReferenceIntegration ▶️ View Recording

📹 Recordings uploaded automatically from CI run #23252295798

@github-actions
Copy link
Contributor

The transient CI rerun workflow requested reruns for the following jobs after analyzing the failed attempt.
GitHub's job rerun API also reruns dependent jobs, so the retry is being tracked in the rerun attempt.
The job links below point to the failed attempt that matched the retry-safe transient failure rules.

@github-actions
Copy link
Contributor

The transient CI rerun workflow requested reruns for the following jobs after analyzing the failed attempt.
GitHub's job rerun API also reruns dependent jobs, so the retry is being tracked in the rerun attempt.
The job links below point to the failed attempt that matched the retry-safe transient failure rules.

Copy link
Member

@mitchdenny mitchdenny left a comment

Choose a reason for hiding this comment

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

Made a suggestion for API shape, but weakly held opinion. Really depends on whether we expect this API to evolve much. If it does evolve we might be better introducing some different method names to avoid overload confusions (since its string, string, ct which smells a bit of primitive obsession).

@IEvangelist
Copy link
Member Author

Hey @copilot - please address the peer review feedback in a PR targeting updates to the dapine/sdk-dump-filtering branch.

Copy link
Contributor

Copilot AI commented Mar 18, 2026

@IEvangelist I've opened a new pull request, #15353, to work on those changes. Once the pull request is ready, I'll request review from you.

* Initial plan

* Refactor RPC client API to use distinct method names instead of nullable parameters

Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>

* Clarify that paired client methods intentionally share RPC endpoint names

Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
@github-actions
Copy link
Contributor

The transient CI rerun workflow requested reruns for the following jobs after analyzing the failed attempt.
GitHub's job rerun API also reruns dependent jobs, so the retry is being tracked in the rerun attempt.
The job links below point to the failed attempt that matched the retry-safe transient failure rules.


try
{
var document = XDocument.Load(projectFile.FullName);
Copy link
Member

Choose a reason for hiding this comment

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

hmm I don't like us doing it via XDocument. What happens if this is in a Directory.Build.props file somewhere? I wonder if an alternative is to try to call the GetTargetPath target on the csproj and print it out or something. Other alternative is of couse loading the project using msbuild dlls but that is not ideal as we would have to bring the dependency.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I'd like to avoid msbuild for the dependency, as you mentioned...but for Directory.Build.props is it ever common to have an assembly name in there?

Copy link
Member

Choose a reason for hiding this comment

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

Other alternative is of couse loading the project using msbuild dlls but that is not ideal as we would have to bring the dependency.

This is probably not possible since we need to Native AOT.


namespace Aspire.Cli.Tests.Commands;

public class IntegrationAssemblyNameResolverTests
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to add test cases for malformed projects?

Copy link
Member Author

@IEvangelist IEvangelist Mar 19, 2026

Choose a reason for hiding this comment

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

That's a good idea, assuming we keep using the XDocument for the parsing - to ensure failure mode flows as expected.

@joperezr
Copy link
Member

Looks like there are some merge conflicts on this one, and probably at this point it is late to take this change, so let's see if this is something we can instead take in servicing (13.2.x) or otherwise re-target to main. Let me know if you have any concerns with this.

@IEvangelist
Copy link
Member Author

Looks like there are some merge conflicts on this one, and probably at this point it is late to take this change, so let's see if this is something we can instead take in servicing (13.2.x) or otherwise re-target to main. Let me know if you have any concerns with this.

No concerns, this isn't a high priority one anyway.

@joperezr
Copy link
Member

Does that mean we should retarget this to main instead then?

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.

7 participants