Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 24, 2025

Fixes #64632

Summary

The documentation for SymbolDisplayDelegateStyle.NameAndSignature and SymbolDisplayDelegateStyle.NameAndParameters was unclear about what controls the content shown in delegate parameter lists. Users expected that using NameAndSignature would automatically include parameter names and types based on the example in the documentation ("void SomeDelegate(int x)"), but were getting empty parameter lists instead.

The Issue

Given this code:

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

// For: public delegate bool SyntaxReceiverCreator(int a, bool b);

Users expected: bool SyntaxReceiverCreator(int a, bool b)
But got: bool A.SyntaxReceiverCreator() (empty parameter list)

Root Cause

The NameAndSignature option only controls whether the signature (return type + parameter list) is shown, not what is shown inside the parameter list. The actual content of the parameter list is controlled by the SymbolDisplayParameterOptions flags.

Changes Made

Updated the XML documentation for both enum values to explicitly clarify:

  1. NameAndParameters: Added documentation stating that this option determines whether the parameter list (the (...) part) is shown, and that the content is controlled by SymbolDisplayParameterOptions.

  2. NameAndSignature: Added documentation stating that this option determines whether the full signature (return type and parameter list) is shown, and that the content is controlled by SymbolDisplayParameterOptions.

Both now include explicit <see cref="SymbolDisplayParameterOptions"/> references to guide users to the correct API for controlling parameter display content.

Example

To get the expected output with parameter details, users need to combine both options:

var format = new SymbolDisplayFormat(
    delegateStyle: SymbolDisplayDelegateStyle.NameAndSignature,
    parameterOptions: SymbolDisplayParameterOptions.IncludeType | 
                     SymbolDisplayParameterOptions.IncludeName,
    // ... other options
);

This will produce: bool SyntaxReceiverCreator(int a, bool b)

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>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

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

@dotnet/roslyn-compiler doc only change.

@jcouv jcouv self-assigned this Nov 6, 2025
Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks (commit 2)

@CyrusNajmabadi CyrusNajmabadi merged commit ea0effa into main Nov 6, 2025
24 checks passed
@CyrusNajmabadi CyrusNajmabadi deleted the copilot/fix-delegate-parameter-display branch November 6, 2025 20:47
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Nov 6, 2025
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

4 participants