-
Notifications
You must be signed in to change notification settings - Fork 744
Calling NUnitLite from LINQpad, can't parse assembly path #3710
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
Comments
I don't use NUnitLite or LINQpad, so this is just testing locally. From the log it seems that it tries to run the assembly file called Ps. I don't think we do a lot of validation of the filename - the stacktrace above is mostly .NET code. |
@astrohart Could you please confirm which version of Linqpad you see this on? |
Hi @stevenaw I am using LINQPad 5.43.00(AnyCPU). |
Just now tried a run as: LINQPad Query:
The following output was displayed: See the circled
It seems to me as if there is a thread somewhere that has not called |
Thanks @astrohart |
I am confused what is it you are able to reproduce? The |
Sorry, I've been juggling commenting from my phone while testing on a desktop. Let me elaborate: When running this:
From a file saved on my desktop I can reproduce the NullReferenceException on Linqpad 5.43.00
|
From looking at the stack trace, I would not be suprised but it seems as if LINQPad itself is not disposing of an internally-used |
Perhaps should the |
I haven't had the chance to dig too much into why this is happening, but when testing locally with This invocation line:
Now throws this:
While using @mikkelbu 's snippet:
works successfully for me now on Linqpad 6. On Linqpad 5 however, I see the same It's tough for me to tell whether this is because of a difference in Linqpad or NUnitlite, since the different versions of Linqpad also consume different versions of NUnitlite (full framework vs core/NET5). I'm going to label this as a bug for further investigation |
There's a use SO answer on this https://stackoverflow.com/a/53753215/2086 |
This may have been fixed via #4325 which is scheduled for the next release |
Confirmed using the
The following linqpad script now no longer errors, and will instead run as expected
|
Indeed, I have just tried the following code: void Main()
{
new TextRunner().Execute(new[] { $@"{Assembly.GetAssembly(typeof(UserQuery)).Location}" });
}
// Define other methods and classes here
[Test]
public void TestMethd()
{
Assert.Pass();
} in LINQPad, and it runs! The output is:
Huzzah! 🚀 |
I am a frequent user of LINQPad and I am trying to run some really quick unit-tests in LINQPad and I have done so by adding the NUnitLite NuGet package to my LINQPad query.
I went on this blog and they advised utiling
NUnitLite
and using the following code in aC# Program
LINQPad query'sMain()
method:Obviously, we're assuming that the NuGet has been added to the query and that all the proper namespaces are brought in.
Well, this does not work with the latest NUnitLite. The results I get are;
And then a
NullReferenceException
is caught.So, I tried to give it the assembly name as follows:
I get:
I am not 100% sure why I am getting a
NotSupportedException
here. There are no spaces in the path and it's a perfectly valid file name. I can highlight the path, copy it and paste it into File Explorer and there's a file that certainly exists at that path.Suspected Issue: NUnitLite, instead of simply calling
System.IO.File.Exists()
on whatever value it's given for theassembly
parameter (and being done with it), instead is laboriously trying to validate the path and stuff. I think this is hogwash.Suggested Fix: Parse out whatever value is passed to
assembly
and simply callSystem.IO.File.Exists(path)
on it.The text was updated successfully, but these errors were encountered: