Skip to content

Commit dce1260

Browse files
committed
obsolete ParseResult.ValueFor*(string) methods
1 parent 105d563 commit dce1260

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/System.CommandLine/Parsing/ParseResult.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,14 @@ internal ParseResult(
8484

8585
public IReadOnlyList<string> UnparsedTokens => _unparsedTokens.Select(t => t.Value).ToArray();
8686

87+
[Obsolete("This method is obsolete and will be removed in a future version. Please use ParseResult.ValueForOption<T>(Option<T>) instead. For details see https://github.com/dotnet/command-line-api/issues/1127")]
8788
public object? ValueForOption(string alias) =>
8889
ValueForOption<object?>(alias);
8990

9091
public object? ValueForOption(Option option) =>
9192
ValueForOption<object?>(option);
9293

94+
[Obsolete("This method is obsolete and will be removed in a future version. Please use ParseResult.ValueForArgument<T>(Option<T>) instead. For details see https://github.com/dotnet/command-line-api/issues/1127")]
9395
public object? ValueForArgument(string alias) =>
9496
ValueForArgument<object?>(alias);
9597

@@ -121,6 +123,7 @@ public T ValueForArgument<T>(Argument argument)
121123
}
122124

123125
[return: MaybeNull]
126+
[Obsolete("This method is obsolete and will be removed in a future version. Please use ParseResult.ValueForArgument<T>(Option<T>) instead. For details see https://github.com/dotnet/command-line-api/issues/1127")]
124127
public T ValueForArgument<T>(string name)
125128
{
126129
if (string.IsNullOrWhiteSpace(name))
@@ -162,9 +165,11 @@ public T ValueForOption<T>(Option option)
162165
return (T)Binder.GetDefaultValue(option.Argument.ArgumentType)!;
163166
}
164167

168+
[Obsolete("This method is obsolete and will be removed in a future version. Please use ParseResult.ValueForOption<T>(Option<T>) instead. For details see https://github.com/dotnet/command-line-api/issues/1127")]
165169
[return: MaybeNull]
166170
public T ValueForOption<T>(string alias)
167171
{
172+
// FIX: (ValueForOption) remove internal refs
168173
if (string.IsNullOrWhiteSpace(alias))
169174
{
170175
throw new ArgumentException("Value cannot be null or whitespace.", nameof(alias));

0 commit comments

Comments
 (0)