GetSignatureForError() public méthode

public GetSignatureForError ( ) : string
Résultat string
Exemple #1
0
		protected void Error_CannotChangeAccessModifiers (MemberCore member, MemberSpec base_member)
		{
			var base_modifiers = base_member.Modifiers;

			// Remove internal modifier from types which are not internally accessible
			if ((base_modifiers & Modifiers.AccessibilityMask) == (Modifiers.PROTECTED | Modifiers.INTERNAL) &&
				!base_member.DeclaringType.MemberDefinition.IsInternalAsPublic (member.Module.DeclaringAssembly))
				base_modifiers = Modifiers.PROTECTED;

			Report.SymbolRelatedToPreviousError (base_member);
			Report.Error (507, member.Location,
				"`{0}': cannot change access modifiers when overriding `{1}' inherited member `{2}'",
				member.GetSignatureForError (),
				ModifiersExtensions.AccessibilityName (base_modifiers),
				base_member.GetSignatureForError ());
		}
Exemple #2
0
	static public string CSharpSignature (MemberSpec mb)
	{
		return mb.GetSignatureForError ();
	}
Exemple #3
0
		//
		// Performs various checks on the MethodInfo `mb' regarding the modifier flags
		// that have been defined.
		//
		protected virtual bool CheckOverrideAgainstBase (MemberSpec base_member)
		{
			bool ok = true;

			if ((base_member.Modifiers & (Modifiers.ABSTRACT | Modifiers.VIRTUAL | Modifiers.OVERRIDE)) == 0) {
				Report.SymbolRelatedToPreviousError (base_member);
				Report.Error (506, Location,
					"`{0}': cannot override inherited member `{1}' because it is not marked virtual, abstract or override",
					 GetSignatureForError (), TypeManager.CSharpSignature (base_member));
				ok = false;
			}

			// Now we check that the overriden method is not final	
			if ((base_member.Modifiers & Modifiers.SEALED) != 0) {
				Report.SymbolRelatedToPreviousError (base_member);
				Report.Error (239, Location, "`{0}': cannot override inherited member `{1}' because it is sealed",
							  GetSignatureForError (), TypeManager.CSharpSignature (base_member));
				ok = false;
			}

			var base_member_type = ((IInterfaceMemberSpec) base_member).MemberType;
			if (!TypeSpecComparer.Override.IsEqual (MemberType, base_member_type)) {
				Report.SymbolRelatedToPreviousError (base_member);
				if (this is PropertyBasedMember) {
					Report.Error (1715, Location, "`{0}': type must be `{1}' to match overridden member `{2}'",
						GetSignatureForError (), base_member_type.GetSignatureForError (), base_member.GetSignatureForError ());
				} else {
					Report.Error (508, Location, "`{0}': return type must be `{1}' to match overridden member `{2}'",
						GetSignatureForError (), base_member_type.GetSignatureForError (), base_member.GetSignatureForError ());
				}
				ok = false;
			}

			return ok;
		}
Exemple #4
0
			bool OverloadResolver.IErrorHandler.AmbiguousCandidates (ResolveContext ec, MemberSpec best, MemberSpec ambiguous)
			{
				ec.Report.SymbolRelatedToPreviousError (best);
				ec.Report.Warning (278, 2, loc,
					"`{0}' contains ambiguous implementation of `{1}' pattern. Method `{2}' is ambiguous with method `{3}'",
					expr.Type.GetSignatureForError (), "enumerable",
					best.GetSignatureForError (), ambiguous.GetSignatureForError ());

				ambiguous_getenumerator_name = true;
				return true;
			}
Exemple #5
0
	static public string GetFullNameSignature (MemberSpec mi)
	{
		return mi.GetSignatureForError ();
	}
Exemple #6
0
 static public string GetFullNameSignature(MemberSpec mi)
 {
     return(mi.GetSignatureForError());
 }
Exemple #7
0
 static public string CSharpSignature(MemberSpec mb)
 {
     return(mb.GetSignatureForError());
 }
Exemple #8
0
		protected void Error_CannotChangeAccessModifiers (MemberCore member, MemberSpec base_member)
		{
			Report.SymbolRelatedToPreviousError (base_member);
			Report.Error (507, member.Location,
				"`{0}': cannot change access modifiers when overriding `{1}' inherited member `{2}'",
				member.GetSignatureForError (),
				ModifiersExtensions.AccessibilityName (base_member.Modifiers),
				base_member.GetSignatureForError ());
		}
Exemple #9
0
 protected static void Error_CannotAccessProtected(ResolveContext ec, Location loc, MemberSpec m, TypeSpec qualifier, TypeSpec container)
 {
     ec.Report.Error (1540, loc, "Cannot access protected member `{0}' via a qualifier of type `{1}'."
         + " The qualifier must be of type `{2}' or derived from it",
         m.GetSignatureForError (),
         TypeManager.CSharpName (qualifier),
         TypeManager.CSharpName (container));
 }
Exemple #10
0
        public void Error_TypeArgumentsCannotBeUsed(Report report, Location loc, MemberSpec member, int arity)
        {
            // Better message for possible generic expressions
            if (member != null && (member.Kind & MemberKind.GenericMask) != 0) {
                report.SymbolRelatedToPreviousError (member);
                if (member is TypeSpec)
                    member = ((TypeSpec) member).GetDefinition ();
                else
                    member = ((MethodSpec) member).GetGenericMethodDefinition ();

                string name = member.Kind == MemberKind.Method ? "method" : "type";
                if (member.IsGeneric) {
                    report.Error (305, loc, "Using the generic {0} `{1}' requires `{2}' type argument(s)",
                        name, member.GetSignatureForError (), member.Arity.ToString ());
                } else {
                    report.Error (308, loc, "The non-generic {0} `{1}' cannot be used with the type arguments",
                        name, member.GetSignatureForError ());
                }
            } else {
                report.Error (307, loc, "The {0} `{1}' cannot be used with type arguments",
                    ExprClassName, GetSignatureForError ());
            }
        }
Exemple #11
0
		static void CheckConversion (IMemberContext mc, MemberSpec context, TypeSpec atype, TypeParameterSpec tparam, TypeSpec ttype, Location loc)
		{
			var expr = new EmptyExpression (atype);
			if (!Convert.ImplicitStandardConversionExists (expr, ttype)) {
				mc.Compiler.Report.SymbolRelatedToPreviousError (tparam);
				if (TypeManager.IsValueType (atype)) {
					mc.Compiler.Report.Error (315, loc, "The type `{0}' cannot be used as type parameter `{1}' in the generic type or method `{2}'. There is no boxing conversion from `{0}' to `{3}'",
						atype.GetSignatureForError (), tparam.GetSignatureForError (), context.GetSignatureForError (), ttype.GetSignatureForError ());
				} else if (atype.IsGenericParameter) {
					mc.Compiler.Report.Error (314, loc, "The type `{0}' cannot be used as type parameter `{1}' in the generic type or method `{2}'. There is no boxing or type parameter conversion from `{0}' to `{3}'",
						atype.GetSignatureForError (), tparam.GetSignatureForError (), context.GetSignatureForError (), ttype.GetSignatureForError ());
				} else {
					mc.Compiler.Report.Error (311, loc, "The type `{0}' cannot be used as type parameter `{1}' in the generic type or method `{2}'. There is no implicit reference conversion from `{0}' to `{3}'",
						atype.GetSignatureForError (), tparam.GetSignatureForError (), context.GetSignatureForError (), ttype.GetSignatureForError ());
				}
			}
		}
Exemple #12
0
		static bool CheckConstraint (IMemberContext mc, MemberSpec context, TypeSpec atype, TypeParameterSpec tparam, Location loc)
		{
			//
			// First, check the `class' and `struct' constraints.
			//
			if (tparam.HasSpecialClass && !TypeManager.IsReferenceType (atype)) {
				mc.Compiler.Report.Error (452, loc,
					"The type `{0}' must be a reference type in order to use it as type parameter `{1}' in the generic type or method `{2}'",
					TypeManager.CSharpName (atype), tparam.GetSignatureForError (), context.GetSignatureForError ());
				return false;
			}

			if (tparam.HasSpecialStruct && (!TypeManager.IsValueType (atype) || TypeManager.IsNullableType (atype))) {
				mc.Compiler.Report.Error (453, loc,
					"The type `{0}' must be a non-nullable value type in order to use it as type parameter `{1}' in the generic type or method `{2}'",
					TypeManager.CSharpName (atype), tparam.GetSignatureForError (), context.GetSignatureForError ());
				return false;
			}

			//
			// The class constraint comes next.
			//
			if (tparam.HasTypeConstraint) {
				CheckConversion (mc, context, atype, tparam, tparam.BaseType, loc);
			}

			//
			// Now, check the interfaces and type parameters constraints
			//
			if (tparam.Interfaces != null) {
				if (TypeManager.IsNullableType (atype)) {
					mc.Compiler.Report.Error (313, loc,
						"The type `{0}' cannot be used as type parameter `{1}' in the generic type or method `{2}'. The nullable type `{0}' never satisfies interface constraint",
						atype.GetSignatureForError (), tparam.GetSignatureForError (), context.GetSignatureForError ());
				} else {
					foreach (TypeSpec iface in tparam.Interfaces) {
						CheckConversion (mc, context, atype, tparam, iface, loc);
					}
				}
			}

			//
			// Finally, check the constructor constraint.
			//
			if (!tparam.HasSpecialConstructor)
				return true;

			if (!HasDefaultConstructor (atype)) {
				mc.Compiler.Report.SymbolRelatedToPreviousError (atype);
				mc.Compiler.Report.Error (310, loc,
					"The type `{0}' must have a public parameterless constructor in order to use it as parameter `{1}' in the generic type or method `{2}'",
					TypeManager.CSharpName (atype), tparam.GetSignatureForError (), context.GetSignatureForError ());
				return false;
			}

			return true;
		}