Mono.Linker.LinkerFatalErrorException: /home/runner/work/FSharp.SystemTextJson/FSharp.SystemTextJson/src/FSharp.SystemTextJson/Collection.fs(15,9): error IL1005: System.Text.Json.Serialization.JsonListConverter<T>.Read(Utf8JsonReader&,Type,JsonSerializerOptions): Error processing method 'System.Text.Json.Serialization.JsonListConverter<T>.Read(Utf8JsonReader&,Type,JsonSerializerOptions)' in assembly 'FSharp.SystemTextJson.dll'
---> System.InvalidOperationException: Operation is not valid due to the current state of the object.
at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.GetValueNodeFromGenericArgument(TypeReference genericArgument)
at Mono.Linker.Dataflow.ReflectionMethodBodyScanner.ProcessGenericArgumentDataFlow(GenericParameter genericParameter, TypeReference genericArgument, IMemberDefinition source)
at Mono.Linker.Steps.MarkStep.MarkGenericArgumentConstructors(IGenericInstance instance, IMemberDefinition sourceLocationMember)
at Mono.Linker.Steps.MarkStep.MarkGenericArguments(IGenericInstance instance, IMemberDefinition sourceLocationMember)
at Mono.Linker.Steps.MarkStep.GetOriginalMethod(MethodReference method, DependencyInfo reason, IMemberDefinition sourceLocationMember)
at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference, DependencyInfo reason, IMemberDefinition sourceLocationMember)
at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction, MethodDefinition method, Boolean& requiresReflectionMethodBodyScanner)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method, DependencyInfo& reason)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
--- End of inner exception stack trace ---
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at Mono.Linker.Driver.Run(ILogger customLogger)
Optimizing assemblies for size, which may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
/usr/local/share/dotnet/sdk/5.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.ILLink.targets(41,5): error NETSDK1144: Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false.
The trigger is the PublishTrimmed=true. This is no a bug per se of FSharp.SystemTextJson but a bug of the linker.
Hello Loïc,
I'm trying to trim some projects on .net 5 with those parameters:
and I'm getting this error on publish:
The trigger is the
PublishTrimmed=true
. This is no a bug per se of FSharp.SystemTextJson but a bug of the linker.Just for information, it looks like there is a workaround meanwhile: https://github.com/dotnet/runtime/issues/43222#issuecomment-706438221
Maybe this coud be ok to implement this ? It will try this on my side and let you know.