dotnet / command-line-api

Command line parsing, invocation, and rendering of terminal output.
https://github.com/dotnet/command-line-api/wiki
MIT License
3.38k stars 380 forks source link

Consider unifying per-subsystem annotation providers #2428

Open mhutch opened 4 months ago

mhutch commented 4 months ago

In Powderhouse, IAnnotationProvider annotation providers are currently per-subsystem. This makes sense - a developer may wish to author or use a provider that provides help descriptions, which would naturally belong with the help subsystem, and another provider that provides default values, which would naturally belong with the default values subsystem.

However, it gets more complicated when we consider that some annotations may be used by multiple subsystems. For example, the completion subsystem uses the help description as the description for completion items. In the scenario above, if the completion subsystem were to use GetAnnotation(symbol, HelpAnnotations.Description) on itself, it would not get the description from the annotation provider on the help subsystem.

The completion subsystem could obtain a reference to the help subsystem and call helpSubsystem.GetAnnotation(symbol, HelpAnnotations.Description) or helpSubsystem.GetDescription(symbol). However, it may not be obvious to subsystem authors that they need to do this.

Another option would be to only have a single annotation provider for use by all the subsystems in the pipeline. Developers who wish to have multiple providers would then need to create a single aggregated provider.