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

Crash On Empty Config File #421

Closed
Kurt-von-Laven opened this issue Aug 25, 2021 · 0 comments · Fixed by #433
Closed

Crash On Empty Config File #421

Kurt-von-Laven opened this issue Aug 25, 2021 · 0 comments · Fixed by #433
Assignees
Labels
area:cli type:bug Something isn't working
Milestone

Comments

@Kurt-von-Laven
Copy link
Contributor

Kurt-von-Laven commented Aug 25, 2021

CSharpier crashes with the following stack trace when run with an empty .csharpierrc.yaml:

$ dotnet tool run dotnet-csharpier .
Unhandled exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at CSharpier.ConfigurationFileOptions.CreatePrinterOptions(String baseDirectoryPath, IFileSystem fileSystem) in /home/runner/work/csha
rpier/csharpier/Src/CSharpier/ConfigurationFileOptions.cs:line 27
   at CSharpier.CommandLineFormatter.<>c__DisplayClass9_0.<<Format>g__CreateFormatter|0>d.MoveNext() in /home/runner/work/csharpier/cshar
pier/Src/CSharpier/CommandLineFormatter.cs:line 69
--- End of stack trace from previous location ---
   at CSharpier.CommandLineFormatter.Format(CommandLineOptions commandLineOptions, IFileSystem fileSystem, IConsole console, Cancellation
Token cancellationToken) in /home/runner/work/csharpier/csharpier/Src/CSharpier/CommandLineFormatter.cs:line 118
   at CSharpier.Program.Run(String[] directoryOrFile, Boolean check, Boolean fast, Boolean skipWrite, Boolean writeStdout, CancellationTo
ken cancellationToken) in /home/runner/work/csharpier/csharpier/Src/CSharpier/Program.cs:line 68
   at System.CommandLine.Invocation.CommandHandler.GetResultCodeAsync(Object value, InvocationContext context)
   at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseParseErrorReporting>b__21_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass25_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass23_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__22_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseParseDirective>b__20_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseDebugDirective>b__11_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__10_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass14_0.<<UseExceptionHandler>b__0>d.MoveNext()

Instead it should probably display a helpful warning that the config file was empty?

@belav belav self-assigned this Aug 26, 2021
@belav belav added area:cli type:bug Something isn't working labels Aug 26, 2021
@belav belav added this to the 0.9.10 milestone Aug 26, 2021
belav added a commit that referenced this issue Aug 26, 2021
belav added a commit that referenced this issue Sep 11, 2021
shocklateboy92 pushed a commit that referenced this issue Sep 12, 2021
* Don't blow up on empty config files

closes #421

* Adding warning for empty config file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:cli type:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants