diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateMethod/GenerateMethodTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateMethod/GenerateMethodTests.vb index e60963e9ad7394f9bb615274be417323ab2eb3d6..003d8dba9c8f141ea83075585fcf9863458f4bfd 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateMethod/GenerateMethodTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateMethod/GenerateMethodTests.vb @@ -2193,7 +2193,7 @@ index:=1) End Sub - + Public Sub TestGenerateMethodWithMethodChaining() 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"), @@ -2201,7 +2201,7 @@ NewLines("Imports System\nImports System.Linq\nImports System.Threading.Tasks\n\ End Sub - + Public Sub TestGenerateMethodWithMethodChaining2() 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"), @@ -2209,6 +2209,14 @@ NewLines("Imports System\nImports System.Linq\nImports System.Threading.Tasks\n\ index:=1) End Sub + + + 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 Inherits AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateVariable/GenerateVariableTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateVariable/GenerateVariableTests.vb index 5c86a5cfd9870eba395c333288d6732d8dc2faa6..0b46da1ebf5731c3b83e761844453acafef4f4a8 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateVariable/GenerateVariableTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateVariable/GenerateVariableTests.vb @@ -907,6 +907,42 @@ index:=2) 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 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 + + + + 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 + + + + 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 + + + + 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 + + + + 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) End Sub End Class diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/ExpressionSyntaxExtensions.vb b/src/Workspaces/VisualBasic/Portable/Extensions/ExpressionSyntaxExtensions.vb index 13e07a72d46fa5b845a4fb10d22942fd05f9ab15..d7351d9fa9c77f57f265cf6a3b1bddc954aec391 100644 --- a/src/Workspaces/VisualBasic/Portable/Extensions/ExpressionSyntaxExtensions.vb +++ b/src/Workspaces/VisualBasic/Portable/Extensions/ExpressionSyntaxExtensions.vb @@ -583,7 +583,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions expression.IsParentKind(SyntaxKind.ForEachStatement) OrElse expression.IsParentKind(SyntaxKind.ForStatement) OrElse expression.IsParentKind(SyntaxKind.ConditionalAccessExpression) OrElse - expression.IsParentKind(SyntaxKind.TypeOfIsExpression) Then + expression.IsParentKind(SyntaxKind.TypeOfIsExpression) OrElse + expression.IsParentKind(SyntaxKind.TypeOfIsNotExpression) Then Return True End If