Skip to content

Commit fae9a17

Browse files
Remove get method
1 parent 9e7bf77 commit fae9a17

File tree

2 files changed

+3
-18
lines changed

2 files changed

+3
-18
lines changed

src/System.CommandLine.Subsystems.Tests/AlternateSubsystems.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public VersionThatUsesHelpData(CliSymbol symbol)
3131
protected override CliExit Execute(PipelineContext pipelineContext)
3232
{
3333
var help = pipelineContext.Pipeline.Help ?? throw new InvalidOperationException("Help cannot be null for this subsystem to work");
34-
string data = help.Description.Get(Symbol);
34+
help.Description.TryGet(Symbol, out var description);
3535

36-
pipelineContext.ConsoleHack.WriteLine(data);
36+
pipelineContext.ConsoleHack.WriteLine(description);
3737
pipelineContext.AlreadyHandled = true;
3838
return CliExit.SuccessfullyHandled(pipelineContext.ParseResult);
3939
}

src/System.CommandLine.Subsystems/Subsystems/Annotations/AnnotationAccessor.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ namespace System.CommandLine.Subsystems.Annotations;
1414
/// <typeparam name="TValue">The type of value to be stored</typeparam>
1515
/// <param name="owner">The subsystem that this annotation store data for.</param>
1616
/// <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>
18-
public struct AnnotationAccessor<TValue>(CliSubsystem owner, AnnotationId<TValue> id, TValue? defaultValue = default)
17+
public struct AnnotationAccessor<TValue>(CliSubsystem owner, AnnotationId<TValue> id)
1918
{
2019
/// <summary>
2120
/// The identifier for this annotation, since subsystems may have multiple annotations.
@@ -36,18 +35,4 @@ public struct AnnotationAccessor<TValue>(CliSubsystem owner, AnnotationId<TValue
3635
/// <param name="value">The value to retrieve.</param>
3736
/// <returns>True if the value was found, false otherwise.</returns>
3837
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>
45-
public readonly TValue? Get(CliSymbol symbol)
46-
{
47-
if (TryGet(symbol, out var value))
48-
{
49-
return value;
50-
}
51-
return defaultValue;
52-
}
5338
}

0 commit comments

Comments
 (0)