Example #1
0
 public static string ToDisplayString(
     ITypeSymbol symbol,
     CodeAnalysis.NullableAnnotation nullableAnnotation,
     SymbolDisplayFormat?format = null)
 {
     return(ToDisplayParts(symbol, nullableAnnotation, format).ToDisplayString());
 }
Example #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());
        }
Example #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());
 }
Example #4
0
        public static string ToFullDisplayString(
            this ISymbol symbol,
            SymbolDisplayFormat?format = null
            )
        {
            var ds = symbol.ToDisplayString(format);

            return(ds);
        }
Example #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));
        }
Example #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));
        }
Example #7
0
        public static string ToGlobalDisplayString(
            this ISymbol symbol,
            SymbolDisplayFormat?format = null
            )
        {
            var ds = symbol.ToDisplayString(format ?? SymbolDisplayFormat.FullyQualifiedFormat);

            return(ds);
        }
Example #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));
 }
Example #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));
 }
Example #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());
 }
Example #11
0
 ImmutableArray <SymbolDisplayPart> ISymbol.ToMinimalDisplayParts(SemanticModel semanticModel, int position, SymbolDisplayFormat?format)
 {
     return(SymbolDisplay.ToMinimalDisplayParts(this, Symbol.GetCSharpSemanticModel(semanticModel), position, format));
 }
Example #12
0
 string ISymbol.ToMinimalDisplayString(SemanticModel semanticModel, int position, SymbolDisplayFormat?format)
 {
     return(SymbolDisplay.ToMinimalDisplayString(this, Symbol.GetCSharpSemanticModel(semanticModel), position, format));
 }
Example #13
0
 ImmutableArray <SymbolDisplayPart> ISymbol.ToDisplayParts(SymbolDisplayFormat?format)
 {
     return(SymbolDisplay.ToDisplayParts(this, format));
 }
Example #14
0
 string ISymbol.ToDisplayString(SymbolDisplayFormat?format)
 {
     return(SymbolDisplay.ToDisplayString(this, format));
 }