Skip to content

Commit b06a806

Browse files
committed
Add skeleton for ComAlias implementation (partial rollback).
1 parent 6209ae7 commit b06a806

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.Linq;
5+
using System.Runtime.InteropServices;
6+
using System.Runtime.InteropServices.ComTypes;
7+
using System.Security.Permissions;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
using TYPEATTR = System.Runtime.InteropServices.ComTypes.TYPEATTR;
11+
12+
namespace Rubberduck.Parsing.ComReflection
13+
{
14+
public class ComAlias : ComBase
15+
{
16+
public VarEnum VarType { get; set; }
17+
18+
public string TypeName { get; set; }
19+
20+
public ComAlias(ITypeLib typeLib, ITypeInfo info, int index, TYPEATTR attributes) : base(typeLib, index)
21+
{
22+
Index = index;
23+
Documentation = new ComDocumentation(typeLib, index);
24+
VarType = (VarEnum)attributes.tdescAlias.vt;
25+
if (ComVariant.TypeNames.ContainsKey(VarType))
26+
{
27+
TypeName = ComVariant.TypeNames[VarType];
28+
}
29+
else if (VarType == VarEnum.VT_USERDEFINED)
30+
{
31+
//?
32+
}
33+
else
34+
{
35+
throw new NotImplementedException(string.Format("Didn't expect an alias with a type of {0}.", VarType));
36+
}
37+
}
38+
}
39+
}

Rubberduck.Parsing/ComReflection/ComProject.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ public class ComProject : ComBase
2525
// ReSharper disable once NotAccessedField.Local
2626
private TypeLibTypeFlags _flags;
2727

28+
private readonly List<ComAlias> _aliases = new List<ComAlias>();
29+
public IEnumerable<ComAlias> Aliases
30+
{
31+
get { return _aliases; }
32+
}
33+
2834
private readonly List<ComInterface> _interfaces = new List<ComInterface>();
2935
public IEnumerable<ComInterface> Interfaces
3036
{
@@ -119,6 +125,7 @@ private void LoadModules(ITypeLib typeLibrary)
119125
_classes.Add(coclass as ComCoClass);
120126
if (type != null) KnownTypes.TryAdd(typeAttributes.guid, coclass);
121127
break;
128+
case TYPEKIND.TKIND_ALIAS:
122129
case TYPEKIND.TKIND_DISPATCH:
123130
case TYPEKIND.TKIND_INTERFACE:
124131
var intface = type ?? new ComInterface(typeLibrary, info, typeAttributes, index);
@@ -134,8 +141,11 @@ private void LoadModules(ITypeLib typeLibrary)
134141
_modules.Add(module as ComModule);
135142
if (type != null) KnownTypes.TryAdd(typeAttributes.guid, module);
136143
break;
137-
case TYPEKIND.TKIND_ALIAS:
138-
//TKIND_ALIAS does not appear to be a supported member type in VBA.
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;
139149
case TYPEKIND.TKIND_UNION:
140150
//TKIND_UNION is not a supported member type in VBA.
141151
break;

Rubberduck.Parsing/Rubberduck.Parsing.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
<Compile Include="Binding\ParenthesizedDefaultBinding.cs" />
112112
<Compile Include="Binding\TypeBindingContext.cs" />
113113
<Compile Include="Binding\ExpressionClassification.cs" />
114+
<Compile Include="ComReflection\ComAlias.cs" />
114115
<Compile Include="ComReflection\ComBase.cs" />
115116
<Compile Include="ComReflection\ComCoClass.cs" />
116117
<Compile Include="ComReflection\ComDocumentation.cs" />

0 commit comments

Comments
 (0)