Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 24, 2025

Fixes #11232

Problem

The documentation for SymbolDisplayDelegateStyle.NameAndSignature was misleading. The example showed "void SomeDelegate(int x)", which suggested that parameter names would always be displayed when using this option. However, the actual behavior depends on the SymbolDisplayParameterOptions flags being set.

Users were confused when NameAndSignature didn't show parameter names or details, not realizing they needed to also specify appropriate SymbolDisplayParameterOptions flags to control what appears within the signature.

Changes

Updated the documentation for both NameAndParameters and NameAndSignature to:

  1. Clarify the separation of concerns:

    • SymbolDisplayDelegateStyle controls whether the signature part appears
    • SymbolDisplayParameterOptions controls what appears in the signature (types, names, modifiers, etc.)
  2. Add explicit references:

    • Changed vague wording like "will be determined by the other flags passed" to explicitly reference <see cref="SymbolDisplayParameterOptions"/>
  3. Fix misleading examples:

    • Changed examples from "void SomeDelegate(int x)" to "void SomeDelegate(int, int)" to avoid implying parameter names are automatically included
    • Parameter names only appear when SymbolDisplayParameterOptions.IncludeName is set

Example

var format1 = new SymbolDisplayFormat(
    delegateStyle: SymbolDisplayDelegateStyle.NameAndSignature,
    parameterOptions: SymbolDisplayParameterOptions.IncludeType);
// Output: "void SomeDelegate(int, bool)" - types only, no parameter names

var format2 = new SymbolDisplayFormat(
    delegateStyle: SymbolDisplayDelegateStyle.NameAndSignature,
    parameterOptions: SymbolDisplayParameterOptions.IncludeType | SymbolDisplayParameterOptions.IncludeName);
// Output: "void SomeDelegate(int a, bool b)" - types AND names

The updated documentation makes it clear that users need to set the appropriate SymbolDisplayParameterOptions flags to get the desired level of detail in the signature.

Original prompt

This section details on the original issue you should resolve

<issue_title>INamedType.ToDisplayString omits delegate's parameters</issue_title>
<issue_description>Version Used: 4.3.0

Steps to Reproduce:

SymbolDisplayFormat options:

var format = new SymbolDisplayFormat(
        globalNamespaceStyle: SymbolDisplayGlobalNamespaceStyle.Omitted,
        typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces,
        delegateStyle: SymbolDisplayDelegateStyle.NameAndSignature,
        miscellaneousOptions: SymbolDisplayMiscellaneousOptions.UseSpecialTypes);

Code example:

namespace A
{
    public delegate bool SyntaxReceiverCreator(int a, bool b);
}

Expected Behavior:
as delegateStyle: SymbolDisplayDelegateStyle.NameAndSignature is active, I expect INamedType.ToDisplayString(format) produces output:

bool SyntaxReceiverCreator(int a, bool b)

Actual Behavior:
INamedType.ToDisplayString(format) produces output (without parameters):

bool A.SyntaxReceiverCreator()

From parameter description:

SymbolDisplayDelegateStyle.NameAndSignature - Shows the name and the signature of the delegate (e.g. "void SomeDelegate(int x)").

Issue in arcade: dotnet/arcade#11232</issue_description>

<agent_instructions>Copilot, can you clarify teh docs for NameAndSignature. It should mention that this flag is just to determine if the signature will be there or not (the (...) part), but not what is shown in the signature. Control of what is in the signature should be explicitly stated using the right SymbolDisplayParameterOptions flags. </agent_instructions>

Comments on the Issue (you are @copilot in this section)

@RikkiGibson The `A.` prefix is expected since we are using `SymbolDisplayTypeQualificationStyle.NameAndContainingTypesAndNamespaces`.

I agree that the documentation of SymbolDisplayDelegateStyle.NameAndSignature indicates that the parameters are expected to be displayed. Let's fix that.</comment_new>
<comment_new>@CyrusNajmabadi
@RikkiGibson i'm thinking this is by-design. The parameter controls if we want the signature or not. But then the format of the signature is controlled by SymbolDisplayParameterOptions. So i think what we want instead is to just doc NameAndSignature to indicate that Parameter options should be provided.</comment_new>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix INamedType.ToDisplayString to include delegate parameters Clarify SymbolDisplayDelegateStyle documentation to reference SymbolDisplayParameterOptions Oct 24, 2025
Copilot AI requested a review from CyrusNajmabadi October 24, 2025 14:36
Copilot finished work on behalf of CyrusNajmabadi October 24, 2025 14:36
@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review November 6, 2025 19:33
@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner November 6, 2025 19:33
@CyrusNajmabadi
Copy link
Member

@dotnet/roslyn-compiler doc only change.

@CyrusNajmabadi
Copy link
Member

Closing in favor of #80885

@CyrusNajmabadi CyrusNajmabadi deleted the copilot/fix-inamedtype-displaystring branch November 6, 2025 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

INamedType.ToDisplayString omits delegate's parameters Expand analyzer analysis to compilation level

2 participants