Skip to content
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

Expose value and error on parser result #634

Conversation

johnjaylward
Copy link
Contributor

@johnjaylward johnjaylward commented May 22, 2020

Fixes #543
Fixes #165

@moh-hassan no existing tests break when I run them through visual studio. I have not added any new tests. Do you want to see any specific examples be tested?

@johnjaylward johnjaylward force-pushed the ExposeValueAndErrorOnParserResult branch from 4311b05 to 4bc7803 Compare May 22, 2020 15:28
@johnjaylward johnjaylward force-pushed the ExposeValueAndErrorOnParserResult branch from 4bc7803 to 108b208 Compare May 22, 2020 15:33

internal NotParsed(TypeInfo typeInfo, IEnumerable<Error> errors)
: base(ParserResultType.NotParsed, typeInfo)
internal NotParsed(IEnumerable<Error> errors, TypeInfo typeInfo)
Copy link
Collaborator

@moh-hassan moh-hassan May 22, 2020

Choose a reason for hiding this comment

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

Is there a reason to switch the parameters of ctor? It's better to keep internal API the same.
It also keep tests without change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was trying to be have the API be consistent across the Hierarchy.
ParseResult(value/error, type) matches Parsed(value, type) and NotParsed(error, type)

I thought it made it easier to see the relation between the constructors better, but I can revert it if you prefer having the parameter orders not match.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, but keeping test without change is very necessary. It proves no break change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I understand your comment. Are you saying that there may be other places using the "internal" constructor outside of this library? That shouldn't be possible unless someone is doing very weird reflection:

https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/internal

the change should only affect the internals of this library, which includes the test cases.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Internals are used by other PRs and test suit.
There are some PRs are still open and sure that will effect their work when merged and cause confliction when merging.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will revert those changes then.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for the good work.

@moh-hassan
Copy link
Collaborator

Good solution.
Please, can you add a test case for simple option and simple two verbs to test the new feature.
These tests can be used in wiki.

@shravan2x
Copy link

@johnjaylward Thank you so much for making this PR! The old flow felt very awkward and this change makes my code cleaner :)

@johnjaylward johnjaylward force-pushed the ExposeValueAndErrorOnParserResult branch from 108b208 to 3094bfb Compare May 22, 2020 21:48
@johnjaylward
Copy link
Contributor Author

I added the test cases. Let me know if they match your expectations or need more improvements.

@moh-hassan
Copy link
Collaborator

Yes, the tests are enough and no breaking change 👍
Congratulation.

@moh-hassan moh-hassan added this to the 2.9 milestone May 30, 2020
@moh-hassan moh-hassan changed the base branch from master to develop June 15, 2020 15:07
@moh-hassan moh-hassan merged commit 25315f2 into commandlineparser:develop Jun 15, 2020
@johnjaylward johnjaylward deleted the ExposeValueAndErrorOnParserResult branch June 15, 2020 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose parsed options object in ParserResult Consider alternative syntax
3 participants