Skip to content

Commit

Permalink
Reduce netcore errors with #if NETSTANDARD1_6
Browse files Browse the repository at this point in the history
  • Loading branch information
adamchester committed Feb 19, 2017
1 parent 3e42705 commit d25376d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
5 changes: 3 additions & 2 deletions Expecto.netcore/Expecto.netcore.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
<Version>1.1.2</Version>
<OutputType>Library</OutputType>
<TargetFramework>netstandard1.6</TargetFramework>
<DebugType>pdbonly</DebugType>
<DebugType>portable</DebugType>
<DefineConstants Condition=" '$(TargetFramework)' == 'netstandard1.6' ">NETSTANDARD1_6;@(DefineConstants)</DefineConstants>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\paket-files\logary\logary\src\Logary.Facade\Facade.fs" />
<Compile Include="..\Expecto\Expecto.fs" />
Expand Down
21 changes: 17 additions & 4 deletions Expecto/Expecto.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Expecto
namespace Expecto

#nowarn "46"

Expand Down Expand Up @@ -315,7 +315,6 @@ module Impl =
open Expecto.Logging.Message
open Helpers
open Mono.Cecil
open Mono.Cecil.Rocks

let logger = Log.create "Expecto"

Expand Down Expand Up @@ -556,14 +555,18 @@ module Impl =
summary = fun summary ->
let spirit =
if summary.errored.Length + summary.failed.Length = 0 then
#if !NETSTANDARD1_6
if Console.OutputEncoding.BodyName = "utf-8" then
"ᕙ໒( ˵ ಠ ╭͜ʖ╮ ಠೃ ˵ )७ᕗ"
else
#endif
"Success!"
else
#if !NETSTANDARD1_6
if Console.OutputEncoding.BodyName = "utf-8" then
"( ರ Ĺ̯ ರೃ )"
else
#endif
""
logger.logWithAck Info (
eventX "EXPECTO! {total} tests run in {duration} – {passes} passed, {ignores} ignored, {failures} failed, {errors} errored. {spirit}"
Expand Down Expand Up @@ -900,9 +903,15 @@ module Impl =
let asMembers x = Seq.map (fun m -> m :> MemberInfo) x
let bindingFlags = BindingFlags.Public ||| BindingFlags.Static
fun (t: Type) ->
#if NETSTANDARD1_6
[ t.GetTypeInfo().GetMethods bindingFlags |> asMembers
t.GetTypeInfo().GetProperties bindingFlags |> asMembers
t.GetTypeInfo().GetFields bindingFlags |> asMembers ]
#else
[ t.GetMethods bindingFlags |> asMembers
t.GetProperties bindingFlags |> asMembers
t.GetFields bindingFlags |> asMembers ]
#endif
|> Seq.collect id
|> Seq.choose testFromMember
|> Seq.toList
Expand All @@ -925,7 +934,11 @@ module Impl =

let getFuncTypeToUse (testFunc:unit->unit) (asm:Assembly) =
let t = testFunc.GetType()
if t.Assembly.FullName = asm.FullName then
#if NETSTANDARD1_6
if t.GetTypeInfo().Assembly.FullName = asm.FullName then
#else
if t.GetType().Assembly.FullName = asm.FullName then
#endif
t
else
let nestedFunc =
Expand Down Expand Up @@ -959,7 +972,7 @@ module Impl =

let getMethods typeName =
match types.TryFind (getEcma335TypeName typeName) with
| Some t -> Some (t.GetMethods())
| Some t -> Some (t.Methods)
| _ -> None

let optionFromObj = function
Expand Down

0 comments on commit d25376d

Please sign in to comment.