@@ -8,12 +8,31 @@ namespace System.CommandLine.Subsystems.Annotations;
8
8
/// <summary>
9
9
/// Allows associating an annotation with a <see cref="CliSymbol"/>. The annotation will be stored by the accessor's owner <see cref="CliSubsystem"/>.
10
10
/// </summary>
11
+ /// <remarks>
12
+ /// The annotation will be stored by the accessor's owner <see cref="CliSubsystem"/>.
13
+ /// </summary>
14
+ /// <typeparam name="TValue">The type of value to be stored</typeparam>
15
+ /// <param name="owner">The subsystem that this annotation store data for.</param>
16
+ /// <param name="id">The identifier for this annotation, since subsystems may have multiple annotations.</param>
11
17
public struct AnnotationAccessor < TValue > ( CliSubsystem owner , AnnotationId < TValue > id )
12
18
{
13
19
/// <summary>
14
- /// The ID of the annotation
20
+ /// The identifier for this annotation, since subsystems may have multiple annotations.
21
+ /// </summary>
22
+ public AnnotationId < TValue > Id { get ; } = id ;
23
+
24
+ /// <summary>
25
+ /// Store a value for the annotation and symbol
26
+ /// </summary>
27
+ /// <param name="symbol">The CliSymbol the value is for.</param>
28
+ /// <param name="value">The value to store.</param>
29
+ public readonly void Set ( CliSymbol symbol , TValue value ) => owner . SetAnnotation ( symbol , Id , value ) ;
30
+
31
+ /// <summary>
32
+ /// Retrieve the value for the annotation and symbol
15
33
/// </summary>
16
- public AnnotationId < TValue > Id { get ; }
17
- public readonly void Set ( CliSymbol symbol , TValue value ) => owner . SetAnnotation ( symbol , id , value ) ;
18
- public readonly bool TryGet ( CliSymbol symbol , [ NotNullWhen ( true ) ] out TValue ? value ) => owner . TryGetAnnotation ( symbol , id , out value ) ;
34
+ /// <param name="symbol">The CliSymbol the value is for.</param>
35
+ /// <param name="value">The value to retrieve.</param>
36
+ /// <returns>True if the value was found, false otherwise.</returns>
37
+ public readonly bool TryGet ( CliSymbol symbol , [ NotNullWhen ( true ) ] out TValue ? value ) => owner . TryGetAnnotation ( symbol , Id , out value ) ;
19
38
}
0 commit comments