Skip to content

Commit d446b83

Browse files
committed
Finish implementation of ComAlias.
1 parent 503df95 commit d446b83

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

Rubberduck.Parsing/ComReflection/ComAlias.cs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,45 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Diagnostics;
4-
using System.Linq;
53
using System.Runtime.InteropServices;
64
using System.Runtime.InteropServices.ComTypes;
7-
using System.Security.Permissions;
8-
using System.Text;
9-
using System.Threading.Tasks;
105
using TYPEATTR = System.Runtime.InteropServices.ComTypes.TYPEATTR;
6+
using TYPEFLAGS = System.Runtime.InteropServices.ComTypes.TYPEFLAGS;
117

128
namespace Rubberduck.Parsing.ComReflection
139
{
10+
[DebuggerDisplay("{Name} As {TypeName}")]
1411
public class ComAlias : ComBase
1512
{
16-
public VarEnum VarType { get; set; }
17-
18-
public string TypeName { get; set; }
13+
public VarEnum VarType { get; private set; }
14+
public string TypeName { get; private set; }
15+
public bool IsHidden { get; private set; }
16+
public bool IsRestricted { get; private set; }
1917

2018
public ComAlias(ITypeLib typeLib, ITypeInfo info, int index, TYPEATTR attributes) : base(typeLib, index)
2119
{
2220
Index = index;
2321
Documentation = new ComDocumentation(typeLib, index);
22+
Guid = attributes.guid;
2423
VarType = (VarEnum)attributes.tdescAlias.vt;
24+
IsHidden = attributes.wTypeFlags.HasFlag(TYPEFLAGS.TYPEFLAG_FHIDDEN);
25+
IsRestricted = attributes.wTypeFlags.HasFlag(TYPEFLAGS.TYPEFLAG_FRESTRICTED);
26+
27+
if (Name.Equals("LONG_PTR"))
28+
{
29+
TypeName = "LongPtr";
30+
return;
31+
}
32+
2533
if (ComVariant.TypeNames.ContainsKey(VarType))
2634
{
2735
TypeName = ComVariant.TypeNames[VarType];
2836
}
2937
else if (VarType == VarEnum.VT_USERDEFINED)
3038
{
31-
//?
39+
ITypeInfo refType;
40+
info.GetRefTypeInfo((int)attributes.tdescAlias.lpValue, out refType);
41+
var doc = new ComDocumentation(refType, -1);
42+
TypeName = doc.Name;
3243
}
3344
else
3445
{

Rubberduck.Parsing/ComReflection/ComDocumentation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private void LoadDocumentation(ITypeLib typeLib, ITypeInfo info, int index)
3636
}
3737

3838
//See http://chat.stackexchange.com/transcript/message/30119269#30119269
39-
Name = name.Equals("LONG_PTR") ? "LongPtr" : name;
39+
Name = name;
4040
DocString = docString;
4141
HelpContext = helpContext;
4242
HelpFile = helpFile;

Rubberduck.Parsing/ComReflection/ComProject.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ private void LoadModules(ITypeLib typeLibrary)
125125
_classes.Add(coclass as ComCoClass);
126126
if (type != null) KnownTypes.TryAdd(typeAttributes.guid, coclass);
127127
break;
128-
case TYPEKIND.TKIND_ALIAS:
129128
case TYPEKIND.TKIND_DISPATCH:
130129
case TYPEKIND.TKIND_INTERFACE:
131130
var intface = type ?? new ComInterface(typeLibrary, info, typeAttributes, index);
@@ -141,11 +140,10 @@ private void LoadModules(ITypeLib typeLibrary)
141140
_modules.Add(module as ComModule);
142141
if (type != null) KnownTypes.TryAdd(typeAttributes.guid, module);
143142
break;
144-
//case TYPEKIND.TKIND_ALIAS:
145-
// //TKIND_ALIAS does not appear to be a supported member type in VBA - cache it internally to use the aliased type.
146-
// var alias = new ComAlias(typeLibrary, info, index, typeAttributes);
147-
// _aliases.Add(alias);
148-
// break;
143+
case TYPEKIND.TKIND_ALIAS:
144+
var alias = new ComAlias(typeLibrary, info, index, typeAttributes);
145+
_aliases.Add(alias);
146+
break;
149147
case TYPEKIND.TKIND_UNION:
150148
//TKIND_UNION is not a supported member type in VBA.
151149
break;

0 commit comments

Comments
 (0)