Skip to content

Support for ValueResult as public type to carry value and location #2372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

KathleenDollard
Copy link
Contributor

@KathleenDollard KathleenDollard commented Apr 4, 2024

I am having an issue where the base of this merge is not what I am expecting. You can see the problem in System.CommandLine.Subsystems/Directives/DirectiveSubsystem.cs which exists in dotnet/command-line-api, but appears as completely fresh code in this PR. Another example is that ParserTests.cs has a bunch of whitespace fixes made by @mhutch that do not appear in the base of this PR.

I either did something dumb or I have lost my mind.

Commits in this PR also need to be cleaned up, so it is not ready to go, but I wanted to put this out so I could get help resolving this.

@@ -1,7 +1,9 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.CommandLine.Directives;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an example of my confusion. If I look at dotnet:main-powderhouse, I see this line present, as well as the files DiagramSubsystemTests.cs, etc.

@KathleenDollard KathleenDollard force-pushed the powderhouse-valueresult branch 2 times, most recently from ba99c86 to 9d83bd3 Compare April 5, 2024 19:12
OptionResult and ArgumentResult access internal data and ValueResult is a public face for the data and location.
@KathleenDollard KathleenDollard force-pushed the powderhouse-valueresult branch from 9d83bd3 to 204a997 Compare April 5, 2024 19:47
@baronfel baronfel marked this pull request as ready for review April 5, 2024 19:53
new CliArgument<string[]>("arg2")
}
};
var command = new CliCommand(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove newline

}
};

ParseResult result = CliParser.Parse(command, new[] { "the-command",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check whitespace

}
*/
*/


Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove blank line

@@ -23,6 +23,7 @@ public void The_tokenizer_can_handle_single_option()
List<CliToken> tokens = null;
List<string> errors = null;
Tokenizer.Tokenize(args, command, new CliConfiguration(command), true, out tokens, out errors);
Tokenizer.Tokenize(args, command, new CliConfiguration(command), true, out tokens, out errors);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line really doubled?

@@ -44,6 +47,7 @@ public sealed class ParseResult
Configuration = configuration;
_rootCommandResult = rootCommandResult;
CommandResult = commandResult;
this.valueResultDictionary = valueResults;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably do not need this this

@@ -159,6 +165,9 @@ public IReadOnlyList<string> UnmatchedTokens
public override string ToString() => ParseDiagramAction.Diagram(this).ToString();
*/

public ValueResult? GetValueResult(CliSymbol symbol)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider TryGetValue here

/// <summary>
/// The argument to which the result applies.
/// </summary>
public CliArgument Argument { get; }

internal bool ArgumentLimitReached => Argument.Arity.MaximumNumberOfValues == (_tokens?.Count ?? 0);


Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove blank line

// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean up usings

var dict = new Dictionary<CliSymbol, ValueResult>();
foreach (KeyValuePair<CliSymbol, SymbolResult> pair in this)
{
var result = pair.Value;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace

@@ -0,0 +1,17 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding this code to ArgumentResult

Also, be sure the ValueResultOutcome method is used

@KathleenDollard KathleenDollard changed the title Temporary to show PR issue Support for ValueResult as public type to carry value and location Apr 5, 2024
@KathleenDollard KathleenDollard force-pushed the powderhouse-valueresult branch 2 times, most recently from 20849d6 to 5d1e815 Compare April 16, 2024 21:54
@KathleenDollard KathleenDollard force-pushed the powderhouse-valueresult branch 2 times, most recently from ee98942 to 67fc72a Compare April 17, 2024 01:48
@KathleenDollard KathleenDollard force-pushed the powderhouse-valueresult branch from 67fc72a to 9ae597c Compare April 17, 2024 02:10
@KathleenDollard KathleenDollard merged commit 4457da4 into dotnet:main-powderhouse Apr 19, 2024
@KathleenDollard KathleenDollard deleted the powderhouse-valueresult branch April 20, 2024 00:05
@KathleenDollard KathleenDollard added the Powderhouse Work to isolate parser and features label Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Powderhouse Work to isolate parser and features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants