Description
Repro steps
I added a repository here to describe the issue, without xunit for clarity. This is a stranger use-case than with a test project, but it makes it clear that xunit is not involved https://github.com/bjartwolf/fsharpnull
Part of the reason for this to show now, I guess, is that console apps now have no main method by default.
Instructions similar to this below, but using xunit as that is a more typical use-case.
dotnet new console -lang "F#" -o consoleapp
dotnet new xunit -lang "F#" -o test
cd test
dotnet add reference ..\consoleapp\consoleapp.fsproj
- Add a point free function like
let parseLine (s:string) = s
let parseLines = Array.map parseLine
and a test like
module Tests
open System
open Xunit
open Program
[<Fact>]
let ``My test`` () =
let foo = parseLines [|"foo"|]
Assert.True(true)
Expected behavior
I expect it to work, or perhaps some warning that point free functions can cause issues across assemblies?
Actual behavior
Null pointer reference when invoking the function (as shown in the repository, this happens also without xunit, but the use-case where this happens is typically a console app with xunit or some other test framework. This can make it a bit more tricky to see what is going on, it is easy to blame the testrunner for the behavoir.)

Known workarounds
Do not use point-free function, add a named argument to the function when exposing it outside assemblies, as pr language guidelines. This avoids the FSharpFunc
or
Add a main method like so in the console app. This somehow causes something to initialize differently?
[<EntryPoint>]
let main args =
0
or
Add the code to a classlib and reference that in the console app. Classlibs work too.
Related information
Asked for some input in the discord first https://discord.com/channels/196693847965696000/441274967607214091/1331376422555746347 and was asked to submit. Nice to have someone to discuss with before posting issues directly. Seems like from the comment that it might has been observed before (or maybe that was something else...)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status