dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.87k stars 782 forks source link

Equality of record with private constructor from another assembly gives MethodAccessException #17773

Open ntwilson opened 7 hours ago

ntwilson commented 7 hours ago

We have a codebase with a record with a private constructor. Code in another assembly will equate instances of the record. If both assemblies are compiled with .net 8.0.3, it will work fine. If both assemblies are compiled with 8.0.4, then you will get a runtime exception

System.MethodAccessException : Attempt by method '\' to access method '\.Equals(\, System.Collections.IEqualityComparer)' failed.

Repro here. You can see the successful run for 8.0.303 and the failed run for 8.0.401 here

Known workarounds

vzarytovskii commented 5 hours ago

Duplicate of https://github.com/dotnet/fsharp/issues/17447

It's suggested to use workarounds described there. I don't think we've backported the fix to 8.0.

@KevinRansom should we? We probably should.