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

Fix Regex features in raw-string-literals. #65838

Merged
merged 4 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -6,7 +6,6 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
<[UseExportProvider]>
<Trait(Traits.Feature, Traits.Features.Completion)>
Public Class CSharpCompletionCommandHandlerTests_Regex

<WpfTheory, CombinatorialData>
Public Async Function ExplicitInvoke(showCompletionInArgumentLists As Boolean) As Task
Using state = TestStateFactory.CreateCSharpTestState(
Expand All @@ -29,6 +28,28 @@ class c
End Using
End Function

<WpfTheory, CombinatorialData>
Public Async Function ExplicitInvoke_Utf8(showCompletionInArgumentLists As Boolean) As Task
Using state = TestStateFactory.CreateCSharpTestState(
<Document><![CDATA[
using System.Text.RegularExpressions;
class c
{
void goo()
{
var r = new Regex("$$"u8);
}
}
]]></Document>, showCompletionInArgumentLists:=showCompletionInArgumentLists)

state.SendInvokeCompletionList()
Await state.AssertSelectedCompletionItem("\A", inlineDescription:=FeaturesResources.Regex_start_of_string_only_short)
state.SendTab()
Await state.AssertNoCompletionSession()
Assert.Contains("new Regex(""\\A""u8)", state.GetLineTextFromCaretPosition(), StringComparison.Ordinal)
End Using
End Function

<WpfTheory, CombinatorialData>
Public Async Function ExplicitInvoke_VerbatimString(showCompletionInArgumentLists As Boolean) As Task
Using state = TestStateFactory.CreateCSharpTestState(
Expand All @@ -51,6 +72,74 @@ class c
End Using
End Function

<WpfTheory, CombinatorialData>
Public Async Function ExplicitInvoke_VerbatimUtf8String(showCompletionInArgumentLists As Boolean) As Task
Using state = TestStateFactory.CreateCSharpTestState(
<Document><![CDATA[
using System.Text.RegularExpressions;
class c
{
void goo()
{
var r = new Regex(@"$$"u8);
}
}
]]></Document>, showCompletionInArgumentLists:=showCompletionInArgumentLists)

state.SendInvokeCompletionList()
Await state.AssertSelectedCompletionItem("\A")
state.SendTab()
Await state.AssertNoCompletionSession()
Assert.Contains("new Regex(@""\A""u8)", state.GetLineTextFromCaretPosition(), StringComparison.Ordinal)
End Using
End Function

<WpfTheory, CombinatorialData>
Public Async Function ExplicitInvoke_RawSingleLineString(showCompletionInArgumentLists As Boolean) As Task
Using state = TestStateFactory.CreateCSharpTestState(
<Document><![CDATA[
using System.Text.RegularExpressions;
class c
{
void goo()
{
var r = new Regex("""$$ """);
Copy link
Member Author

Choose a reason for hiding this comment

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

this case would previously assert, but not crash.

}
}
]]></Document>, showCompletionInArgumentLists:=showCompletionInArgumentLists)

state.SendInvokeCompletionList()
Await state.AssertSelectedCompletionItem("\A")
state.SendTab()
Await state.AssertNoCompletionSession()
Assert.Contains("new Regex(""""""\A """""")", state.GetLineTextFromCaretPosition(), StringComparison.Ordinal)
End Using
End Function

<WpfTheory, CombinatorialData>
Public Async Function ExplicitInvoke_RawMultiLineString(showCompletionInArgumentLists As Boolean) As Task
Using state = TestStateFactory.CreateCSharpTestState(
<Document><![CDATA[
using System.Text.RegularExpressions;
class c
{
void goo()
{
var r = new Regex("""
$$
""");
}
}
]]></Document>, showCompletionInArgumentLists:=showCompletionInArgumentLists)

state.SendInvokeCompletionList()
Await state.AssertSelectedCompletionItem("\A")
state.SendTab()
Await state.AssertNoCompletionSession()
Assert.Contains(" \A", state.GetLineTextFromCaretPosition(), StringComparison.Ordinal)
End Using
End Function

<WpfTheory, CombinatorialData>
Public Async Function TestCaretPlacement(showCompletionInArgumentLists As Boolean) As Task
Using state = TestStateFactory.CreateCSharpTestState(
Expand Down
Loading