From 09ce863133faae620cd1f9fd81c3f824f87785c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Petryka?= <35800402+MichalPetryka@users.noreply.github.com> Date: Tue, 17 Sep 2024 03:17:51 +0200 Subject: [PATCH] Filter nested types properly --- Disasmo/Utils/SymbolUtils.cs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Disasmo/Utils/SymbolUtils.cs b/Disasmo/Utils/SymbolUtils.cs index 295116f..a48f252 100644 --- a/Disasmo/Utils/SymbolUtils.cs +++ b/Disasmo/Utils/SymbolUtils.cs @@ -13,17 +13,10 @@ public static DisasmoSymbolInfo FromSymbol(ISymbol symbol) string prefix = ""; ISymbol containingType = symbol as ITypeSymbol ?? symbol.ContainingType; - // match all for nested types - if (containingType.ContainingType is { }) - prefix = "*"; - - else if (containingType.ContainingNamespace?.Name is { Length: > 0 } containingNamespace) + if (containingType.ContainingNamespace?.MetadataName is { Length: > 0 } containingNamespace) prefix = containingNamespace + "."; - prefix += containingType.MetadataName; - - if (containingType is INamedTypeSymbol { IsGenericType: true }) - prefix += "*"; + prefix += GetTypeNameFilter(containingType); if (symbol is IMethodSymbol ms) { @@ -61,5 +54,15 @@ public static DisasmoSymbolInfo FromSymbol(ISymbol symbol) methodName = "*"; } return new DisasmoSymbolInfo(target, hostType, methodName); + + static string GetTypeNameFilter(ISymbol type) + { + string filter = type.MetadataName; + if (type is INamedTypeSymbol { IsGenericType: true }) + filter += "*"; + if (type.ContainingType is { } containingType) + filter = $"{GetTypeNameFilter(containingType)}+{filter}"; + return filter; + } } }