提交 c3c50eef 编写于 作者: S Stephen Swensen 提交者: KevinRansom

Fix #68 - filter out type initializer from Type.GetConstructor portable implementation

上级 b9d2f3fb
......@@ -67,3 +67,7 @@ type FSharpQuotationsTests() =
let wrongValue = <@ "!" @>
Check.argumentException(fun () -> ExprShape.RebuildShapeCombination(shape, [wrongValue;lambda]))
| _ -> Assert.Fail()
[<Test>]
member x.GetConstructorFiltersOutStaticConstructor() =
ignore <@ System.Exception() @>
\ No newline at end of file
......@@ -125,9 +125,12 @@ module ReflectionAdapters =
member this.GetConstructor(parameterTypes : Type[]) =
this.GetTypeInfo().DeclaredConstructors
|> Seq.filter (fun ci ->
let parameters = ci.GetParameters()
(parameters.Length = parameterTypes.Length) &&
(parameterTypes, parameters) ||> Array.forall2 (fun ty pi -> pi.ParameterType.Equals ty)
not ci.IsStatic && //exclude type initializer
(
let parameters = ci.GetParameters()
(parameters.Length = parameterTypes.Length) &&
(parameterTypes, parameters) ||> Array.forall2 (fun ty pi -> pi.ParameterType.Equals ty)
)
)
|> Seq.toArray
|> commit
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册