Skip to content

Allow passing parent to WithParentRelationship as IResourceBuilder<T> #7594

@afscrome

Description

@afscrome

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

9.1 has added the following method

public static IResourceBuilder<T> WithParentRelationship<T>(this IResourceBuilder<T> builder, IResource parent) where T : IResource

However using this when building resources is a bit clunky as you usually have

var db = builder.AddPostgres("db");
var migrator = builder
   .AddExecutable("migrator", "migrator.exe", ".")
   .WithParentRelationship(db.Resource);

Describe the solution you'd like

It would be nice if WithParentRelationship accepted the parent as an IResourceBuilder<IResource> rather than IResource. That would allow the above to simplify to:

var db = builder.AddPostgres("db");
var migrator = builder
   .AddExecutable("migrator", "migrator.exe", ".")
-   .WithParentRelationship(db.Resource);
+   .WithParentRelationship(db);

Additional context

No response

Metadata

Metadata

Assignees

Labels

area-app-modelIssues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions