CSharpSignature() статический публичный Метод

static public CSharpSignature ( MemberSpec mb ) : string
mb MemberSpec
Результат string
Пример #1
0
		protected override Expression DoResolve (ResolveContext ec)
		{
			constructor_method = Delegate.GetConstructor (type);

			var invoke_method = Delegate.GetInvokeMethod (type);

			Arguments arguments = CreateDelegateMethodArguments (ec, invoke_method.Parameters, invoke_method.Parameters.Types, loc);
			method_group = method_group.OverloadResolve (ec, ref arguments, this, OverloadResolver.Restrictions.CovariantDelegate);
			if (method_group == null)
				return null;

			var delegate_method = method_group.BestCandidate;
			
			if (delegate_method.DeclaringType.IsNullableType) {
				ec.Report.Error (1728, loc, "Cannot create delegate from method `{0}' because it is a member of System.Nullable<T> type",
					delegate_method.GetSignatureForError ());
				return null;
			}		
			
			if (!AllowSpecialMethodsInvocation)
				Invocation.IsSpecialMethodInvocation (ec, delegate_method, loc);

			ExtensionMethodGroupExpr emg = method_group as ExtensionMethodGroupExpr;
			if (emg != null) {
				method_group.InstanceExpression = emg.ExtensionExpression;
				TypeSpec e_type = emg.ExtensionExpression.Type;
				if (TypeSpec.IsValueType (e_type)) {
					ec.Report.Error (1113, loc, "Extension method `{0}' of value type `{1}' cannot be used to create delegates",
						delegate_method.GetSignatureForError (), e_type.GetSignatureForError ());
				}
			}

			TypeSpec rt = delegate_method.ReturnType;
			if (rt.BuiltinType == BuiltinTypeSpec.Type.Dynamic)
				rt = ec.BuiltinTypes.Object;

			if (!Delegate.IsTypeCovariant (ec, rt, invoke_method.ReturnType)) {
				Expression ret_expr = new TypeExpression (delegate_method.ReturnType, loc);
				Error_ConversionFailed (ec, delegate_method, ret_expr);
			}

			if (delegate_method.IsConditionallyExcluded (ec, loc)) {
				ec.Report.SymbolRelatedToPreviousError (delegate_method);
				MethodOrOperator m = delegate_method.MemberDefinition as MethodOrOperator;
				if (m != null && m.IsPartialDefinition) {
					ec.Report.Error (762, loc, "Cannot create delegate from partial method declaration `{0}'",
						delegate_method.GetSignatureForError ());
				} else {
					ec.Report.Error (1618, loc, "Cannot create delegate with `{0}' because it has a Conditional attribute",
						TypeManager.CSharpSignature (delegate_method));
				}
			}

			var expr = method_group.InstanceExpression;
			if (expr != null && (expr.Type.IsGenericParameter || !TypeSpec.IsReferenceType (expr.Type)))
				method_group.InstanceExpression = new BoxedCast (expr, ec.BuiltinTypes.Object);

			eclass = ExprClass.Value;
			return this;
		}
Пример #2
0
        /// <summary>
        ///   Verifies that any pending abstract methods or interface methods
        ///   were implemented.
        /// </summary>
        public bool VerifyPendingMethods()
        {
            int  top    = pending_implementations.Length;
            bool errors = false;
            int  i;

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

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

                for (int j = 0; j < pending_implementations [i].methods.Count; ++j)
                {
                    var mi = pending_implementations[i].methods[j];
                    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;
                }
            }
            return(errors);
        }
Пример #3
0
        /// <summary>
        ///   Verifies that any pending abstract methods or interface methods
        ///   were implemented.
        /// </summary>
        public bool VerifyPendingMethods()
        {
            int  top    = pending_implementations.Length;
            bool errors = false;
            int  i;

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

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

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

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

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

                        if (pending_implementations [i].optional)
                        {
                            continue;
                        }

                        MethodInfo 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.MethodBuilder;
                            }
                        }

                        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(), TypeManager.CSharpSignature(mi, true), TypeManager.CSharpSignature(candidate));
                            }
                            else if (!candidate.IsPublic)
                            {
                                Report.Error(737, container.Location,
                                             "`{0}' does not implement interface member `{1}' and the best implementing candidate `{2}' in not public",
                                             container.GetSignatureForError(), TypeManager.CSharpSignature(mi, true), TypeManager.CSharpSignature(candidate, true));
                            }
                            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(), TypeManager.CSharpSignature(mi, true), 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(), TypeManager.CSharpSignature(mi, true));
                        }
                    }
                    else
                    {
                        Report.Error(534, container.Location, "`{0}' does not implement inherited abstract member `{1}'",
                                     container.GetSignatureForError(), TypeManager.CSharpSignature(mi, true));
                    }
                    errors = true;
                    j++;
                }
            }
            return(errors);
        }
Пример #4
0
        public override Expression DoResolve(ResolveContext ec)
        {
            constructor_method = Delegate.GetConstructor(ec.Compiler, ec.CurrentType, type);

            MethodInfo invoke_method = Delegate.GetInvokeMethod(ec.Compiler, ec.CurrentType, type);

            method_group.DelegateType       = type;
            method_group.CustomErrorHandler = this;

            Arguments arguments = CreateDelegateMethodArguments(TypeManager.GetParameterData(invoke_method), loc);

            method_group = method_group.OverloadResolve(ec, ref arguments, false, loc);
            if (method_group == null)
            {
                return(null);
            }

            delegate_method = (MethodInfo)method_group;

            if (TypeManager.IsNullableType(delegate_method.DeclaringType))
            {
                ec.Report.Error(1728, loc, "Cannot create delegate from method `{0}' because it is a member of System.Nullable<T> type",
                                TypeManager.GetFullNameSignature(delegate_method));
                return(null);
            }

            Invocation.IsSpecialMethodInvocation(ec, delegate_method, loc);

            ExtensionMethodGroupExpr emg = method_group as ExtensionMethodGroupExpr;

            if (emg != null)
            {
                delegate_instance_expression = emg.ExtensionExpression;
                Type e_type = delegate_instance_expression.Type;
                if (TypeManager.IsValueType(e_type))
                {
                    ec.Report.Error(1113, loc, "Extension method `{0}' of value type `{1}' cannot be used to create delegates",
                                    TypeManager.CSharpSignature(delegate_method), TypeManager.CSharpName(e_type));
                }
            }

            Type       rt       = TypeManager.TypeToCoreType(delegate_method.ReturnType);
            Expression ret_expr = new TypeExpression(rt, loc);

            if (!Delegate.IsTypeCovariant(ret_expr, (TypeManager.TypeToCoreType(invoke_method.ReturnType))))
            {
                Error_ConversionFailed(ec, delegate_method, ret_expr);
            }

            if (Invocation.IsMethodExcluded(delegate_method, loc))
            {
                ec.Report.SymbolRelatedToPreviousError(delegate_method);
                MethodOrOperator m = TypeManager.GetMethod(delegate_method) as MethodOrOperator;
                if (m != null && m.IsPartialDefinition)
                {
                    ec.Report.Error(762, loc, "Cannot create delegate from partial method declaration `{0}'",
                                    TypeManager.CSharpSignature(delegate_method));
                }
                else
                {
                    ec.Report.Error(1618, loc, "Cannot create delegate with `{0}' because it has a Conditional attribute",
                                    TypeManager.CSharpSignature(delegate_method));
                }
            }

            DoResolveInstanceExpression(ec);
            eclass = ExprClass.Value;
            return(this);
        }
Пример #5
0
 public static void Error_TypeArgumentsCannotBeUsed(MethodBase mi, Location loc)
 {
     Report.SymbolRelatedToPreviousError(mi);
     Error_TypeArgumentsCannotBeUsed(loc, "method", TypeManager.CSharpSignature(mi));
 }