33using  System . Linq ; 
44using  System . Runtime . InteropServices ; 
55using  System . Runtime . InteropServices . ComTypes ; 
6+ using  Rubberduck . Parsing . Grammar ; 
67using  Rubberduck . VBEditor . Utility ; 
78using  ELEMDESC  =  System . Runtime . InteropServices . ComTypes . ELEMDESC ; 
89using  PARAMFLAG  =  System . Runtime . InteropServices . ComTypes . PARAMFLAG ; 
@@ -39,12 +40,13 @@ public class ComParameter
3940        public  bool  IsReturnValue  {  get ;  } 
4041        public  bool  IsParamArray  {  get ;  set ;  } 
4142        public  object  DefaultValue  {  get ;  } 
43+         public  bool  HasDefaultValue  =>  DefaultValue  !=  null ; 
4244
4345        public  string  DefaultAsEnum 
4446        { 
4547            get 
4648            { 
47-                 if  ( ! _typeName . IsEnumMember  ||  ! ComProject . KnownEnumerations . TryGetValue ( _typeName . EnumGuid ,  out  ComEnumeration  enumType ) ) 
49+                 if  ( ! _typeName . IsEnumMember  ||  ! HasDefaultValue   ||   ! ComProject . KnownEnumerations . TryGetValue ( _typeName . EnumGuid ,  out  ComEnumeration  enumType ) ) 
4850                { 
4951                    return  string . Empty ; 
5052                } 
@@ -114,7 +116,7 @@ private void GetParameterType(TYPEDESC desc, ITypeInfo info)
114116                    using  ( DisposalActionContainer . Create ( attribPtr ,  refTypeInfo . ReleaseTypeAttr ) ) 
115117                    { 
116118                        var  attribs  =  Marshal . PtrToStructure < TYPEATTR > ( attribPtr ) ; 
117-                         var  type  =  new  ComDocumentation ( refTypeInfo ,  - 1 ) . Name ; 
119+                         var  type  =  new  ComDocumentation ( refTypeInfo ,  ComDocumentation . LibraryIndex ) . Name ; 
118120                        if  ( attribs . typekind  ==  TYPEKIND . TKIND_ENUM ) 
119121                        { 
120122                            _typeName  =  new  ComTypeName ( Project ,  type ,  attribs . guid ,  Guid . Empty ) ; 
@@ -131,7 +133,7 @@ private void GetParameterType(TYPEDESC desc, ITypeInfo info)
131133                } 
132134                catch  ( COMException ) 
133135                { 
134-                     _typeName  =  new  ComTypeName ( Project ,  " Object" ) ; 
136+                     _typeName  =  new  ComTypeName ( Project ,  Tokens . Object ) ; 
135137                } 
136138            } 
137139            else  if  ( vt  ==  VarEnum . VT_SAFEARRAY  ||  vt  ==  VarEnum . VT_CARRAY  ||  vt . HasFlag ( VarEnum . VT_ARRAY ) ) 
@@ -142,11 +144,11 @@ private void GetParameterType(TYPEDESC desc, ITypeInfo info)
142144            } 
143145            else  if  ( vt  ==  VarEnum . VT_HRESULT ) 
144146            { 
145-                 _typeName  =  new  ComTypeName ( Project ,  " Long" ) ; 
147+                 _typeName  =  new  ComTypeName ( Project ,  Tokens . Long ) ; 
146148            } 
147149            else 
148150            { 
149-                 _typeName  =  new  ComTypeName ( Project ,  ( ComVariant . TypeNames . TryGetValue ( vt ,  out  string  result ) )  ?  result  :  " Object" ) ; 
151+                 _typeName  =  new  ComTypeName ( Project ,  ( ComVariant . TypeNames . TryGetValue ( vt ,  out  string  result ) )  ?  result  :  Tokens . Object ) ; 
150152            } 
151153        } 
152154    } 
0 commit comments