@@ -8,14 +8,40 @@ 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>
17+ /// <param name="defaultValue">The default value to return if the annotation is not set.</param>
1118public struct AnnotationAccessor < TValue > ( CliSubsystem owner , AnnotationId < TValue > id , TValue ? defaultValue = default )
1219{
1320 /// <summary>
14- /// The ID of the annotation
21+ /// The identifier for this annotation, since subsystems may have multiple annotations.
1522 /// </summary>
1623 public AnnotationId < TValue > Id { get ; } = id ;
24+
25+ /// <summary>
26+ /// Store a value for the annotation and symbol
27+ /// </summary>
28+ /// <param name="symbol">The CliSymbol the value is for.</param>
29+ /// <param name="value">The value to store.</param>
1730 public readonly void Set ( CliSymbol symbol , TValue value ) => owner . SetAnnotation ( symbol , Id , value ) ;
31+
32+ /// <summary>
33+ /// Retrieve the value for the annotation and symbol
34+ /// </summary>
35+ /// <param name="symbol">The CliSymbol the value is for.</param>
36+ /// <param name="value">The value to retrieve/</param>
37+ /// <returns>True if the value was found, false otherwise.</returns>
1838 public readonly bool TryGet ( CliSymbol symbol , [ NotNullWhen ( true ) ] out TValue ? value ) => owner . TryGetAnnotation ( symbol , Id , out value ) ;
39+
40+ /// <summary>
41+ /// Retrieve the value for the annotation and symbol
42+ /// </summary>
43+ /// <param name="symbol">The CliSymbol the value is for.</param>
44+ /// <returns>The retrieved value or <see cref="defaultValue"/> if the value was not found.</returns>
1945 public readonly TValue ? Get ( CliSymbol symbol )
2046 {
2147 if ( TryGet ( symbol , out var value ) )
0 commit comments