microsoft / microsoft/aspire

Add a Roslyn analyzer for WithRoleAssignments when not using targeted role assignments infrastructure

Open
#8,379 0 comments 2 reactions 0 assignees View on GitHub
area-integrations azure
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

With #6161, the new WithRoleAssignments methods only work today when you enable ACA infrastructure via `Aspire.Hosting.Azure.AppContainers`. Future compute environments can also enable support as well, when they are implemented.

When you call WithRoleAssignments without enabling a compute infrastructure that supports targeted role assignments, you get an exception at runtime saying it isn't supported and you need to enable something like our ACA infrastructure to make it supported.

We could consider writing an analyzer for this situation to "shift left" the error experience to a build time warning, and potential code fixer. Although, I'm not sure if a code fixer can add a nuget package?

One consideration is that you will get an error at F5 time as soon as you call WithRoleAssignments, so you didn't get too far down the error path before finding out you need to add more to your app.

cc @captainsafia @DamianEdwards

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.