diff --git a/Source/VSProj/Src/Core/ReflectionMethodInvoker.cs b/Source/VSProj/Src/Core/ReflectionMethodInvoker.cs index 2de7441..b730435 100644 --- a/Source/VSProj/Src/Core/ReflectionMethodInvoker.cs +++ b/Source/VSProj/Src/Core/ReflectionMethodInvoker.cs @@ -34,6 +34,7 @@ internal class ReflectionMethodInvoker bool isNullableHasValue = false; bool isNullableValue = false; + bool isNullableGetValueOrDefault = false; public ReflectionMethodInvoker(MethodBase method) { @@ -75,6 +76,7 @@ public ReflectionMethodInvoker(MethodBase method) && method.DeclaringType.GetGenericTypeDefinition() == typeof(Nullable<>); isNullableHasValue = isNullableMethod && method.Name == "get_HasValue"; isNullableValue = isNullableMethod && method.Name == "get_Value"; + isNullableGetValueOrDefault = isNullableMethod && method.Name == "GetValueOrDefault"; } // #lizard forgives @@ -156,6 +158,20 @@ public unsafe void Invoke(VirtualMachine virtualMachine, ref Call call, bool isI { ret = instance; } + else if (isNullableGetValueOrDefault) + { + if(instance == null) + { + if(paramCount == 0) + ret = System.Activator.CreateInstance(returnType); + else + ret = args[0]; + } + else + { + ret = instance; + } + } else { if (method.IsStatic == false && instance == null)