예제 #1
0
        private Declaration CreateFieldDeclaration(ITypeInfo info, int fieldIndex, DeclarationType typeDeclarationType,
                                                   QualifiedModuleName typeQualifiedModuleName, Declaration moduleDeclaration)
        {
            IntPtr ppVarDesc;

            info.GetVarDesc(fieldIndex, out ppVarDesc);

            var varDesc = (VARDESC)Marshal.PtrToStructure(ppVarDesc, typeof(VARDESC));

            var names = new string[255];
            int namesArrayLength;

            info.GetNames(varDesc.memid, names, 255, out namesArrayLength);

            var fieldName      = names[0];
            var fieldValueType = (VarEnum)varDesc.elemdescVar.tdesc.vt;
            var memberType     = GetDeclarationType(varDesc, typeDeclarationType);

            string asTypeName;

            if (!TypeNames.TryGetValue(fieldValueType, out asTypeName))
            {
                asTypeName = TypeNames[VarEnum.VT_VARIANT];
            }

            return(new Declaration(new QualifiedMemberName(typeQualifiedModuleName, fieldName),
                                   moduleDeclaration, moduleDeclaration, asTypeName, false, false, Accessibility.Global, memberType, null,
                                   Selection.Home));
        }
예제 #2
0
        public static string[] GetNames(this FuncDesc fd, ITypeInfo ti)
        {
            var names = new string[fd.cParams + 1];

            ti.GetNames(fd.memid, names, fd.cParams + 1, out _);
            return(names);
        }
예제 #3
0
        private void LoadParameters(FUNCDESC funcDesc, ITypeInfo info)
        {
            var names = new string[255];

            info.GetNames(Index, names, names.Length, out _);

            for (var index = 0; index < funcDesc.cParams; index++)
            {
                var paramPtr = new IntPtr(funcDesc.lprgelemdescParam.ToInt64() + Marshal.SizeOf(typeof(ELEMDESC)) * index);
                var elemDesc = Marshal.PtrToStructure <ELEMDESC>(paramPtr);
                var param    = new ComParameter(this, elemDesc, info, names[index + 1] ?? $"{index}unnamedParameter");
                _parameters.Add(param);
            }

            // See https://docs.microsoft.com/en-us/windows/desktop/midl/propput
            // "A function that has the [propput] attribute must also have, as its last parameter, a parameter that has the [in] attribute."
            if (funcDesc.invkind.HasFlag(INVOKEKIND.INVOKE_PROPERTYPUTREF) ||
                funcDesc.invkind.HasFlag(INVOKEKIND.INVOKE_PROPERTYPUT))
            {
                AsTypeName  = _parameters.Last();
                _parameters = _parameters.Take(funcDesc.cParams - 1).ToList();
                return;
            }

            if (Parameters.Any() && funcDesc.cParamsOpt == -1)
            {
                Parameters.Last().IsParamArray = true;
            }
        }
예제 #4
0
        internal ComMethodDesc(ITypeInfo typeInfo, FUNCDESC funcDesc)
            : this(funcDesc.memid)
        {
            _hasTypeInfo = true;
            InvokeKind   = funcDesc.invkind;

            int cNames;

            string[] rgNames = new string[1 + funcDesc.cParams];
            typeInfo.GetNames(_memid, rgNames, rgNames.Length, out cNames);
            if (IsPropertyPut && rgNames[rgNames.Length - 1] == null)
            {
                rgNames[rgNames.Length - 1] = "value";
                cNames++;
            }
            Debug.Assert(cNames == rgNames.Length);
            _name = rgNames[0];

            _parameters = new ComParamDesc[funcDesc.cParams];

            int offset = 0;

            for (int i = 0; i < funcDesc.cParams; i++)
            {
                ELEMDESC elemDesc = (ELEMDESC)Marshal.PtrToStructure(
                    new IntPtr(funcDesc.lprgelemdescParam.ToInt64() + offset),
                    typeof(ELEMDESC));

                _parameters[i] = new ComParamDesc(ref elemDesc, rgNames[1 + i]);

                offset += Marshal.SizeOf(typeof(ELEMDESC));
            }
        }
예제 #5
0
        internal ComMethodDesc(ITypeInfo typeInfo, FUNCDESC funcDesc)
            : this(funcDesc.memid) {

            _hasTypeInfo = true;
            InvokeKind = funcDesc.invkind;

            int cNames;
            string[] rgNames = new string[1 + funcDesc.cParams];
            typeInfo.GetNames(_memid, rgNames, rgNames.Length, out cNames);
            if (IsPropertyPut && rgNames[rgNames.Length - 1] == null) {
                rgNames[rgNames.Length - 1] = "value";
                cNames++;
            }
            Debug.Assert(cNames == rgNames.Length);
            _name = rgNames[0];

            _parameters = new ComParamDesc[funcDesc.cParams];

            int offset = 0;
            for (int i = 0; i < funcDesc.cParams; i++) {
                ELEMDESC elemDesc = (ELEMDESC)Marshal.PtrToStructure(
                    new IntPtr(funcDesc.lprgelemdescParam.ToInt64() + offset),
                    typeof(ELEMDESC));

                _parameters[i] = new ComParamDesc(ref elemDesc, rgNames[1 + i]);

                offset += Marshal.SizeOf(typeof(ELEMDESC));
            }
        }
예제 #6
0
        internal ComMethodDesc(ITypeInfo typeInfo, FUNCDESC funcDesc)
            : this(funcDesc.memid)
        {
            InvokeKind = funcDesc.invkind;

            int cNames;

            string[] rgNames = new string[1 + funcDesc.cParams];
            typeInfo.GetNames(DispId, rgNames, rgNames.Length, out cNames);

            bool skipLast = false;

            if (IsPropertyPut && rgNames[rgNames.Length - 1] == null)
            {
                rgNames[rgNames.Length - 1] = "value";
                cNames++;
                skipLast = true;
            }
            Debug.Assert(cNames == rgNames.Length);
            _name = rgNames[0];

            ParamCount = funcDesc.cParams;

            ReturnType           = ComUtil.GetTypeFromTypeDesc(funcDesc.elemdescFunc.tdesc);
            ParameterInformation = ComUtil.GetParameterInformation(funcDesc, skipLast);
        }
        private Declaration CreateFieldDeclaration(ITypeInfo info, int fieldIndex, DeclarationType typeDeclarationType,
                                                   QualifiedModuleName typeQualifiedModuleName, Declaration moduleDeclaration)
        {
            IntPtr ppVarDesc;

            info.GetVarDesc(fieldIndex, out ppVarDesc);

            var varDesc = (VARDESC)Marshal.PtrToStructure(ppVarDesc, typeof(VARDESC));

            var names = new string[255];
            int namesArrayLength;

            info.GetNames(varDesc.memid, names, 255, out namesArrayLength);

            var fieldName  = names[0];
            var memberType = GetDeclarationType(varDesc, typeDeclarationType);

            var asTypeName = GetParameterInfo(varDesc.elemdescVar.tdesc, info);

            info.ReleaseVarDesc(ppVarDesc);

            return(new Declaration(new QualifiedMemberName(typeQualifiedModuleName, fieldName),
                                   moduleDeclaration, moduleDeclaration, asTypeName.Name, null, false, false, Accessibility.Global, memberType, null,
                                   Selection.Home, false, null));
        }
예제 #8
0
        private void LoadFuncs(ITypeInfo typeInfo, TYPEATTR typeAttr)
        {
            var skippingFlags = FUNCFLAGS.FUNCFLAG_FRESTRICTED | FUNCFLAGS.FUNCFLAG_FHIDDEN;

            for (var i = 0; i < typeAttr.cFuncs; i++)
            {
                typeInfo.GetFuncDesc(i, out var ptFuncDesc);
                var funcDesc = Marshal.PtrToStructure <FUNCDESC>(ptFuncDesc);

                var currentFlags = (FUNCFLAGS)funcDesc.wFuncFlags;

                if ((currentFlags & skippingFlags) != 0)
                {
                    Marshal.Release(ptFuncDesc);
                    continue;
                }

                var arrOfNames = new string[1];
                var cNames     = arrOfNames.Length;
                var dispId     = funcDesc.memid;

                typeInfo.GetNames(dispId, arrOfNames, cNames, out var names);

                if (names == 0)
                {
                    Marshal.Release(ptFuncDesc);
                    continue;
                }

                var memberName = arrOfNames[0];

                if (funcDesc.invkind == INVOKEKIND.INVOKE_FUNC)
                {
                    var isFunc = funcDesc.elemdescFunc.tdesc.vt != VT_VOID;
                    AddMethod(memberName, dispId, isFunc);
                }
                else
                {
                    var prop = GetOrAddProperty(memberName, dispId);

                    if (funcDesc.invkind == INVOKEKIND.INVOKE_PROPERTYGET)
                    {
                        prop.IsReadable = true;
                    }
                    else
                    {
                        prop.IsWritable = true;
                    }
                }

                Marshal.Release(ptFuncDesc);
            }
        }
예제 #9
0
        public ComEnumerationMember(ITypeInfo info, VARDESC varDesc)
        {
            var value = new ComVariant(varDesc.desc.lpvarValue);

            Value     = (int)value.Value;
            ValueType = value.VariantType;

            var names = new string[1];
            int count;

            info.GetNames(varDesc.memid, names, names.Length, out count);
            Debug.Assert(count == 1);
            Name = names[0];
        }
예제 #10
0
        public MethodDesc(ITypeInfo typeInfo, FUNCDESC funcDesc)
        {
            // Initialise the standard member information.

            string name;
            string docString;
            int    helpContext;
            string helpFile;

            typeInfo.GetDocumentation(funcDesc.memid, out name, out docString, out helpContext, out helpFile);
            Initialise(MemberTypes.Method, name);

            // Get the names of the parameters (index 0 corresponds to the method name itself).

            string[] names = new string[funcDesc.cParams + 1];
            int      nameCount;

            typeInfo.GetNames(funcDesc.memid, names, funcDesc.cParams + 1, out nameCount);

            // Need to account for the return value if there is one.

            bool includeReturnParam = (VarEnum)funcDesc.elemdescFunc.tdesc.vt != VarEnum.VT_VOID &&
                                      (VarEnum)funcDesc.elemdescFunc.tdesc.vt != VarEnum.VT_HRESULT;

            int paramCount = funcDesc.cParams + (includeReturnParam ? 1 : 0);

            m_parameters = new ParameterDesc[paramCount];

            // Iterate over the specified parameters.

            for (int index = 0; index < funcDesc.cParams; ++index)
            {
                // Extract the ELEMDESC.

                IntPtr ptr = (IntPtr)(funcDesc.lprgelemdescParam.ToInt64()
                                      + (long)(Marshal.SizeOf(typeof(ELEMDESC)) * index));
                ELEMDESC elemdesc = (ELEMDESC)Marshal.PtrToStructure(ptr, typeof(ELEMDESC));

                m_parameters[index] = new ParameterDesc(names[index + 1], GetComType(typeInfo, elemdesc.tdesc), elemdesc.desc.idldesc.wIDLFlags);
            }

            // Now add the return value if needed.

            if (includeReturnParam)
            {
                m_parameters[paramCount - 1] = new ParameterDesc("ret", GetComType(typeInfo, funcDesc.elemdescFunc.tdesc) + "*", funcDesc.elemdescFunc.desc.idldesc.wIDLFlags | IDLFLAG.IDLFLAG_FOUT | IDLFLAG.IDLFLAG_FRETVAL);
            }
        }
예제 #11
0
        public unsafe static ICollection <string?> GetMemberNames(this ITypeInfo typeInfo, MemberId id, uint count)
        {
            BasicString *names = stackalloc BasicString[(int)(count)];

            typeInfo.GetNames(id, names, count, out count)
            .ThrowIfFailed($"Failed to get names for member id: {id.Value}");

            var results = new List <string?>((int)count);

            for (int i = 0; i < count; i++)
            {
                results.Add(names[i].ToStringAndFree());
            }

            return(results);
        }
예제 #12
0
        internal ComMethodDesc(ITypeInfo typeInfo, FUNCDESC funcDesc)
            : this(funcDesc.memid)
        {
            _invokeKind = funcDesc.invkind;

            string[] rgNames = new string[1 + funcDesc.cParams];
            typeInfo.GetNames(DispId, rgNames, rgNames.Length, out int cNames);
            if (IsPropertyPut && rgNames[rgNames.Length - 1] == null)
            {
                rgNames[rgNames.Length - 1] = "value";
                cNames++;
            }
            Debug.Assert(cNames == rgNames.Length);
            Name = rgNames[0];

            ParamCount = funcDesc.cParams;
        }
예제 #13
0
        private void GetComFields(ITypeInfo info, TYPEATTR attrib)
        {
            var names = new string[1];

            for (var index = 0; index < attrib.cVars; index++)
            {
                IntPtr varPtr;
                info.GetVarDesc(index, out varPtr);
                var desc = (VARDESC)Marshal.PtrToStructure(varPtr, typeof(VARDESC));
                int length;
                info.GetNames(desc.memid, names, names.Length, out length);
                Debug.Assert(length == 1);

                _fields.Add(new ComField(names[0], desc, index, DeclarationType.Constant));
                info.ReleaseVarDesc(varPtr);
            }
        }
예제 #14
0
        private void GetComFields(ITypeInfo info, TYPEATTR attrib)
        {
            var names = new string[1];

            for (var index = 0; index < attrib.cVars; index++)
            {
                info.GetVarDesc(index, out IntPtr varPtr);
                using (DisposalActionContainer.Create(varPtr, info.ReleaseVarDesc))
                {
                    var desc = Marshal.PtrToStructure <VARDESC>(varPtr);
                    info.GetNames(desc.memid, names, names.Length, out int length);
                    Debug.Assert(length == 1);

                    _fields.Add(new ComField(this, info, names[0], desc, index, DeclarationType.Constant));
                }
            }
        }
예제 #15
0
        internal ComMethodDesc(ITypeInfo typeInfo, FUNCDESC funcDesc)
            : this(funcDesc.memid) {

            InvokeKind = funcDesc.invkind;

            int cNames;
            string[] rgNames = new string[1 + funcDesc.cParams];
            typeInfo.GetNames(_memid, rgNames, rgNames.Length, out cNames);
            if (IsPropertyPut && rgNames[rgNames.Length - 1] == null) {
                rgNames[rgNames.Length - 1] = "value";
                cNames++;
            }
            Debug.Assert(cNames == rgNames.Length);
            _name = rgNames[0];

            _paramCnt = funcDesc.cParams;
        }
예제 #16
0
        private void GetComFields(ITypeInfo info, TYPEATTR attrib)
        {
            var names = new string[1];

            for (var index = 0; index < attrib.cVars; index++)
            {
                info.GetVarDesc(index, out IntPtr varPtr);
                using (DisposalActionContainer.Create(varPtr, info.ReleaseVarDesc))
                {
                    var desc = Marshal.PtrToStructure <VARDESC>(varPtr);
                    info.GetNames(desc.memid, names, names.Length, out int length);
                    Debug.Assert(length == 1);

                    DeclarationType type;
                    if (info is ITypeInfoWrapper wrapped && wrapped.HasVBEExtensions)
                    {
                        type = desc.IsValidVBAConstant() ? DeclarationType.Constant : DeclarationType.Variable;
                    }
예제 #17
0
        private void LoadParameters(FUNCDESC funcDesc, ITypeInfo info)
        {
            Parameters = new List<ComParameter>();
            var names = new string[255];
            int count;
            info.GetNames(Index, names, 255, out count);

            for (var index = 0; index < count - 1; index++)
            {
                var paramPtr = new IntPtr(funcDesc.lprgelemdescParam.ToInt64() + Marshal.SizeOf(typeof(ELEMDESC)) * index);
                var elemDesc = (ELEMDESC)Marshal.PtrToStructure(paramPtr, typeof(ELEMDESC));
                var param = new ComParameter(elemDesc, info, names[index + 1]);
                Parameters.Add(param);
            }
            if (Parameters.Any() && funcDesc.cParamsOpt == -1)
            {
                Parameters.Last().IsParamArray = true;
            }
        }
예제 #18
0
        public static IEnumerable <DispatchMember> GetDispatchMembers(this ITypeInfo typeInfo)
        {
            var funcCount    = typeInfo.GetTypeAttr().cFuncs;
            var isEnumerable = false;

            var names = new string[1];

            for (var index = 0; index < funcCount; index++)
            {
                IntPtr pDesc;
                typeInfo.GetFuncDesc(index, out pDesc);
                try
                {
                    var desc = (FUNCDESC)Marshal.PtrToStructure(pDesc, typeof(FUNCDESC));
                    if (desc.memid == SpecialDispIDs.NewEnum)
                    {
                        isEnumerable = true;
                    }

                    if ((desc.wFuncFlags & (short)FUNCFLAGS.FUNCFLAG_FRESTRICTED) != 0)
                    {
                        continue;
                    }

                    int nameCount;
                    typeInfo.GetNames(desc.memid, names, 1, out nameCount);
                    if (nameCount > 0)
                    {
                        yield return(new DispatchMember(names[0], desc.memid, desc.invkind));
                    }
                }
                finally
                {
                    typeInfo.ReleaseFuncDesc(pDesc);
                }

                if (isEnumerable)
                {
                    yield return(new DispatchMember("GetEnumerator", SpecialDispIDs.GetEnumerator, INVOKEKIND.INVOKE_FUNC));
                }
            }
        }
예제 #19
0
        public static IEnumerable <DispatchMember> GetDispatchMembers(this ITypeInfo typeInfo)
        {
            using (var attrScope = typeInfo.CreateAttrScope())
            {
                var count        = attrScope.Value.cFuncs;
                var isEnumerable = false;

                var names = new string[1];
                for (var index = 0; index < count; index++)
                {
                    using (var funcDescScope = typeInfo.CreateFuncDescScope(index))
                    {
                        if (funcDescScope.Value.memid == SpecialDispIDs.NewEnum)
                        {
                            isEnumerable = true;
                        }

                        if ((funcDescScope.Value.wFuncFlags & (short)FUNCFLAGS.FUNCFLAG_FRESTRICTED) != 0)
                        {
                            continue;
                        }

                        int nameCount;
                        typeInfo.GetNames(funcDescScope.Value.memid, names, 1, out nameCount);
                        if (nameCount > 0)
                        {
                            yield return(new DispatchMember(names[0], funcDescScope.Value.memid, funcDescScope.Value.invkind));
                        }

                        if (isEnumerable)
                        {
                            yield return(new DispatchMember("GetEnumerator", SpecialDispIDs.GetEnumerator, INVOKEKIND.INVOKE_FUNC));
                        }
                    }
                }
            }
        }
예제 #20
0
        internal ComMethodDesc(ITypeInfo typeInfo, FUNCDESC funcDesc)
            : this(funcDesc.memid)
        {
            InvokeKind = funcDesc.invkind;

            int cNames;
            string[] rgNames = new string[1 + funcDesc.cParams];
            typeInfo.GetNames(DispId, rgNames, rgNames.Length, out cNames);

            bool skipLast = false;
            if (IsPropertyPut && rgNames[rgNames.Length - 1] == null)
            {
                rgNames[rgNames.Length - 1] = "value";
                cNames++;
                skipLast = true;
            }
            Debug.Assert(cNames == rgNames.Length);
            _name = rgNames[0];

            ParamCount = funcDesc.cParams;

            ReturnType = ComUtil.GetTypeFromTypeDesc(funcDesc.elemdescFunc.tdesc);
            ParameterInformation = ComUtil.GetParameterInformation(funcDesc, skipLast);
        }
예제 #21
0
        private Declaration CreateMemberDeclaration(out FUNCDESC memberDescriptor, TYPEKIND typeKind, ITypeInfo info, int memberIndex,
                                                    QualifiedModuleName typeQualifiedModuleName, Declaration moduleDeclaration, out string[] memberNames)
        {
            IntPtr memberDescriptorPointer;

            info.GetFuncDesc(memberIndex, out memberDescriptorPointer);
            memberDescriptor = (FUNCDESC)Marshal.PtrToStructure(memberDescriptorPointer, typeof(FUNCDESC));

            if (memberDescriptor.callconv != CALLCONV.CC_STDCALL)
            {
                memberDescriptor = new FUNCDESC();
                memberNames      = new string[] {};
                return(null);
            }

            memberNames = new string[255];
            int namesArrayLength;

            info.GetNames(memberDescriptor.memid, memberNames, 255, out namesArrayLength);

            var memberName            = memberNames[0];
            var funcValueType         = (VarEnum)memberDescriptor.elemdescFunc.tdesc.vt;
            var memberDeclarationType = GetDeclarationType(memberDescriptor, funcValueType, typeKind);

            var asTypeName = string.Empty;

            if (memberDeclarationType != DeclarationType.Procedure && !TypeNames.TryGetValue(funcValueType, out asTypeName))
            {
                if (funcValueType == VarEnum.VT_PTR)
                {
                    try
                    {
                        var asTypeDesc = (TYPEDESC)Marshal.PtrToStructure(memberDescriptor.elemdescFunc.tdesc.lpValue, typeof(TYPEDESC));
                        asTypeName = GetTypeName(asTypeDesc, info);
                    }
                    catch
                    {
                        asTypeName = funcValueType.ToString(); //TypeNames[VarEnum.VT_VARIANT];
                    }
                }
                else
                {
                    asTypeName = funcValueType.ToString(); //TypeNames[VarEnum.VT_VARIANT];
                }
            }

            var attributes = new Attributes();

            if (memberName == "_NewEnum" && ((FUNCFLAGS)memberDescriptor.wFuncFlags).HasFlag(FUNCFLAGS.FUNCFLAG_FNONBROWSABLE))
            {
                attributes.AddEnumeratorMemberAttribute(memberName);
            }
            else if (memberDescriptor.memid == 0)
            {
                attributes.AddDefaultMemberAttribute(memberName);
                //Debug.WriteLine("Default member found: {0}.{1} ({2} / {3})", moduleDeclaration.IdentifierName, memberName, memberDeclarationType, (VarEnum)memberDescriptor.elemdescFunc.tdesc.vt);
            }
            else if (((FUNCFLAGS)memberDescriptor.wFuncFlags).HasFlag(FUNCFLAGS.FUNCFLAG_FHIDDEN))
            {
                attributes.AddHiddenMemberAttribute(memberName);
            }

            return(new Declaration(new QualifiedMemberName(typeQualifiedModuleName, memberName),
                                   moduleDeclaration, moduleDeclaration, asTypeName, false, false, Accessibility.Global, memberDeclarationType,
                                   null, Selection.Home, true, null, attributes));
        }
        private Declaration CreateMemberDeclaration(FUNCDESC memberDescriptor, TYPEKIND typeKind, ITypeInfo info, IMPLTYPEFLAGS parentImplFlags,
                                                    QualifiedModuleName typeQualifiedModuleName, Declaration moduleDeclaration, out string[] memberNames)
        {
            if (memberDescriptor.callconv != CALLCONV.CC_STDCALL)
            {
                memberNames = new string[] { };
                return(null);
            }

            memberNames = new string[255];
            int namesArrayLength;

            info.GetNames(memberDescriptor.memid, memberNames, 255, out namesArrayLength);

            var memberName            = memberNames[0];
            var funcValueType         = (VarEnum)memberDescriptor.elemdescFunc.tdesc.vt;
            var memberDeclarationType = GetDeclarationType(memberName, memberDescriptor, funcValueType, typeKind, parentImplFlags);

            if (((FUNCFLAGS)memberDescriptor.wFuncFlags).HasFlag(FUNCFLAGS.FUNCFLAG_FRESTRICTED) &&
                IgnoredInterfaceMembers.Contains(memberName)) // Ignore IDispatch and IUnknown members - quick-and-dirty for beta
            {
                return(null);
            }

            var asTypeName = new ComParameter(string.Empty, false);

            if (memberDeclarationType != DeclarationType.Procedure)
            {
                asTypeName = GetParameterInfo(memberDescriptor.elemdescFunc.tdesc, info);
            }
            var attributes = new Attributes();

            if (memberName == "_NewEnum" && ((FUNCFLAGS)memberDescriptor.wFuncFlags).HasFlag(FUNCFLAGS.FUNCFLAG_FNONBROWSABLE))
            {
                attributes.AddEnumeratorMemberAttribute(memberName);
            }
            else if (memberDescriptor.memid == 0)
            {
                attributes.AddDefaultMemberAttribute(memberName);
            }
            else if (((FUNCFLAGS)memberDescriptor.wFuncFlags).HasFlag(FUNCFLAGS.FUNCFLAG_FHIDDEN))
            {
                attributes.AddHiddenMemberAttribute(memberName);
            }

            switch (memberDeclarationType)
            {
            case DeclarationType.Procedure:
                return(new SubroutineDeclaration(
                           new QualifiedMemberName(typeQualifiedModuleName, memberName),
                           moduleDeclaration,
                           moduleDeclaration,
                           asTypeName.Name,
                           Accessibility.Global,
                           null,
                           Selection.Home,
                           true,
                           null,
                           attributes));

            case DeclarationType.Function:
                return(new FunctionDeclaration(
                           new QualifiedMemberName(typeQualifiedModuleName, memberName),
                           moduleDeclaration,
                           moduleDeclaration,
                           asTypeName.Name,
                           null,
                           null,
                           Accessibility.Global,
                           null,
                           Selection.Home,
                           asTypeName.IsArray,
                           true,
                           null,
                           attributes));

            case DeclarationType.PropertyGet:
                return(new PropertyGetDeclaration(
                           new QualifiedMemberName(typeQualifiedModuleName, memberName),
                           moduleDeclaration,
                           moduleDeclaration,
                           asTypeName.Name,
                           null,
                           null,
                           Accessibility.Global,
                           null,
                           Selection.Home,
                           asTypeName.IsArray,
                           true,
                           null,
                           attributes));

            case DeclarationType.PropertySet:
                return(new PropertySetDeclaration(
                           new QualifiedMemberName(typeQualifiedModuleName, memberName),
                           moduleDeclaration,
                           moduleDeclaration,
                           asTypeName.Name,
                           Accessibility.Global,
                           null,
                           Selection.Home,
                           true,
                           null,
                           attributes));

            case DeclarationType.PropertyLet:
                return(new PropertyLetDeclaration(
                           new QualifiedMemberName(typeQualifiedModuleName, memberName),
                           moduleDeclaration,
                           moduleDeclaration,
                           asTypeName.Name,
                           Accessibility.Global,
                           null,
                           Selection.Home,
                           true,
                           null,
                           attributes));

            default:
                return(new Declaration(
                           new QualifiedMemberName(typeQualifiedModuleName, memberName),
                           moduleDeclaration,
                           moduleDeclaration,
                           asTypeName.Name,
                           null,
                           false,
                           false,
                           Accessibility.Global,
                           memberDeclarationType,
                           null,
                           Selection.Home,
                           false,
                           null,
                           true,
                           null,
                           attributes));
            }
        }