Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -934,5 +934,34 @@ class C

Await VerifyTypeHints(input, output)
End Function

<WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/48941")>
Public Async Function TestNoDoubleClickWithCollectionExpression() As Task
Dim input =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
class A
{
private static readonly ImmutableHashSet&lt;string?&gt; Hashes = {| ImmutableHashSet&lt;string?&gt;:|}[];
}
</Document>
</Project>
</Workspace>

Dim output =
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document>
class A
{
private static readonly ImmutableHashSet&lt;string?&gt; Hashes = [];
}
</Document>
</Project>
</Workspace>

Await VerifyTypeHints(input, output)
End Function
End Class
End Namespace
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ internal sealed class CSharpInlineTypeHintsService() : AbstractInlineTypeHintsSe
if (IsValidType(type))
{
var span = new TextSpan(collectionExpression.OpenBracketToken.SpanStart, 0);
return new(type, span, new TextChange(span, GetTypeDisplayString(type)), leadingSpace: true);

// We pass null for the TextChange in collection expressions because
// inserting with the type is incorrect and will make the code uncompilable.
return new(type, span, textChange: null, leadingSpace: true);
}
}
}
Expand Down
Loading