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

Support .NET Core #126

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6f3f21b
add unquote project.json
enricosada Jul 26, 2016
bd29779
no exception serialization, like portable profile
enricosada Jul 26, 2016
c33c5b9
ignore project.lock.json
enricosada Jul 26, 2016
f03ec26
no appdomain
enricosada Jul 26, 2016
03bc3d6
IsGenericType,GetGenericTypeDefinition are defined in TypeInfo
enricosada Jul 26, 2016
a566bb2
compiler bug? without the open System.Reflection, the compiler return…
enricosada Jul 26, 2016
1e93a19
GetCustomAttributes is in TypeInfo and is seq not array
enricosada Jul 26, 2016
8e8abb8
IsGenericTypeDefinition is inside TypeInfo
enricosada Jul 26, 2016
4663b7c
reflection, refactored to avoid duplicate logic
enricosada Jul 26, 2016
b06d495
temporary fail on netstandard, to make it build
enricosada Jul 26, 2016
129a504
add UnquoteTests project.json
enricosada Jul 26, 2016
e8308ac
no stackframe in netstandard
enricosada Jul 26, 2016
fa2660e
need to open System.Reflection to use GetTypeInfo (compiler bug?)
enricosada Jul 26, 2016
2f03a94
skip failing test, dont know if should fail on .net core (like mono) …
enricosada Jul 26, 2016
50cdfd1
add VerifyNonFrameworkSupport project.json
enricosada Jul 26, 2016
5178fb4
add VerifyXunit2Support project.json
enricosada Jul 26, 2016
ec022ca
add VerifyNunit3Support project.json
enricosada Jul 26, 2016
d32f657
add dotnet-mergenupkg tool
enricosada Jul 26, 2016
5dabdf9
build.bat will add netstandard to package, if UNQUOTE_NETCORE env var…
enricosada Jul 26, 2016
5de36f2
dont use f# 4 compiler define conditionals
enricosada Jul 26, 2016
ab53b9c
fix portable profile
enricosada Jul 28, 2016
81b71ed
build .net core if .net core sdk is installed, dont check env var
enricosada Jul 28, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ builds/
packages/
.vs/
*.suo
project.lock.json
9 changes: 9 additions & 0 deletions Unquote/AssertionFailedException.fs
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
namespace Swensen.Unquote

open System
#if NETSTANDARD1_6
#else
open System.Runtime.Serialization
#endif

///Exception used to signal assertion failure to be caught by any exception framework
///(used when not NUnit or xUnit.net or when compiled for framework versions lacking serialization features)
#if PORTABLE
#else
#if NETSTANDARD1_6
#else
[<Serializable>]
#endif
#endif
type AssertionFailedException =
inherit exn
new () = { inherit exn() }
new (message:string) = { inherit exn(message) }
new (message:string, innerException:Exception) = { inherit exn(message, innerException) }
#if PORTABLE
#else
#if NETSTANDARD1_6
#else
//although we should, we can't make this protected: http://www.atalasoft.com/cs/blogs/stevehawley/archive/2010/08/10/using-a-proxy-class-to-fix-f-protected-access-limitation.aspx
new (info:SerializationInfo, context:StreamingContext) = { inherit exn(info, context) } //must implement for Serilization to succeed
#endif
#endif
4 changes: 4 additions & 0 deletions Unquote/Assertions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ module Internal =

#if PORTABLE
outputReducedExprsMsg outputGenericTestFailedMsg
#else
#if NETSTANDARD1_6
outputReducedExprsMsg outputGenericTestFailedMsg
#else
//moved from top-level private module function since silverlight does not support printf (i.e. standard out)
let fsiTestFailed (reducedExprs:Expr list) additionalInfo =
Expand Down Expand Up @@ -121,6 +124,7 @@ module Internal =
(fun msg -> del.Invoke(msg)) |> outputReducedExprsMsg
| Generic ->
outputGenericTestFailedMsg |> outputReducedExprsMsg
#endif
#endif

let inline expectedExnButWrongExnRaisedMsg ty1 ty2 = sprintf "Expected exception of type '%s', but '%s' was raised instead" ty1 ty2
Expand Down
3 changes: 3 additions & 0 deletions Unquote/Decompilation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ module CustomContext =

module CC = CustomContext


open System.Reflection

//todo:
// precedence applied to lhs of . not right, see skipped SourceOpTests
// note: Dictionary<_,_> values are not sprinted as nicely as in FSI, consider using FSI style
Expand Down
11 changes: 10 additions & 1 deletion Unquote/EvaluationException.fs
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
namespace Swensen.Unquote
open System
#if NETSTANDARD1_6
#else
open System.Runtime.Serialization
#endif
//see http://stackoverflow.com/questions/1619567/f-type-inheritance
//see http://stackoverflow.com/questions/94488/what-is-the-correct-way-to-make-a-custom-net-exception-serializable
//see http://msdn.microsoft.com/en-us/library/ms229064.aspx
///Exception used to distinguish an error in the quotation evaluation engine.
#if PORTABLE
#else
#if NETSTANDARD1_6
#else
[<Serializable>] //must mark as Serializable for serialization to succeed
#endif
#endif
type EvaluationException =
inherit exn
new () = { inherit exn() }
new (message:string) = { inherit exn(message) }
new (message:string, innerException:Exception) = { inherit exn(message, innerException) }
#if PORTABLE
#else
#if NETSTANDARD1_6
#else
//although we should, we can't make this protected: http://www.atalasoft.com/cs/blogs/stevehawley/archive/2010/08/10/using-a-proxy-class-to-fix-f-protected-access-limitation.aspx
new (info:SerializationInfo, context:StreamingContext) = { inherit exn(info, context) } //must implement for Serilization to succeed
#endif
#endif
#endif
23 changes: 21 additions & 2 deletions Unquote/ExtraReflection.fs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,14 @@ module SymbolicOps =
Some(sprintf "(%s)" symbol)
| _ -> None

open System.Reflection

let inline isGenericTypeDefinedFrom<'a> (ty:Type) =
#if NETSTANDARD1_6
ty.GetTypeInfo().IsGenericType && ty.GetTypeInfo().GetGenericTypeDefinition() = typedefof<'a>
#else
ty.IsGenericType && ty.GetGenericTypeDefinition() = typedefof<'a>
#endif

///is the top-level FSI module
let inline isFsiModule (declaringType:Type) =
Expand All @@ -190,7 +196,11 @@ let inline isFsiModule (declaringType:Type) =
//best we can seem to do
let isOpenModule (declaringType:Type) =
isFsiModule declaringType ||
#if NETSTANDARD1_6
declaringType.GetTypeInfo().GetCustomAttributes(true) |> Array.ofSeq
#else
declaringType.GetCustomAttributes(true)
#endif
|> Array.tryFind (function | :? AutoOpenAttribute -> true | _ -> false)
|> (function | Some _ -> true | None -> false)

Expand Down Expand Up @@ -308,7 +318,11 @@ let sprintSig (outerTy:Type) =

match ty.GetGenericArgumentsArrayInclusive() with
| args when args.Length = 0 ->
#if NETSTANDARD1_6
(if outerTy.GetTypeInfo().IsGenericTypeDefinition then "'" else "") + (displayName cleanName) + arrSig
#else
(if outerTy.IsGenericTypeDefinition then "'" else "") + (displayName cleanName) + arrSig
#endif
| args when cleanName = "System.Tuple" ->
(applyParens (if arrSig.Length > 0 then 0 else 3) (sprintf "%s" (args |> Array.map (sprintSig 3) |> String.concat " * "))) + arrSig
| [|lhs;rhs|] when cleanName = "Microsoft.FSharp.Core.FSharpFunc" -> //right assoc, binding not as strong as tuples
Expand All @@ -331,8 +345,13 @@ let genericArgsInferable (mi:MethodInfo) =
|> Seq.append (Seq.singleton miDefinition.ReturnParameter)
|> Seq.map
(fun p ->
if p.ParameterType.IsGenericParameter then [|p.ParameterType|]
elif p.ParameterType.ContainsGenericParameters then p.ParameterType.GetGenericArguments()
#if NETSTANDARD1_6
let pti = p.ParameterType.GetTypeInfo()
#else
let pti = p.ParameterType
#endif
if pti.IsGenericParameter then [|p.ParameterType|]
elif pti.ContainsGenericParameters then pti.GetGenericArguments()
else [||])
|> Seq.concat
|> Seq.map (fun t -> t.Name)
Expand Down
9 changes: 9 additions & 0 deletions Unquote/ReductionException.fs
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
namespace Swensen.Unquote

open System
#if NETSTANDARD1_6
#else
open System.Runtime.Serialization
#endif

///Exception used to indicate an exception captured during reduction (typically not raised itself).
#if PORTABLE
#else
#if NETSTANDARD1_6
#else
[<Serializable>]
#endif
#endif
type ReductionException =
inherit exn
new (inner:Exception) = { inherit exn("An exception was raised during quotation reduction", inner) }
#if PORTABLE
#else
#if NETSTANDARD1_6
#else
//although we should, we can't make this protected: http://www.atalasoft.com/cs/blogs/stevehawley/archive/2010/08/10/using-a-proxy-class-to-fix-f-protected-access-limitation.aspx
new (info:SerializationInfo, context:StreamingContext) = { inherit exn(info, context) } //must implement for Serilization to succeed
#endif
#endif

48 changes: 48 additions & 0 deletions Unquote/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"compilerName": "fsc",
"compile": {
"includeFiles": [
"Utils/Prelude.fs",
"Utils/Regex.fs",
"Utils/Printf.fs",
"Utils/List.fs",
"Utils/Type.fs",
"AssemblyInfo.fs",
"DynamicOperators.fs",
"EvaluationException.fs",
"Evaluation.fs",
"OperatorPrecedence.fs",
"ExtraReflection.fs",
"ExtraPatterns.fs",
"ReductionException.fs",
"Decompilation.fs",
"Reduction.fs",
"UnquotedExpression.fs",
"Extensions.fs",
"Operators.fs",
"AssertionFailedException.fs",
"Assertions.fs"
]
}
},
"dependencies": {
"Microsoft.FSharp.Core.netcore": "1.0.0-alpha-*"
},
"frameworks": {
"netstandard1.6": {
"dependencies": {
"NETStandard.Library": "1.6.0"
}
}
},
"tools": {
"dotnet-mergenupkg": { "target": "package", "version": "1.0.*" },
"dotnet-compile-fsc": {
"version": "1.0.0-preview2-*",
"imports": "dnxcore50"
}
}
}
4 changes: 4 additions & 0 deletions UnquoteTests/CheckedDynamicOperatorsEvaluationTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ let ``ToUInt64 reflective`` () =

#if MONO
#else
#if NETCOREAPP1_0
[<Fact(Skip="This fails on .net core, is ok?")>]
#else
[<Fact>]
#endif
let ``ToUIntPtr primitive`` () =
testEvalCheckedOverflow <@ Checked.unativeint UInt64.MaxValue @>
#endif
Expand Down
3 changes: 3 additions & 0 deletions UnquoteTests/DecompilationTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ let ``generic NewUnionCase with nested construction`` () =
#else
#if PORTABLE //can't access stack frame
#else
#if NETCOREAPP1_0 //can't access stack frame
#else
#if NET40 //relative file names cause issues
#else
//issue #3 -- UnionCaseTests
Expand All @@ -413,6 +415,7 @@ let ``union case test list not requiring op_Dynamic`` () = //this test is a litt
#endif
#endif
#endif
#endif

let h = World (Hello2(Hello 3, true))
[<Fact>] //issue #3
Expand Down
49 changes: 49 additions & 0 deletions UnquoteTests/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"compilerName": "fsc",
"compile": {
"includeFiles": [
"EvaluationTests.fs",
"DynamicOperatorsEvaluationTests.fs",
"CheckedDynamicOperatorsEvaluationTests.fs",
"FSharpNameTests.fs",
"DecompilationTests.fs",
"ReductionTests.fs",
"AssertionOperatorsTests.fs",
"UnquotedExpressionTests.fs"
]
}
},
"dependencies": {
"Microsoft.FSharp.Core.netcore": "1.0.0-alpha-*",
"System.Runtime.Serialization.Primitives": "4.1.1",
"xunit": "2.2.0-beta2-build3300",
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"Unquote": { "target": "project" }
},
"testRunner": "xunit",
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
},
"imports": [
"dotnet5.4",
"portable-net451+win8"
]
}
},

"tools": {
"dotnet-compile-fsc": {
"version": "1.0.0-preview2-*",
"imports": "dnxcore50"
}
}

}
36 changes: 36 additions & 0 deletions VerifyNonFrameworkSupport/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true,
"compilerName": "fsc",
"compile": {
"includeFiles": [
"Program.fs"
]
}
},
"dependencies": {
"Microsoft.FSharp.Core.netcore": "1.0.0-alpha-*",
"Unquote": {
"target": "project"
}
},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
},
"imports": "dnxcore50"
}
},
"tools": {
"dotnet-compile-fsc": {
"version": "1.0.0-preview2-*",
"imports": "dnxcore50"
}
}
}
41 changes: 41 additions & 0 deletions VerifyNunit3Support/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"compilerName": "fsc",
"compile": {
"includeFiles": [
"VerifyNunit3Support.fs"
]
}
},

"dependencies": {
"Microsoft.FSharp.Core.netcore": "1.0.0-alpha-*",
"NUnit": "3.4.1",
"dotnet-test-nunit": "3.4.0-beta-1",
"Unquote": { "target": "project" }
},

"testRunner": "nunit",

"frameworks": {
"netcoreapp1.0": {
"imports": "portable-net45+win8",
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0-*",
"type": "platform"
}
}
}
},

"tools": {
"dotnet-compile-fsc": {
"version": "1.0.0-preview2-*",
"imports": "dnxcore50"
}
}

}
Loading