Skip to content

Commit

Permalink
Fix stack overflow on type providers
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinRansom committed Sep 28, 2017
1 parent 780b6c4 commit a023426
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/utils/reshapedreflection.fs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ module internal ReflectionAdapters =
let isStaticFlag f = hasFlag BindingFlags.Static f
let isInstanceFlag f = hasFlag BindingFlags.Instance f
let isNonPublicFlag f = hasFlag BindingFlags.NonPublic f

//custom instance void System.Reflection.AssemblyFileVersionAttribute::.ctor(string) = { string('4.6.24410.01') }
//object[] attributes = assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false);
let isOldCorlib =
let attributes = typeof<RuntimeTypeHandle>.GetTypeInfo().Assembly.GetCustomAttributes<AssemblyFileVersionAttribute>() |> Seq.toArray
if attributes.Length = 0 then false else attributes.[0].Version = "4.6.24410.01"

#if FX_NO_TYPECODE
[<System.Flags>]
Expand Down Expand Up @@ -327,7 +333,14 @@ module internal ReflectionAdapters =
override this.Load (assemblyName:AssemblyName):Assembly =
this.LoadFromAssemblyName(assemblyName)

let globalLoadContext = new CustomAssemblyResolver()
let globalLoadContext =
// This is an unfortunate temporary fix!!!!
// ========================================
// We need to run fsi tests on a very old version of the corclr because of an unfortunate test framework
// This hack detects that, and uses the old code.
// On slightly newer code AssemblyLoadContext.Default is the way to go.
if isOldCorlib then new CustomAssemblyResolver() :> AssemblyLoadContext
else AssemblyLoadContext.Default

#endif
type System.Reflection.Assembly with
Expand Down

0 comments on commit a023426

Please sign in to comment.