Skip to content

Commit 88c6e7c

Browse files
authored
Merge pull request #3702 from WaynePhillipsEA/com-collector-corrections
Minor corrections to uses of ITypeLib/ITypeInfo
2 parents 1efea16 + d722ce3 commit 88c6e7c

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

Rubberduck.Parsing/ComReflection/ComEnumerationMember.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public ComEnumerationMember(ITypeInfo info, VARDESC varDesc)
1818
Value = (int)value.Value;
1919
ValueType = value.VariantType;
2020

21-
var names = new string[255];
21+
var names = new string[1];
2222
int count;
23-
info.GetNames(varDesc.memid, names, 1, out count);
23+
info.GetNames(varDesc.memid, names, names.Length, out count);
2424
Debug.Assert(count == 1);
2525
Name = names[0];
2626
}

Rubberduck.Parsing/ComReflection/ComMember.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private void LoadParameters(FUNCDESC funcDesc, ITypeInfo info)
8585
Parameters = new List<ComParameter>();
8686
var names = new string[255];
8787
int count;
88-
info.GetNames(Index, names, 255, out count);
88+
info.GetNames(Index, names, names.Length, out count);
8989

9090
for (var index = 0; index < count - 1; index++)
9191
{

Rubberduck.Parsing/ComReflection/ComModule.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ public ComModule(ITypeLib typeLib, ITypeInfo info, TYPEATTR attrib, int index) :
5252

5353
private void GetComFields(ITypeInfo info, TYPEATTR attrib)
5454
{
55-
var names = new string[255];
55+
var names = new string[1];
5656
for (var index = 0; index < attrib.cVars; index++)
5757
{
5858
IntPtr varPtr;
5959
info.GetVarDesc(index, out varPtr);
6060
var desc = (VARDESC)Marshal.PtrToStructure(varPtr, typeof(VARDESC));
6161
int length;
62-
info.GetNames(desc.memid, names, 255, out length);
62+
info.GetNames(desc.memid, names, names.Length, out length);
6363
Debug.Assert(length == 1);
6464

6565
_fields.Add(new ComField(names[0], desc, index, DeclarationType.Constant));

Rubberduck.Parsing/ComReflection/ComProject.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ private void ProcessLibraryAttributes(ITypeLib typeLibrary)
9393
MinorVersion = typeAttr.wMinorVerNum;
9494
_flags = (TypeLibTypeFlags)typeAttr.wLibFlags;
9595
Guid = typeAttr.guid;
96+
97+
typeLibrary.ReleaseTLibAttr(attribPtr);
9698
}
9799
catch (COMException) { }
98100
}

Rubberduck.Parsing/ComReflection/ComStruct.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ public ComStruct(ITypeLib typeLib, ITypeInfo info, TYPEATTR attrib, int index)
2727

2828
private void GetFields(ITypeInfo info, TYPEATTR attrib)
2929
{
30-
var names = new string[255];
30+
var names = new string[1];
3131
for (var index = 0; index < attrib.cVars; index++)
3232
{
3333
IntPtr varPtr;
3434
info.GetVarDesc(index, out varPtr);
3535
var desc = (VARDESC)Marshal.PtrToStructure(varPtr, typeof(VARDESC));
3636
int length;
37-
info.GetNames(desc.memid, names, 255, out length);
37+
info.GetNames(desc.memid, names, names.Length, out length);
3838
Debug.Assert(length == 1);
3939

4040
_fields.Add(new ComField(names[0], desc, index, DeclarationType.UserDefinedTypeMember));

0 commit comments

Comments
 (0)