示例#1
0
 public static string ToDisplayString(
     ITypeSymbol symbol,
     CodeAnalysis.NullableAnnotation nullableAnnotation,
     SymbolDisplayFormat?format = null)
 {
     return(ToDisplayParts(symbol, nullableAnnotation, format).ToDisplayString());
 }
示例#2
0
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters

        /// <summary>
        /// Displays a symbol in the C# style, based on a <see cref="SymbolDisplayFormat"/>.
        /// Based on the context, qualify type and member names as little as possible without
        /// introducing ambiguities.
        /// </summary>
        /// <param name="symbol">The symbol to be displayed.</param>
        /// <param name="semanticModel">Semantic information about the context in which the symbol is being displayed.</param>
        /// <param name="position">A position within the <see cref="SyntaxTree"/> or <paramref name="semanticModel"/>.</param>
        /// <param name="format">The formatting options to apply.  If null is passed, <see cref="SymbolDisplayFormat.CSharpErrorMessageFormat"/> will be used.</param>
        /// <returns>A formatted string that can be displayed to the user.</returns>
        /// <remarks>
        /// The return value is not expected to be syntactically valid C#.
        /// </remarks>
        public static string ToMinimalDisplayString(
            ISymbol symbol,
            SemanticModel semanticModel,
            int position,
            SymbolDisplayFormat?format = null)
        {
            return(ToMinimalDisplayParts(symbol, semanticModel, position, format).ToDisplayString());
        }
示例#3
0
 public static string ToMinimalDisplayString(
     ITypeSymbol symbol,
     CodeAnalysis.NullableAnnotation nullableAnnotation,
     SemanticModel semanticModel,
     int position,
     SymbolDisplayFormat?format = null)
 {
     return(ToMinimalDisplayParts(symbol, nullableAnnotation, semanticModel, position, format).ToDisplayString());
 }
示例#4
0
        public static string ToFullDisplayString(
            this ISymbol symbol,
            SymbolDisplayFormat?format = null
            )
        {
            var ds = symbol.ToDisplayString(format);

            return(ds);
        }
示例#5
0
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters

        /// <summary>
        /// Convert a symbol to an array of string parts, each of which has a kind. Useful for
        /// colorizing the display string.
        /// </summary>
        /// <param name="symbol">The symbol to be displayed.</param>
        /// <param name="semanticModel">Semantic information about the context in which the symbol is being displayed.</param>
        /// <param name="position">A position within the <see cref="SyntaxTree"/> or <paramref name="semanticModel"/>.</param>
        /// <param name="format">The formatting options to apply.  If null is passed, <see cref="SymbolDisplayFormat.CSharpErrorMessageFormat"/> will be used.</param>
        /// <returns>A list of display parts.</returns>
        /// <remarks>
        /// Parts are not localized until they are converted to strings.
        /// </remarks>
        public static ImmutableArray <SymbolDisplayPart> ToMinimalDisplayParts(
            ISymbol symbol,
            SemanticModel semanticModel,
            int position,
            SymbolDisplayFormat?format = null)
        {
            format ??= SymbolDisplayFormat.MinimallyQualifiedFormat;
            return(ToDisplayParts(symbol, semanticModel, position, format, minimal: true));
        }
示例#6
0
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters

        /// <summary>
        /// Convert a symbol to an array of string parts, each of which has a kind. Useful for
        /// colorizing the display string.
        /// </summary>
        /// <param name="symbol">The symbol to be displayed.</param>
        /// <param name="format">The formatting options to apply.  If null is passed, <see cref="SymbolDisplayFormat.CSharpErrorMessageFormat"/> will be used.</param>
        /// <returns>A list of display parts.</returns>
        /// <remarks>
        /// Parts are not localized until they are converted to strings.
        /// </remarks>
        public static ImmutableArray <SymbolDisplayPart> ToDisplayParts(
            ISymbol symbol,
            SymbolDisplayFormat?format = null)
        {
            // null indicates the default format
            format = format ?? SymbolDisplayFormat.CSharpErrorMessageFormat;
            return(ToDisplayParts(
                       symbol, semanticModelOpt: null, positionOpt: -1, format: format, minimal: false));
        }
示例#7
0
        public static string ToGlobalDisplayString(
            this ISymbol symbol,
            SymbolDisplayFormat?format = null
            )
        {
            var ds = symbol.ToDisplayString(format ?? SymbolDisplayFormat.FullyQualifiedFormat);

            return(ds);
        }
示例#8
0
 public static ImmutableArray <SymbolDisplayPart> ToMinimalDisplayParts(
     ITypeSymbol symbol,
     CodeAnalysis.NullableAnnotation nullableAnnotation,
     SemanticModel semanticModel,
     int position,
     SymbolDisplayFormat?format = null)
 {
     format ??= SymbolDisplayFormat.MinimallyQualifiedFormat;
     return(ToDisplayParts(symbol.WithNullableAnnotation(nullableAnnotation), semanticModel, position, format, minimal: true));
 }
示例#9
0
 public static ImmutableArray <SymbolDisplayPart> ToDisplayParts(
     ITypeSymbol symbol,
     CodeAnalysis.NullableAnnotation nullableAnnotation,
     SymbolDisplayFormat?format = null)
 {
     // null indicates the default format
     format ??= SymbolDisplayFormat.CSharpErrorMessageFormat;
     return(ToDisplayParts(
                symbol.WithNullableAnnotation(nullableAnnotation), semanticModelOpt: null, positionOpt: -1, format: format, minimal: false));
 }
示例#10
0
 /// <summary>
 /// Displays a symbol in the C# style, based on a <see cref="SymbolDisplayFormat"/>.
 /// </summary>
 /// <param name="symbol">The symbol to be displayed.</param>
 /// <param name="format">The formatting options to apply.  If null is passed, <see cref="SymbolDisplayFormat.CSharpErrorMessageFormat"/> will be used.</param>
 /// <returns>A formatted string that can be displayed to the user.</returns>
 /// <remarks>
 /// The return value is not expected to be syntactically valid C#.
 /// </remarks>
 public static string ToDisplayString(
     ISymbol symbol,
     SymbolDisplayFormat?format = null)
 {
     return(ToDisplayParts(symbol, format).ToDisplayString());
 }
示例#11
0
 ImmutableArray <SymbolDisplayPart> ISymbol.ToMinimalDisplayParts(SemanticModel semanticModel, int position, SymbolDisplayFormat?format)
 {
     return(SymbolDisplay.ToMinimalDisplayParts(this, Symbol.GetCSharpSemanticModel(semanticModel), position, format));
 }
示例#12
0
 string ISymbol.ToMinimalDisplayString(SemanticModel semanticModel, int position, SymbolDisplayFormat?format)
 {
     return(SymbolDisplay.ToMinimalDisplayString(this, Symbol.GetCSharpSemanticModel(semanticModel), position, format));
 }
示例#13
0
 ImmutableArray <SymbolDisplayPart> ISymbol.ToDisplayParts(SymbolDisplayFormat?format)
 {
     return(SymbolDisplay.ToDisplayParts(this, format));
 }
示例#14
0
 string ISymbol.ToDisplayString(SymbolDisplayFormat?format)
 {
     return(SymbolDisplay.ToDisplayString(this, format));
 }