microsoft / microsoft/aspire

Consider using Roslyn Analyzer (Source generator) for `IServiceMetadata` gen.

Open
#601 4 comments 0 reactions 0 assignees View on GitHub
area-app-model
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

Currently the `IServiceMetadata` implementations that are created within the `Projects` namespace are discovered and compiled using the following MSBuild target:

https://github.com/dotnet/aspire/blob/12af412b50c7533a75748edae2776d70a64c890e/src/Aspire.Hosting/build/Aspire.Hosting.targets#L15-L64

I'm proposing that you consider creating and using a Roslyn Analyzer (Source generator) instead. When I first explored this generated `IServiceMetadata` implementation I was surprised to see that I could edit the file, which wouldn't be the case with a source generated file.

Additionally, I would like to propose that instead of replacing `.` and `-` with `_`, that you simply remove them instead. For example, consider the following differences in these two approaches:

- `AspireSample.Web` would be `AspireSampleWeb` instead of `AspireSample_Web`.
- `AspireSample.ApiService` would be `AspireSampleApiService` instead of `AspireSample_ApiService`.

This feels a bit more idiomatic.

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.