DNT icon indicating copy to clipboard operation
DNT copied to clipboard

Difficult to understand error when switcher.json file has spelling mistakes.

Open viblo-majority opened this issue 1 year ago • 2 comments

I created a switcher.json file with the following content

{
  "solution": "Minority.Transactions.sln",
  "mapptings": {
      "some nuget name": "path-to-csproj"
   }

This gives a null ref exception:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Dnt.Commands.Packages.SwitchPackagesToProjectsCommand.AddProjectsToSolutionAsync(ReferenceSwitcherConfiguration configuration, IConsoleHost host) in C:\projects\dnt\src\Dnt.Commands\Packages\SwitchPackagesToProjectsCommand.cs:line 42
   at Dnt.Commands.Packages.SwitchPackagesToProjectsCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in C:\projects\dnt\src\Dnt.Commands\Packages\SwitchPackagesToProjectsCommand.cs:line 29
   at NConsole.CommandLineProcessor.ProcessSingleAsync(String[] args, Object input)
   at NConsole.CommandLineProcessor.ProcessAsync(String[] args, Object input)
   at NConsole.CommandLineProcessor.Process(String[] args, Object input)
   at Dnt.Program.Main(String[] args) in C:\projects\dnt\src\Dnt\Program.cs:line 33

Of course, this is a stupid spelling mistake to make ('mapptings' should be 'mappings'), but took me a while to find. It would have been great if it had done some kind of validation and told me I had a mistake in the file, since now I dont know if my file is bad or something else (this was the first time I tried dnt).

viblo-majority avatar Dec 09 '23 20:12 viblo-majority

https://github.com/RicoSuter/DNT/pull/141

If you have any ideas, then tell me, I want to make a small contribution to the project 🐱 While we wait for Rico to sober up from Jack Daniels, Happy New Year! ☃️

7645re avatar Jan 02 '24 17:01 7645re

I dont have any specific comment, any fix would be great from my point of view. From a quick look it seems your PR will improve the error given nicely :)

viblo-majority avatar Jan 10 '24 12:01 viblo-majority