Skip to content

Commit

Permalink
Merge pull request #65838 from CyrusNajmabadi/rawRegex
Browse files Browse the repository at this point in the history
Fix Regex features in raw-string-literals.
  • Loading branch information
CyrusNajmabadi authored Dec 8, 2022
2 parents 92d2ddd + b96eb89 commit 85712db
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 85 deletions.
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("""$$ """);
}
}
]]></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

0 comments on commit 85712db

Please sign in to comment.