/// <summary>
 /// This version also accepts <see cref="SymbolDisplayCompilerInternalOptions"/>.
 /// </summary>
 internal SymbolDisplayFormat(
     SymbolDisplayCompilerInternalOptions compilerInternalOptions,
     SymbolDisplayGlobalNamespaceStyle globalNamespaceStyle     = default(SymbolDisplayGlobalNamespaceStyle),
     SymbolDisplayTypeQualificationStyle typeQualificationStyle = default(SymbolDisplayTypeQualificationStyle),
     SymbolDisplayGenericsOptions genericsOptions           = default(SymbolDisplayGenericsOptions),
     SymbolDisplayMemberOptions memberOptions               = default(SymbolDisplayMemberOptions),
     SymbolDisplayParameterOptions parameterOptions         = default(SymbolDisplayParameterOptions),
     SymbolDisplayDelegateStyle delegateStyle               = default(SymbolDisplayDelegateStyle),
     SymbolDisplayExtensionMethodStyle extensionMethodStyle = default(SymbolDisplayExtensionMethodStyle),
     SymbolDisplayPropertyStyle propertyStyle               = default(SymbolDisplayPropertyStyle),
     SymbolDisplayLocalOptions localOptions = default(SymbolDisplayLocalOptions),
     SymbolDisplayKindOptions kindOptions   = default(SymbolDisplayKindOptions),
     SymbolDisplayMiscellaneousOptions miscellaneousOptions = default(SymbolDisplayMiscellaneousOptions))
 {
     this.GlobalNamespaceStyle    = globalNamespaceStyle;
     this.TypeQualificationStyle  = typeQualificationStyle;
     this.GenericsOptions         = genericsOptions;
     this.MemberOptions           = memberOptions;
     this.ParameterOptions        = parameterOptions;
     this.DelegateStyle           = delegateStyle;
     this.ExtensionMethodStyle    = extensionMethodStyle;
     this.PropertyStyle           = propertyStyle;
     this.LocalOptions            = localOptions;
     this.KindOptions             = kindOptions;
     this.MiscellaneousOptions    = miscellaneousOptions;
     this.CompilerInternalOptions = compilerInternalOptions;
 }
        /// <summary>
        /// This version also accepts <see cref="SymbolDisplayCompilerInternalOptions"/>.
        /// </summary>
        internal SymbolDisplayFormat(
            SymbolDisplayCompilerInternalOptions compilerInternalOptions,
            SymbolDisplayGlobalNamespaceStyle globalNamespaceStyle     = default(SymbolDisplayGlobalNamespaceStyle),
            SymbolDisplayTypeQualificationStyle typeQualificationStyle = default(SymbolDisplayTypeQualificationStyle),
            SymbolDisplayGenericsOptions genericsOptions           = default(SymbolDisplayGenericsOptions),
            SymbolDisplayMemberOptions memberOptions               = default(SymbolDisplayMemberOptions),
            SymbolDisplayParameterOptions parameterOptions         = default(SymbolDisplayParameterOptions),
            SymbolDisplayDelegateStyle delegateStyle               = default(SymbolDisplayDelegateStyle),
            SymbolDisplayExtensionMethodStyle extensionMethodStyle = default(SymbolDisplayExtensionMethodStyle),
            SymbolDisplayPropertyStyle propertyStyle               = default(SymbolDisplayPropertyStyle),
            SymbolDisplayLocalOptions localOptions = default(SymbolDisplayLocalOptions),
            SymbolDisplayKindOptions kindOptions   = default(SymbolDisplayKindOptions),
            SymbolDisplayMiscellaneousOptions miscellaneousOptions = default(SymbolDisplayMiscellaneousOptions))
        {
            // If we want to display `!`, then we surely also want to display `?`
            Debug.Assert(miscellaneousOptions.IncludesOption(SymbolDisplayMiscellaneousOptions.IncludeNullableReferenceTypeModifier) ||
                         !compilerInternalOptions.IncludesOption(SymbolDisplayCompilerInternalOptions.IncludeNonNullableTypeModifier));

            this.GlobalNamespaceStyle    = globalNamespaceStyle;
            this.TypeQualificationStyle  = typeQualificationStyle;
            this.GenericsOptions         = genericsOptions;
            this.MemberOptions           = memberOptions;
            this.ParameterOptions        = parameterOptions;
            this.DelegateStyle           = delegateStyle;
            this.ExtensionMethodStyle    = extensionMethodStyle;
            this.PropertyStyle           = propertyStyle;
            this.LocalOptions            = localOptions;
            this.KindOptions             = kindOptions;
            this.MiscellaneousOptions    = miscellaneousOptions;
            this.CompilerInternalOptions = compilerInternalOptions;
        }
 /// <summary>
 /// Constructs a new instance of <see cref="SymbolDisplayFormat"/> accepting a variety of optional parameters.
 /// </summary>
 /// <param name="globalNamespaceStyle">
 /// The settings that determine how the global namespace is displayed.
 /// </param>
 /// <param name="typeQualificationStyle">
 /// The settings that determine how types are qualified (e.g. Nested vs Containing.Nested vs Namespace.Containing.Nested).
 /// </param>
 /// <param name="genericsOptions">
 /// The settings that determine how generics (on types and methods) should be described (i.e. the level of detail).
 /// </param>
 /// <param name="memberOptions">
 /// The settings that determine how fields, properties, events, and methods are displayed.
 /// </param>
 /// <param name="delegateStyle">
 /// The settings that determine how delegates are displayed (e.g. name vs full signature).
 /// </param>
 /// <param name="extensionMethodStyle">
 /// The settings that determine how extension methods are displayed.
 /// </param>
 /// <param name="parameterOptions">
 /// The settings that determine how parameters (of methods, properties/indexers, and delegates) are displayed.
 /// </param>
 /// <param name="propertyStyle">
 /// The settings that determine how properties are displayed.
 /// For example, "Prop" vs "Prop { get; set; }" in C# or "Prop" vs. "ReadOnly Prop" in Visual Basic.
 /// </param>
 /// <param name="localOptions">
 /// The settings that determine how local variables are displayed.
 /// </param>
 /// <param name="kindOptions">
 /// The settings that determine which kind keywords should be included when displaying symbols.
 /// </param>
 /// <param name="miscellaneousOptions">
 /// The settings that determine other characteristics of how symbols are displayed.
 /// </param>
 public SymbolDisplayFormat(
     SymbolDisplayGlobalNamespaceStyle globalNamespaceStyle     = default(SymbolDisplayGlobalNamespaceStyle),
     SymbolDisplayTypeQualificationStyle typeQualificationStyle = default(SymbolDisplayTypeQualificationStyle),
     SymbolDisplayGenericsOptions genericsOptions           = default(SymbolDisplayGenericsOptions),
     SymbolDisplayMemberOptions memberOptions               = default(SymbolDisplayMemberOptions),
     SymbolDisplayDelegateStyle delegateStyle               = default(SymbolDisplayDelegateStyle),
     SymbolDisplayExtensionMethodStyle extensionMethodStyle = default(SymbolDisplayExtensionMethodStyle),
     SymbolDisplayParameterOptions parameterOptions         = default(SymbolDisplayParameterOptions),
     SymbolDisplayPropertyStyle propertyStyle               = default(SymbolDisplayPropertyStyle),
     SymbolDisplayLocalOptions localOptions = default(SymbolDisplayLocalOptions),
     SymbolDisplayKindOptions kindOptions   = default(SymbolDisplayKindOptions),
     SymbolDisplayMiscellaneousOptions miscellaneousOptions = default(SymbolDisplayMiscellaneousOptions))
     : this(
         compilerInternalOptions : default,
         globalNamespaceStyle,
         typeQualificationStyle,
         genericsOptions,
         memberOptions,
         parameterOptions,
         delegateStyle,
         extensionMethodStyle,
         propertyStyle,
         localOptions,
         kindOptions,
         miscellaneousOptions)
 {
 }
 /// <summary>
 /// Determines if a flag is set on the <see cref="SymbolDisplayKindOptions"/> enum.
 /// </summary>
 /// <param name="options">The value to check.</param>
 /// <param name="flag">An enum field that specifies the flag.</param>
 /// <returns>Whether the <paramref name="flag"/> is set on the <paramref name="options"/>.</returns>
 internal static bool IncludesOption(
     this SymbolDisplayKindOptions options,
     SymbolDisplayKindOptions flag
     )
 {
     return((options & flag) == flag);
 }
 /// <summary>
 /// Creates a copy of the SymbolDisplayFormat but with replaced set of <seealso cref="SymbolDisplayKindOptions"/>.
 /// </summary>
 /// <param name="options">
 /// An object specifying parameters with which symbols belonging to kind keywords should be formatted.
 /// </param>
 /// <returns>
 /// A duplicate of the SymbolDisplayFormat, with a replaced set of <seealso cref="SymbolDisplayKindOptions"/>.
 /// </returns>
 public SymbolDisplayFormat WithKindOptions(SymbolDisplayKindOptions options)
 {
     return(new SymbolDisplayFormat(
                this.GlobalNamespaceStyle,
                this.TypeQualificationStyle,
                this.GenericsOptions,
                this.MemberOptions,
                this.DelegateStyle,
                this.ExtensionMethodStyle,
                this.ParameterOptions,
                this.PropertyStyle,
                this.LocalOptions,
                options,
                this.MiscellaneousOptions));
 }
Beispiel #6
0
        public static string ToDocComment(this ISymbol symbol,
                                          SymbolDisplayGlobalNamespaceStyle globalNamespaceStyle     = SymbolDisplayGlobalNamespaceStyle.Included,
                                          SymbolDisplayTypeQualificationStyle typeQualificationStyle = SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces,
                                          SymbolDisplayGenericsOptions genericsOptions           = SymbolDisplayGenericsOptions.IncludeTypeParameters,
                                          SymbolDisplayMemberOptions memberOptions               = SymbolDisplayMemberOptions.IncludeContainingType,
                                          SymbolDisplayDelegateStyle delegateStyle               = SymbolDisplayDelegateStyle.NameAndSignature,
                                          SymbolDisplayExtensionMethodStyle extensionMethodStyle = SymbolDisplayExtensionMethodStyle.StaticMethod,
                                          SymbolDisplayParameterOptions parameterOptions         = SymbolDisplayParameterOptions.IncludeType,
                                          SymbolDisplayPropertyStyle propertyStyle               = SymbolDisplayPropertyStyle.NameOnly,
                                          SymbolDisplayLocalOptions localOptions = SymbolDisplayLocalOptions.None,
                                          SymbolDisplayKindOptions kindOptions   = SymbolDisplayKindOptions.None,
                                          SymbolDisplayMiscellaneousOptions miscellaneousOptions = SymbolDisplayMiscellaneousOptions.ExpandNullable)
        {
            if (symbol == null)
            {
                return(string.Empty);
            }
            var fmt = symbol.ToDisplayString(new SymbolDisplayFormat(globalNamespaceStyle, typeQualificationStyle, genericsOptions, memberOptions, delegateStyle, extensionMethodStyle, parameterOptions, propertyStyle, localOptions, kindOptions, miscellaneousOptions));
            var sb  = new StringBuilder(fmt.Length);

            for (var i = 0; i < fmt.Length; i++)
            {
                var c = fmt[i];
                if (fmt[i] == '<')
                {
                    sb.Append('{');
                }
                else if (fmt[i] == '>')
                {
                    sb.Append('}');
                }
                else
                {
                    sb.Append(c);
                }
            }
            return(sb.ToString());
        }
 /// <summary>
 /// Creates a copy of the SymbolDisplayFormat but with a set of <seealso cref="SymbolDisplayKindOptions"/> stripped away from the original object.
 /// </summary>
 /// <param name="options">
 /// The settings that determine other characteristics of how symbols are displayed.
 /// </param>
 /// <returns>
 /// A duplicate of the SymbolDisplayFormat, with a set of <seealso cref="SymbolDisplayKindOptions"/> stripped away from the original object.
 /// </returns>
 public SymbolDisplayFormat RemoveKindOptions(SymbolDisplayKindOptions options)
 {
     return(this.WithKindOptions(this.KindOptions & ~options));
 }
 /// <summary>
 /// Creates a copy of the SymbolDisplayFormat but with an additional set of <seealso cref="SymbolDisplayKindOptions"/>.
 /// </summary>
 /// <param name="options">
 /// An object specifying additional parameters with which symbols belonging to kind keywords should be formatted.
 /// </param>
 /// <returns>
 /// A duplicate of the SymbolDisplayFormat, with an additional set of <seealso cref="SymbolDisplayKindOptions"/>.
 /// </returns>
 public SymbolDisplayFormat AddKindOptions(SymbolDisplayKindOptions options)
 {
     return(this.WithKindOptions(this.KindOptions | options));
 }
 /// <summary>
 /// Determines if a flag is set on the <see cref="SymbolDisplayKindOptions"/> enum.
 /// </summary>
 /// <param name="options">The value to check.</param>
 /// <param name="flag">An enum field that specifies the flag.</param>
 /// <returns>Whether the <paramref name="flag"/> is set on the <paramref name="options"/>.</returns>
 internal static bool IncludesOption(this SymbolDisplayKindOptions options, SymbolDisplayKindOptions flag)
 {
     return (options & flag) == flag;
 }
Beispiel #10
0
 /// <summary>
 /// Creates a copy of the SymbolDisplayFormat but with a set of <seealso cref="SymbolDisplayKindOptions"/> stripped away from the original object.
 /// </summary>
 /// <param name="options">
 /// The settings that determine other characteristics of how symbols are displayed.
 /// </param>
 /// <returns>
 /// A duplicate of the SymbolDisplayFormat, with a set of <seealso cref="SymbolDisplayKindOptions"/> stripped away from the original object.
 /// </returns>
 public SymbolDisplayFormat RemoveKindOptions(SymbolDisplayKindOptions options)
 {
     return this.WithKindOptions(this.KindOptions & ~options);
 }
Beispiel #11
0
 /// <summary>
 /// Creates a copy of the SymbolDisplayFormat but with an additional set of <seealso cref="SymbolDisplayKindOptions"/>.
 /// </summary>
 /// <param name="options">
 /// An object specifying additional parameters with which symbols belonging to kind keywords should be formatted.
 /// </param>
 /// <returns>
 /// A duplicate of the SymbolDisplayFormat, with an additional set of <seealso cref="SymbolDisplayKindOptions"/>.
 /// </returns>
 public SymbolDisplayFormat AddKindOptions(SymbolDisplayKindOptions options)
 {
     return this.WithKindOptions(this.KindOptions | options);
 }
Beispiel #12
0
 /// <summary>
 /// Creates a copy of the SymbolDisplayFormat but with replaced set of <seealso cref="SymbolDisplayKindOptions"/>.
 /// </summary>
 /// <param name="options">
 /// An object specifying parameters with which symbols belonging to kind keywords should be formatted.
 /// </param>
 /// <returns>
 /// A duplicate of the SymbolDisplayFormat, with a replaced set of <seealso cref="SymbolDisplayKindOptions"/>.
 /// </returns>
 public SymbolDisplayFormat WithKindOptions(SymbolDisplayKindOptions options)
 {
     return new SymbolDisplayFormat(
         this.GlobalNamespaceStyle,
         this.TypeQualificationStyle,
         this.GenericsOptions,
         this.MemberOptions,
         this.DelegateStyle,
         this.ExtensionMethodStyle,
         this.ParameterOptions,
         this.PropertyStyle,
         this.LocalOptions,
         options,
         this.MiscellaneousOptions);
 }
Beispiel #13
0
 /// <summary>
 /// This version also accepts <see cref="SymbolDisplayCompilerInternalOptions"/>.
 /// </summary>
 internal SymbolDisplayFormat(
     SymbolDisplayCompilerInternalOptions compilerInternalOptions,
     SymbolDisplayGlobalNamespaceStyle globalNamespaceStyle = default(SymbolDisplayGlobalNamespaceStyle),
     SymbolDisplayTypeQualificationStyle typeQualificationStyle = default(SymbolDisplayTypeQualificationStyle),
     SymbolDisplayGenericsOptions genericsOptions = default(SymbolDisplayGenericsOptions),
     SymbolDisplayMemberOptions memberOptions = default(SymbolDisplayMemberOptions),
     SymbolDisplayParameterOptions parameterOptions = default(SymbolDisplayParameterOptions),
     SymbolDisplayDelegateStyle delegateStyle = default(SymbolDisplayDelegateStyle),
     SymbolDisplayExtensionMethodStyle extensionMethodStyle = default(SymbolDisplayExtensionMethodStyle),
     SymbolDisplayPropertyStyle propertyStyle = default(SymbolDisplayPropertyStyle),
     SymbolDisplayLocalOptions localOptions = default(SymbolDisplayLocalOptions),
     SymbolDisplayKindOptions kindOptions = default(SymbolDisplayKindOptions),
     SymbolDisplayMiscellaneousOptions miscellaneousOptions = default(SymbolDisplayMiscellaneousOptions))
 {
     this.GlobalNamespaceStyle = globalNamespaceStyle;
     this.TypeQualificationStyle = typeQualificationStyle;
     this.GenericsOptions = genericsOptions;
     this.MemberOptions = memberOptions;
     this.ParameterOptions = parameterOptions;
     this.DelegateStyle = delegateStyle;
     this.ExtensionMethodStyle = extensionMethodStyle;
     this.PropertyStyle = propertyStyle;
     this.LocalOptions = localOptions;
     this.KindOptions = kindOptions;
     this.MiscellaneousOptions = miscellaneousOptions;
     this.CompilerInternalOptions = compilerInternalOptions;
 }
Beispiel #14
0
 /// <summary>
 /// Constructs a new instance of <see cref="SymbolDisplayFormat"/> accepting a variety of optional parameters.
 /// </summary>
 /// <param name="globalNamespaceStyle">
 /// The settings that determine how the global namespace is displayed.
 /// </param>
 /// <param name="typeQualificationStyle">
 /// The settings that determine how types are qualified (e.g. Nested vs Containing.Nested vs Namespace.Containing.Nested).
 /// </param>
 /// <param name="genericsOptions">
 /// The settings that determine how generics (on types and methods) should be described (i.e. the level of detail).
 /// </param>
 /// <param name="memberOptions">
 /// The settings that determine how fields, properties, events, and methods are displayed.
 /// </param>
 /// <param name="delegateStyle">
 /// The settings that determine how delegates are displayed (e.g. name vs full signature).
 /// </param>
 /// <param name="extensionMethodStyle">
 /// The settings that determine how extension methods are displayed.
 /// </param>
 /// <param name="parameterOptions">
 /// The settings that determine how parameters (of methods, properties/indexers, and delegates) are displayed.
 /// </param>
 /// <param name="propertyStyle">
 /// The settings that determine how properties are displayed. 
 /// For example, "Prop" vs "Prop { get; set; }" in C# or "Prop" vs. "ReadOnly Prop" in Visual Basic.
 /// </param>
 /// <param name="localOptions">
 /// The settings that determine how local variables are displayed.
 /// </param>
 /// <param name="kindOptions">
 /// The settings that determine which kind keywords should be included when displaying symbols.
 /// </param>
 /// <param name="miscellaneousOptions">
 /// The settings that determine other characteristics of how symbols are displayed.
 /// </param>
 public SymbolDisplayFormat(
     SymbolDisplayGlobalNamespaceStyle globalNamespaceStyle = default(SymbolDisplayGlobalNamespaceStyle),
     SymbolDisplayTypeQualificationStyle typeQualificationStyle = default(SymbolDisplayTypeQualificationStyle),
     SymbolDisplayGenericsOptions genericsOptions = default(SymbolDisplayGenericsOptions),
     SymbolDisplayMemberOptions memberOptions = default(SymbolDisplayMemberOptions),
     SymbolDisplayDelegateStyle delegateStyle = default(SymbolDisplayDelegateStyle),
     SymbolDisplayExtensionMethodStyle extensionMethodStyle = default(SymbolDisplayExtensionMethodStyle),
     SymbolDisplayParameterOptions parameterOptions = default(SymbolDisplayParameterOptions),
     SymbolDisplayPropertyStyle propertyStyle = default(SymbolDisplayPropertyStyle),
     SymbolDisplayLocalOptions localOptions = default(SymbolDisplayLocalOptions),
     SymbolDisplayKindOptions kindOptions = default(SymbolDisplayKindOptions),
     SymbolDisplayMiscellaneousOptions miscellaneousOptions = default(SymbolDisplayMiscellaneousOptions))
     : this(
         default(SymbolDisplayCompilerInternalOptions),
         globalNamespaceStyle,
         typeQualificationStyle,
         genericsOptions,
         memberOptions,
         parameterOptions,
         delegateStyle,
         extensionMethodStyle,
         propertyStyle,
         localOptions,
         kindOptions,
         miscellaneousOptions)
 {
 }