Пример #1
0
		public void VisitMethod(MethodDefinition method)
		{
			if (m_needsCheck)
			{
				if (method.Reuses("System.Boolean", "Equals", "System.Object"))
				{
					Log.DebugLine(this, "{0}", method); 
					m_foundEquals = true;
				}
				else if (method.Matches("System.Int32", "CompareTo", method.DeclaringType.FullName))
				{
					Log.DebugLine(this, "{0}", method); 
					m_foundCompare = true;
				}
			}
		}
Пример #2
0
		private static bool DoIsIFormattableToString(MethodDefinition method)
		{
			bool equals = false;
			
			if (method.Parameters.Count == 2 && method.IsVirtual)
			{
				if (method.Matches("System.String", "ToString", "System.String", "System.IFormatProvider"))
					equals = true;

				else if (method.Matches("System.String", "System.IFormattable.ToString", "System.String", "System.IFormatProvider"))
					equals = true;
			}
			
			return equals;
		}
		// Return true if the method matches:
		// 		public static bool operator==(xxx, xxx), where xxx is not a value type
		private static bool DoIsOperatorEquals(MethodDefinition method)
		{
			bool equals = false;
			
			if (method.IsStatic)
				if (method.Matches("System.Boolean", "op_Equality", method.DeclaringType.FullName, method.DeclaringType.FullName))
					if (!method.Parameters[0].ParameterType.IsValueType)
						equals = true;
			
			return equals;
		}
		// Return true if the method matches one of:
		// 		public override bool Equals(object)
		// 		public bool Equals(xxx), where xxx is not a value type
		private static bool DoIsEquals(MethodDefinition method)
		{
			bool equals = false;
			
			if (method.Reuses("System.Boolean", "Equals", "System.Object"))
				equals = true;
			
			else if (method.Matches("System.Boolean", "Equals", method.DeclaringType.FullName))
				if (!method.IsStatic)
					if (!method.Parameters[0].ParameterType.IsValueType)
						equals = true;
			
			return equals;
		}