@@ -8,12 +8,31 @@ namespace System.CommandLine.Subsystems.Annotations;
88/// <summary>
99/// Allows associating an annotation with a <see cref="CliSymbol"/>. The annotation will be stored by the accessor's owner <see cref="CliSubsystem"/>.
1010/// </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>
1117public struct AnnotationAccessor < TValue > ( CliSubsystem owner , AnnotationId < TValue > id )
1218{
1319 /// <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
1533 /// </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 ) ;
1938}
0 commit comments