ICSharpCode.NRefactory.CSharp.Resolver.CSharpResolver.HandleEnumComparison C# (CSharp) Method

HandleEnumComparison() private method

Handle the case where an enum value is compared with another enum value bool operator op(E x, E y);
private HandleEnumComparison ( BinaryOperatorType op, IType enumType, bool isNullable, ResolveResult lhs, ResolveResult rhs ) : ResolveResult
op BinaryOperatorType
enumType IType
isNullable bool
lhs ResolveResult
rhs ResolveResult
return ResolveResult
		ResolveResult HandleEnumComparison(BinaryOperatorType op, IType enumType, bool isNullable, ResolveResult lhs, ResolveResult rhs)
		{
			// evaluate as ((U)x op (U)y)
			IType elementType = GetEnumUnderlyingType(enumType);
			if (lhs.IsCompileTimeConstant && rhs.IsCompileTimeConstant && !isNullable && elementType.Kind != TypeKind.Enum) {
				var rr = ResolveBinaryOperator(op, ResolveCast(elementType, lhs), ResolveCast(elementType, rhs));
				if (rr.IsCompileTimeConstant)
					return rr;
			}
			IType resultType = compilation.FindType(KnownTypeCode.Boolean);
			return BinaryOperatorResolveResult(resultType, lhs, op, rhs, isNullable);
		}
		
CSharpResolver