public static string ToMinimalCSharpDisplayString(this ITypeSymbol symbol, SemanticModel vbSemanticModel, int position, SymbolDisplayFormat format = null)
        {
            if (TryGetSpecialVBTypeConversion(symbol, out var cSharpDisplayString))
            {
                return(cSharpDisplayString);
            }
            var minimalCSharpDisplayString = symbol.ToMinimalDisplayString(vbSemanticModel, position, format);
            var parentTypes = symbol.FollowProperty(t => t?.ContainingSymbol as ITypeSymbol).Count() - 1;

            // Workaround: The above call can return a name qualified by a partial namespace, e.g. IO.Path if System is already imported.
            // So check that we don't end up qualifying with non-type symbols by checking the number of dots
            return(minimalCSharpDisplayString.Count(x => x == '.') > parentTypes?ToCSharpDisplayString(symbol, format) : minimalCSharpDisplayString);
        }
Beispiel #2
0
 public static bool ContainsMember(this ITypeSymbol potentialContainer, ISymbol potentialMember)
 {
     return(potentialContainer.FollowProperty(t => t.BaseType).Contains(potentialMember.ContainingType, SymbolEqualityComparer.IncludeNullability));
 }
 public static bool ContainsMember(this ITypeSymbol potentialContainer, ISymbol potentialMember)
 {
     return(potentialContainer.FollowProperty(t => t.BaseType).Contains(potentialMember.ContainingType));
 }