Closed jirisykora83 closed 7 years ago
I'm sorry I didn't dig deep but it turns out that the HttpWebRequest
class was changed in .NET Core version. var ctrs = typeof(HttpWebRequest).GetConstructors();
gives you an empty array while it returns a constructor in .NET version.
@alexandrnikitin I look on currently TypeExtensions source code via decompiler and it's look currently .NET Core doesn't support GetConstructors();
public static ConstructorInfo[] GetConstructors(this Type type) { return (ConstructorInfo[]) null; }
@jirisykora83 I wouldn't be surprised if they shipped that not implemented version. But hopefully they didn't. https://github.com/dotnet/corefx/blob/release/1.0.0/src/System.Reflection.TypeExtensions/src/System/Reflection/TypeExtensions.CoreCLR.cs
I again try look on typeof(HttpWebRequest)
and here what a i get.
I think it's have constructors (non-public) but it's look currently GetConstructors(); not support non-public.
Could not reproduce this with NSub 3.0 and .NET Core 2.0. Please re-open is this is still an issue.
In .NET Core not working this code. But same code working on full .NET.
HttpWebRequest webRequestMock = Substitute.For<HttpWebRequest>();
Error message: Parent does not have a default constructor. The default constructor must be explicitly defined.
StackTrace: