Skip to content

Commit

Permalink
Fix merge issue (dotnet#7518)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinRansom committed Sep 9, 2019
1 parent 665b33c commit d520c29
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1,926 deletions.
33 changes: 24 additions & 9 deletions tests/FSharp.Core.UnitTests/LibraryTestFx.fs
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,40 @@ module SurfaceArea =

// gets string form of public surface area for the currently-loaded FSharp.Core
let private getActual () =

// get current FSharp.Core
let asm =
typeof<int list>.Assembly
let asm = typeof<int list>.Assembly
let fsCoreFullName = asm.FullName

// public types only
let types =
asm.GetExportedTypes()
let types = asm.ExportedTypes |> Seq.filter (fun ty -> let ti = ty.GetTypeInfo() in ti.IsPublic || ti.IsNestedPublic) |> Array.ofSeq
let typenames = new System.Collections.Generic.List<string>()

// extract canonical string form for every public member of every type
let getTypeMemberStrings (t : Type) =
// for System.Runtime-based profiles, need to do lots of manual work
t.GetMembers()
|> Array.map (fun v -> sprintf "%s: %s" (v.ReflectedType.ToString()) (v.ToString()))

let getMembers (t : Type) =
let ti = t.GetTypeInfo()
let cast (info: #MemberInfo) = (t, info :> MemberInfo)
let isDeclaredInFSharpCore (m:MemberInfo) = m.DeclaringType.Assembly.FullName = fsCoreFullName
seq {
yield! t.GetRuntimeEvents() |> Seq.filter (fun m -> m.AddMethod.IsPublic && m |> isDeclaredInFSharpCore) |> Seq.map cast
yield! t.GetRuntimeProperties() |> Seq.filter (fun m -> m.GetMethod.IsPublic && m |> isDeclaredInFSharpCore) |> Seq.map cast
yield! t.GetRuntimeMethods() |> Seq.filter (fun m -> m.IsPublic && m |> isDeclaredInFSharpCore) |> Seq.map cast
yield! t.GetRuntimeFields() |> Seq.filter (fun m -> m.IsPublic && m |> isDeclaredInFSharpCore) |> Seq.map cast
yield! ti.DeclaredConstructors |> Seq.filter (fun m -> m.IsPublic) |> Seq.map cast
yield! ti.DeclaredNestedTypes |> Seq.filter (fun ty -> ty.IsNestedPublic) |> Seq.map cast
} |> Array.ofSeq


getMembers t
|> Array.map (fun (ty, m) -> sprintf "%s: %s" (ty.ToString()) (m.ToString()))

let actual =
types |> Array.collect getTypeMemberStrings

asm,actual
asm, actual

// verify public surface area matches expected
let verify expected platform (fileName : string) =
let normalize (s:string) =
Expand Down
Loading

0 comments on commit d520c29

Please sign in to comment.