Skip to content
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

`FSharpType.IsUnion` broken inside of F# Interactive due to missing `System.Reflection.Emit.AssemblyBuilder.ReflectionOnly` implementation #13028

baronfel opened this issue Feb 15, 2019 · 3 comments · Fixed by #14406


Copy link

@baronfel baronfel commented Feb 15, 2019

Steps to Reproduce

For the FSAutoComplete project (language server tooling for F#) we run a suite of integration tests in F# Interactive to test various editor tooling features like linting, autocompletion, tooltips, and error reporting. We run these tests against a travis CI test suite that covers (on linux) mono versions 5.18, latest (5.18 right now) and weekly (

Right now we have a few tests failing on weekly due to the use of the FSharpType.IsUnion function, which uses System.Reflection.Emit.AssemblyBuilder.ReflectionOnly, which is not supported on mono master from what I can tell(per This certainly breaks our use case and will likely break other reflection-focused use cases in F# Interactive, so I wanted to get ahead of the next stable release and ask if there's a timeline to implement this member and/or a way to help implement or workaround its absence.

A sample test run can be found at, and the actual failure can be seen on this run:

Current Behavior

Tests that stress the HTTP transport in FSAutoComplete fail on nightly with NotImplementedExceptions

Expected Behavior

Tests are able to use reflection-based functionality in F# Interactive

On which platforms did you notice this

[ ] macOS
[x] Linux
[ ] Windows

Version Used:

Travis CI weekly as of February 14th, 2019 (


A stacktrace of json serialization of a union type
System.NotImplementedException: The method or operation is not implemented.
  at System.Reflection.Emit.AssemblyBuilder.get_ReflectionOnly () [0x00000] in <dfbc4bb8759d4df18fd61c54e0b9082a>:0 
  at Microsoft.FSharp.Reflection.Impl.tryFindCompilationMappingAttributeFromType (System.Type typ) [0x00012] in <5b02f7c8dff9fae1a7450383c8f7025b>:0 
  at Microsoft.FSharp.Reflection.Impl.tryFindSourceConstructFlagsOfType (System.Type typ) [0x00000] in <5b02f7c8dff9fae1a7450383c8f7025b>:0 
  at Microsoft.FSharp.Reflection.Impl.isExceptionRepr (System.Type typ, System.Reflection.BindingFlags bindingFlags) [0x00000] in <5b02f7c8dff9fae1a7450383c8f7025b>:0 
  at Microsoft.FSharp.Reflection.Impl.getTypeOfReprType (System.Type typ, System.Reflection.BindingFlags bindingFlags) [0x00000] in <5b02f7c8dff9fae1a7450383c8f7025b>:0 
  at Microsoft.FSharp.Reflection.FSharpType.IsUnion (System.Type typ, Microsoft.FSharp.Core.FSharpOption`1[T] bindingFlags) [0x00026] in <5b02f7c8dff9fae1a7450383c8f7025b>:0 
  at (wrapper dynamic-method) Microsoft.FSharp.Reflection.FSharpType.Boolean IsUnion(System.Type, Microsoft.FSharp.Core.FSharpOption`1[System.Reflection.BindingFlags])(object,object[])
  at Newtonsoft.Json.Converters.DiscriminatedUnionConverter.CanConvert (System.Type objectType) [0x00060] in <836484b0267d488c8d30f28b57efebd9>:0 
  at Newtonsoft.Json.JsonSerializer.GetMatchingConverter (System.Collections.Generic.IList`1[T] converters, System.Type objectType) [0x0000f] in <836484b0267d488c8d30f28b57efebd9>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.InitializeContract (Newtonsoft.Json.Serialization.JsonContract contract) [0x00052] in <836484b0267d488c8d30f28b57efebd9>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract (System.Type objectType) [0x00007] in <836484b0267d488c8d30f28b57efebd9>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract (System.Type objectType) [0x0010f] in <836484b0267d488c8d30f28b57efebd9>:0 
  at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00034] in <dfbc4bb8759d4df18fd61c54e0b9082a>:0 
  at Newtonsoft.Json.Utilities.ThreadSafeStore`2[TKey,TValue].Get (TKey key) [0x00000] in <836484b0267d488c8d30f28b57efebd9>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract (System.Type type) [0x0000b] in <836484b0267d488c8d30f28b57efebd9>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.GetContractSafe (System.Object value) [0x00016] in <836484b0267d488c8d30f28b57efebd9>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00028] in <836484b0267d488c8d30f28b57efebd9>:0 
  at Newtonsoft.Json.JsonSerializer.SerializeInternal (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x0023a] in <836484b0267d488c8d30f28b57efebd9>:0 
  at Newtonsoft.Json.JsonSerializer.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00000] in <836484b0267d488c8d30f28b57efebd9>:0 
  at Newtonsoft.Json.JsonConvert.SerializeObjectInternal (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializer jsonSerializer) [0x00028] in <836484b0267d488c8d30f28b57efebd9>:0 
  at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00007] in <836484b0267d488c8d30f28b57efebd9>:0 
  at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value) [0x00000] in <836484b0267d488c8d30f28b57efebd9>:0 
  at FSI_0001.TestHelpers+FsAutoCompleteWrapperHttp.doRequest[0] (System.String action, System.Int32 requestId, a r) [0x00043] in <17f6cdc310cd4dcfba2c5b97d42e4de8>:0 
  at FSI_0001.TestHelpers+FsAutoCompleteWrapperHttp.recordRequest[0] (System.String action, System.Int32 requestId, a r) [0x00016] in <17f6cdc310cd4dcfba2c5b97d42e4de8>:0 
  at FSI_0001.TestHelpers+FsAutoCompleteWrapperHttp.project (System.String s) [0x00028] in <17f6cdc310cd4dcfba2c5b97d42e4de8>:0 
  at <StartupCode$FSI_0002>.$FSI_0002.main@ () [0x00023] in <17f6cdc310cd4dcfba2c5b97d42e4de8>:0 
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <dfbc4bb8759d4df18fd61c54e0b9082a>:0 

This comment has been minimized.

Copy link

@lambdageek lambdageek commented Feb 20, 2019

This is due to e14ef8a (#12805) - System.Reflection.Assembly used to provide an icall that was used to implement this property for both for System.Reflection.Assembly and System.Reflection.Emit.AssemblyBuilder


This comment has been minimized.

Copy link

@marek-safar marek-safar commented Feb 20, 2019

@vargaz could you please address the regression


This comment has been minimized.

Copy link

@lambdageek lambdageek commented May 6, 2019

@CoffeeFlux This looks like a good getting started issue.

CoffeeFlux added a commit to CoffeeFlux/mono that referenced this issue May 7, 2019
CoffeeFlux added a commit to CoffeeFlux/mono that referenced this issue May 8, 2019
alexanderkyte pushed a commit to alexanderkyte/mono that referenced this issue May 8, 2019
* [corlib] Implement AssemblyBuilder.get_ReflectionOnly()

Fixes mono#13028

* Bump API snapshot submodule
monojenkins added a commit to monojenkins/mono that referenced this issue May 11, 2019
akoeplinger added a commit that referenced this issue May 12, 2019

* [corlib] Implement AssemblyBuilder.get_ReflectionOnly()

Fixes #13028

* Bump API snapshot submodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
4 participants
You can’t perform that action at this time.