You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Attempts to get the value for the annotation <paramref name="annotationId"/> associated with the <paramref name="symbol"/> in the internal annotation
93
-
/// storage used to store values set via <see cref="SetAnnotation{TValue}(CliSymbol, AnnotationId{TValue}, TValue)"/>.
91
+
/// storage used to store values set via <see cref="SetAnnotation(CliSymbol, AnnotationId, object?)"/>.
94
92
/// </summary>
95
-
/// <typeparam name="TValue">The type of the annotation value</typeparam>
93
+
/// <typeparam name="TValue">
94
+
/// The expected type of the annotation value. If the type does not match, a <see cref="AnnotationTypeException"/> will be thrown.
95
+
/// If the annotation allows multiple types for its values, and a type parameter cannot be determined statically,
96
+
/// use <see cref="TryGetAnnotation(CliSymbol, AnnotationId, out object?)"/> to access the annotation value without checking its type.
97
+
/// </typeparam>
96
98
/// <param name="symbol">The symbol that is annotated</param>
97
99
/// <param name="annotationId">
98
100
/// The identifier for the annotation. For example, the annotation identifier for the help description is <see cref="HelpAnnotations.Description">.
99
101
/// </param>
100
102
/// <param name="value">The annotation value, if successful, otherwise <c>default</c></param>
101
103
/// <returns>True if successful</returns>
102
104
/// <remarks>
103
-
/// This is intended to be called by specialized ID-specific accessors for CLI authors such as <see cref="HelpAnnotationExtensions.GetDescription{TSymbol}(TSymbol)"/>.
104
-
/// Subsystems should not call it, as it does not account for values from the subsystem's <see cref="IAnnotationProvider"/>. They should instead call
105
-
/// <see cref="CliSubsystem.TryGetAnnotation{TValue}(CliSymbol, AnnotationId{TValue}, out TValue?)"/> or an ID-specific accessor on the subsystem such
105
+
/// If the annotation value does not have a single expected type for this symbol, use the <see cref="TryGetAnnotation(CliSymbol, AnnotationId, out object?)"/> overload instead.
106
+
/// <para>
107
+
/// This is intended to be called by the implementation of specialized ID-specific accessors for CLI authors such as <see cref="HelpAnnotationExtensions.GetDescription{TSymbol}(TSymbol)"/>.
108
+
/// </para>
109
+
/// <para>
110
+
/// Subsystems should not call it directly, as it does not account for values from the subsystem's <see cref="IAnnotationProvider"/>. They should instead call
111
+
/// <see cref="CliSubsystem.TryGetAnnotation{TValue}(CliSymbol, AnnotationId, out TValue?)"/> or an ID-specific accessor on the subsystem such
112
+
/// <see cref="HelpSubsystem.TryGetDescription(CliSymbol, out string?)"/>.
/// Attempts to get the value for the annotation <paramref name="annotationId"/> associated with the <paramref name="symbol"/> in the internal annotation
133
+
/// storage used to store values set via <see cref="SetAnnotation(CliSymbol, AnnotationId, object?)"/>.
134
+
/// </summary>
135
+
/// <param name="symbol">The symbol that is annotated</param>
136
+
/// <param name="annotationId">
137
+
/// The identifier for the annotation. For example, the annotation identifier for the help description is <see cref="HelpAnnotations.Description">.
138
+
/// </param>
139
+
/// <param name="value">The annotation value, if successful, otherwise <c>default</c></param>
140
+
/// <returns>True if successful</returns>
141
+
/// <remarks>
142
+
/// If the expected type of the annotation value is known, use the <see cref="TryGetAnnotation{TValue}(CliSymbol, AnnotationId, out TValue?)"/> overload instead.
143
+
/// <para>
144
+
/// This is intended to be called by the implementation of specialized ID-specific accessors for CLI authors such as <see cref="HelpAnnotationExtensions.GetDescription{TSymbol}(TSymbol)"/>.
145
+
/// </para>
146
+
/// <para>
147
+
/// Subsystems should not call it directly, as it does not account for values from the subsystem's <see cref="IAnnotationProvider"/>. They should instead call
148
+
/// <see cref="CliSubsystem.TryGetAnnotation(CliSymbol, AnnotationId, out object?)"/> or an ID-specific accessor on the subsystem such
106
149
/// <see cref="HelpSubsystem.TryGetDescription(CliSymbol, out string?)"/>.
/// Attempts to get the value for the annotation <paramref name="annotationId"/> associated with the <paramref name="symbol"/> in the internal annotation
121
-
/// storage used to store values set via <see cref="SetAnnotation{TValue}(CliSymbol, AnnotationId{TValue}, TValue)"/>.
165
+
/// storage used to store values set via <see cref="SetAnnotation{TValue}(CliSymbol, AnnotationId, TValue)"/>.
122
166
/// </summary>
123
167
/// <typeparam name="TValue">The type of the annotation value</typeparam>
124
168
/// <param name="symbol">The symbol that is annotated</param>
/// This is intended to be called by specialized ID-specific accessors for CLI authors such as <see cref="HelpAnnotationExtensions.GetDescription{TSymbol}(TSymbol)"/>.
131
175
/// Subsystems should not call it, as it does not account for values from the subsystem's <see cref="IAnnotationProvider"/>. They should instead call
132
-
/// <see cref="CliSubsystem.TryGetAnnotation{TValue}(CliSymbol, AnnotationId{TValue}, out TValue?)"/> or an ID-specific accessor on the subsystem such
176
+
/// <see cref="CliSubsystem.TryGetAnnotation{TValue}(CliSymbol, AnnotationId, out TValue?)"/> or an ID-specific accessor on the subsystem such
133
177
/// <see cref="HelpSubsystem.TryGetDescription(CliSymbol, out string?)"/>.
$"Typed accessor for annotation '${AnnotationId}' expected type '{ExpectedType}' but the annotation provider returned an annotation of type '{ActualType?.ToString()??"[null]"}'. "+
24
+
$"This may be an authoring error in in the annotation provider '{Provider.GetType()}' or in a typed annotation accessor.";
25
+
26
+
}
27
+
28
+
return
29
+
$"Typed accessor for annotation '${AnnotationId}' expected type '{ExpectedType}' but the stored annotation is of type '{ActualType?.ToString()??"[null]"}'. "+
30
+
$"This may be an authoring error in a typed annotation accessor, or the annotation may have be stored directly with the incorrect type, bypassing the typed accessors.";
/// <param name="value">An out parameter to contain the result</param>
46
50
/// <returns>True if successful</returns>
47
51
/// <remarks>
52
+
/// If the annotation value does not have a single expected type for this symbol, use the <see cref="TryGetAnnotation(CliSymbol, AnnotationId, out object?)"/> overload instead.
53
+
/// <para>
48
54
/// Subsystem authors must use this to access annotation values, as it respects the subsystem's <see cref="IAnnotationProvider"/> if it has one.
49
55
/// This value is protected because it is intended for use only by subsystem authors. It calls <see cref="AnnotationStorageExtensions"/>
/// Attempt to retrieve the <paramref name="symbol"/>'s value for the annotation <paramref name="id"/>. This will check the
75
+
/// annotation provider that was passed to the subsystem constructor, and the internal annotation storage.
76
+
/// </summary>
77
+
/// <param name="symbol">The symbol the value is attached to</param>
78
+
/// <param name="id">
79
+
/// The identifier for the annotation value to be retrieved.
80
+
/// For example, the annotation identifier for the help description is <see cref="HelpAnnotations.Description">.
81
+
/// </param>
82
+
/// <param name="value">An out parameter to contain the result</param>
83
+
/// <returns>True if successful</returns>
84
+
/// <remarks>
85
+
/// If the expected type of the annotation value is known, use the <see cref="TryGetAnnotation{TValue}(CliSymbol, AnnotationId, out TValue?)"/> overload instead.
86
+
/// <para>
87
+
/// Subsystem authors must use this to access annotation values, as it respects the subsystem's <see cref="IAnnotationProvider"/> if it has one.
88
+
/// This value is protected because it is intended for use only by subsystem authors. It calls <see cref="AnnotationStorageExtensions"/>
0 commit comments