diff --git a/Codist/Helpers/CodeAnalysisHelper.Symbol.cs b/Codist/Helpers/CodeAnalysisHelper.Symbol.cs index 7fc57ed2..78d63948 100644 --- a/Codist/Helpers/CodeAnalysisHelper.Symbol.cs +++ b/Codist/Helpers/CodeAnalysisHelper.Symbol.cs @@ -162,6 +162,14 @@ public static ISymbol GetAliasTarget(this ISymbol symbol) { return symbol.Kind == SymbolKind.Alias ? (symbol as IAliasSymbol).Target : symbol; } + public static IEnumerable GetContainingTypes(this ISymbol symbol) { + var t = symbol.ContainingType; + while (t != null) { + yield return t; + t = t.ContainingType; + } + } + public static ITypeSymbol ResolveElementType(this ITypeSymbol t) { switch (t.Kind) { case SymbolKind.ArrayType: return ResolveElementType(((IArrayTypeSymbol)t).ElementType); diff --git a/Codist/Helpers/CodeAnalysisHelper.SymbolFinder.cs b/Codist/Helpers/CodeAnalysisHelper.SymbolFinder.cs index a24082ea..9751d0a4 100644 --- a/Codist/Helpers/CodeAnalysisHelper.SymbolFinder.cs +++ b/Codist/Helpers/CodeAnalysisHelper.SymbolFinder.cs @@ -425,19 +425,19 @@ public static KeyValuePair[] FindReferencingSymbols(this SyntaxNod Predicate usageFilter = null; switch (symbol.Kind) { case SymbolKind.NamedType: - if ((symbol as INamedTypeSymbol).IsBoundedGenericType()) { + // hack: In VS 2017 with Rosyln 2.10, we don't need this, + // but in VS 2019, we have to do that, otherwise we will get nothing. + // The same to SymbolKind.Method. + if ((symbol as INamedTypeSymbol).IsBoundedGenericType() + || symbol.GetContainingTypes().Any(t => t.IsBoundedGenericType())) { sign = symbol.ToDisplayString(); - // hack: in VS 2017 with Rosyln 2.10, we don't need this, - // but in VS 2019, we have to do that, otherwise we will get nothing symbol = symbol.OriginalDefinition; } break; case SymbolKind.Method: var m = symbol as IMethodSymbol; - if (m.IsBoundedGenericMethod()) { + if (m.IsBoundedGenericMethod() || m.GetContainingTypes().Any(t => t.IsBoundedGenericType())) { sign = symbol.ToDisplayString(); - // hack: in VS 2017 with Rosyln 2.10, we don't need this, - // but in VS 2019, we have to do that, otherwise we will get nothing symbol = symbol.OriginalDefinition; } else if (m.IsExtensionMethod) {