当前位置: 首页>>代码示例>>C#>>正文


C# Report.SymbolRelatedToPreviousError方法代码示例

本文整理汇总了C#中Mono.CSharp.Report.SymbolRelatedToPreviousError方法的典型用法代码示例。如果您正苦于以下问题:C# Report.SymbolRelatedToPreviousError方法的具体用法?C# Report.SymbolRelatedToPreviousError怎么用?C# Report.SymbolRelatedToPreviousError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mono.CSharp.Report的用法示例。


在下文中一共展示了Report.SymbolRelatedToPreviousError方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Define

		public bool Define (DeclSpace parent, string method_full_name, Report Report)
		{
			TypeContainer container = parent.PartialContainer;

			PendingImplementation pending = container.PendingImplementations;
			if (pending != null){
				implementing = pending.IsInterfaceMethod (method.MethodName, member.InterfaceType, this);

				if (member.InterfaceType != null){
					if (implementing == null){
						if (member is PropertyBase) {
							Report.Error (550, method.Location, "`{0}' is an accessor not found in interface member `{1}{2}'",
								      method.GetSignatureForError (), TypeManager.CSharpName (member.InterfaceType),
								      member.GetSignatureForError ().Substring (member.GetSignatureForError ().LastIndexOf ('.')));

						} else {
							Report.Error (539, method.Location,
								      "`{0}.{1}' in explicit interface declaration is not a member of interface",
								      TypeManager.CSharpName (member.InterfaceType), member.ShortName);
						}
						return false;
					}
					if (implementing.IsAccessor && !(method is AbstractPropertyEventMethod)) {
						Report.SymbolRelatedToPreviousError (implementing);
						Report.Error (683, method.Location, "`{0}' explicit method implementation cannot implement `{1}' because it is an accessor",
							member.GetSignatureForError (), TypeManager.CSharpSignature (implementing));
						return false;
					}
				} else {
					if (implementing != null) {
						AbstractPropertyEventMethod prop_method = method as AbstractPropertyEventMethod;
						if (prop_method == null) {
							if (implementing.IsAccessor) {
								Report.SymbolRelatedToPreviousError (implementing);
								Report.Error (470, method.Location, "Method `{0}' cannot implement interface accessor `{1}'",
									method.GetSignatureForError (), TypeManager.CSharpSignature (implementing));
							}
						} else if (implementing.DeclaringType.IsInterface) {
							if (!implementing.IsAccessor) {
								Report.SymbolRelatedToPreviousError (implementing);
								Report.Error (686, method.Location, "Accessor `{0}' cannot implement interface member `{1}' for type `{2}'. Use an explicit interface implementation",
									method.GetSignatureForError (), TypeManager.CSharpSignature (implementing), container.GetSignatureForError ());
							} else {
								PropertyBase.PropertyMethod pm = prop_method as PropertyBase.PropertyMethod;
								if (pm != null && pm.HasCustomAccessModifier && (pm.ModFlags & Modifiers.PUBLIC) == 0) {
									Report.SymbolRelatedToPreviousError (implementing);
									Report.Error (277, method.Location, "Accessor `{0}' must be declared public to implement interface member `{1}'",
										method.GetSignatureForError (), implementing.GetSignatureForError ());
								}
							}
						}
					}
				}
			}

			//
			// For implicit implementations, make sure we are public, for
			// explicit implementations, make sure we are private.
			//
			if (implementing != null){
				//
				// Setting null inside this block will trigger a more
				// verbose error reporting for missing interface implementations
				//
				// The "candidate" function has been flagged already
				// but it wont get cleared
				//
				if (member.IsExplicitImpl){
					if (method.ParameterInfo.HasParams && !implementing.Parameters.HasParams) {
						Report.SymbolRelatedToPreviousError (implementing);
						Report.Error (466, method.Location, "`{0}': the explicit interface implementation cannot introduce the params modifier",
							method.GetSignatureForError ());
					}
				} else {
					if (implementing.DeclaringType.IsInterface) {
						//
						// If this is an interface method implementation,
						// check for public accessibility
						//
						if ((flags & MethodAttributes.MemberAccessMask) != MethodAttributes.Public)
						{
							implementing = null;
						}
					} else if ((flags & MethodAttributes.MemberAccessMask) == MethodAttributes.Private){
						// We may never be private.
						implementing = null;

					} else if ((modifiers & Modifiers.OVERRIDE) == 0){
						//
						// We may be protected if we're overriding something.
						//
						implementing = null;
					}
				}
					
				//
				// Static is not allowed
				//
				if ((modifiers & Modifiers.STATIC) != 0){
					implementing = null;
//.........这里部分代码省略.........
开发者ID:spencerhakim,项目名称:mono,代码行数:101,代码来源:method.cs

示例2: Error_VariableOfStaticClass

		public static void Error_VariableOfStaticClass (Location loc, string variable_name, TypeSpec static_class, Report Report)
		{
			Report.SymbolRelatedToPreviousError (static_class);
			Report.Error (723, loc, "`{0}': cannot declare variables of static types",
				variable_name);
		}
开发者ID:agallero,项目名称:mono,代码行数:6,代码来源:field.cs

示例3: VerifyClsParameterConflict

 		/// <summary>
 		/// Cls compliance check whether methods or constructors parameters differing only in ref or out, or in array rank
 		/// </summary>
 		/// 
		// TODO: refactor as method is always 'this'
 		public static void VerifyClsParameterConflict (ArrayList al, MethodCore method, MemberInfo this_builder, Report Report)
 		{
 			EntryType tested_type = (method is Constructor ? EntryType.Constructor : EntryType.Method) | EntryType.Public;
 
 			for (int i = 0; i < al.Count; ++i) {
 				MemberCache.CacheEntry entry = (MemberCache.CacheEntry) al [i];
 		
 				// skip itself
 				if (entry.Member == this_builder)
 					continue;
 		
 				if ((entry.EntryType & tested_type) != tested_type)
 					continue;
 		
				MethodBase method_to_compare = (MethodBase)entry.Member;
				AttributeTester.Result result = AttributeTester.AreOverloadedMethodParamsClsCompliant (
					method.Parameters, TypeManager.GetParameterData (method_to_compare));

 				if (result == AttributeTester.Result.Ok)
 					continue;

				IMethodData md = TypeManager.GetMethod (method_to_compare);

				// TODO: now we are ignoring CLSCompliance(false) on method from other assembly which is buggy.
				// However it is exactly what csc does.
				if (md != null && !md.IsClsComplianceRequired ())
					continue;
 		
 				Report.SymbolRelatedToPreviousError (entry.Member);
				switch (result) {
				case AttributeTester.Result.RefOutArrayError:
					Report.Warning (3006, 1, method.Location,
							"Overloaded method `{0}' differing only in ref or out, or in array rank, is not CLS-compliant",
							method.GetSignatureForError ());
					continue;
				case AttributeTester.Result.ArrayArrayError:
					Report.Warning (3007, 1, method.Location,
							"Overloaded method `{0}' differing only by unnamed array types is not CLS-compliant",
							method.GetSignatureForError ());
					continue;
				}

				throw new NotImplementedException (result.ToString ());
 			}
  		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:50,代码来源:decl.cs

示例4: CheckExistingMembersOverloads

		public bool CheckExistingMembersOverloads (MemberCore member, string name, ParametersCompiled parameters, Report Report)
		{
			ArrayList entries = (ArrayList)member_hash [name];
			if (entries == null)
				return true;

			int method_param_count = parameters.Count;
			for (int i = entries.Count - 1; i >= 0; --i) {
				CacheEntry ce = (CacheEntry) entries [i];

				if (ce.Container != member.Parent.PartialContainer)
					return true;

				Type [] p_types;
				AParametersCollection pd;
				if ((ce.EntryType & EntryType.Property) != 0) {
					pd = TypeManager.GetParameterData ((PropertyInfo) ce.Member);
					p_types = pd.Types;
				} else {
					MethodBase mb = (MethodBase) ce.Member;
		
					// TODO: This is more like a hack, because we are adding generic methods
					// twice with and without arity name
					if (TypeManager.IsGenericMethod (mb) && !member.MemberName.IsGeneric)
						continue;

					pd = TypeManager.GetParameterData (mb);
					p_types = pd.Types;
				}

				if (p_types.Length != method_param_count)
					continue;

				if (method_param_count > 0) {
					int ii = method_param_count - 1;
					Type type_a, type_b;
					do {
						type_a = parameters.Types [ii];
						type_b = p_types [ii];

#if GMCS_SOURCE
						if (TypeManager.IsGenericParameter (type_a) && type_a.DeclaringMethod != null)
							type_a = typeof (TypeParameter);

						if (TypeManager.IsGenericParameter (type_b) && type_b.DeclaringMethod != null)
							type_b = typeof (TypeParameter);
#endif
						if ((pd.FixedParameters [ii].ModFlags & Parameter.Modifier.ISBYREF) !=
							(parameters.FixedParameters [ii].ModFlags & Parameter.Modifier.ISBYREF))
							type_a = null;

					} while (type_a == type_b && ii-- != 0);

					if (ii >= 0)
						continue;

					//
					// Operators can differ in return type only
					//
					if (member is Operator) {
						Operator op = TypeManager.GetMethod ((MethodBase) ce.Member) as Operator;
						if (op != null && op.ReturnType != ((Operator) member).ReturnType)
							continue;
					}

					//
					// Report difference in parameter modifiers only
					//
					if (pd != null && member is MethodCore) {
						ii = method_param_count;
						while (ii-- != 0 && parameters.FixedParameters [ii].ModFlags == pd.FixedParameters [ii].ModFlags &&
							parameters.ExtensionMethodType == pd.ExtensionMethodType);

						if (ii >= 0) {
							MethodCore mc = TypeManager.GetMethod ((MethodBase) ce.Member) as MethodCore;
							Report.SymbolRelatedToPreviousError (ce.Member);
							if ((member.ModFlags & Modifiers.PARTIAL) != 0 && (mc.ModFlags & Modifiers.PARTIAL) != 0) {
								if (parameters.HasParams || pd.HasParams) {
									Report.Error (758, member.Location,
										"A partial method declaration and partial method implementation cannot differ on use of `params' modifier");
								} else {
									Report.Error (755, member.Location,
										"A partial method declaration and partial method implementation must be both an extension method or neither");
								}
							} else {
								if (member is Constructor) {
									Report.Error (851, member.Location,
										"Overloaded contructor `{0}' cannot differ on use of parameter modifiers only",
										member.GetSignatureForError ());
								} else {
									Report.Error (663, member.Location,
										"Overloaded method `{0}' cannot differ on use of parameter modifiers only",
										member.GetSignatureForError ());
								}
							}
							return false;
						}
					}
				}

//.........这里部分代码省略.........
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:101,代码来源:decl.cs

示例5: Error_TypeArgumentsCannotBeUsed

        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 ());
            }
        }
开发者ID:speier,项目名称:shake,代码行数:23,代码来源:ecore.cs

示例6: VerifyPendingMethods

        /// <summary>
        ///   Verifies that any pending abstract methods or interface methods
        ///   were implemented.
        /// </summary>
        public bool VerifyPendingMethods(Report Report)
        {
            int top = pending_implementations.Length;
            bool errors = false;
            int i;

            for (i = 0; i < top; i++){
                TypeSpec type = pending_implementations [i].type;
                int j = 0;

                bool base_implements_type = type.IsInterface &&
                    container.BaseType != null &&
                    container.BaseType.ImplementsInterface (type);

                foreach (var mi in pending_implementations [i].methods){
                    if (mi == null)
                        continue;

                    if (type.IsInterface){
                        var need_proxy =
                            pending_implementations [i].need_proxy [j];

                        if (need_proxy != null) {
                            DefineProxy (type, need_proxy, mi);
                            continue;
                        }

                        if (pending_implementations [i].optional)
                            continue;

                        MethodSpec candidate = null;
                        if (base_implements_type || BaseImplements (type, mi, out candidate))
                            continue;

                        if (candidate == null) {
                            MethodData md = pending_implementations [i].found [j];
                            if (md != null)
                                candidate = md.method.Spec;
                        }

                        Report.SymbolRelatedToPreviousError (mi);
                        if (candidate != null) {
                            Report.SymbolRelatedToPreviousError (candidate);
                            if (candidate.IsStatic) {
                                Report.Error (736, container.Location,
                                    "`{0}' does not implement interface member `{1}' and the best implementing candidate `{2}' is static",
                                    container.GetSignatureForError (), mi.GetSignatureForError (), TypeManager.CSharpSignature (candidate));
                            } else if ((candidate.Modifiers & Modifiers.PUBLIC) == 0) {
                                Report.Error (737, container.Location,
                                    "`{0}' does not implement interface member `{1}' and the best implementing candidate `{2}' in not public",
                                    container.GetSignatureForError (), mi.GetSignatureForError (), candidate.GetSignatureForError ());
                            } else {
                                Report.Error (738, container.Location,
                                    "`{0}' does not implement interface member `{1}' and the best implementing candidate `{2}' return type `{3}' does not match interface member return type `{4}'",
                                    container.GetSignatureForError (), mi.GetSignatureForError (), TypeManager.CSharpSignature (candidate),
                                    TypeManager.CSharpName (candidate.ReturnType), TypeManager.CSharpName (mi.ReturnType));
                            }
                        } else {
                            Report.Error (535, container.Location, "`{0}' does not implement interface member `{1}'",
                                container.GetSignatureForError (), mi.GetSignatureForError ());
                        }
                    } else {
                        Report.SymbolRelatedToPreviousError (mi);
                        Report.Error (534, container.Location, "`{0}' does not implement inherited abstract member `{1}'",
                            container.GetSignatureForError (), mi.GetSignatureForError ());
                    }
                    errors = true;
                    j++;
                }
            }
            return errors;
        }
开发者ID:speier,项目名称:shake,代码行数:76,代码来源:pending.cs

示例7: VerifyClsCompliance

		public void VerifyClsCompliance (Report report)
		{
			foreach (var c in constraints)
			{
				if (c == null)
					continue;

				if (!c.Type.IsCLSCompliant ()) {
					report.SymbolRelatedToPreviousError (c.Type);
					report.Warning (3024, 1, loc, "Constraint type `{0}' is not CLS-compliant",
						c.Type.GetSignatureForError ());
				}
			}
		}
开发者ID:ikvm,项目名称:mono,代码行数:14,代码来源:generic.cs

示例8: Warning_ConstrainIsNotClsCompliant

		void Warning_ConstrainIsNotClsCompliant (Type t, Location loc, Report Report)
		{
			Report.SymbolRelatedToPreviousError (t);
			Report.Warning (3024, 1, loc, "Constraint type `{0}' is not CLS-compliant",
				TypeManager.CSharpName (t));
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:6,代码来源:generic.cs

示例9: Resolve

		/// <summary>
		///   Resolve the constraints - but only resolve things into Expression's, not
		///   into actual types.
		/// </summary>
		public bool Resolve (MemberCore ec, TypeParameter tp, Report Report)
		{
			if (resolved)
				return true;

			if (ec == null)
				return false;

			iface_constraints = new ArrayList (2);	// TODO: Too expensive allocation
			type_param_constraints = new ArrayList ();

			foreach (object obj in constraints) {
				if (HasConstructorConstraint) {
					Report.Error (401, loc,
						      "The new() constraint must be the last constraint specified");
					return false;
				}

				if (obj is SpecialConstraint) {
					SpecialConstraint sc = (SpecialConstraint) obj;

					if (sc == SpecialConstraint.Constructor) {
						if (!HasValueTypeConstraint) {
							attrs |= GenericParameterAttributes.DefaultConstructorConstraint;
							continue;
						}

						Report.Error (451, loc, "The `new()' constraint " +
							"cannot be used with the `struct' constraint");
						return false;
					}

					if ((num_constraints > 0) || HasReferenceTypeConstraint || HasValueTypeConstraint) {
						Report.Error (449, loc, "The `class' or `struct' " +
							      "constraint must be the first constraint specified");
						return false;
					}

					if (sc == SpecialConstraint.ReferenceType)
						attrs |= GenericParameterAttributes.ReferenceTypeConstraint;
					else
						attrs |= GenericParameterAttributes.NotNullableValueTypeConstraint;
					continue;
				}

				int errors = Report.Errors;
				FullNamedExpression fn = ((Expression) obj).ResolveAsTypeStep (ec, false);

				if (fn == null) {
					if (errors != Report.Errors)
						return false;

					NamespaceEntry.Error_NamespaceNotFound (loc, ((Expression)obj).GetSignatureForError (), Report);
					return false;
				}

				TypeExpr expr;
				GenericTypeExpr cexpr = fn as GenericTypeExpr;
				if (cexpr != null) {
					expr = cexpr.ResolveAsBaseTerminal (ec, false);
				} else
					expr = ((Expression) obj).ResolveAsTypeTerminal (ec, false);

				if ((expr == null) || (expr.Type == null))
					return false;

				if (!ec.IsAccessibleAs (fn.Type)) {
					Report.SymbolRelatedToPreviousError (fn.Type);
					Report.Error (703, loc,
						"Inconsistent accessibility: constraint type `{0}' is less accessible than `{1}'",
						fn.GetSignatureForError (), ec.GetSignatureForError ());
					return false;
				}

				if (TypeManager.IsGenericParameter (expr.Type))
					type_param_constraints.Add (expr);
				else if (expr.IsInterface)
					iface_constraints.Add (expr);
				else if (class_constraint != null || iface_constraints.Count != 0) {
					Report.Error (406, loc,
						"The class type constraint `{0}' must be listed before any other constraints. Consider moving type constraint to the beginning of the constraint list",
						expr.GetSignatureForError ());
					return false;
				} else if (HasReferenceTypeConstraint || HasValueTypeConstraint) {
					Report.Error (450, loc, "`{0}': cannot specify both " +
						      "a constraint class and the `class' " +
						      "or `struct' constraint", expr.GetSignatureForError ());
					return false;
				} else
					class_constraint = expr;


				//
				// Checks whether each generic method parameter constraint type
				// is valid with respect to T
				//
//.........这里部分代码省略.........
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:101,代码来源:generic.cs

示例10: CheckConversion

 static void CheckConversion(MemberSpec context, TypeSpec atype, TypeParameterSpec tparam, TypeSpec ttype, Location loc, Report report)
 {
     var expr = new EmptyExpression (atype);
     if (!Convert.ImplicitStandardConversionExists (expr, ttype)) {
         report.SymbolRelatedToPreviousError (tparam);
         if (TypeManager.IsValueType (atype)) {
             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) {
             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 {
             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 ());
         }
     }
 }
开发者ID:speier,项目名称:shake,代码行数:17,代码来源:generic.cs

示例11: CheckConstraint

        static bool CheckConstraint(MemberSpec context, TypeSpec atype, TypeParameterSpec tparam, Location loc, Report report)
        {
            //
            // First, check the `class' and `struct' constraints.
            //
            if (tparam.HasSpecialClass && !TypeManager.IsReferenceType (atype)) {
                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))) {
                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 (context, atype, tparam, tparam.BaseType, loc, report);
            }

            //
            // Now, check the interfaces and type parameters constraints
            //
            if (tparam.Interfaces != null) {
                if (TypeManager.IsNullableType (atype)) {
                    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 (context, atype, tparam, iface, loc, report);
                    }
                }
            }

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

            if (!HasDefaultConstructor (atype)) {
                report.SymbolRelatedToPreviousError (atype);
                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;
        }
开发者ID:speier,项目名称:shake,代码行数:57,代码来源:generic.cs


注:本文中的Mono.CSharp.Report.SymbolRelatedToPreviousError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。