Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signature help should use SymbolDisplayMiscellaneousOptions.AllowDefaultLiteral #47552

Merged
merged 4 commits into from
Sep 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,30 @@ void Goo(int someParameter, bool something)

#region "Trigger tests"

[Fact, Trait(Traits.Feature, Traits.Features.SignatureHelp)]
[WorkItem(47364, "https://github.com/dotnet/roslyn/issues/47364")]
public async Task TestInvocationOnTriggerParens_OptionalDefaultStruct()
{
var markup = @"
using System;
using System.Threading;

class Program
{
static void SomeMethod(CancellationToken token = default) => throw new NotImplementedException();

static void Main(string[] args)
{
[|SomeMethod($$|]);
}
}";

var expectedOrderedItems = new List<SignatureHelpTestItem>();
expectedOrderedItems.Add(new SignatureHelpTestItem("void Program.SomeMethod([CancellationToken token = default])", string.Empty, null, currentParameterIndex: 0));

await TestAsync(markup, expectedOrderedItems, usePreviousCharAsTrigger: true);
}

[Fact, Trait(Traits.Feature, Traits.Features.SignatureHelp)]
public async Task TestInvocationOnTriggerParens()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ namespace Microsoft.CodeAnalysis.CSharp.SignatureHelp
{
internal abstract class AbstractCSharpSignatureHelpProvider : AbstractSignatureHelpProvider
{
private static readonly SymbolDisplayFormat s_allowDefaultLiteralFormat = SymbolDisplayFormat.MinimallyQualifiedFormat
.AddMiscellaneousOptions(SymbolDisplayMiscellaneousOptions.AllowDefaultLiteral);

protected AbstractCSharpSignatureHelpProvider()
{
}
Expand Down Expand Up @@ -53,7 +56,7 @@ protected static SignatureHelpSymbolParameter Convert(
parameter.Name,
parameter.IsOptional,
parameter.GetDocumentationPartsFactory(semanticModel, position, formatter),
parameter.ToMinimalDisplayParts(semanticModel, position));
parameter.ToMinimalDisplayParts(semanticModel, position, s_allowDefaultLiteralFormat));
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to take into account language version, so we don't show default literals to people on C# <7.1? Or do we not worry about that sort of thing? Or does ToMinimalDisplayParts take care of that?

Copy link
Member Author

Choose a reason for hiding this comment

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

@davidwengier I don't know if ToMinimalDisplayParts accounts for language version or not.
Probably @sharwell or @CyrusNajmabadi know?

Copy link
Member

Choose a reason for hiding this comment

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

It doesn't need to account for lang version. How we present info is different from what suggestions we offer, or what code we generate :)

}

/// <summary>
Expand Down