Example #1
0
        public bool Matches(ParameterName name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            // TODO Sentinel matching could impact this (uncommon)
            return(StaticMatches(this, name));
        }
Example #2
0
        public bool Matches(MethodName name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            return(name.Name == Name &&
                   TypeName.SafeMatch(DeclaringType, name.DeclaringType) &&
                   this.GenericParameterCount == name.GenericParameterCount &&
                   TypeName.MatchGenericArguments(this.GenericArguments, name.GenericArguments) &&
                   ParameterName.MatchHelper(this, name));
        }
Example #3
0
 private ParameterName CloneParameter(ParameterName t, int index)
 {
     return(new DefaultParameterName(this, index, t.Name, t.ParameterType, t.Modifiers));
 }
Example #4
0
 public MethodName RemoveParameter(ParameterName parameter)
 {
     return(WithParameters(Parameters.ImmutableRemove(parameter, CloneParameter)));
 }
Example #5
0
 public PropertyName RemoveIndexParameter(ParameterName parameter)
 {
     return(WithIndexParameters(IndexParameters.ImmutableRemove(parameter, CloneParameter)));
 }
Example #6
0
 internal void FinalizeReturnType(TypeName returnType)
 {
     _returnParameter = new DefaultReturnParameterName(this, returnType, null);
 }
 public FunctionPointerTypeName RemoveParameter(ParameterName parameter)
 {
     return(WithParameters(Parameters.ImmutableRemove(parameter, CloneParameter)));
 }
        protected internal virtual string FormatParameter(string format, ParameterName name, IFormatProvider formatProvider)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            if (string.IsNullOrEmpty(format))
            {
                format = GetDefaultFormat(formatProvider, SymbolType.Parameter);
            }

            else if (format.Length > 2)
            {
                throw new FormatException();
            }

            // Valid formats:
            // {G|C|N|F|U} {V|v}?
            char c         = format[0];
            var  modifiers = name.Modifiers.Count == 0
                ? ""
                : name.Modifiers.ToString() + " ";

            string over = modifiers + "{1} {0}"; // Beans cool

            if (format.Length == 2)
            {
                if (format[1] == 'V')
                {
                    over = "{0}:{1}"; // cool:Beans
                }
                else if (format[1] == 'v')
                {
                    over = "{1}"; // Beans
                }
                else
                {
                    throw new FormatException();
                }
            }

            if (string.IsNullOrEmpty(name.Name))
            {
                over = "{1}"; // Beans
            }
            switch (c)
            {
            case 'G':
            case 'C':
            case 'N':
            case 'F':
            case 'U':
                if (string.IsNullOrEmpty(name.Name) && name.ParameterType == null)
                {
                    return(string.Empty);
                }
                string pmType = string.Empty;
                if (name.ParameterType != null)
                {
                    pmType = name.ParameterType.ToString(c.ToString(), formatProvider);
                }
                return(string.Format(over, name.Name, pmType));

            default:
                throw new FormatException();
            }
        }
 protected internal override string FormatParameter(string format, ParameterName name, IFormatProvider formatProvider)
 {
     return(name.ParameterType.Name);
 }
Example #10
0
 static bool StaticMatches(ParameterName self, ParameterName name)
 {
     return(self.Position == name.Position &&
            TypeName.SafeMatch((TypeName)self.ParameterType, (TypeName)name.ParameterType) &&
            self.Modifiers.Match(name.Modifiers));
 }