dotnet/aspire

IResourceWithParent not supported with projects and executables

Opened this issue · 0 comments

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

There is logic in ApplicationExecutor for setting parent information onto child resources. However, it's only supported when the parent is a container:

private static ILookup<IResource?, IResourceWithParent> GetParentChildLookup(DistributedApplicationModel model)
{
static IResource? SelectParentContainerResource(IResource resource) => resource switch
{
IResourceWithParent rp => SelectParentContainerResource(rp.Parent),
IResource r when r.IsContainer() => r,
_ => null
};
// parent -> children lookup
return model.Resources.OfType<IResourceWithParent>()
.Select(x => (Child: x, Root: SelectParentContainerResource(x.Parent)))
.Where(x => x.Root is not null)
.ToLookup(x => x.Root, x => x.Child);
}

Expected Behavior

IResourceWithParent should work well for containers, projects and executables.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version info

No response

Anything else?

No response