提交 97b66030 编写于 作者: J Jonathon Marolf

Allow generate from useaga to work in TypOfIsNot expressions

上级 6307dbc1
...@@ -2193,7 +2193,7 @@ index:=1) ...@@ -2193,7 +2193,7 @@ index:=1)
End Sub End Sub
<WorkItem(643, "https://github.com/dotnet/roslyn/issues/643")> <WorkItem(643, "https://github.com/dotnet/roslyn/issues/643")>
<Fact(), Trait(Traits.Feature, Traits.Features.CodeActionsGenerateVariable)> <Fact(), Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)>
Public Sub TestGenerateMethodWithMethodChaining() Public Sub TestGenerateMethodWithMethodChaining()
Test( Test(
NewLines("Imports System \n Imports System.Linq \n Module M \n Async Sub T() \n Dim x As Boolean = Await [|F|]().ContinueWith(Function(a) True).ContinueWith(Function(a) False) \n End Sub \n End Module"), NewLines("Imports System \n Imports System.Linq \n Module M \n Async Sub T() \n Dim x As Boolean = Await [|F|]().ContinueWith(Function(a) True).ContinueWith(Function(a) False) \n End Sub \n End Module"),
...@@ -2201,7 +2201,7 @@ NewLines("Imports System\nImports System.Linq\nImports System.Threading.Tasks\n\ ...@@ -2201,7 +2201,7 @@ NewLines("Imports System\nImports System.Linq\nImports System.Threading.Tasks\n\
End Sub End Sub
<WorkItem(643, "https://github.com/dotnet/roslyn/issues/643")> <WorkItem(643, "https://github.com/dotnet/roslyn/issues/643")>
<Fact(), Trait(Traits.Feature, Traits.Features.CodeActionsGenerateVariable)> <Fact(), Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)>
Public Sub TestGenerateMethodWithMethodChaining2() Public Sub TestGenerateMethodWithMethodChaining2()
Test( Test(
NewLines("Imports System \n Imports System.Linq \n Module M \n Async Sub T() \n Dim x As Boolean = Await [|F|]().ContinueWith(Function(a) True).ContinueWith(Function(a) False) \n End Sub \n End Module"), NewLines("Imports System \n Imports System.Linq \n Module M \n Async Sub T() \n Dim x As Boolean = Await [|F|]().ContinueWith(Function(a) True).ContinueWith(Function(a) False) \n End Sub \n End Module"),
...@@ -2209,6 +2209,14 @@ NewLines("Imports System\nImports System.Linq\nImports System.Threading.Tasks\n\ ...@@ -2209,6 +2209,14 @@ NewLines("Imports System\nImports System.Linq\nImports System.Threading.Tasks\n\
index:=1) index:=1)
End Sub End Sub
<WorkItem(1130960)>
<Fact(), Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)>
Public Sub TestGenerateMethodInTypeOfIsNot()
Test(
NewLines("Imports System \n Imports System.Collections.Generic \n Imports System.Linq \n Module Program \n Sub M() \n If TypeOf [|Prop|] IsNot TypeOfIsNotDerived Then \n End If \n End Sub \n End Module"),
NewLines("Imports System \n Imports System.Collections.Generic \n Imports System.Linq \n Module Program \n Sub M() \n If TypeOf Prop IsNot TypeOfIsNotDerived Then \n End If \n End Sub \n Private Function Prop() As TypeOfIsNotDerived \n Throw New NotImplementedException() \n End Function \n End Module"))
End Sub
Public Class GenerateConversionTests Public Class GenerateConversionTests
Inherits AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest Inherits AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest
......
...@@ -907,6 +907,42 @@ index:=2) ...@@ -907,6 +907,42 @@ index:=2)
Test( Test(
NewLines("Module C \n Sub Test() \n If TypeOf [|B|] Is String Then \n End If \n End Sub \n End Module"), NewLines("Module C \n Sub Test() \n If TypeOf [|B|] Is String Then \n End If \n End Sub \n End Module"),
NewLines("Module C \n Sub Test() \n Dim B As String = Nothing \n If TypeOf B Is String Then \n End If \n End Sub \n End Module"), NewLines("Module C \n Sub Test() \n Dim B As String = Nothing \n If TypeOf B Is String Then \n End If \n End Sub \n End Module"),
index:=3)
End Sub
<WorkItem(1130960)>
<Fact(), Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)>
Public Sub TestGeneratePropertyInTypeOfIsNot()
Test(
NewLines("Imports System \n Imports System.Collections.Generic \n Imports System.Linq \n Module Program \n Sub M() \n If TypeOf [|Prop|] IsNot TypeOfIsNotDerived Then \n End If \n End Sub \n End Module"),
NewLines("Imports System \n Imports System.Collections.Generic \n Imports System.Linq \n Module Program \n Public Property Prop As TypeOfIsNotDerived \n Sub M() \n If TypeOf Prop IsNot TypeOfIsNotDerived Then \n End If \n End Sub \n End Module"),
index:=0)
End Sub
<WorkItem(1130960)>
<Fact(), Trait(Traits.Feature, Traits.Features.CodeActionsGenerateVariable)>
Public Sub TestGenerateFieldInTypeOfIsNot()
Test(
NewLines("Imports System \n Imports System.Collections.Generic \n Imports System.Linq \n Module Program \n Sub M() \n If TypeOf [|Prop|] IsNot TypeOfIsNotDerived Then \n End If \n End Sub \n End Module"),
NewLines("Imports System \n Imports System.Collections.Generic \n Imports System.Linq \n Module Program \n Private Prop As TypeOfIsNotDerived \n Sub M() \n If TypeOf Prop IsNot TypeOfIsNotDerived Then \n End If \n End Sub \n End Module"),
index:=1)
End Sub
<WorkItem(1130960)>
<Fact(), Trait(Traits.Feature, Traits.Features.CodeActionsGenerateVariable)>
Public Sub TestGenerateReadOnlyFieldInTypeOfIsNot()
Test(
NewLines("Imports System \n Imports System.Collections.Generic \n Imports System.Linq \n Module Program \n Sub M() \n If TypeOf [|Prop|] IsNot TypeOfIsNotDerived Then \n End If \n End Sub \n End Module"),
NewLines("Imports System \n Imports System.Collections.Generic \n Imports System.Linq \n Module Program \n Private ReadOnly Prop As TypeOfIsNotDerived \n Sub M() \n If TypeOf Prop IsNot TypeOfIsNotDerived Then \n End If \n End Sub \n End Module"),
index:=2)
End Sub
<WorkItem(1130960)>
<Fact(), Trait(Traits.Feature, Traits.Features.CodeActionsGenerateVariable)>
Public Sub TestGenerateLocalInTypeOfIsNot()
Test(
NewLines("Imports System \n Imports System.Collections.Generic \n Imports System.Linq \n Module Program \n Sub M() \n If TypeOf [|Prop|] IsNot TypeOfIsNotDerived Then \n End If \n End Sub \n End Module"),
NewLines("Imports System \n Imports System.Collections.Generic \n Imports System.Linq \n Module Program \n Sub M() \n Dim Prop As TypeOfIsNotDerived = Nothing \n If TypeOf Prop IsNot TypeOfIsNotDerived Then \n End If \n End Sub \n End Module"),
index:=3) index:=3)
End Sub End Sub
End Class End Class
......
...@@ -583,7 +583,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions ...@@ -583,7 +583,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
expression.IsParentKind(SyntaxKind.ForEachStatement) OrElse expression.IsParentKind(SyntaxKind.ForEachStatement) OrElse
expression.IsParentKind(SyntaxKind.ForStatement) OrElse expression.IsParentKind(SyntaxKind.ForStatement) OrElse
expression.IsParentKind(SyntaxKind.ConditionalAccessExpression) OrElse expression.IsParentKind(SyntaxKind.ConditionalAccessExpression) OrElse
expression.IsParentKind(SyntaxKind.TypeOfIsExpression) Then expression.IsParentKind(SyntaxKind.TypeOfIsExpression) OrElse
expression.IsParentKind(SyntaxKind.TypeOfIsNotExpression) Then
Return True Return True
End If End If
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册