alirezanet / Husky.Net

Git hooks made easy with Husky.Net internal task runner! 🐶 It brings the dev-dependency concept to the .NET world!
https://alirezanet.github.io/Husky.Net/
MIT License
632 stars 29 forks source link

Extended assembly support for execute #38

Closed Xemrox closed 2 years ago

Xemrox commented 2 years ago

Details

Hello,

while writing a new csx for husky exec I tried to use System.Linq and failed to do so. This results propably from the static assembly list here: https://github.com/alirezanet/Husky.Net/blob/07f36179c589c825595b97116fa6fe82ab5514ab/src/Husky/Cli/ExecCommand.cs#L37-L39 How about we create a mechanism like the following in a csx file:

// cs_reference System.Linq;
using System.Linq;

Which hints the execution to include that particular assembly.

Greetings Xemrox

alirezanet commented 2 years ago

Hi, We already support using statements, for example, in this repository, I am using System.Text.RegularExpressions; in commit-lint.csx file. although I'm not sure why you couldn't do that! can you provide an example?

https://github.com/alirezanet/Husky.Net/blob/07f36179c589c825595b97116fa6fe82ab5514ab/.husky/csx/commit-lint.csx#L7

Also, you can add external assemblies or scripts using #r and #load keywords:

https://github.com/alirezanet/Husky.Net/blob/07f36179c589c825595b97116fa6fe82ab5514ab/.husky/csx/hello.csx#L1-L5

Xemrox commented 2 years ago

I wasn't aware of the #r and #load within csscript. Here is a broken example which can be fixed by adding a #r "System.Linq"

using System.Linq;

private var test = new [] {"a", "b", "c"};
private var test2 = test.First();