public override List <SD_Instance_Parameter> GetParameters()
    {
        if (kind != SymbolKind.Delegate)
        {
            return(null);
        }

        if (parameters == null)
        {
            var invoke = reflectedType.GetMethod("Invoke");

            returnType = ReflectedTypeReference.ForType(invoke.ReturnType);

            parameters = new List <SD_Instance_Parameter>();
            foreach (var p in invoke.GetParameters())
            {
                var isByRef       = p.ParameterType.IsByRef;
                var parameterType = isByRef ? p.ParameterType.GetElementType() : p.ParameterType;
                parameters.Add(new SD_Instance_Parameter
                {
                    kind         = SymbolKind.Parameter,
                    parentSymbol = this,
                    name         = p.Name,
                    type         = ReflectedTypeReference.ForType(parameterType),
                    modifiers    = isByRef ? (p.IsOut ? Modifiers.Out : Modifiers.Ref) : Attribute.IsDefined(p, typeof(ParamArrayAttribute)) ? Modifiers.Params : Modifiers.None,
                });
            }
        }

        return(parameters);
    }
 public override TypeDefinitionBase BaseType()
 {
     if (baseType == null)
     {
         baseType = ReflectedTypeReference.ForType(typeof(MulticastDelegate));
     }
     return(baseType.Definition as TypeDefinitionBase);
 }
Exemple #3
0
    public SD_Mehod_ReflectedConstructor(ConstructorInfo constructorInfo, SymbolDefinition memberOf)
    {
        modifiers =
            constructorInfo.IsPublic ? Modifiers.Public :
            constructorInfo.IsFamilyOrAssembly ? Modifiers.Internal | Modifiers.Protected :
            constructorInfo.IsAssembly ? Modifiers.Internal :
            constructorInfo.IsFamily ? Modifiers.Protected :
            Modifiers.Private;
        if (constructorInfo.IsAbstract)
        {
            modifiers |= Modifiers.Abstract;
        }
        if (constructorInfo.IsStatic)
        {
            modifiers |= Modifiers.Static;
        }
        accessLevel = AccessLevelFromModifiers(modifiers);

        name         = ".ctor";
        kind         = SymbolKind.Constructor;
        parentSymbol = memberOf;

        returnType = new SymbolReference(memberOf);

        if (parameters == null)
        {
            parameters = new List <SD_Instance_Parameter>();
        }
        foreach (var p in constructorInfo.GetParameters())
        {
            var isByRef        = p.ParameterType.IsByRef;
            var parameterType  = isByRef ? p.ParameterType.GetElementType() : p.ParameterType;
            var parameterToAdd = new SD_Instance_Parameter
            {
                kind         = SymbolKind.Parameter,
                parentSymbol = this,
                name         = p.Name,
                type         = ReflectedTypeReference.ForType(parameterType),
                modifiers    = isByRef ? (p.IsOut ? Modifiers.Out : Modifiers.Ref) : Attribute.IsDefined(p, typeof(ParamArrayAttribute)) ? Modifiers.Params : Modifiers.None,
            };
            if (p.RawDefaultValue != DBNull.Value)
            {
                parameterToAdd.defaultValue = p.RawDefaultValue == null ? "null" : p.RawDefaultValue.ToString();
            }
            parameters.Add(parameterToAdd);
        }
    }
            public override string Expand()
            {
                string modifiersString =
                    method.IsInternal ? (method.IsProtected ? "internal protected" : "internal") :
                    method.IsProtected ? "protected" : "public";
                string returnType = method.ReturnType().RelativeName(context);
                string generics   = method.NumTypeParameters == 0 ? "" :
                                    "<" +
                                    string.Join(", ", (from t in method.typeParameters select t.name).ToArray())
                                    + ">";
                var parameters          = method.GetParameters();
                var parametersSignature = method.PrintParameters(parameters, true);         // TODO: Use the context!
                var argumentSeparator   = "";
                var arguments           = "";

                for (var i = 0; i < parameters.Count; i++)
                {
                    var p = parameters[i];
                    arguments += argumentSeparator;
                    if (p.IsRef)
                    {
                        arguments += "ref ";
                    }
                    else if (p.IsOut)
                    {
                        arguments += "out ";
                    }
                    arguments        += p.name;
                    argumentSeparator = ", ";
                }
                var baseCall = method.IsAbstract ?
                               "throw new " + ReflectedTypeReference.ForType(typeof(System.NotImplementedException)).definition.RelativeName(context) + "();" :
                               "base." + method.name + generics + "(" + arguments + ");";
                var returnStatement = returnType == "void" || method.IsAbstract ? "" : "return ";

                var expandedCode = string.Format(
                    "{0} override {1} {2}{3}({4}){5}{{\n\t{6}{7}$end$\n}}",
                    modifiersString, returnType, method.name, generics, parametersSignature,
                    SISettings.magicMethods_openingBraceOnSameLine ? " " : "\n",
                    returnStatement, baseCall);

                return(expandedCode);
            }
    public override List <SymbolReference> Interfaces()
    {
        if (arrayGenericInterfaces == null && rank == 1)
        {
            arrayGenericInterfaces = new List <SymbolReference> {
                ReflectedTypeReference.ForType(typeof(IEnumerable <>)),
                ReflectedTypeReference.ForType(typeof(IList <>)),
                ReflectedTypeReference.ForType(typeof(ICollection <>)),
            };

            var typeArguments = new[] { new SymbolReference(elementType) };
            for (var i = 0; i < arrayGenericInterfaces.Count; ++i)
            {
                var genericInterface = arrayGenericInterfaces[i].Definition as SD_Type;
                genericInterface          = genericInterface.ConstructType(typeArguments);
                arrayGenericInterfaces[i] = new SymbolReference(genericInterface);
            }
        }
        interfaces = arrayGenericInterfaces ?? base.Interfaces();
        return(interfaces);
    }
Exemple #6
0
    public override SymbolDefinition TypeOf()
    {
        if (memberInfo.MemberType == MemberTypes.Constructor)
        {
            return(parentSymbol.TypeOf());
        }

        if (type != null && (type.Definition == null || !type.Definition.IsValid()))
        {
            type = null;
        }

        if (type == null)
        {
            Type memberType = null;
            switch (memberInfo.MemberType)
            {
            case MemberTypes.Field:
                memberType = ((FieldInfo)memberInfo).FieldType;
                break;

            case MemberTypes.Property:
                memberType = ((PropertyInfo)memberInfo).PropertyType;
                break;

            case MemberTypes.Event:
                memberType = ((EventInfo)memberInfo).EventHandlerType;
                break;

            case MemberTypes.Method:
                memberType = ((MethodInfo)memberInfo).ReturnType;
                break;
            }
            type = ReflectedTypeReference.ForType(memberType);
        }

        return(type != null ? type.Definition : unknownType);
    }
        private void DrawEventListener(Rect rect, int index, bool isactive, bool isfocused)
        {
            var  element            = listenersArray.GetArrayElementAtIndex(index);
            var  propertyMethodName = element.FindPropertyRelative("m_MethodName");
            bool isDefined          = !string.IsNullOrEmpty(propertyMethodName.stringValue);

            MethodInfo method = null;

            if (isDefined && currentEvent != null)
            {
                try
                {
                    rebuildMethod.Invoke(currentEvent, null);
                } catch {}
                persistentCallGroup = persistentCallsField.GetValue(currentEvent);
                var persistentCall = getListenerMethod.Invoke(persistentCallGroup, new object[] { index });
                method = findMethodMethod.Invoke(currentEvent, new [] { persistentCall }) as MethodInfo;

                isDefined = false;
                if (method != null)
                {
                    var declaringType = method.DeclaringType;
                    if (declaringType != null)
                    {
                        var name = declaringType.Assembly.GetName().Name.ToLowerInvariant();
                        isDefined = name == "assembly-csharp" || name == "assembly-csharp-firstpass" ||
                                    name == "assembly-csharp-editor" || name == "assembly-csharp-editor-firstpass";
                    }
                }
            }

            bool isDoubleClick = Event.current.type == EventType.MouseDown &&
                                 Event.current.clickCount == 2 && rect.Contains(Event.current.mousePosition);

            Rect rc = rect;

            rc.y     += 3f;
            rc.height = 15f;
            rc.xMin   = rc.xMax - 21f;
            rc.width  = 21f;

            rect.width -= 20f;
            if (originalCallback != null)
            {
                originalCallback(rect, index, isactive, isfocused);
            }

            if (isactive && isfocused && Event.current.type == EventType.KeyDown && Event.current.character == '\n')
            {
                isDoubleClick = true;
            }

            bool wasEnabled = GUI.enabled;

            GUI.enabled = isDefined;
            bool isButtonClick = GUI.Button(rc, "...", EditorStyles.miniButtonRight);

            if (isDefined && (isButtonClick || isDoubleClick && Event.current.type != EventType.Used))
            {
                var declaringType = ReflectedTypeReference.ForType(method.DeclaringType).definition;
                if (declaringType != null)
                {
                    var member = declaringType.FindName(method.IsSpecialName ? method.Name.Substring("set_".Length) : method.Name, 0, false);
                    if (member != null)
                    {
                        List <SymbolDeclaration> declarations = null;

                        var methodGroup = member as MethodGroupDefinition;
                        if (member.kind == SymbolKind.MethodGroup && methodGroup != null)
                        {
                            var parameters = method.GetParameters();
                            foreach (var m in methodGroup.methods)
                            {
                                if (m.IsStatic)
                                {
                                    continue;
                                }

                                var p = m.GetParameters() ?? new List <ParameterDefinition>();
                                if (p.Count != parameters.Length)
                                {
                                    continue;
                                }

                                for (var i = p.Count; i-- > 0;)
                                {
                                    var pType = p[i].TypeOf();
                                    if (pType == null)
                                    {
                                        goto nextMethod;
                                    }

                                    var parameterType = ReflectedTypeReference.ForType(parameters[i].ParameterType).definition as TypeDefinitionBase;
                                    if (!pType.IsSameType(parameterType))
                                    {
                                        goto nextMethod;
                                    }
                                }

                                // Yay! We found it :)
                                declarations = m.declarations;
                                if (declarations == null || declarations.Count == 0)
                                {
                                    declarations = FGFindInFiles.FindDeclarations(m);
                                    if (declarations == null || declarations.Count == 0)
                                    {
                                        // Boo! Something went wrong.
                                        break;
                                    }
                                }

nextMethod:
                                continue;
                            }
                        }
                        else
                        {
                            // It's a property

                            declarations = member.declarations;
                            if (declarations == null || declarations.Count == 0)
                            {
                                declarations = FGFindInFiles.FindDeclarations(member);
                            }
                        }

                        if (declarations != null && declarations.Count > 0)
                        {
                            foreach (var decl in declarations)
                            {
                                var node = decl.NameNode();
                                if (node == null || !node.HasLeafs())
                                {
                                    continue;
                                }

                                string cuPath = null;
                                for (var scope = decl.scope; scope != null; scope = scope.parentScope)
                                {
                                    var cuScope = scope as CompilationUnitScope;
                                    if (cuScope != null)
                                    {
                                        cuPath = cuScope.path;
                                        break;
                                    }
                                }
                                if (cuPath == null)
                                {
                                    continue;
                                }

                                var cuObject = AssetDatabase.LoadAssetAtPath(cuPath, typeof(MonoScript));
                                if (cuObject == null)
                                {
                                    continue;
                                }

                                var buffer = FGTextBufferManager.GetBuffer(cuObject);
                                if (buffer == null)
                                {
                                    continue;
                                }

                                // Declaration is valid!

                                if (buffer.lines.Count == 0)
                                {
                                    buffer.LoadImmediately();
                                }
                                var span = buffer.GetParseTreeNodeSpan(node);
                                EditorApplication.delayCall += () =>
                                {
                                    FGCodeWindow.OpenAssetInTab(AssetDatabase.AssetPathToGUID(cuPath), span.line + 1);
                                };
                            }
                        }
                    }
                }
            }
            GUI.enabled = wasEnabled;
        }
Exemple #8
0
    public override TypeDefinitionBase BaseType()
    {
        if (resolvingBaseType)
        {
            return(null);
        }
        resolvingBaseType = true;

        if (baseType != null && (baseType.Definition == null || !baseType.Definition.IsValid()) ||
            interfaces != null && interfaces.Exists(x => x.Definition == null || !x.Definition.IsValid()))
        {
            baseType   = null;
            interfaces = null;
        }

        if (baseType == null && interfaces == null)
        {
            interfaces = new List <SymbolReference>();

            SyntaxTreeNode_Rule baseNode          = null;
            SyntaxTreeNode_Rule interfaceListNode = null;
            SymbolDeclaration   decl = null;
            if (declarations != null)
            {
                foreach (var d in declarations)
                {
                    if (d != null)
                    {
                        baseNode = (SyntaxTreeNode_Rule)d.parseTreeNode.FindChildByName(
                            d.kind == SymbolKind.Class ? "classBase" :
                            d.kind == SymbolKind.Struct ? "structInterfaces" :
                            "interfaceBase");
                        interfaceListNode = baseNode != null?baseNode.NodeAt(1) : null;

                        if (baseNode != null)
                        {
                            decl = d;
                            break;
                        }
                    }
                }
            }

            if (decl != null)
            {
                switch (decl.kind)
                {
                case SymbolKind.Class:
                    if (interfaceListNode != null)
                    {
                        baseType = new SymbolReference(interfaceListNode.ChildAt(0));
                        if (baseType.Definition.kind == SymbolKind.Interface)
                        {
                            interfaces.Add(baseType);
                            baseType = this != builtInTypes_object?ReflectedTypeReference.ForType(typeof(object)) : null;
                        }

                        for (var i = 2; i < interfaceListNode.NumValidNodes; i += 2)
                        {
                            interfaces.Add(new SymbolReference(interfaceListNode.ChildAt(i)));
                        }
                    }
                    else
                    {
                        baseType = this != builtInTypes_object?ReflectedTypeReference.ForType(typeof(object)) : null;
                    }
                    break;

                case SymbolKind.Struct:
                case SymbolKind.Interface:
                    baseType = decl.kind == SymbolKind.Struct ?
                               ReflectedTypeReference.ForType(typeof(ValueType)) :
                               ReflectedTypeReference.ForType(typeof(object));
                    if (interfaceListNode != null)
                    {
                        for (var i = 0; i < interfaceListNode.NumValidNodes; i += 2)
                        {
                            interfaces.Add(new SymbolReference(interfaceListNode.ChildAt(i)));
                        }
                    }
                    break;

                case SymbolKind.Enum:
                    baseType = ReflectedTypeReference.ForType(typeof(Enum));
                    break;

                case SymbolKind.Delegate:
                    baseType = ReflectedTypeReference.ForType(typeof(MulticastDelegate));
                    break;
                }
            }
            //Debug.Log("BaseType() of " + this + " is " + (baseType != null ? baseType.definition.ToString() : "null"));
        }

        var result = baseType != null ? baseType.Definition as TypeDefinitionBase : base.BaseType();

        if (result == this)
        {
            baseType = new SymbolReference(circularBaseType);
            result   = circularBaseType;
        }
        resolvingBaseType = false;
        return(result);
    }
    public SD_Type_Reflected(Type type)
    {
        reflectedType = type;
        modifiers     = type.IsNested ?
                        (type.IsNestedPublic ? Modifiers.Public :
                         type.IsNestedFamORAssem ? Modifiers.Internal | Modifiers.Protected :
                         type.IsNestedAssembly ? Modifiers.Internal :
                         type.IsNestedFamily ? Modifiers.Protected :
                         Modifiers.Private)
            :
                        (type.IsPublic ? Modifiers.Public :
                         !type.IsVisible ? Modifiers.Internal :
                         Modifiers.Private);
        if (type.IsAbstract && type.IsSealed)
        {
            modifiers |= Modifiers.Static;
        }
        else if (type.IsAbstract)
        {
            modifiers |= Modifiers.Abstract;
        }
        else if (type.IsSealed)
        {
            modifiers |= Modifiers.Sealed;
        }
        accessLevel = AccessLevelFromModifiers(modifiers);

        var assemblyDefinition = SD_Assembly.FromAssembly(type.Assembly);

        var generic = type.Name.IndexOf('`');

        name         = generic < 0 ? type.Name : type.Name.Substring(0, generic);
        name         = name.Replace("[*]", "[]");
        parentSymbol = string.IsNullOrEmpty(type.Namespace) ? assemblyDefinition.GlobalNamespace : assemblyDefinition.FindNamespace(type.Namespace);
        if (type.IsInterface)
        {
            kind = SymbolKind.Interface;
        }
        else if (type.IsEnum)
        {
            kind = SymbolKind.Enum;
        }
        else if (type.IsValueType)
        {
            kind = SymbolKind.Struct;
        }
        else if (type.IsClass)
        {
            kind = SymbolKind.Class;
            if (type.BaseType == typeof(System.MulticastDelegate))
            {
                kind = SymbolKind.Delegate;
            }
        }
        else
        {
            kind = SymbolKind.None;
        }

        if (type.IsGenericTypeDefinition)
        {
            var gtd            = type.GetGenericTypeDefinition() ?? type;
            var tp             = gtd.GetGenericArguments();
            var numGenericArgs = tp.Length;
            var declaringType  = gtd.DeclaringType;
            if (declaringType != null && declaringType.IsGenericType)
            {
                var parentArgs = declaringType.GetGenericArguments();
                numGenericArgs -= parentArgs.Length;
            }

            if (numGenericArgs > 0)
            {
                typeParameters = new List <SD_Type_Parameter>(numGenericArgs);
                for (var i = tp.Length - numGenericArgs; i < tp.Length; ++i)
                {
                    var tpDef = new SD_Type_Parameter {
                        kind = SymbolKind.TypeParameter, name = tp[i].Name, parentSymbol = this
                    };
                    typeParameters.Add(tpDef);
                }
            }
        }

        if (type.BaseType != null)
        {
            baseType = ReflectedTypeReference.ForType(type.BaseType ?? typeof(object));
        }

        interfaces = new List <SymbolReference>();
        var implements = type.GetInterfaces();

        for (var i = 0; i < implements.Length; ++i)
        {
            interfaces.Add(ReflectedTypeReference.ForType(implements[i]));
        }

        if (IsStatic && NumTypeParameters == 0 && !type.IsNested)
        {
            var attributes = System.Attribute.GetCustomAttributes(type);
            foreach (var attribute in attributes)
            {
                if (attribute is System.Runtime.CompilerServices.ExtensionAttribute)
                {
                    ReflectAllMembers(BindingFlags.Public | BindingFlags.NonPublic);
                    break;
                }
            }
        }
    }
Exemple #10
0
    public static SymbolDefinition GetResolvedSymbol_Internal(ParseTree.BaseNode baseNode)
    {
#endif
        var leaf = baseNode as SyntaxTreeNode_Leaf;
        if (leaf != null)
        {
            if (leaf.ResolvedSymbol == null && leaf.Parent != null)
            {
                ResolveNode(leaf.Parent);
            }
            return(leaf.ResolvedSymbol);
        }

        var node = baseNode as SyntaxTreeNode_Rule;
        if (node == null || node.NumValidNodes == 0)
        {
            return(null);
        }

        switch (node.RuleName)
        {
        case "primaryExpressionStart":
            if (node.NumValidNodes < 3)
            {
                return(GetResolvedSymbol(node.ChildAt(0)));
            }
            leaf = node.LeafAt(2);
            return(leaf != null ? leaf.ResolvedSymbol : null);

        case "primaryExpressionPart":
            return(GetResolvedSymbol(node.NodeAt(0)));

        case "arguments":
            return(GetResolvedSymbol(node.FindPreviousNode() as SyntaxTreeNode_Rule));

        case "objectCreationExpression":
            var newType = GetResolvedSymbol(node.FindPreviousNode() as SyntaxTreeNode_Rule);
            if (newType == null || newType.kind == SymbolKind.Error)
            {
                newType = SymbolDefinition.builtInTypes_object;
            }
            var typeOfNewType = (TypeDefinitionBase)newType.TypeOf();
            return(typeOfNewType.GetThisInstance());

        case "arrayCreationExpression":
            var elementType   = GetResolvedSymbol(node.FindPreviousNode() as SyntaxTreeNode_Rule);
            var arrayInstance = SymbolDefinition.ResolveNode(node, null, elementType);
            return(arrayInstance ?? SymbolDefinition.builtInTypes_Array.GetThisInstance());

        case "nonArrayType":
            var typeNameType = GetResolvedSymbol(node.NodeAt(0)) as TypeDefinitionBase;
            if (typeNameType == null || typeNameType.kind == SymbolKind.Error)
            {
                typeNameType = SymbolDefinition.builtInTypes_object;
            }
            return(node.NumValidNodes == 1 ? typeNameType : typeNameType.MakeNullableType());

        case "typeName":
            return(GetResolvedSymbol(node.NodeAt(0)));

        case "namespaceOrTypeName":
            return(GetResolvedSymbol(node.NodeAt(node.NumValidNodes & ~1)));

        case "accessIdentifier":
            leaf = node.NumValidNodes < 2 ? null : node.LeafAt(1);
            if (leaf != null && leaf.ResolvedSymbol == null)
            {
                SymbolResolver.ResolveNode(node);
            }
            return(leaf != null ? leaf.ResolvedSymbol : null);

        case "predefinedType":
        case "typeOrGeneric":
            return(node.LeafAt(0).ResolvedSymbol);

        case "typeofExpression":
            return(((TypeDefinitionBase)ReflectedTypeReference.ForType(typeof(Type)).Definition).GetThisInstance());

        case "sizeofExpression":
            return(SymbolDefinition.builtInTypes_int.GetThisInstance());

        case "localVariableType":
        case "brackets":
        case "expression":
        case "unaryExpression":
        case "parenExpression":
        case "checkedExpression":
        case "uncheckedExpression":
        case "defaultValueExpression":
        case "relationalExpression":
        case "inclusiveOrExpression":
        case "exclusiveOrExpression":
        case "andExpression":
        case "equalityExpression":
        case "shiftExpression":
        case "primaryExpression":
        case "type":
            return(SymbolDefinition.ResolveNode(node, null, null, 0));

        default:
#if SI3_WARNINGS
            Debug.LogWarning(node.RuleName);
#endif
            return(SymbolDefinition.ResolveNode(node, null, null, 0));
        }
    }
    public SD_Method_Reflected(MethodInfo methodInfo, SymbolDefinition memberOf)
    {
        modifiers =
            methodInfo.IsPublic ? Modifiers.Public :
            methodInfo.IsFamilyOrAssembly ? Modifiers.Internal | Modifiers.Protected :
            methodInfo.IsAssembly ? Modifiers.Internal :
            methodInfo.IsFamily ? Modifiers.Protected :
            Modifiers.Private;
        if (methodInfo.IsAbstract)
        {
            modifiers |= Modifiers.Abstract;
        }
        if (methodInfo.IsVirtual)
        {
            modifiers |= Modifiers.Virtual;
        }
        if (methodInfo.IsStatic)
        {
            modifiers |= Modifiers.Static;
        }
        if (methodInfo.GetBaseDefinition().DeclaringType != methodInfo.DeclaringType)
        {
            modifiers = (modifiers & ~Modifiers.Virtual) | Modifiers.Override;
        }
        if (methodInfo.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), false) && IsStatic)
        {
            var parentType = memberOf.parentSymbol as TypeDefinitionBase;
            if (parentType.kind == SymbolKind.Class && parentType.IsStatic && parentType.NumTypeParameters == 0)
            {
                isExtensionMethod = true;
                ++parentType.numExtensionMethods;
            }
        }
        accessLevel = AccessLevelFromModifiers(modifiers);

        reflectedMethodInfo = methodInfo;
        var genericMarker = methodInfo.Name.IndexOf('`');

        name         = genericMarker < 0 ? methodInfo.Name : methodInfo.Name.Substring(0, genericMarker);
        parentSymbol = memberOf;

        var tp = methodInfo.GetGenericArguments();

        if (tp.Length > 0)
        {
            var numGenericArgs = tp.Length;
            typeParameters = new List <SD_Type_Parameter>(tp.Length);
            for (var i = tp.Length - numGenericArgs; i < tp.Length; ++i)
            {
                var tpDef = new SD_Type_Parameter {
                    kind = SymbolKind.TypeParameter, name = tp[i].Name, parentSymbol = this
                };
                typeParameters.Add(tpDef);
            }
        }

        returnType = ReflectedTypeReference.ForType(methodInfo.ReturnType);

        if (parameters == null)
        {
            parameters = new List <SD_Instance_Parameter>();
        }
        var methodParameters = methodInfo.GetParameters();

        for (var i = 0; i < methodParameters.Length; ++i)
        {
            var p = methodParameters[i];

            var isByRef        = p.ParameterType.IsByRef;
            var parameterType  = isByRef ? p.ParameterType.GetElementType() : p.ParameterType;
            var parameterToAdd = new SD_Instance_Parameter
            {
                kind         = SymbolKind.Parameter,
                parentSymbol = this,
                name         = p.Name,
                type         = ReflectedTypeReference.ForType(parameterType),
                modifiers    = isByRef ? (p.IsOut ? Modifiers.Out : Modifiers.Ref) : Attribute.IsDefined(p, typeof(ParamArrayAttribute)) ? Modifiers.Params : Modifiers.None,
            };
            if (i == 0 && isExtensionMethod)
            {
                parameterToAdd.modifiers |= Modifiers.This;
            }
            if (p.RawDefaultValue != DBNull.Value)
            {
                //var dv = Attribute.GetCustomAttribute(p, typeof(System.ComponentModel.DefaultValueAttribute));
                parameterToAdd.defaultValue = p.RawDefaultValue == null ? "null" : p.RawDefaultValue.ToString();
            }
            parameters.Add(parameterToAdd);
        }
    }