Debug.Assert(type != null);
ConstructorInfo realMethod = type.GetConstructor(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, binder: null, Type.EmptyTypes, modifiers: null);
+ if (type.IsAbstract)
+ {
+ return null;
+ }
+
if (realMethod == null && !type.IsValueType)
{
return null;
Debug.Assert(type != null);
ConstructorInfo realMethod = type.GetConstructor(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, binder: null, Type.EmptyTypes, modifiers: null);
+ if (type.IsAbstract)
+ {
+ return null;
+ }
+
if (realMethod == null && !type.IsValueType)
{
return null;
Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<char>("1"));
Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<char?>("1"));
+ // This throws because Enum is an abstract type.
Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<Enum>(unexpectedString));
}