Skip to content

Nulling a property of CommandLineArgumentsConfiguration between assigning it to CommandLineArguments.Configuration and calling CommandLineArguments.TryParse() or .DisplayHelp() results in NullReferenceExceptions #62

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

Closed
akamsteeg opened this issue May 5, 2020 · 0 comments
Assignees
Labels
Milestone

Comments

@akamsteeg
Copy link
Owner

It's possible to create a CommandLineArgumentsConfiguration object, assign it to CommandLineArguments.Configuration and then null the Parser and/or HelpWriter property of the configuration. This results in NullRefefenceExceptions when calling CommandLineArguments.TryParse() or CommandLineArguments.DisplayHelp() because the configuration is only validated when assiging it to CommandLineArguments.Configuration.

Example

var config = new CommandLineArgumentsConfiguration()
{
  Parser = new WindowsStyleParser(),
  HelpWriter = new WindowsStyleHelpWriter()
};

CommandLineArguments.Configuration = config; // Configuration is validated here

config.Parser = null;

CommandLineArguments.TryParse(args, out var parsedArguments);; // NullReferenceException
@akamsteeg akamsteeg added the bug label May 5, 2020
@akamsteeg akamsteeg added this to the 3.x milestone May 5, 2020
@akamsteeg akamsteeg self-assigned this May 5, 2020
@akamsteeg akamsteeg modified the milestones: 3.x, 3.1 Jul 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant