GustavEikaas / easy-dotnet.nvim

Neovim plugin written in Lua for working with .Net projects in Neovim. Makes it easier to run/test/build/debug projects. Supports both F# and C#
MIT License
53 stars 3 forks source link

feat:🎁 Allow passing additional args to `dotnet ..` #87

Closed GustavEikaas closed 1 day ago

GustavEikaas commented 1 week ago

This plugin executes a lot of dotnet .. commands, as of now these are pre-configured commands. It would be nice if there was a way for the user to pass their own args aswell dotnet .. <args> --<additional user supplied args>. This should be implemented for all commands and we should find a way to make it not interfere with the behaviour of the command.

There are a couple of cases which makes this complicated.

Testrunner: When running a test we specify --logger... because we depend on an output file to parse the results. If the user also specified the logger argument after the plugins initial argument, there would be a conflict and a bug.

The cases listed above might be something that shouldnt be solved, rather just discouraged. Like e.g Pass extra arguments at your own risk and remove them before filing an issue or a bug.

Please, anyone feel free to chime in on this

AjayKMehta commented 1 week ago

As far as dotnet test goes, specifying multiple loggers is supported. Scroll down on this page until you see -l|--logger <LOGGER>:

Specifies a logger for test results and optionally switches for the logger. Specify this parameter multiple times to enable multiple loggers.

(emphasis added)

I have done this before but if you use the same logger more than once but with different file names, the last one wins.

For example, if I run this command for one of my C# projects:

dotnet test --logger:'trx;LogFileName=testResults.xml' --logger:'trx;LogFileName=testResults2.xml' --results-directory C:\temp\tests

then I only see C:\temp\tests\testResults2.xml.

I would like to specify additional settings for dotnet test related to code coverage.

This can be done with a .runsettings file: https://learn.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file?view=vs-2022.

AjayKMehta commented 1 week ago

I would like to still have the ability to provide additional arguments supported for commands with the goal being to have sensible, intuitive defaults. yet, if someone wants to provide additional arguments, they can do so at their own risk or if we want to make this robust, how about the following:

  1. Add commonly used arguments to commands. If value is nil, do not include in CLI invocation.
  2. Add extra_args parameter. This will be a Lua table with key = argument name and value = argument value (ignored if argument is a switch, e.g. --verbose).
  3. Construct CLI invocation based on provided arguments.

I can try to sketch this out for a single command in a PR when I have time.

GustavEikaas commented 1 week ago

Github auto closing issues linked to a PR is annoying sometimes...

I would love to see an example PR on this. I exposed this ability for dotnet build lua functions but only the ones which does not pass through the terminal handler. Next step is to add it to testrunner/watcher

GustavEikaas commented 1 day ago

Testrunner now supports additional args passed through the plugin options