Skip to content

Conversation

Fumblesneeze
Copy link
Contributor

@Fumblesneeze Fumblesneeze commented Dec 17, 2017

I ran across the problem of having to know which verb had been selected when an error occured. The ParserResult would be a NotParsed<object> because I use the ParseArguments overload that takes an array of types. From that result there was no way to obtain the type of the verb except with some reflection to access these private members, so I request that typeinfo be made available.

Code now:

var typeinfo = result.GetType().GetProperty("TypeInfo", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(result);
var option = (Type)typeinfo.GetType().GetProperty("Current", BindingFlags.Public | BindingFlags.Instance).GetValue(typeinfo);

Code then:

var option = result.TypeInfo.Current;

Copy link
Member

@ericnewton76 ericnewton76 left a comment

Choose a reason for hiding this comment

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

I'm wondering if we should approach this from a different way, making an internal class public can have mutability consequences.

Perhaps the ParserResult class itself should have some kind of type info available that doesnt leak out all the internals

@ericnewton76 ericnewton76 merged commit 68d46c7 into commandlineparser:master Aug 13, 2018
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.

2 participants