Skip to content

Commit fe286fc

Browse files
Generate DebuggerTypeProxy attribute for Vtbls automatically
1 parent 6aec784 commit fe286fc

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

SharpGen/Generator/VtblGenerator.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32
using System.Linq;
3+
using Microsoft.CodeAnalysis;
44
using Microsoft.CodeAnalysis.CSharp;
55
using Microsoft.CodeAnalysis.CSharp.Syntax;
66
using SharpGen.Config;
@@ -11,6 +11,21 @@ namespace SharpGen.Generator
1111
{
1212
internal sealed class VtblGenerator : CodeGeneratorBase, ICodeGenerator<CsInterface, MemberDeclarationSyntax>
1313
{
14+
private static readonly SyntaxList<AttributeListSyntax> DebuggerTypeProxyAttribute = SingletonList(
15+
AttributeList(
16+
SingletonSeparatedList(
17+
Attribute(
18+
ParseName("System.Diagnostics.DebuggerTypeProxy"),
19+
AttributeArgumentList(
20+
SingletonSeparatedList(
21+
AttributeArgument(TypeOfExpression(IdentifierName("CppObjectVtblDebugView")))
22+
)
23+
)
24+
)
25+
)
26+
)
27+
);
28+
1429
public MemberDeclarationSyntax GenerateCode(CsInterface csElement)
1530
{
1631
var vtblClassName = csElement.VtblName.Split('.').Last();
@@ -105,6 +120,7 @@ StatementSyntax MethodBuilder(PlatformDetectionType platform)
105120
ModelUtilities.VisibilityToTokenList(vtblVisibility, SyntaxKind.UnsafeKeyword,
106121
SyntaxKind.PartialKeyword)
107122
)
123+
.WithAttributeLists(DebuggerTypeProxyAttribute)
108124
.WithBaseList(
109125
BaseList(
110126
SingletonSeparatedList<BaseTypeSyntax>(

0 commit comments

Comments
 (0)