@@ -10,13 +10,18 @@ namespace System.CommandLine.Subsystems.Annotations;
10
10
/// taking into account both the values stored directly on the symbol via extension methods
11
11
/// and any values from <see cref="IAnnotationProvider"/> providers.
12
12
/// </summary>
13
+ /// <param name="providers">The providers from which annotation values will be resolved</param>
14
+ /// <param name="context">The context for resolving annotation values</param>
13
15
/// <remarks>
14
16
/// The <paramref name="providers"/> will be enumerated each time an annotation value is requested.
15
17
/// It may be modified after the resolver is created.
16
18
/// </remarks>
17
- public class AnnotationResolver ( ICollection < IAnnotationProvider > providers )
19
+ public class AnnotationResolver ( IEnumerable < IAnnotationProvider > providers , AnnotationResolveContext context )
18
20
{
19
- private readonly IEnumerable < IAnnotationProvider > providers = providers ?? throw new ArgumentNullException ( nameof ( providers ) ) ;
21
+ public AnnotationResolver ( PipelineResult pipelineResult )
22
+ : this ( pipelineResult . Pipeline . AnnotationProviders , new AnnotationResolveContext ( pipelineResult ) )
23
+ {
24
+ }
20
25
21
26
/// <summary>
22
27
/// Attempt to retrieve the <paramref name="symbol"/>'s value for the annotation <paramref name="id"/>. This will check any
@@ -48,7 +53,7 @@ public bool TryGet<TValue>(CliSymbol symbol, AnnotationId annotationId, [NotNull
48
53
{
49
54
foreach ( var provider in providers )
50
55
{
51
- if ( provider . TryGet ( symbol , annotationId , out object ? rawValue ) )
56
+ if ( provider . TryGet ( symbol , annotationId , context , out object ? rawValue ) )
52
57
{
53
58
if ( rawValue is TValue expectedTypeValue )
54
59
{
@@ -87,7 +92,7 @@ public bool TryGet(CliSymbol symbol, AnnotationId annotationId, [NotNullWhen(tru
87
92
{
88
93
foreach ( var provider in providers )
89
94
{
90
- if ( provider . TryGet ( symbol , annotationId , out value ) )
95
+ if ( provider . TryGet ( symbol , annotationId , context , out value ) )
91
96
{
92
97
return true ;
93
98
}
0 commit comments