MustRewriteChildToSameType() статический приватный Метод

InvalidOperationException with message like "Rewriting child expression from type '{0}' to type '{1}' is not allowed, because it would change the meaning of the operation. If this is intentional, override '{2}' and change it to allow this rewrite."
static private MustRewriteChildToSameType ( object p0, object p1, object p2 ) : Exception
p0 object
p1 object
p2 object
Результат System.Exception
 private static void ValidateChildType(Type before, Type after, string methodName)
 {
     if (before.IsValueType)
     {
         if (TypeUtils.AreEquivalent(before, after))
         {
             return;
         }
     }
     else if (!after.IsValueType)
     {
         return;
     }
     throw Error.MustRewriteChildToSameType(before, after, methodName);
 }
Пример #2
0
        // Value types must stay as the same type, otherwise it's now a
        // different operation, e.g. adding two doubles vs adding two ints.
        private static void ValidateChildType(Type before, Type after, string methodName)
        {
            if (before.GetTypeInfo().IsValueType)
            {
                if (TypeUtils.AreEquivalent(before, after))
                {
                    // types are the same value type
                    return;
                }
            }
            else if (!after.GetTypeInfo().IsValueType)
            {
                // both are reference types
                return;
            }

            // Otherwise, it's an invalid type change.
            throw Error.MustRewriteChildToSameType(before, after, methodName);
        }