ICSharpCode.NRefactory.MonoCSharp.Method.CheckImplementingMethodConstraints C# (CSharp) Method

CheckImplementingMethodConstraints() public static method

public static CheckImplementingMethodConstraints ( TypeContainer container, MethodSpec method, MethodSpec baseMethod ) : bool
container TypeContainer
method MethodSpec
baseMethod MethodSpec
return bool
		public static bool CheckImplementingMethodConstraints (TypeContainer container, MethodSpec method, MethodSpec baseMethod)
		{
			var tparams = method.Constraints;
			var base_tparams = baseMethod.Constraints;
			for (int i = 0; i < tparams.Length; ++i) {
				if (!tparams[i].HasSameConstraintsImplementation (base_tparams[i])) {
					container.Compiler.Report.SymbolRelatedToPreviousError (method);
					container.Compiler.Report.SymbolRelatedToPreviousError (baseMethod);

					// Using container location because the interface can be implemented
					// by base class
					var tp = (tparams [i].MemberDefinition as MemberCore) ?? container;
					container.Compiler.Report.Error (425, tp.Location,
						"The constraints for type parameter `{0}' of method `{1}' must match the constraints for type parameter `{2}' of interface method `{3}'. Consider using an explicit interface implementation instead",
						tparams[i].GetSignatureForError (), method.GetSignatureForError (),
						base_tparams[i].GetSignatureForError (), baseMethod.GetSignatureForError ());
 
					return false;
				}
			}

			return true;
		}