This repository has been archived by the owner on Jan 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 322
Result builder throwing null reference exception #892
Comments
This is an unfortunate known issue when unit-testing Exe projects that don't have an explicit Either
|
cc @cartermp for visibility. It would be great if we could somehow give a proper error/warning about this |
Thanks @dsyme, have resolved with option 2. However, I couldn't get option 1 to work? Happy to close if issue is a dupe. |
@blair55 if your project file is like this it should work: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
<Import Project="..\.paket\Paket.Restore.targets" />
</Project> |
@cartermp yep, you're right. Not sure what I was doing earlier but works with that tweak now 👍 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I'm not sure if this is the right place but I've eliminated all libraries other than
Expecto
which I'm sure is not related. It only exists to help demonstrate.Repro steps
Checkout this repo and run
dotnet run -p tests
.https://github.com/blair55/ResultBuilder-IssueRepro
Expected behavior
The test case should pass.
Actual behavior
The test case fails with
System.NullReferenceException: Object reference not set to an instance of an object.
Known workarounds
The issue can be resolved by moving all the code from
src/Program.fs
intotests/Main.fs
and re-pointing the test at the new function.Related information
Provide any related information
The text was updated successfully, but these errors were encountered: