Switch ATS attribute discovery to name-based matching for third-party support#14977
Open
sebastienros wants to merge 2 commits intorelease/13.2from
Open
Switch ATS attribute discovery to name-based matching for third-party support#14977sebastienros wants to merge 2 commits intorelease/13.2from
sebastienros wants to merge 2 commits intorelease/13.2from
Conversation
…buteData Replace concrete GetCustomAttribute<T>() calls in AtsCapabilityScanner with CustomAttributeData-based name matching. This allows third-party integration authors to define their own copies of AspireExport, AspireExportIgnore, AspireDto, and AspireUnion attributes in any namespace without referencing Aspire.Hosting. Changes: - Add AttributeDataReader with adapter types (AspireExportData, AspireUnionData) that wrap CustomAttributeData and provide typed property access - Update all 11 helper methods in AtsCapabilityScanner to use name-based lookup - Update CreateTypeInfo, CreateCapabilityInfo, ShouldExportMember, and CreateUnionTypeRef to use adapter types instead of concrete attribute types - Add ThirdPartyAtsAttributes.md documenting how third-party authors create their own attribute types - Add 10 tests proving cross-namespace attribute discovery works, including full integration tests via ScanAssemblies Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… name
Replace parameter-name-based matching ("id", "type") with
signature-based matching (arity + argument type) so third-party
attribute copies with different constructor parameter names are
still parsed correctly.
Add test with RenamedParam mock attribute that uses "name" instead
of "id" and "targetType" instead of "type" to verify this.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
|
@davidfowl Do we want to ship a public nuget packages with these types before 13.2? (Aspire.Hosting 13.2 will have these). IMO it's not necessary, they can use the sample provided in this PR to start annotating their integrations until 13.2 is available. |
76 tasks
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14977Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14977" |
Contributor
🎬 CLI E2E Test RecordingsThe following terminal recordings are available for commit
📹 Recordings uploaded automatically from CI run #22729667261 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Switch ATS (Aspire Type System) attribute discovery from concrete type matching via
GetCustomAttribute<T>()to name-based matching viaCustomAttributeData. This allows third-party integration authors to define their own copies ofAspireExport,AspireExportIgnore,AspireDto, andAspireUnionattributes in any namespace without requiring a package reference toAspire.Hosting.When we ship the official attribute types publicly, anyone who created custom mock types will not be broken — both official and custom attributes are recognized by name.
Changes
AttributeDataReader.cs— New internal helper with adapter types (AspireExportData,AspireUnionData) that parseCustomAttributeDataby type name. Constructor args are matched by signature (arity + type) rather than parameter name for maximum third-party compatibility.AtsCapabilityScanner.cs— Updated all 11 helper methods and method signatures (CreateTypeInfo,CreateCapabilityInfo,ShouldExportMember,CreateUnionTypeRef) to use the adapter types.ThirdPartyAtsAttributes.md— Documentation showing third-party authors how to define their own attribute types.ScanAssembliesintegration tests.Validation
aspire init --language typescript+aspire add Aspire.Hosting.Redisgenerates correct TypeScript SDK with all Redis methodsChecklist