diff --git a/src/EditorFeatures/CSharp/EndConstruct/CSharpEndConstructGenerationService.cs b/src/EditorFeatures/CSharp/EndConstruct/CSharpEndConstructGenerationService.cs index d44bf6e7c6a66..ce65cec44f0f4 100644 --- a/src/EditorFeatures/CSharp/EndConstruct/CSharpEndConstructGenerationService.cs +++ b/src/EditorFeatures/CSharp/EndConstruct/CSharpEndConstructGenerationService.cs @@ -6,29 +6,21 @@ using System.Composition; using System.Diagnostics.CodeAnalysis; using System.Threading; +using System.Threading.Tasks; using Microsoft.CodeAnalysis.Editor.Implementation.EndConstructGeneration; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor; +using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Editor.CSharp.EndConstructGeneration; [ExportLanguageService(typeof(IEndConstructGenerationService), LanguageNames.CSharp), Shared] [ExcludeFromCodeCoverage] -internal class CSharpEndConstructGenerationService : IEndConstructGenerationService +[method: ImportingConstructor] +[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] +internal sealed class CSharpEndConstructGenerationService() : IEndConstructGenerationService { - [ImportingConstructor] - [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] - public CSharpEndConstructGenerationService() - { - } - - public bool TryDo( - ITextView textView, - ITextBuffer subjectBuffer, - char typedChar, - CancellationToken cancellationToken) - { - return false; - } + public Task TryDoAsync(ITextView textView, ITextBuffer subjectBuffer, char typedChar, CancellationToken cancellationToken) + => SpecializedTasks.False; } diff --git a/src/EditorFeatures/Core/EndConstructGeneration/IEndConstructGenerationService.cs b/src/EditorFeatures/Core/EndConstructGeneration/IEndConstructGenerationService.cs index 99e2571f7ace6..0014088bc5f3d 100644 --- a/src/EditorFeatures/Core/EndConstructGeneration/IEndConstructGenerationService.cs +++ b/src/EditorFeatures/Core/EndConstructGeneration/IEndConstructGenerationService.cs @@ -2,9 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#nullable disable - using System.Threading; +using System.Threading.Tasks; using Microsoft.CodeAnalysis.Host; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor; @@ -13,5 +12,5 @@ namespace Microsoft.CodeAnalysis.Editor.Implementation.EndConstructGeneration; internal interface IEndConstructGenerationService : ILanguageService { - bool TryDo(ITextView textView, ITextBuffer subjectBuffer, char typedChar, CancellationToken cancellationToken); + Task TryDoAsync(ITextView textView, ITextBuffer subjectBuffer, char typedChar, CancellationToken cancellationToken); } diff --git a/src/EditorFeatures/VisualBasic/EndConstructGeneration/EndConstructCommandHandler.vb b/src/EditorFeatures/VisualBasic/EndConstructGeneration/EndConstructCommandHandler.vb index f7752ec605b3f..4759ff490677e 100644 --- a/src/EditorFeatures/VisualBasic/EndConstructGeneration/EndConstructCommandHandler.vb +++ b/src/EditorFeatures/VisualBasic/EndConstructGeneration/EndConstructCommandHandler.vb @@ -66,21 +66,25 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.EndConstructGeneration End Function Public Sub ExecuteCommand_TypeCharCommandHandler(args As TypeCharCommandArgs, nextHandler As Action, context As CommandExecutionContext) Implements IChainedCommandHandler(Of TypeCharCommandArgs).ExecuteCommand - nextHandler() + _threadingContext.JoinableTaskFactory.Run( + Async Function() + nextHandler() - If Not _editorOptionsService.GlobalOptions.GetOption(EndConstructGenerationOptionsStorage.EndConstruct, LanguageNames.VisualBasic) Then - Return - End If + If Not _editorOptionsService.GlobalOptions.GetOption(EndConstructGenerationOptionsStorage.EndConstruct, LanguageNames.VisualBasic) Then + Return + End If - Dim textSnapshot = args.SubjectBuffer.CurrentSnapshot - Dim document = textSnapshot.GetOpenDocumentInCurrentContextWithChanges() - If document Is Nothing Then - Return - End If + Dim textSnapshot = args.SubjectBuffer.CurrentSnapshot + Dim document = textSnapshot.GetOpenDocumentInCurrentContextWithChanges() + If document Is Nothing Then + Return + End If - ' End construct is not cancellable. - Dim endConstructService = document.GetLanguageService(Of IEndConstructGenerationService)() - endConstructService.TryDo(args.TextView, args.SubjectBuffer, args.TypedChar, context.OperationContext.UserCancellationToken) + ' End construct is not cancellable. + Dim endConstructService = document.GetLanguageService(Of IEndConstructGenerationService)() + Await endConstructService.TryDoAsync( + args.TextView, args.SubjectBuffer, args.TypedChar, context.OperationContext.UserCancellationToken).ConfigureAwait(True) + End Function) End Sub Public Function GetCommandState_AutomaticLineEnderCommandHandler(args As AutomaticLineEnderCommandArgs, nextHandler As Func(Of CommandState)) As CommandState Implements IChainedCommandHandler(Of AutomaticLineEnderCommandArgs).GetCommandState @@ -123,7 +127,8 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.EndConstructGeneration textView, subjectBuffer, document, cancellationToken).ConfigureAwait(True) Dim endConstructService = document.GetLanguageService(Of IEndConstructGenerationService)() - Dim result = endConstructService.TryDo(textView, subjectBuffer, vbLf(0), cancellationToken) + Dim result = Await endConstructService.TryDoAsync( + textView, subjectBuffer, vbLf(0), cancellationToken).ConfigureAwait(True) If Not result Then nextHandler() diff --git a/src/EditorFeatures/VisualBasic/EndConstructGeneration/EndConstructState.vb b/src/EditorFeatures/VisualBasic/EndConstructGeneration/EndConstructState.vb index bbbe521955a7e..9705c29bd91d1 100644 --- a/src/EditorFeatures/VisualBasic/EndConstructGeneration/EndConstructState.vb +++ b/src/EditorFeatures/VisualBasic/EndConstructGeneration/EndConstructState.vb @@ -2,15 +2,17 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. +Imports System.Threading + Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.EndConstructGeneration - Friend Class EndConstructState + Friend NotInheritable Class EndConstructState Private ReadOnly _caretPosition As Integer - Private ReadOnly _semanticModel As Lazy(Of SemanticModel) + Private ReadOnly _semanticModel As AsyncLazy(Of SemanticModel) Private ReadOnly _tree As SyntaxTree Private ReadOnly _tokenToLeft As SyntaxToken Private ReadOnly _newLineCharacter As String - Public Sub New(caretPosition As Integer, semanticModel As Lazy(Of SemanticModel), syntaxTree As SyntaxTree, tokenToLeft As SyntaxToken, newLineCharacter As String) + Public Sub New(caretPosition As Integer, semanticModel As AsyncLazy(Of SemanticModel), syntaxTree As SyntaxTree, tokenToLeft As SyntaxToken, newLineCharacter As String) ThrowIfNull(syntaxTree) _caretPosition = caretPosition @@ -26,11 +28,9 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.EndConstructGeneration End Get End Property - Public ReadOnly Property SemanticModel As SemanticModel - Get - Return _semanticModel.Value - End Get - End Property + Public Function GetSemanticModelAsync(cancellationToken As CancellationToken) As Task(Of SemanticModel) + Return _semanticModel.GetValueAsync(cancellationToken) + End Function Public ReadOnly Property SyntaxTree As SyntaxTree Get diff --git a/src/EditorFeatures/VisualBasic/EndConstructGeneration/EndConstructStatementVisitor.vb b/src/EditorFeatures/VisualBasic/EndConstructGeneration/EndConstructStatementVisitor.vb index ecf27a11ee082..09789a442303d 100644 --- a/src/EditorFeatures/VisualBasic/EndConstructGeneration/EndConstructStatementVisitor.vb +++ b/src/EditorFeatures/VisualBasic/EndConstructGeneration/EndConstructStatementVisitor.vb @@ -12,25 +12,51 @@ Imports Microsoft.VisualStudio.Text.Editor Imports Microsoft.VisualStudio.Text.Editor.OptionsExtensionMethods Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.EndConstructGeneration - Partial Friend Class EndConstructStatementVisitor + Partial Friend NotInheritable Class EndConstructStatementVisitor Inherits VisualBasicSyntaxVisitor(Of AbstractEndConstructResult) Private ReadOnly _textView As ITextView Private ReadOnly _subjectBuffer As ITextBuffer - Private ReadOnly _cancellationToken As CancellationToken Private ReadOnly _state As EndConstructState + Private ReadOnly _cancellationToken As CancellationToken + + ''' + ''' Note: this is only passed in when return true. Any functions that require + ''' a semantic model must declare their need up front so we do not pay the cost for semantics for all the cases + ''' that do not need it. + ''' + Private ReadOnly _semanticModel As SemanticModel - Public Sub New(textView As ITextView, - subjectBuffer As ITextBuffer, - state As EndConstructState, - cancellationToken As CancellationToken) + Public Sub New( + textView As ITextView, + subjectBuffer As ITextBuffer, + state As EndConstructState, + semanticModel As SemanticModel, + cancellationToken As CancellationToken) _textView = textView _subjectBuffer = subjectBuffer _state = state + _semanticModel = semanticModel _cancellationToken = cancellationToken End Sub + Public Shared Function NeedsSemanticModel(node As SyntaxNode) As Boolean + ' All of these call HandleMethodBlockSyntax, which needs semantics + If TypeOf node Is MethodStatementSyntax OrElse + TypeOf node Is SubNewStatementSyntax OrElse + TypeOf node Is OperatorStatementSyntax Then + Return True + End If + + ' Calls GenerateAddOrRemoveHandler and GenerateRaiseEventHandler, both which needs semantics + If TypeOf node Is EventStatementSyntax Then + Return True + End If + + Return False + End Function + Public Overrides Function VisitDoStatement(node As DoStatementSyntax) As AbstractEndConstructResult Dim needsEnd = node.GetAncestorsOrThis(Of DoLoopBlockSyntax)().Any(Function(block) block.LoopStatement.IsMissing) @@ -100,11 +126,12 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.EndConstructGeneration End If End Function - Private Function TryGenerateResultForConstructorSpitWithInitializeComponent(methodBlock As MethodBlockBaseSyntax) As AbstractEndConstructResult + Private Function TryGenerateResultForConstructorSpitWithInitializeComponent( + methodBlock As MethodBlockBaseSyntax) As AbstractEndConstructResult If methodBlock.BlockStatement.Kind = SyntaxKind.SubNewStatement Then - Dim boundConstructor = _state.SemanticModel.GetDeclaredSymbol(DirectCast(methodBlock.BlockStatement, SubNewStatementSyntax)) + Dim boundConstructor = _semanticModel.GetDeclaredSymbol(DirectCast(methodBlock.BlockStatement, SubNewStatementSyntax)) If boundConstructor IsNot Nothing Then - If boundConstructor.ContainingType.IsDesignerGeneratedTypeWithInitializeComponent(_state.SemanticModel.Compilation) Then + If boundConstructor.ContainingType.IsDesignerGeneratedTypeWithInitializeComponent(_semanticModel.Compilation) Then Dim aligningWhitespace = _subjectBuffer.CurrentSnapshot.GetAligningWhitespace(methodBlock.BlockStatement.SpanStart) Dim innerAligningWhitespace = aligningWhitespace & " " @@ -161,10 +188,10 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.EndConstructGeneration Dim aligningWhitespace = _subjectBuffer.CurrentSnapshot.GetAligningWhitespace(node.SpanStart) Dim stringBuilder As New StringBuilder stringBuilder.Append(_textView.Options.GetNewLineCharacter()) - StringBuilder.Append(aligningWhitespace & " Case ") + stringBuilder.Append(aligningWhitespace & " Case ") Dim finalCaretPoint = stringBuilder.Length stringBuilder.AppendLine() - StringBuilder.Append(aligningWhitespace & "End Select") + stringBuilder.Append(aligningWhitespace & "End Select") Return New ReplaceSpanResult(New SnapshotSpan(_subjectBuffer.CurrentSnapshot, _state.CaretPosition, 0), stringBuilder.ToString(), newCaretPosition:=finalCaretPoint) diff --git a/src/EditorFeatures/VisualBasic/EndConstructGeneration/EndConstructStatementVisitor_CustomEvents.vb b/src/EditorFeatures/VisualBasic/EndConstructGeneration/EndConstructStatementVisitor_CustomEvents.vb index 5c8274840d942..6640cc9406133 100644 --- a/src/EditorFeatures/VisualBasic/EndConstructGeneration/EndConstructStatementVisitor_CustomEvents.vb +++ b/src/EditorFeatures/VisualBasic/EndConstructGeneration/EndConstructStatementVisitor_CustomEvents.vb @@ -37,21 +37,21 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.EndConstructGeneration End Function Private Function GenerateAddOrRemoveHandler(eventStatement As EventStatementSyntax, kind As SyntaxKind) As String() - Dim type = _state.SemanticModel.GetTypeInfo(DirectCast(eventStatement.AsClause, SimpleAsClauseSyntax).Type, Me._cancellationToken) + Dim type = _semanticModel.GetTypeInfo(DirectCast(eventStatement.AsClause, SimpleAsClauseSyntax).Type, Me._cancellationToken) Dim position As Integer = eventStatement.SpanStart Dim aligningWhitespace = _subjectBuffer.CurrentSnapshot.GetAligningWhitespace(position) & " " - Return {aligningWhitespace & SyntaxFacts.GetText(kind) & "(value As " & type.Type.ToMinimalDisplayString(_state.SemanticModel, position, SymbolDisplayFormats.NameFormat) & ")", + Return {aligningWhitespace & SyntaxFacts.GetText(kind) & "(value As " & type.Type.ToMinimalDisplayString(_semanticModel, position, SymbolDisplayFormats.NameFormat) & ")", "", aligningWhitespace & "End " & SyntaxFacts.GetText(kind)} End Function Private Function GenerateRaiseEventHandler(eventStatement As EventStatementSyntax) As String() - Dim type = TryCast(_state.SemanticModel.GetTypeInfo(DirectCast(eventStatement.AsClause, SimpleAsClauseSyntax).Type, Me._cancellationToken).Type, INamedTypeSymbol) + Dim type = TryCast(_semanticModel.GetTypeInfo(DirectCast(eventStatement.AsClause, SimpleAsClauseSyntax).Type, Me._cancellationToken).Type, INamedTypeSymbol) Dim signature = "" If type IsNot Nothing AndAlso type.DelegateInvokeMethod IsNot Nothing Then Dim parameterStrings = type.DelegateInvokeMethod.Parameters.Select( - Function(p) p.ToMinimalDisplayString(_state.SemanticModel, eventStatement.SpanStart)) + Function(p) p.ToMinimalDisplayString(_semanticModel, eventStatement.SpanStart)) signature = String.Join(", ", parameterStrings) End If diff --git a/src/EditorFeatures/VisualBasic/EndConstructGeneration/EndConstructStatementVisitor_IfStatement.vb b/src/EditorFeatures/VisualBasic/EndConstructGeneration/EndConstructStatementVisitor_IfStatement.vb index f723001094a47..b47d0ee67032a 100644 --- a/src/EditorFeatures/VisualBasic/EndConstructGeneration/EndConstructStatementVisitor_IfStatement.vb +++ b/src/EditorFeatures/VisualBasic/EndConstructGeneration/EndConstructStatementVisitor_IfStatement.vb @@ -7,7 +7,6 @@ Imports Microsoft.CodeAnalysis.VisualBasic.Syntax Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.EndConstructGeneration Partial Friend Class EndConstructStatementVisitor - Public Overrides Function VisitIfStatement(node As IfStatementSyntax) As AbstractEndConstructResult Dim needsEnd = node.GetAncestorsOrThis(Of MultiLineIfBlockSyntax)().Any(Function(block) block.EndIfStatement.IsMissing) diff --git a/src/EditorFeatures/VisualBasic/EndConstructGeneration/VisualBasicEndConstructGenerationService.vb b/src/EditorFeatures/VisualBasic/EndConstructGeneration/VisualBasicEndConstructGenerationService.vb index eb290da618bfd..11b3e8dee49be 100644 --- a/src/EditorFeatures/VisualBasic/EndConstructGeneration/VisualBasicEndConstructGenerationService.vb +++ b/src/EditorFeatures/VisualBasic/EndConstructGeneration/VisualBasicEndConstructGenerationService.vb @@ -161,12 +161,13 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.EndConstructGeneration Dim bufferOptions = _editorOptionsFactoryService.GetOptions(subjectBuffer) Return New EndConstructState( - caretPosition.Value, New Lazy(Of SemanticModel)(Function() document.GetSemanticModelAsync(cancellationToken).WaitAndGetResult(cancellationToken)), tree, tokenToLeft, bufferOptions.GetNewLineCharacter()) + caretPosition.Value, AsyncLazy.Create(Function(c) document.GetSemanticModelAsync(c)), tree, tokenToLeft, bufferOptions.GetNewLineCharacter()) End Function - Friend Overridable Function TryDoEndConstructForEnterKey(textView As ITextView, - subjectBuffer As ITextBuffer, - cancellationToken As CancellationToken) As Boolean + Friend Overridable Async Function TryDoEndConstructForEnterKeyAsync( + textView As ITextView, + subjectBuffer As ITextBuffer, + cancellationToken As CancellationToken) As Task(Of Boolean) Using Logger.LogBlock(FunctionId.EndConstruct_DoStatement, cancellationToken) Using transaction = New CaretPreservingEditTransaction(VBEditorResources.End_Construct, textView, _undoHistoryRegistry, _editorOperationsFactoryService) transaction.MergePolicy = AutomaticCodeChangeMergePolicy.Instance @@ -285,7 +286,10 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.EndConstructGeneration Return False End If - Dim visitor = New EndConstructStatementVisitor(textView, subjectBuffer, state, cancellationToken) + Dim semanticModel = If(EndConstructStatementVisitor.NeedsSemanticModel(statement), + Await state.GetSemanticModelAsync(cancellationToken).ConfigureAwait(True), + Nothing) + Dim visitor = New EndConstructStatementVisitor(textView, subjectBuffer, state, semanticModel, cancellationToken) Dim result = visitor.Visit(statement) If result Is Nothing Then @@ -480,10 +484,10 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.EndConstructGeneration End Using End Function - Public Function TryDo(textView As ITextView, subjectBuffer As ITextBuffer, typedChar As Char, cancellationToken As CancellationToken) As Boolean Implements IEndConstructGenerationService.TryDo + Public Async Function TryDoAsync(textView As ITextView, subjectBuffer As ITextBuffer, typedChar As Char, cancellationToken As CancellationToken) As Task(Of Boolean) Implements IEndConstructGenerationService.TryDoAsync Select Case typedChar Case vbLf(0) - Return Me.TryDoEndConstructForEnterKey(textView, subjectBuffer, cancellationToken) + Return Await Me.TryDoEndConstructForEnterKeyAsync(textView, subjectBuffer, cancellationToken).ConfigureAwait(True) Case ">"c Return Me.TryDoXmlElementEndConstruct(textView, subjectBuffer, cancellationToken) Case "-"c diff --git a/src/EditorFeatures/VisualBasic/Utilities/CommandHandlers/AbstractImplementAbstractClassOrInterfaceCommandHandler.vb b/src/EditorFeatures/VisualBasic/Utilities/CommandHandlers/AbstractImplementAbstractClassOrInterfaceCommandHandler.vb index c884c7215587b..d529709ebbfcc 100644 --- a/src/EditorFeatures/VisualBasic/Utilities/CommandHandlers/AbstractImplementAbstractClassOrInterfaceCommandHandler.vb +++ b/src/EditorFeatures/VisualBasic/Utilities/CommandHandlers/AbstractImplementAbstractClassOrInterfaceCommandHandler.vb @@ -67,7 +67,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Utilities.CommandHandlers ' It's possible that there may be an end construct to generate at this position. ' We'll go ahead and generate it before determining whether we need to move the caret - TryGenerateEndConstruct(args, _cancellationToken) + Await TryGenerateEndConstructAsync(args, _cancellationToken).ConfigureAwait(True) Dim snapshot = args.SubjectBuffer.CurrentSnapshot Dim caretPosition = args.TextView.GetCaretPoint(args.SubjectBuffer).Value @@ -92,7 +92,9 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Utilities.CommandHandlers Return True End Function - Private Shared Function TryGenerateEndConstruct(args As ReturnKeyCommandArgs, cancellationToken As CancellationToken) As Boolean + Private Shared Async Function TryGenerateEndConstructAsync( + args As ReturnKeyCommandArgs, + cancellationToken As CancellationToken) As Task(Of Boolean) Dim textSnapshot = args.SubjectBuffer.CurrentSnapshot Dim document = textSnapshot.GetOpenDocumentInCurrentContextWithChanges() @@ -112,7 +114,8 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Utilities.CommandHandlers Dim endConstructGenerationService = document.GetLanguageService(Of IEndConstructGenerationService)() - Return endConstructGenerationService.TryDo(args.TextView, args.SubjectBuffer, vbLf(0), cancellationToken) + Return Await endConstructGenerationService.TryDoAsync( + args.TextView, args.SubjectBuffer, vbLf(0), cancellationToken).ConfigureAwait(True) End Function Private Overloads Async Function TryExecuteAsync( diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/CharacterTypingTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/CharacterTypingTests.vb index d00841abcb342..1a32ab75fd050 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/CharacterTypingTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/CharacterTypingTests.vb @@ -9,8 +9,8 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Public Class CharacterTypingTests - Public Sub TestXmlEndConstructApplied() - VerifyEndConstructAppliedAfterChar( + Public Async Function TestXmlEndConstructApplied() As Task + Await VerifyEndConstructAppliedAfterCharAsync( before:= .NormalizedValue, typedChar:=">"c, endCaretPos:={3, 21}) - End Sub + End Function - Public Sub TestXmlEndConstructNotApplied() - VerifyEndConstructNotAppliedAfterChar( + Public Async Function TestXmlEndConstructNotApplied() As Task + Await VerifyEndConstructNotAppliedAfterCharAsync( before:= .NormalizedValue, typedChar:=">"c, endCaretPos:={3, 14}) - End Sub + End Function - Public Sub TestXmlCommentEndConstructApplied() - VerifyEndConstructAppliedAfterChar( + Public Async Function TestXmlCommentEndConstructApplied() As Task + Await VerifyEndConstructAppliedAfterCharAsync( before:= .NormalizedValue, typedChar:="-"c, endCaretPos:={3, 25}) - End Sub + End Function - Public Sub TestXmlCommentEndConstructNotApplied() - VerifyEndConstructNotAppliedAfterChar( + Public Async Function TestXmlCommentEndConstructNotApplied() As Task + Await VerifyEndConstructNotAppliedAfterCharAsync( before:= .NormalizedValue, typedChar:="-"c, endCaretPos:={3, 19}) - End Sub + End Function - Public Sub TestXmlEmbeddedExpressionEndConstructApplied() - VerifyEndConstructAppliedAfterChar( + Public Async Function TestXmlEmbeddedExpressionEndConstructApplied() As Task + Await VerifyEndConstructAppliedAfterCharAsync( before:= .NormalizedValue, typedChar:="="c, endCaretPos:={3, 30}) - End Sub + End Function - Public Sub TestXmlEmbeddedExpressionEndConstructNotApplied() - VerifyEndConstructNotAppliedAfterChar( + Public Async Function TestXmlEmbeddedExpressionEndConstructNotApplied() As Task + Await VerifyEndConstructNotAppliedAfterCharAsync( before:= .NormalizedValue, typedChar:="="c, endCaretPos:={3, 15}) - End Sub + End Function - Public Sub TestXmlCDataEndConstructApplied() - VerifyEndConstructAppliedAfterChar( + Public Async Function TestXmlCDataEndConstructApplied() As Task + Await VerifyEndConstructAppliedAfterCharAsync( before:= .NormalizedValue, typedChar:="["c, endCaretPos:={3, 30}) - End Sub + End Function - Public Sub TestXmlCDataEndConstructNotApplied() - VerifyEndConstructNotAppliedAfterChar( + Public Async Function TestXmlCDataEndConstructNotApplied() As Task + Await VerifyEndConstructNotAppliedAfterCharAsync( before:= .NormalizedValue, typedChar:="["c, endCaretPos:={3, 18}) - End Sub + End Function - Public Sub TestXmlProcessingInstructionEndConstructApplied() - VerifyEndConstructAppliedAfterChar( + Public Async Function TestXmlProcessingInstructionEndConstructApplied() As Task + Await VerifyEndConstructAppliedAfterCharAsync( before:= .NormalizedValue, typedChar:="?"c, endCaretPos:={3, 18}) - End Sub + End Function - Public Sub TestXmlProcessingInstructionEndConstructNotApplied() - VerifyEndConstructNotAppliedAfterChar( + Public Async Function TestXmlProcessingInstructionEndConstructNotApplied() As Task + Await VerifyEndConstructNotAppliedAfterCharAsync( before:= .NormalizedValue, typedChar:="?"c, endCaretPos:={3, 18}) - End Sub - + End Function End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/CustomEventTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/CustomEventTests.vb index 004afcb0be2cc..19ca00759e62f 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/CustomEventTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/CustomEventTests.vb @@ -7,8 +7,8 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Public Class CustomEventTests - Public Sub TestApplyAfterCustomEvent() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterCustomEvent() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Custom Event goo As System.EventHandler End Class", @@ -27,11 +27,11 @@ End Class", End Event End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub TestApplyAfterCustomEventWithImportsStatement() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterCustomEventWithImportsStatement() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Imports System Class c1 Custom Event goo As EventHandler @@ -52,11 +52,11 @@ Class c1 End Event End Class", afterCaret:={4, -1}) - End Sub + End Function - Public Sub TestApplyAfterCustomEventWithMissingDelegateType() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterCustomEventWithMissingDelegateType() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Imports System Class c1 Custom Event goo As GooHandler @@ -77,11 +77,11 @@ Class c1 End Event End Class", afterCaret:={4, -1}) - End Sub + End Function - Public Sub TestApplyAfterCustomEventWithNonDelegateType() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterCustomEventWithNonDelegateType() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Imports System Class c1 Custom Event goo As Object @@ -102,11 +102,11 @@ Class c1 End Event End Class", afterCaret:={4, -1}) - End Sub + End Function - Public Sub TestApplyAfterCustomEventWithGenericType() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterCustomEventWithGenericType() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Imports System Class c1 Custom Event goo As EventHandler(Of ConsoleCancelEventArgs) @@ -127,11 +127,11 @@ Class c1 End Event End Class", afterCaret:={4, -1}) - End Sub + End Function - Public Sub DoNotApplyAfterCustomEventAlreadyTerminated() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyAfterCustomEventAlreadyTerminated() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Imports System Class c1 Custom Event goo As EventHandler(Of ConsoleCancelEventArgs) @@ -147,6 +147,6 @@ Class c1 End Event End Class", caret:={2, -1}) - End Sub + End Function End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/DoLoopTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/DoLoopTests.vb index dbedfb25e4364..82d1218b7f92e 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/DoLoopTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/DoLoopTests.vb @@ -7,8 +7,8 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Public Class DoLoopTests - Public Sub TestApplyAfterUnmatchedDo() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterUnmatchedDo() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Sub goo() Do @@ -23,11 +23,11 @@ End Class", End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub TestVerifyNestedDo() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyNestedDo() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Sub goo() Do @@ -46,39 +46,39 @@ End Class", End Sub End Class", afterCaret:={4, -1}) - End Sub + End Function - Public Sub DoNotApplyFromPairedDo() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyFromPairedDo() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 Do Loop End Class", caret:={1, -1}) - End Sub + End Function - Public Sub DoNotApplyFromInsideDo() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyFromInsideDo() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 Do End Class", caret:={1, 1}) - End Sub + End Function - Public Sub DoNotApplyFromDoOutsideMethod() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyFromDoOutsideMethod() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 Do End Class", caret:={1, -1}) - End Sub + End Function - Public Sub TestVerifyDoWhile() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyDoWhile() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub s Do While True @@ -94,11 +94,11 @@ End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub TestVerifyNestedDoWhile() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyNestedDoWhile() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub s do While True @@ -117,11 +117,11 @@ End Class", End Sub End Class", afterCaret:={4, -1}) - End Sub + End Function - Public Sub TestVerifyDoUntil() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyDoUntil() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub s do Until true @@ -136,11 +136,11 @@ End Class", End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub TestVerifyNestedDoUntil() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyNestedDoUntil() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub s do Until True @@ -159,11 +159,11 @@ End Class", End Sub End Class", afterCaret:={4, -1}) - End Sub + End Function - Public Sub TestVerifyDoWhileInBrokenSub() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyDoWhileInBrokenSub() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub s Do While True @@ -176,35 +176,35 @@ End Class", Loop End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub VerifyDoUntilInvalidLocation01() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyDoUntilInvalidLocation01() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Sub s End Sub do Until True End Class", caret:={3, -1}) - End Sub + End Function - Public Sub VerifyDoUntilInvalidLocation02() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyDoUntilInvalidLocation02() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Do", caret:={0, -1}) - End Sub + End Function - Public Sub VerifyDoUntilInvalidLocation03() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyDoUntilInvalidLocation03() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Sub s End Sub do Until End Class", caret:={3, -1}) - End Sub + End Function End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/EndConstructCommandHandlerTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/EndConstructCommandHandlerTests.vb index 583abaf9ac0ee..b7fcfe8135e32 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/EndConstructCommandHandlerTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/EndConstructCommandHandlerTests.vb @@ -16,35 +16,6 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Private ReadOnly _textViewMock As New Mock(Of ITextView)(MockBehavior.Strict) Private ReadOnly _textBufferMock As New Mock(Of ITextBuffer)(MockBehavior.Strict) -#If False Then - Private ReadOnly _featureOptions As New Mock(Of ILegacyWorkspaceOptionService)(MockBehavior.Strict) - - ' TODO(jasonmal): Figure out how to enable these tests. - - Public Sub ServiceNotCompletingShouldCallNextHandler() - _endConstructServiceMock.Setup(Function(s) s.TryDo(It.IsAny(Of ITextView), It.IsAny(Of ITextBuffer), It.IsAny(Of Char))).Returns(False) - _featureOptions.Setup(Function(s) s.GetOption(FeatureOnOffOptions.EndConstruct)).Returns(True) - - Dim nextHandlerCalled = False - Dim handler As New EndConstructCommandHandler(_featureOptions.Object, _endConstructServiceMock.Object) - handler.ExecuteCommand_ReturnKeyCommandHandler(New ReturnKeyCommandArgs(_textViewMock.Object, _textBufferMock.Object), Sub() nextHandlerCalled = True) - - Assert.True(nextHandlerCalled) - End Sub - - - Public Sub ServiceCompletingShouldCallNextHandler() - _endConstructServiceMock.Setup(Function(s) s.TryDo(It.IsAny(Of ITextView), It.IsAny(Of ITextBuffer), It.IsAny(Of Char))).Returns(True) - _featureOptions.Setup(Function(s) s.GetOption(FeatureOnOffOptions.EndConstruct)).Returns(True) - - Dim nextHandlerCalled = False - Dim handler As New EndConstructCommandHandler(_featureOptions.Object, _endConstructServiceMock.Object) - handler.ExecuteCommand_ReturnKeyCommandHandler(New ReturnKeyCommandArgs(_textViewMock.Object, _textBufferMock.Object), Sub() nextHandlerCalled = True) - - Assert.False(nextHandlerCalled) - End Sub -#End If - Public Sub EndConstruct_AfterCodeCleanup() Dim code = Class C @@ -111,12 +82,12 @@ End Module.Value.Replace(vbLf, vbCrLf) End Sub - Public Sub EndConstruct_NotOnLineFollowingToken() - VerifyStatementEndConstructNotApplied( + Public Async Function EndConstruct_NotOnLineFollowingToken() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C ", caret:={2, 0}) - End Sub + End Function End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/EndConstructTestingHelpers.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/EndConstructTestingHelpers.vb index b1214f4924398..75dc3eb375333 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/EndConstructTestingHelpers.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/EndConstructTestingHelpers.vb @@ -7,7 +7,6 @@ Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Editor.[Shared].Utilities Imports Microsoft.CodeAnalysis.Editor.UnitTests Imports Microsoft.CodeAnalysis.Editor.UnitTests.Utilities -Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces Imports Microsoft.CodeAnalysis.Editor.VisualBasic.EndConstructGeneration Imports Microsoft.CodeAnalysis.Editor.VisualBasic.LineCommit Imports Microsoft.CodeAnalysis.Options @@ -27,11 +26,12 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Return mock.Object End Function - Private Sub VerifyTypedCharApplied(doFunc As Func(Of VisualBasicEndConstructService, ITextView, ITextBuffer, Boolean), - before As String, - after As String, - typedChar As Char, - endCaretPos As Integer()) + Private Async Function VerifyTypedCharAppliedAsync( + doFunc As Func(Of VisualBasicEndConstructService, ITextView, ITextBuffer, Task(Of Boolean)), + before As String, + after As String, + typedChar As Char, + endCaretPos As Integer()) As Task Dim caretPos = before.IndexOf("$$", StringComparison.Ordinal) Dim beforeText = before.Replace("$$", "") Using workspace = EditorTestWorkspace.CreateVisualBasic(beforeText, composition:=EditorTestCompositions.EditorFeatures) @@ -48,7 +48,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera workspace.GetService(Of IEditorOptionsFactoryService)) view.TextBuffer.Replace(New Span(caretPos, 0), typedChar.ToString()) - Assert.True(doFunc(endConstructService, view, view.TextBuffer)) + Assert.True(Await doFunc(endConstructService, view, view.TextBuffer)) Assert.Equal(after, view.TextSnapshot.GetText()) Dim actualLine As Integer @@ -57,13 +57,14 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Assert.Equal(endCaretPos(0), actualLine) Assert.Equal(endCaretPos(1), actualChar) End Using - End Sub + End Function - Private Sub VerifyApplied(doFunc As Func(Of VisualBasicEndConstructService, ITextView, ITextBuffer, Boolean), - before As String, - beforeCaret As Integer(), - after As String, - afterCaret As Integer()) + Private Async Function VerifyAppliedAsync( + doFunc As Func(Of VisualBasicEndConstructService, ITextView, ITextBuffer, Task(Of Boolean)), + before As String, + beforeCaret As Integer(), + after As String, + afterCaret As Integer()) As Task Using workspace = EditorTestWorkspace.CreateVisualBasic(before, composition:=EditorTestCompositions.EditorFeatures) Dim globalOptions = workspace.GetService(Of IGlobalOptionService) globalOptions.SetGlobalOption(LineCommitOptionsStorage.PrettyListing, LanguageNames.VisualBasic, False) @@ -87,7 +88,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera workspace.GetService(Of IEditorOperationsFactoryService), workspace.GetService(Of IEditorOptionsFactoryService)) - Assert.True(doFunc(endConstructService, textView, textView.TextSnapshot.TextBuffer)) + Assert.True(Await doFunc(endConstructService, textView, textView.TextSnapshot.TextBuffer)) Assert.Equal(EditorFactory.LinesToFullText(after), textView.TextSnapshot.GetText()) Dim afterLine = textView.TextSnapshot.GetLineFromLineNumber(afterCaret(0)) @@ -100,7 +101,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Assert.Equal(Of Integer)(afterCaretPoint, textView.GetCaretPoint(subjectBuffer).Value.Position) End Using - End Sub + End Function Private Function GetSnapshotPointFromArray(view As ITextView, caret As Integer(), startIndex As Integer) As SnapshotPoint Dim line = view.TextSnapshot.GetLineFromLineNumber(caret(startIndex)) @@ -112,9 +113,10 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera End If End Function - Private Sub VerifyNotApplied(doFunc As Func(Of VisualBasicEndConstructService, ITextView, ITextBuffer, Boolean), - text As String, - caret As Integer()) + Private Async Function VerifyNotAppliedAsync( + doFunc As Func(Of VisualBasicEndConstructService, ITextView, ITextBuffer, Task(Of Boolean)), + text As String, + caret As Integer()) As Task Using workspace = EditorTestWorkspace.CreateVisualBasic(text) Dim textView = workspace.Documents.First().GetTextView() Dim subjectBuffer = workspace.Documents.First().GetTextBuffer() @@ -135,7 +137,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera workspace.GetService(Of IEditorOperationsFactoryService), workspace.GetService(Of IEditorOptionsFactoryService)) - Assert.False(doFunc(endConstructService, textView, textView.TextSnapshot.TextBuffer), "End Construct should not have generated anything.") + Assert.False(Await doFunc(endConstructService, textView, textView.TextSnapshot.TextBuffer), "End Construct should not have generated anything.") ' The text should not have changed Assert.Equal(EditorFactory.LinesToFullText(text), textView.TextSnapshot.GetText()) @@ -143,63 +145,65 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera ' The caret should not have moved Assert.Equal(Of Integer)(caretPosition, textView.GetCaretPoint(subjectBuffer).Value.Position) End Using - End Sub + End Function - Public Sub VerifyStatementEndConstructApplied(before As String, beforeCaret As Integer(), after As String, afterCaret As Integer()) - VerifyApplied(Function(s, v, b) s.TryDoEndConstructForEnterKey(v, b, CancellationToken.None), before, beforeCaret, after, afterCaret) - End Sub + Public Function VerifyStatementEndConstructAppliedAsync(before As String, beforeCaret As Integer(), after As String, afterCaret As Integer()) As Task + Return VerifyAppliedAsync(Function(s, v, b) s.TryDoEndConstructForEnterKeyAsync(v, b, CancellationToken.None), before, beforeCaret, after, afterCaret) + End Function - Public Sub VerifyStatementEndConstructNotApplied(text As String, caret As Integer()) - VerifyNotApplied(Function(s, v, b) s.TryDoEndConstructForEnterKey(v, b, CancellationToken.None), text, caret) - End Sub + Public Function VerifyStatementEndConstructNotAppliedAsync(text As String, caret As Integer()) As Task + Return VerifyNotAppliedAsync(Function(s, v, b) s.TryDoEndConstructForEnterKeyAsync(v, b, CancellationToken.None), text, caret) + End Function - Public Sub VerifyXmlElementEndConstructApplied(before As String, beforeCaret As Integer(), after As String, afterCaret As Integer()) - VerifyApplied(Function(s, v, b) s.TryDoXmlElementEndConstruct(v, b, Nothing), before, beforeCaret, after, afterCaret) - End Sub +#Disable Warning BC42356 ' This async method lacks 'Await' operators and so will run synchronously + Public Function VerifyXmlElementEndConstructAppliedAsync(before As String, beforeCaret As Integer(), after As String, afterCaret As Integer()) As Task + Return VerifyAppliedAsync(Async Function(s, v, b) s.TryDoXmlElementEndConstruct(v, b, Nothing), before, beforeCaret, after, afterCaret) + End Function - Public Sub VerifyXmlElementEndConstructNotApplied(text As String, caret As Integer()) - VerifyNotApplied(Function(s, v, b) s.TryDoXmlElementEndConstruct(v, b, Nothing), text, caret) - End Sub + Public Function VerifyXmlElementEndConstructNotAppliedAsync(text As String, caret As Integer()) As Task + Return VerifyNotAppliedAsync(Async Function(s, v, b) s.TryDoXmlElementEndConstruct(v, b, Nothing), text, caret) + End Function - Public Sub VerifyXmlCommentEndConstructApplied(before As String, beforeCaret As Integer(), after As String, afterCaret As Integer()) - VerifyApplied(Function(s, v, b) s.TryDoXmlCommentEndConstruct(v, b, Nothing), before, beforeCaret, after, afterCaret) - End Sub + Public Function VerifyXmlCommentEndConstructAppliedAsync(before As String, beforeCaret As Integer(), after As String, afterCaret As Integer()) As Task + Return VerifyAppliedAsync(Async Function(s, v, b) s.TryDoXmlCommentEndConstruct(v, b, Nothing), before, beforeCaret, after, afterCaret) + End Function - Public Sub VerifyXmlCommentEndConstructNotApplied(text As String, caret As Integer()) - VerifyNotApplied(Function(s, v, b) s.TryDoXmlCommentEndConstruct(v, b, Nothing), text, caret) - End Sub + Public Function VerifyXmlCommentEndConstructNotAppliedAsync(text As String, caret As Integer()) As Task + Return VerifyNotAppliedAsync(Async Function(s, v, b) s.TryDoXmlCommentEndConstruct(v, b, Nothing), text, caret) + End Function - Public Sub VerifyXmlCDataEndConstructApplied(before As String, beforeCaret As Integer(), after As String, afterCaret As Integer()) - VerifyApplied(Function(s, v, b) s.TryDoXmlCDataEndConstruct(v, b, Nothing), before, beforeCaret, after, afterCaret) - End Sub + Public Function VerifyXmlCDataEndConstructAppliedAsync(before As String, beforeCaret As Integer(), after As String, afterCaret As Integer()) As Task + Return VerifyAppliedAsync(Async Function(s, v, b) s.TryDoXmlCDataEndConstruct(v, b, Nothing), before, beforeCaret, after, afterCaret) + End Function - Public Sub VerifyXmlCDataEndConstructNotApplied(text As String, caret As Integer()) - VerifyNotApplied(Function(s, v, b) s.TryDoXmlCDataEndConstruct(v, b, Nothing), text, caret) - End Sub + Public Function VerifyXmlCDataEndConstructNotAppliedAsync(text As String, caret As Integer()) As Task + Return VerifyNotAppliedAsync(Async Function(s, v, b) s.TryDoXmlCDataEndConstruct(v, b, Nothing), text, caret) + End Function - Public Sub VerifyXmlEmbeddedExpressionEndConstructApplied(before As String, beforeCaret As Integer(), after As String, afterCaret As Integer()) - VerifyApplied(Function(s, v, b) s.TryDoXmlEmbeddedExpressionEndConstruct(v, b, Nothing), before, beforeCaret, after, afterCaret) - End Sub + Public Function VerifyXmlEmbeddedExpressionEndConstructAppliedAsync(before As String, beforeCaret As Integer(), after As String, afterCaret As Integer()) As Task + Return VerifyAppliedAsync(Async Function(s, v, b) s.TryDoXmlEmbeddedExpressionEndConstruct(v, b, Nothing), before, beforeCaret, after, afterCaret) + End Function - Public Sub VerifyXmlEmbeddedExpressionEndConstructNotApplied(text As String, caret As Integer()) - VerifyNotApplied(Function(s, v, b) s.TryDoXmlEmbeddedExpressionEndConstruct(v, b, Nothing), text, caret) - End Sub + Public Function VerifyXmlEmbeddedExpressionEndConstructNotAppliedAsync(text As String, caret As Integer()) As Task + Return VerifyNotAppliedAsync(Async Function(s, v, b) s.TryDoXmlEmbeddedExpressionEndConstruct(v, b, Nothing), text, caret) + End Function - Public Sub VerifyXmlProcessingInstructionEndConstructApplied(before As String, beforeCaret As Integer(), after As String, afterCaret As Integer()) - VerifyApplied(Function(s, v, b) s.TryDoXmlProcessingInstructionEndConstruct(v, b, Nothing), before, beforeCaret, after, afterCaret) - End Sub + Public Function VerifyXmlProcessingInstructionEndConstructAppliedAsync(before As String, beforeCaret As Integer(), after As String, afterCaret As Integer()) As Task + Return VerifyAppliedAsync(Async Function(s, v, b) s.TryDoXmlProcessingInstructionEndConstruct(v, b, Nothing), before, beforeCaret, after, afterCaret) + End Function - Public Sub VerifyXmlProcessingInstructionNotApplied(text As String, caret As Integer()) - VerifyNotApplied(Function(s, v, b) s.TryDoXmlProcessingInstructionEndConstruct(v, b, Nothing), text, caret) - End Sub + Public Function VerifyXmlProcessingInstructionNotAppliedAsync(text As String, caret As Integer()) As Task + Return VerifyNotAppliedAsync(Async Function(s, v, b) s.TryDoXmlProcessingInstructionEndConstruct(v, b, Nothing), text, caret) + End Function +#Enable Warning BC42356 ' This async method lacks 'Await' operators and so will run synchronously - Public Sub VerifyEndConstructAppliedAfterChar(before As String, after As String, typedChar As Char, endCaretPos As Integer()) - VerifyTypedCharApplied(Function(s, v, b) s.TryDo(v, b, typedChar, Nothing), before, after, typedChar, endCaretPos) - End Sub + Public Function VerifyEndConstructAppliedAfterCharAsync(before As String, after As String, typedChar As Char, endCaretPos As Integer()) As Task + Return VerifyTypedCharAppliedAsync(Function(s, v, b) s.TryDoAsync(v, b, typedChar, Nothing), before, after, typedChar, endCaretPos) + End Function - Public Sub VerifyEndConstructNotAppliedAfterChar(before As String, after As String, typedChar As Char, endCaretPos As Integer()) - VerifyTypedCharApplied(Function(s, v, b) Not s.TryDo(v, b, typedChar, Nothing), before, after, typedChar, endCaretPos) - End Sub + Public Function VerifyEndConstructNotAppliedAfterCharAsync(before As String, after As String, typedChar As Char, endCaretPos As Integer()) As Task + Return VerifyTypedCharAppliedAsync(Async Function(s, v, b) Not Await s.TryDoAsync(v, b, typedChar, Nothing), before, after, typedChar, endCaretPos) + End Function Public Sub VerifyAppliedAfterReturnUsingCommandHandler( before As String, diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/ForLoopTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/ForLoopTests.vb index d1c1e129ee287..e51898d0f835f 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/ForLoopTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/ForLoopTests.vb @@ -7,8 +7,8 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Public Class ForLoopTests - Public Sub TestVerifyForWithIndex() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyForWithIndex() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Sub goo() For i = 1 To 10 @@ -23,11 +23,11 @@ End Class", End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub TestVerifyForEach() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyForEach() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Sub goo() For Each i In collection @@ -42,11 +42,11 @@ End Class", End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub VerifyIndexMatchedInner1() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyIndexMatchedInner1() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 Sub goo() For i = 1 To 10 @@ -55,11 +55,11 @@ End Class", End Sub End Class", caret:={3, -1}) - End Sub + End Function - Public Sub TestVerifyIndexMatchedInner2() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyIndexMatchedInner2() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Sub goo() For i = 1 To 10 @@ -78,11 +78,11 @@ End Class", End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub VerifyIndexSharedNext() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyIndexSharedNext() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 Sub goo() For i = 1 To 10 @@ -91,11 +91,11 @@ End Class", End Sub End Class", caret:={3, -1}) - End Sub + End Function - Public Sub TestVerifyNestedFor() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyNestedFor() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="' NestedFor Class C Sub s @@ -116,11 +116,11 @@ Class C End sub End Class", afterCaret:={5, -1}) - End Sub + End Function - Public Sub TestVerifyNestedForEach() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyNestedForEach() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C function f(byval x as Integer, byref y as string) as string @@ -143,11 +143,11 @@ End Class", End Function End Class", afterCaret:={5, -1}) - End Sub + End Function - Public Sub VerifyReCommitForEach() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyReCommitForEach() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Public Property p(byval x as Integer) as Integer for each i in {1,2,3} @@ -155,26 +155,25 @@ End Class", End Property End Class", caret:={2, -1}) - End Sub + End Function - Public Sub VerifyForAtIncorrectLocation() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyForAtIncorrectLocation() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C For i = 1 to 10", caret:={1, -1}) - End Sub + End Function - Public Sub VerifyInvalidForSyntax() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyInvalidForSyntax() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Sub s for For End Sub End Class", caret:={2, -1}) - End Sub - + End Function End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/ITextSnapshotExtensionsTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/ITextSnapshotExtensionsTests.vb index 77e704798a831..130d4c68faa5f 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/ITextSnapshotExtensionsTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/ITextSnapshotExtensionsTests.vb @@ -8,9 +8,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Public Class ITextSnapshotExtensionsTests Public Sub ThrowsWithNullSnapshot() - Assert.Throws(Of ArgumentNullException)(Sub() - EndConstructExtensions.GetAligningWhitespace(Nothing, 0) - End Sub) + Assert.Throws(Of ArgumentNullException)(Sub() EndConstructExtensions.GetAligningWhitespace(Nothing, 0)) End Sub End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/IfBlockTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/IfBlockTests.vb index aa38593306930..361ee5f84de92 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/IfBlockTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/IfBlockTests.vb @@ -7,8 +7,8 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Public Class IfBlockTests - Public Sub TestApplyAfterSimpleIfThen() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterSimpleIfThen() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Sub goo() If True Then @@ -23,11 +23,11 @@ End Class", End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub TestApplyAfterLineIfNextToThen() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterLineIfNextToThen() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Sub goo() If True Then goo() @@ -42,11 +42,11 @@ End Class", End Sub End Class", afterCaret:={3, 12}) - End Sub + End Function - Public Sub TestApplyAfterLineIfWithMultipleStatements() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterLineIfWithMultipleStatements() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Sub goo() If True Then goo() : goo() @@ -62,11 +62,11 @@ End Class", End Sub End Class", afterCaret:={3, 12}) - End Sub + End Function - Public Sub TestApplyAfterLineIfNextToStatement() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterLineIfNextToStatement() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Sub goo() If True Then goo() @@ -81,11 +81,11 @@ End Class", End Sub End Class", afterCaret:={3, 12}) - End Sub + End Function - Public Sub TestVerifySingleLineIfWithMultiLineLambda() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifySingleLineIfWithMultiLineLambda() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub S If True Then Dim x = Function(x As Integer) @@ -110,11 +110,11 @@ End Class", End Sub End Class", afterCaret:={3, 12}) - End Sub + End Function - Public Sub TestVerifySingleLineIfThenElse() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifySingleLineIfThenElse() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub S If True Then dim x = 1 Else y = 6 @@ -131,11 +131,11 @@ End Class", End Sub End Class", afterCaret:={3, 12}) - End Sub + End Function - Public Sub TestVerifyNestedIf() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyNestedIf() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub S If True Then @@ -157,11 +157,11 @@ End Class", End Class", afterCaret:={4, -1}) - End Sub + End Function - Public Sub TestVerifyNestedSingleLineIf() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyNestedSingleLineIf() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub S If True Then If True Then X = 1 Else X = 2 @@ -176,11 +176,11 @@ End Class", End Sub End Class", afterCaret:={3, 12}) - End Sub + End Function - Public Sub VerifyAddingElseIf() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyAddingElseIf() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Sub S If true Then @@ -189,11 +189,11 @@ End Class", End Sub End Class", caret:={3, -1}) - End Sub + End Function - Public Sub TestVerifyIfWithImplicitLC() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyIfWithImplicitLC() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub S If True And @@ -210,11 +210,11 @@ End Class", End Sub End Class", afterCaret:={4, -1}) - End Sub + End Function - Public Sub VerifyReCommitWithCode() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyReCommitWithCode() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Sub S If True Then @@ -224,11 +224,11 @@ End Class", End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub VerifyReCommitWithoutCode() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyReCommitWithoutCode() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Sub S If True Then @@ -236,22 +236,22 @@ End Class", End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub VerifyWithMultiLineChar() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyWithMultiLineChar() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Sub S If True Then : Elseif true then: End If End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub TestVerifyWithSkippedTokens() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyWithSkippedTokens() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub S If True Then #Const goo = 2 ' x = 42 @@ -266,11 +266,11 @@ End Class", End Sub End Class", afterCaret:={3, 12}) - End Sub + End Function - Public Sub VerifyInvalidMissingEndIf() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyInvalidMissingEndIf() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Sub S If True Then @@ -278,20 +278,20 @@ End Class", End Sub End Class", caret:={3, -1}) - End Sub + End Function - Public Sub VerifyIfInInvalidCode() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyIfInInvalidCode() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="If True Then if True then End If", caret:={1, -1}) - End Sub + End Function - Public Sub TestVerifyInternationalCharacter() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyInternationalCharacter() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Sub goo() If True Then Dim xæ大% = 1 @@ -306,12 +306,12 @@ End Class", End Sub End Class", afterCaret:={3, 12}) - End Sub + End Function - Public Sub TestBugFix6380() - VerifyStatementEndConstructApplied( + Public Async Function TestBugFix6380() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Imports System Imports System.Collections.Generic Imports System.Linq @@ -337,11 +337,11 @@ Module Program End Sub End Module", afterCaret:={8, 12}) - End Sub + End Function - Public Sub TestVerifyRewriteOfIfWithColons() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyRewriteOfIfWithColons() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub Goo() If True Then : Return : End If @@ -356,14 +356,14 @@ End Class", End Sub End Class", afterCaret:={3, 12}) - End Sub + End Function - Public Sub TestVerifyRewriteOfIfWithEmptyStatement() + Public Async Function TestVerifyRewriteOfIfWithEmptyStatement() As Task ' Verify the caret is at the beginning of line 3 here. In VS, it will be moved to the ' correct virtual offset as part of the edit. This is an edge case that we really just ' need to avoid crashing. - VerifyStatementEndConstructApplied( + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub Goo() If True Then Else ' asdf @@ -380,6 +380,6 @@ End Class", End Sub End Class", afterCaret:={3, 0}) - End Sub + End Function End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/MethodBlockTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/MethodBlockTests.vb index 02407969683d2..af9db1065a055 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/MethodBlockTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/MethodBlockTests.vb @@ -7,8 +7,8 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Public Class MethodBlockTests - Public Sub TestApplyAfterSimpleSubDeclarationWithTrailingComment() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterSimpleSubDeclarationWithTrailingComment() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Sub goo() 'Extra Comment End Class", @@ -19,11 +19,11 @@ End Class", End Sub End Class", afterCaret:={2, -1}) - End Sub + End Function - Public Sub TestApplyAfterConstructorDeclaration() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterConstructorDeclaration() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Sub New() End Class", @@ -34,11 +34,11 @@ End Class", End Sub End Class", afterCaret:={2, -1}) - End Sub + End Function - Public Sub TestApplyAfterConstructorDeclarationForDesignerGeneratedClass() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterConstructorDeclarationForDesignerGeneratedClass() As Task + Await VerifyStatementEndConstructAppliedAsync( before:=" Class c1 Sub New() @@ -62,11 +62,11 @@ Class c1 End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub TestApplyAfterConstructorDeclarationWithTrailingComment() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterConstructorDeclarationWithTrailingComment() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Sub New() 'Extra Comment End Class", @@ -77,11 +77,11 @@ End Class", End Sub End Class", afterCaret:={2, -1}) - End Sub + End Function - Public Sub TestApplyAfterSimpleFunctionDeclarationWithTrailingComment() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterSimpleFunctionDeclarationWithTrailingComment() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Function goo() As Integer 'Extra Comment End Class", @@ -92,20 +92,20 @@ End Class", End Function End Class", afterCaret:={2, -1}) - End Sub + End Function - Public Sub DoNotApplyForInterfaceFunction() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyForInterfaceFunction() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Interface IGoo Function Goo() as Integer End Interface", caret:={1, -1}) - End Sub + End Function - Public Sub TestVerifySubInAModule() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifySubInAModule() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Module C Public Sub s End Module", @@ -116,11 +116,11 @@ Public Sub s End Sub End Module", afterCaret:={2, -1}) - End Sub + End Function - Public Sub TestVerifySubWithParameters() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifySubWithParameters() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Module C Private Sub s1(byval x as Integer, Optional y as Integer = 5) End Module", @@ -131,11 +131,11 @@ End Module", End Sub End Module", afterCaret:={2, -1}) - End Sub + End Function - Public Sub TestVerifyFuncWithParameters() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyFuncWithParameters() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Module C Public function f(byval x as Integer, byref y as string) as string @@ -148,11 +148,11 @@ End Module", End function End Module", afterCaret:={3, -1}) - End Sub + End Function - Public Sub TestVerifyFuncNamedWithKeyWord() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyFuncNamedWithKeyWord() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C private funCtion f1(Optional x as integer = 5) as [if] End Class", @@ -163,11 +163,11 @@ End Class", End funCtion End Class", afterCaret:={2, -1}) - End Sub + End Function - Public Sub TestVerifySharedOperator() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifySharedOperator() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Public Shared Operator +(ByVal a As bar, ByVal b As bar) As bar End Class", @@ -178,39 +178,38 @@ End Class", End Operator End Class", afterCaret:={2, -1}) - End Sub + End Function - Public Sub VerifyRecommit() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyRecommit() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Protected friend sub S End sub End Class", caret:={1, -1}) - End Sub + End Function - Public Sub VerifyInvalidLocation01() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyInvalidLocation01() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Sub S Sub P End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub TestVerifyInvalidLocation02() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyInvalidLocation02() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Sub S", beforeCaret:={0, -1}, after:="Sub S End Sub", afterCaret:={1, -1}) - End Sub - + End Function End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/MiscellaneousTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/MiscellaneousTests.vb index 133bddbca95fb..422a2a7084333 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/MiscellaneousTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/MiscellaneousTests.vb @@ -15,23 +15,23 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Public Class MiscellaneousTests - Public Sub DoesNothingOnEmptyFile() - VerifyStatementEndConstructNotApplied( + Public Async Function DoesNothingOnEmptyFile() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="", caret:={0, -1}) - End Sub + End Function - Public Sub DoesNothingOnFileWithNoStatement() - VerifyStatementEndConstructNotApplied( + Public Async Function DoesNothingOnFileWithNoStatement() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="'Goo ", caret:={0, -1}) - End Sub + End Function - Public Sub VerifyLineContinuationMark() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyLineContinuationMark() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C function f(byval x as Integer, byref y as string) as string @@ -40,11 +40,11 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera End Function End Class", caret:={3, -1}) - End Sub + End Function - Public Sub VerifyImplicitLineContinuation() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyImplicitLineContinuation() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C function f() as string While 1 + @@ -52,11 +52,11 @@ End Class", End Function End Class", caret:={2, -1}) - End Sub + End Function - Public Sub TestVerifyNestedDo() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyNestedDo() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C function f() as string for i = 1 to 10", @@ -67,11 +67,11 @@ End Class", Next", afterCaret:={3, -1}) - End Sub + End Function - Public Sub TestVerifyMultilinesChar() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyMultilinesChar() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C sub s do :do @@ -88,11 +88,11 @@ End Class", End sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub TestVerifyInlineComments() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyInlineComments() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C sub s If true then 'here @@ -107,27 +107,27 @@ End Class", End sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub VerifyNotAppliedWithJunkAtEndOfLine() + Public Async Function VerifyNotAppliedWithJunkAtEndOfLine() As Task ' Try this without a newline at the end of the file - VerifyStatementEndConstructNotApplied( + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C End Class", caret:={0, "Class C".Length}) - End Sub + End Function - Public Sub VerifyNotAppliedWithJunkAtEndOfLine2() + Public Async Function VerifyNotAppliedWithJunkAtEndOfLine2() As Task ' Try this with a newline at the end of the file - VerifyStatementEndConstructNotApplied( + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C End Class ", caret:={0, "Class C".Length}) - End Sub + End Function - Public Sub DeletesSelectedText() + Public Async Function DeletesSelectedText() As Task Using workspace = EditorTestWorkspace.CreateVisualBasic("Interface IGoo ~~") Dim textView = workspace.Documents.Single().GetTextView() Dim subjectBuffer = workspace.Documents.First().GetTextBuffer() @@ -143,10 +143,11 @@ End Class", workspace.GetService(Of IEditorOperationsFactoryService), workspace.GetService(Of IEditorOptionsFactoryService)) - Assert.True(endConstructService.TryDoEndConstructForEnterKey(textView, textView.TextSnapshot.TextBuffer, CancellationToken.None)) + Assert.True(Await endConstructService.TryDoEndConstructForEnterKeyAsync( + textView, textView.TextSnapshot.TextBuffer, CancellationToken.None)) Assert.Equal("End Interface", textView.TextSnapshot.Lines.Last().GetText()) End Using - End Sub + End Function End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/MultiLineLambdaTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/MultiLineLambdaTests.vb index cbab0b2f161ee..e9114af38da65 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/MultiLineLambdaTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/MultiLineLambdaTests.vb @@ -7,8 +7,8 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Public Class MultiLineLambdaTests - Public Sub TestApplyWithFunctionLambda() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyWithFunctionLambda() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Sub goo() Dim x = Function() @@ -23,11 +23,11 @@ End Class", End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub TestApplyWithFunctionLambdaWithMissingEndFunction() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyWithFunctionLambdaWithMissingEndFunction() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Function goo() Dim x = Function() @@ -40,11 +40,11 @@ End Class", End Function End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub TestApplyWithSubLambda() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyWithSubLambda() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Function goo() Dim x = Sub() @@ -59,11 +59,11 @@ End Class", End Function End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub TestApplyWithSubLambdaWithNoParameterParenthesis() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyWithSubLambdaWithNoParameterParenthesis() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Function goo() Dim x = Sub @@ -78,11 +78,11 @@ End Class", End Function End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub TestApplyWithSubLambdaInsideMethodCall() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyWithSubLambdaInsideMethodCall() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Function goo() M(Sub()) @@ -97,11 +97,11 @@ End Class", End Function End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub TestApplyWithSubLambdaAndStatementInsideMethodCall() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyWithSubLambdaAndStatementInsideMethodCall() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Function goo() M(Sub() Exit Sub) @@ -116,11 +116,11 @@ End Class", End Function End Class", afterCaret:={3, 10}) - End Sub + End Function - Public Sub TestApplyWithFunctionLambdaInsideMethodCall() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyWithFunctionLambdaInsideMethodCall() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Function goo() M(Function() 1) @@ -135,11 +135,11 @@ End Class", End Function End Class", afterCaret:={3, 17}) - End Sub + End Function - Public Sub TestVerifyAnonymousType() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyAnonymousType() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub s() Dim x = New With {.x = Function(x) @@ -154,33 +154,33 @@ End Class", End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub VerifySingleLineLambdaFunc() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifySingleLineLambdaFunc() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Sub s() Dim x = Function(x) x End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub VerifySingleLineLambdaSub() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifySingleLineLambdaSub() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Sub s() Dim y = Sub(x As Integer) x.ToString() End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub TestVerifyAsDefaultParameterValue() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyAsDefaultParameterValue() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub s(Optional ByVal f As Func(Of String, String) = Function(x As String) End Class", @@ -191,11 +191,11 @@ End Class", End Function End Class", afterCaret:={2, -1}) - End Sub + End Function - Public Sub TestVerifyNestedLambda() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyNestedLambda() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C sub s Dim x = Function (x) @@ -214,11 +214,11 @@ End Class", End sub End Class", afterCaret:={4, -1}) - End Sub + End Function - Public Sub TestVerifyInField() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyInField() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Dim x = Sub() End Class", @@ -229,55 +229,55 @@ End Class", End Sub End Class", afterCaret:={2, -1}) - End Sub + End Function - Public Sub VerifyInvalidLambdaSyntax() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyInvalidLambdaSyntax() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Sub s() Sub(x) End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub VerifyNotAppliedIfSubLambdaContainsEndSub() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyNotAppliedIfSubLambdaContainsEndSub() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Sub s() Dim x = Sub() End Sub End Sub End Class", caret:={2, 21}) - End Sub + End Function - Public Sub VerifyNotAppliedIfSyntaxIsFunctionLambdaContainsEndFunction() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyNotAppliedIfSyntaxIsFunctionLambdaContainsEndFunction() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Sub s() Dim x = Function() End Function End Sub End Class", caret:={2, 26}) - End Sub + End Function - Public Sub VerifyLambdaWithImplicitLC() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyLambdaWithImplicitLC() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Sub s() Dim x = Function(y As Integer) y + End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub TestVerifyLambdaWithMissingParenthesis() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyLambdaWithMissingParenthesis() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub s() Dim x = Function @@ -292,11 +292,11 @@ End Class", End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub TestVerifySingleLineSubLambdaToMultiLine() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifySingleLineSubLambdaToMultiLine() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub s() Dim x = Sub() f() @@ -311,11 +311,11 @@ End Class", End Sub End Class", afterCaret:={3, 20}) - End Sub + End Function - Public Sub TestVerifySingleLineSubLambdaToMultiLineWithTrailingTrivia() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifySingleLineSubLambdaToMultiLineWithTrailingTrivia() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub s() Dim x = Sub() f() ' Invokes f() @@ -330,11 +330,11 @@ End Class", End Sub End Class", afterCaret:={3, 20}) - End Sub + End Function - Public Sub TestVerifySingleLineFunctionLambdaToMultiLine() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifySingleLineFunctionLambdaToMultiLine() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub s() Dim x = Function() f() @@ -349,11 +349,11 @@ End Class", End Sub End Class", afterCaret:={3, 27}) - End Sub + End Function - Public Sub TestVerifySingleLineFunctionLambdaToMultiLineWithTrailingTrivia() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifySingleLineFunctionLambdaToMultiLineWithTrailingTrivia() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub s() Dim x = Function() 4 ' Returns Constant 4 @@ -368,12 +368,12 @@ End Class", End Sub End Class", afterCaret:={3, 27}) - End Sub + End Function - Public Sub TestVerifySingleLineFunctionLambdaToMultiLineInsideXMLTag() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifySingleLineFunctionLambdaToMultiLineInsideXMLTag() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub s() Dim x = <%= Function()%> @@ -388,12 +388,12 @@ End Class", End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub TestVerifySingleLineSubLambdaToMultiLineInsideXMLTag() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifySingleLineSubLambdaToMultiLineInsideXMLTag() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub s() Dim x = <%= Sub()%> @@ -408,6 +408,6 @@ End Class", End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/NamespaceBlockTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/NamespaceBlockTests.vb index b59d637829e12..ad34f791206b6 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/NamespaceBlockTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/NamespaceBlockTests.vb @@ -7,19 +7,19 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Public Class NamespaceBlockTests - Public Sub TestApplyAfterNamespace() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterNamespace() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Namespace goo", beforeCaret:={0, -1}, after:="Namespace goo End Namespace", afterCaret:={1, -1}) - End Sub + End Function - Public Sub TestApplyAfterNestedNamespace() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterNestedNamespace() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Namespace goo Namespace bar End Namespace", @@ -30,34 +30,34 @@ Namespace bar End Namespace End Namespace", afterCaret:={2, -1}) - End Sub + End Function - Public Sub VerifyRecommit() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyRecommit() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="NameSpace Bar End Namespace", caret:={0, -1}) - End Sub + End Function - Public Sub VerifyInvalidNSInMethod() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyInvalidNSInMethod() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Sub S NameSpace T End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub VerifyInvalidNSInModule() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyInvalidNSInModule() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Module M Namespace n End Module", caret:={1, -1}) - End Sub + End Function End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/PreprocessorIfTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/PreprocessorIfTests.vb index 1ea270f2e9f48..984acb9bc18f0 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/PreprocessorIfTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/PreprocessorIfTests.vb @@ -7,31 +7,31 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Public Class PreprocessorIfTests - Public Sub ApplyAfterHashIf() - VerifyStatementEndConstructApplied( + Public Async Function ApplyAfterHashIf() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="#If True Then", beforeCaret:={0, -1}, after:="#If True Then #End If", afterCaret:={1, -1}) - End Sub + End Function - Public Sub DoNotApplyAfterHashIfWhenEndIfExists() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyAfterHashIfWhenEndIfExists() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="#If True Then #End If", caret:={0, -1}) - End Sub + End Function - Public Sub DoNotApplyAfterHashElseIfWhenEndIfExists() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyAfterHashElseIfWhenEndIfExists() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="#If True Then #ElseIf True Then #End If", caret:={1, -1}) - End Sub + End Function End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/PreprocessorRegionsTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/PreprocessorRegionsTests.vb index 59c85a5698e33..d4fda6639d87f 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/PreprocessorRegionsTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/PreprocessorRegionsTests.vb @@ -7,19 +7,19 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Public Class PreprocessorRegionTests - Public Sub ApplyAfterHashRegion() - VerifyStatementEndConstructApplied( + Public Async Function ApplyAfterHashRegion() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="#Region ""Goo""", beforeCaret:={0, -1}, after:="#Region ""Goo"" #End Region", afterCaret:={1, -1}) - End Sub + End Function - Public Sub ApplyAfterHashRegion1() - VerifyStatementEndConstructApplied( + Public Async Function ApplyAfterHashRegion1() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="#Region ""Goo"" #Region ""Bar"" #End Region", @@ -30,41 +30,41 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera #End Region #End Region", afterCaret:={2, -1}) - End Sub + End Function - Public Sub DoNotApplyAfterHashRegionWithoutStringConstant() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyAfterHashRegionWithoutStringConstant() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="#Region", caret:={0, -1}) - End Sub + End Function - Public Sub DoNotApplyAfterHashRegionWhenEndRegionExists1() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyAfterHashRegionWhenEndRegionExists1() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="#Region ""Goo"" #End Region", caret:={0, -1}) - End Sub + End Function - Public Sub DoNotApplyAfterHashRegionWhenEndRegionExists2() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyAfterHashRegionWhenEndRegionExists2() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="#Region ""Goo"" #Region ""Bar"" #End Region #End Region", caret:={0, -1}) - End Sub + End Function - Public Sub DoNotApplyAfterHashRegionWhenEndRegionExists3() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyAfterHashRegionWhenEndRegionExists3() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="#Region ""Goo"" #Region ""Bar"" #End Region #End Region", caret:={1, -1}) - End Sub + End Function End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/PropertyBlockTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/PropertyBlockTests.vb index d8db42f7098b1..90e39597af9fe 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/PropertyBlockTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/PropertyBlockTests.vb @@ -7,35 +7,35 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Public Class PropertyBlockTests - Public Sub DoNotApplyForAutoProperty() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyForAutoProperty() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 Property goo As Integer End Class", caret:={1, -1}) - End Sub + End Function - Public Sub DoNotApplyForAutoPropertyWithEmptyParens() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyForAutoPropertyWithEmptyParens() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 Property goo() As Integer End Class", caret:={1, -1}) - End Sub + End Function - Public Sub DoNotApplyForMustInheritProperty() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyForMustInheritProperty() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="MustInherit Class C MustOverride Property goo(x as integer) As Integer End Class", caret:={1, -1}) - End Sub + End Function - Public Sub TestApplyForPropertyWithParameters() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyForPropertyWithParameters() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Property goo(i As Integer) As Integer End Class", @@ -51,20 +51,20 @@ End Class", End Property End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub DoNotApplyForReadOnlyProperty() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyForReadOnlyProperty() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 ReadOnly Property goo As Integer End Class", caret:={1, -1}) - End Sub + End Function - Public Sub DoNotApplyForReadOnlyPropertyAfterExistingGet() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyForReadOnlyPropertyAfterExistingGet() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 ReadOnly Property goo As Integer Get @@ -73,11 +73,11 @@ End Class", End Property End Class", caret:={2, -1}) - End Sub + End Function - Public Sub DoNotApplyForReadOnlyWithSecondGetPropertyAfterExistingGet() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyForReadOnlyWithSecondGetPropertyAfterExistingGet() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 ReadOnly Property goo As Integer Get @@ -88,20 +88,20 @@ End Class", End Property End Class", caret:={6, -1}) - End Sub + End Function - Public Sub DoNotApplyForWriteOnlyProperty() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyForWriteOnlyProperty() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 WriteOnly Property goo As Integer End Class", caret:={1, -1}) - End Sub + End Function - Public Sub TestApplyOnGetForRegularProperty() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyOnGetForRegularProperty() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Property goo As Integer Get @@ -118,11 +118,11 @@ End Class", End Property End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub TestApplyOnSetForRegularProperty() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyOnSetForRegularProperty() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Property goo As Integer Set @@ -139,21 +139,21 @@ End Class", End Property End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub DoNotApplyForReadOnlyPropertyIfEndPropertyMissingWhenInvokedAfterProperty() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyForReadOnlyPropertyIfEndPropertyMissingWhenInvokedAfterProperty() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 ReadOnly Property goo As Integer Get End Class", caret:={1, -1}) - End Sub + End Function - Public Sub TestApplyOnGetForRegularPropertyWithSetPresent() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyOnGetForRegularPropertyWithSetPresent() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Property goo As Integer Get @@ -176,20 +176,20 @@ End Class", End Property End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub DoNotApplyForWriteOnlyPropertyWithTypeCharacter() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyForWriteOnlyPropertyWithTypeCharacter() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 WriteOnly Property goo$ End Class", caret:={1, -1}) - End Sub + End Function - Public Sub TestApplyForPropertyWithIndexer() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyForPropertyWithIndexer() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Property goo(arg as Integer) As Integer End Class", @@ -205,11 +205,11 @@ End Class", End Property End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub DoNotApplyForDuplicateGet() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyForDuplicateGet() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 ReadOnly Property goo As Integer Get @@ -219,11 +219,11 @@ End Class", End Property End Class", caret:={5, -1}) - End Sub + End Function - Public Sub DoNotApplyForDuplicateSet() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyForDuplicateSet() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 WriteOnly Property goo As Integer Set(ByVal value As Integer) @@ -233,51 +233,51 @@ End Class", End Property End Class", caret:={5, -1}) - End Sub + End Function - Public Sub DoNotApplyForSetInReadOnly() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyForSetInReadOnly() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 ReadOnly Property goo As Integer Set End Property End Class", caret:={2, -1}) - End Sub + End Function - Public Sub DoNotApplyForGetInReadOnly() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyForGetInReadOnly() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 WriteOnly Property goo As Integer Get End Property End Class", caret:={2, -1}) - End Sub + End Function - Public Sub VerifyInternationalCharacter() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyInternationalCharacter() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 WriteOnly Property gooæ End Class", caret:={1, -1}) - End Sub + End Function - Public Sub DoNotApplyInsideAnInterface() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyInsideAnInterface() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Interface IGoo Property Goo(x As Integer) As String End Interface", caret:={1, -1}) - End Sub + End Function - Public Sub TestDoNotGenerateSetForReadonlyProperty() - VerifyStatementEndConstructApplied( + Public Async Function TestDoNotGenerateSetForReadonlyProperty() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Readonly Property goo(arg as Integer) As Integer End Class", @@ -290,11 +290,11 @@ End Class", End Property End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub TestDoNotGenerateGetForWriteonlyProperty() - VerifyStatementEndConstructApplied( + Public Async Function TestDoNotGenerateGetForWriteonlyProperty() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Writeonly Property goo(arg as Integer) As Integer End Class", @@ -307,6 +307,6 @@ End Class", End Property End Class", afterCaret:={3, -1}) - End Sub + End Function End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/SelectBlockTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/SelectBlockTests.vb index d08f41f44584c..93ece3a19bcc0 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/SelectBlockTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/SelectBlockTests.vb @@ -7,8 +7,8 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Public Class SelectBlockTests - Public Sub TestApplyAfterSelectKeyword() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterSelectKeyword() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Sub goo() Select goo @@ -23,11 +23,11 @@ End Select End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub TestApplyAfterSelectCaseKeyword() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterSelectCaseKeyword() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Sub goo() Select Case goo @@ -42,11 +42,11 @@ End Select End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub VerifyNestedDo() - VerifyStatementEndConstructApplied( + Public Async Function VerifyNestedDo() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub S Select Case 1 @@ -67,22 +67,22 @@ End Class", End Sub End Class", afterCaret:={5, -1}) - End Sub + End Function - Public Sub VerifyInvalidSelectBlock() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyInvalidSelectBlock() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Sub S dim x = Select 1 End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub VerifyInvalidSelectBlock01() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyInvalidSelectBlock01() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class EC Sub T Select 1 @@ -90,20 +90,20 @@ End Class", End Sub End Class", caret:={3, -1}) - End Sub + End Function - Public Sub VerifyInvalidSelectBlock02() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyInvalidSelectBlock02() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class EC Select 1 End Class", caret:={1, -1}) - End Sub + End Function - Public Sub VerifyReCommitSelectBlock() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyReCommitSelectBlock() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Sub S Select Case 1 @@ -112,6 +112,6 @@ End Class", End Sub End Class", caret:={2, -1}) - End Sub + End Function End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/SyncLockBlockTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/SyncLockBlockTests.vb index 88f14a8a1e49e..74050194336fb 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/SyncLockBlockTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/SyncLockBlockTests.vb @@ -7,8 +7,8 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Public Class SyncLockBlockTests - Public Sub ApplyAfterSyncLockStatement() - VerifyStatementEndConstructApplied( + Public Async Function ApplyAfterSyncLockStatement() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Sub goo() SyncLock variable @@ -23,11 +23,11 @@ End SyncLock End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub DoNotApplyForMatchedUsing() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyForMatchedUsing() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 Sub goo() SyncLock variable @@ -35,11 +35,11 @@ End SyncLock End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub VerifyNestedSyncBlock() - VerifyStatementEndConstructApplied( + Public Async Function VerifyNestedSyncBlock() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub S SyncLock x @@ -58,26 +58,26 @@ End Class", End Sub End Class", afterCaret:={4, -1}) - End Sub + End Function - Public Sub VerifyInvalidSyntax() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyInvalidSyntax() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Sub S Using (SyncLock 1) End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub VerifyInvalidLocation() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyInvalidLocation() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class EC Synclock 1 End Class", caret:={1, -1}) - End Sub + End Function End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/TryBlockTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/TryBlockTests.vb index e2518511aab8f..71cb45072dc76 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/TryBlockTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/TryBlockTests.vb @@ -7,8 +7,8 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Public Class TryBlockTests - Public Sub ApplyAfterTryStatement() - VerifyStatementEndConstructApplied( + Public Async Function ApplyAfterTryStatement() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Sub goo() Try @@ -25,11 +25,11 @@ End Try End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub DoNotApplyForMatchedTryWithCatch() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyForMatchedTryWithCatch() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 Sub goo() Try @@ -38,11 +38,11 @@ End Try End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub DoNotApplyForMatchedTryWithoutCatch() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyForMatchedTryWithoutCatch() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 Sub goo() Try @@ -50,11 +50,11 @@ End Try End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub VerifyNestedTryBlock() - VerifyStatementEndConstructApplied( + Public Async Function VerifyNestedTryBlock() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub S Try @@ -79,11 +79,11 @@ End Class", End Sub End Class", afterCaret:={6, -1}) - End Sub + End Function - Public Sub VerifyNestedTryBlockWithCode() - VerifyStatementEndConstructApplied( + Public Async Function VerifyNestedTryBlockWithCode() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub S Try @@ -104,11 +104,11 @@ End Class", End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub VerifyMissingCatchInTryBlock() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyMissingCatchInTryBlock() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Sub S dim x = function(x) @@ -119,27 +119,26 @@ End Class", End Sub End Class", caret:={3, -1}) - End Sub + End Function - Public Sub VerifyInvalidSyntax() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyInvalidSyntax() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class EC Sub S Dim x = try End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub VerifyInvalidLocation() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyInvalidLocation() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class EC Sub Try End Class", caret:={1, -1}) - End Sub - + End Function End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/TypeBlockTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/TypeBlockTests.vb index 7899d0278b956..04202526cc4ce 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/TypeBlockTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/TypeBlockTests.vb @@ -7,71 +7,71 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Public Class TypeBlockTests - Public Sub TestApplyAfterClassStatement() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterClassStatement() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1", beforeCaret:={0, -1}, after:="Class c1 End Class", afterCaret:={1, -1}) - End Sub + End Function - Public Sub TestApplyAfterModuleStatement() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterModuleStatement() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Module m1", beforeCaret:={0, -1}, after:="Module m1 End Module", afterCaret:={1, -1}) - End Sub + End Function - Public Sub DoNotApplyForMatchedClass() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyForMatchedClass() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 End Class", caret:={0, -1}) - End Sub + End Function - Public Sub TestApplyAfterInterfaceStatement() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterInterfaceStatement() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Interface IGoo", beforeCaret:={0, -1}, after:="Interface IGoo End Interface", afterCaret:={1, -1}) - End Sub + End Function - Public Sub TestApplyAfterStructureStatement() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterStructureStatement() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Structure Goo", beforeCaret:={0, -1}, after:="Structure Goo End Structure", afterCaret:={1, -1}) - End Sub + End Function - Public Sub TestApplyAfterEnumStatement() - VerifyStatementEndConstructApplied( + Public Async Function TestApplyAfterEnumStatement() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Enum Goo", beforeCaret:={0, -1}, after:="Enum Goo End Enum", afterCaret:={1, -1}) - End Sub + End Function - Public Sub TestVerifyGenericClass() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyGenericClass() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="NameSpace X Class C(of T)", beforeCaret:={1, -1}, @@ -80,11 +80,11 @@ End Enum", End Class", afterCaret:={2, -1}) - End Sub + End Function - Public Sub TestVerifyStructInAClass() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyStructInAClass() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Structure s End Class", @@ -95,11 +95,11 @@ End Class", End Structure End Class", afterCaret:={2, -1}) - End Sub + End Function - Public Sub TestVerifyClassInAModule() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyClassInAModule() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Module M Class C End Module", @@ -110,22 +110,22 @@ End Module", End Class End Module", afterCaret:={2, -1}) - End Sub + End Function - Public Sub TestVerifyClassDeclaration() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyClassDeclaration() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Partial Friend MustInherit Class C", beforeCaret:={0, -1}, after:="Partial Friend MustInherit Class C End Class", afterCaret:={1, -1}) - End Sub + End Function - Public Sub TestVerifyEnumInAClass() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyEnumInAClass() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Public Enum e End Class", @@ -136,69 +136,69 @@ End Class", End Enum End Class", afterCaret:={2, -1}) - End Sub + End Function - Public Sub VerifyInvalidSyntax() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyInvalidSyntax() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class EC Sub S Class B End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub VerifyInvalidSyntax01() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyInvalidSyntax01() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Enum e(Of T)", caret:={0, -1}) - End Sub + End Function - Public Sub VerifyInvalidSyntax02() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyInvalidSyntax02() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Class", caret:={0, -1}) - End Sub + End Function - Public Sub TestVerifyInheritsDecl() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyInheritsDecl() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C : Inherits B", beforeCaret:={0, -1}, after:="Class C : Inherits B End Class", afterCaret:={1, -1}) - End Sub + End Function - Public Sub VerifyInheritsDeclNotApplied() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyInheritsDeclNotApplied() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C : Inherits B End Class", caret:={0, -1}) - End Sub + End Function - Public Sub TestVerifyImplementsDecl() - VerifyStatementEndConstructApplied( + Public Async Function TestVerifyImplementsDecl() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C : Implements IB", beforeCaret:={0, -1}, after:="Class C : Implements IB End Class", afterCaret:={1, -1}) - End Sub + End Function - Public Sub VerifyImplementsDeclNotApplied() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyImplementsDeclNotApplied() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C : Implements IB End Class", caret:={0, -1}) - End Sub + End Function End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/UsingBlockTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/UsingBlockTests.vb index 44ec4f54998db..38d27a5da39af 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/UsingBlockTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/UsingBlockTests.vb @@ -7,8 +7,8 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Public Class UsingBlockTests - Public Sub ApplyAfterUsingStatement() - VerifyStatementEndConstructApplied( + Public Async Function ApplyAfterUsingStatement() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Sub goo() Using variable @@ -23,11 +23,11 @@ End Using End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub DoNotApplyForMatchedUsing() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyForMatchedUsing() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 Sub goo() Using variable @@ -35,11 +35,11 @@ End Using End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub VerifyNestedUsing() - VerifyStatementEndConstructApplied( + Public Async Function VerifyNestedUsing() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub S Using y @@ -58,11 +58,11 @@ End Class", End Sub End Class", afterCaret:={4, -1}) - End Sub + End Function - Public Sub VerifyUsingWithDelegate() - VerifyStatementEndConstructApplied( + Public Async Function VerifyUsingWithDelegate() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub S Using Func(of String, String) @@ -77,26 +77,26 @@ End Class", End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub VerifyUsingAtInvalidSyntax() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyUsingAtInvalidSyntax() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class EC Sub S Using x asf asdf End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub VerifyUsingAtInvalidLocation() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyUsingAtInvalidLocation() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class EC Using x End Class", caret:={1, -1}) - End Sub + End Function End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/WhileLoopTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/WhileLoopTests.vb index 0dc9b3a2484ea..5dfa92cf9cf6a 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/WhileLoopTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/WhileLoopTests.vb @@ -7,8 +7,8 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Public Class WhileLoopTests - Public Sub ApplyAfterWithStatement() - VerifyStatementEndConstructApplied( + Public Async Function ApplyAfterWithStatement() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Sub goo() While variable @@ -23,11 +23,11 @@ End While End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub DoNotApplyForMatchedWith() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyForMatchedWith() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 Sub goo() While variable @@ -35,11 +35,11 @@ End While End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub VerifyNestedWhileBlock() - VerifyStatementEndConstructApplied( + Public Async Function VerifyNestedWhileBlock() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub S While True @@ -60,11 +60,11 @@ End Class", End Sub End Class", afterCaret:={4, -1}) - End Sub + End Function - Public Sub VerifyRecommitWhileBlock() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyRecommitWhileBlock() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class C Sub S While [while] = [while] @@ -72,26 +72,26 @@ End Class", End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub VerifyInvalidWhileSyntax() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyInvalidWhileSyntax() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class EC Sub S While asdf asdf asd End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub VerifyInvalidWhileLocation() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyInvalidWhileLocation() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class EC While True End Class", caret:={1, -1}) - End Sub + End Function End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/WhiteSpacesInsertTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/WhiteSpacesInsertTests.vb index aa0d902427e3b..0d913f04ee8cd 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/WhiteSpacesInsertTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/WhiteSpacesInsertTests.vb @@ -7,8 +7,8 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Public Class WhiteSpacesInsertTests - Public Sub VerifyInsertWhiteSpace() - VerifyStatementEndConstructApplied( + Public Async Function VerifyInsertWhiteSpace() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class X Sub y() End Class", @@ -19,11 +19,11 @@ End Class", End Sub End Class", afterCaret:={2, -1}) - End Sub + End Function - Public Sub VerifyInsertTabSpace() - VerifyStatementEndConstructApplied( + Public Async Function VerifyInsertTabSpace() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class X Sub y() End Class", @@ -34,11 +34,11 @@ End Class", End Sub End Class", afterCaret:={2, -1}) - End Sub + End Function - Public Sub VerifyInsertDoubleWideWhiteSpace() - VerifyStatementEndConstructApplied( + Public Async Function VerifyInsertDoubleWideWhiteSpace() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class X Sub y() End Class", @@ -50,6 +50,6 @@ End Class", End Class", afterCaret:={2, -1}) - End Sub + End Function End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/WithBlockTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/WithBlockTests.vb index 2459fdab98daf..8a0f5700a937d 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/WithBlockTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/WithBlockTests.vb @@ -7,8 +7,8 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Public Class WithBlockTests - Public Sub ApplyAfterWithStatement() - VerifyStatementEndConstructApplied( + Public Async Function ApplyAfterWithStatement() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class c1 Sub goo() With variable @@ -23,11 +23,11 @@ End With End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub DoNotApplyForMatchedWith() - VerifyStatementEndConstructNotApplied( + Public Async Function DoNotApplyForMatchedWith() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class c1 Sub goo() With variable @@ -35,11 +35,11 @@ End With End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub VerifyNestedWith() - VerifyStatementEndConstructApplied( + Public Async Function VerifyNestedWith() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub S With K @@ -58,11 +58,11 @@ End Class", End Sub End Class", afterCaret:={4, -1}) - End Sub + End Function - Public Sub VerifyWithFollowsCode() - VerifyStatementEndConstructApplied( + Public Async Function VerifyWithFollowsCode() As Task + Await VerifyStatementEndConstructAppliedAsync( before:="Class C Sub S With K @@ -79,26 +79,26 @@ End Class", End Sub End Class", afterCaret:={3, -1}) - End Sub + End Function - Public Sub VerifyInvalidWithSyntax() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyInvalidWithSyntax() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class EC Sub S With using End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub VerifyInvalidWithLocation() - VerifyStatementEndConstructNotApplied( + Public Async Function VerifyInvalidWithLocation() As Task + Await VerifyStatementEndConstructNotAppliedAsync( text:="Class EC With True End Class", caret:={1, -1}) - End Sub + End Function End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/XmlLiteralTests.vb b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/XmlLiteralTests.vb index 18a5ad08c5358..d9e0b6bf92c0f 100644 --- a/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/XmlLiteralTests.vb +++ b/src/EditorFeatures/VisualBasicTest/EndConstructGeneration/XmlLiteralTests.vb @@ -7,8 +7,8 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.EndConstructGenera Public Class XmlLiteralTests - Public Sub TestApplyAfterXmlStartElement() - VerifyXmlElementEndConstructApplied( + Public Async Function TestApplyAfterXmlStartElement() As Task + Await VerifyXmlElementEndConstructAppliedAsync( before:="Class C1 Sub M1() Dim x = @@ -21,11 +21,11 @@ End Class", End Sub End Class", afterCaret:={2, 21}) - End Sub + End Function - Public Sub TestApplyAfterXmlStartElementSplitAcrossLines() - VerifyXmlElementEndConstructApplied( + Public Async Function TestApplyAfterXmlStartElementSplitAcrossLines() As Task + Await VerifyXmlElementEndConstructAppliedAsync( before:="Class C1 Sub M1() Dim x = - Public Sub TestApplyAfterXmlStartElementWithNamespace() - VerifyXmlElementEndConstructApplied( + Public Async Function TestApplyAfterXmlStartElementWithNamespace() As Task + Await VerifyXmlElementEndConstructAppliedAsync( before:="Class C1 Sub M1() Dim x = @@ -57,76 +57,76 @@ End Class", End Sub End Class", afterCaret:={2, 21}) - End Sub + End Function - Public Sub DoNotApplyInParameterDeclaration1() - VerifyXmlElementEndConstructNotApplied( + Public Async Function DoNotApplyInParameterDeclaration1() As Task + Await VerifyXmlElementEndConstructNotAppliedAsync( text:="Class C1 Sub M1() End Sub End Class", caret:={1, 16}) - End Sub + End Function - Public Sub DoNotApplyInParameterDeclaration2() - VerifyXmlElementEndConstructNotApplied( + Public Async Function DoNotApplyInParameterDeclaration2() As Task + Await VerifyXmlElementEndConstructNotAppliedAsync( text:="Class C1 Sub M1(i As Integer, ) End Sub End Class", caret:={2, 16}) - End Sub + End Function - Public Sub DoNotApplyAfterXmlStartElementWithEndElement() - VerifyXmlElementEndConstructNotApplied( + Public Async Function DoNotApplyAfterXmlStartElementWithEndElement() As Task + Await VerifyXmlElementEndConstructNotAppliedAsync( text:="Class C1 Sub M1() Dim x = End Sub End Class", caret:={2, 23}) - End Sub + End Function - Public Sub DoNotApplyAfterXmlEndElement() - VerifyXmlElementEndConstructNotApplied( + Public Async Function DoNotApplyAfterXmlEndElement() As Task + Await VerifyXmlElementEndConstructNotAppliedAsync( text:="Class C1 Sub M1() Dim x = End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub DoNotApplyAfterSingleXmlTag() - VerifyXmlElementEndConstructNotApplied( + Public Async Function DoNotApplyAfterSingleXmlTag() As Task + Await VerifyXmlElementEndConstructNotAppliedAsync( text:="Class C1 Sub M1() Dim x = End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub DoNotApplyAfterProcessingInstruction() - VerifyXmlElementEndConstructNotApplied( + Public Async Function DoNotApplyAfterProcessingInstruction() As Task + Await VerifyXmlElementEndConstructNotAppliedAsync( text:="Class C1 Sub M1() Dim x = End Sub End Class", caret:={2, -1}) - End Sub + End Function - Public Sub TestApplyAfterXmlStartElementWhenPassedAsParameter1() - VerifyXmlElementEndConstructApplied( + Public Async Function TestApplyAfterXmlStartElementWhenPassedAsParameter1() As Task + Await VerifyXmlElementEndConstructAppliedAsync( before:="Class C1 Sub M1() M2( @@ -139,11 +139,11 @@ End Class", End Sub End Class", afterCaret:={2, 16}) - End Sub + End Function - Public Sub TestApplyAfterXmlStartElementWhenPassedAsParameter2() - VerifyXmlElementEndConstructApplied( + Public Async Function TestApplyAfterXmlStartElementWhenPassedAsParameter2() As Task + Await VerifyXmlElementEndConstructAppliedAsync( before:="Class C1 Sub M1() M2() @@ -156,11 +156,11 @@ End Class", End Sub End Class", afterCaret:={2, 16}) - End Sub + End Function - Public Sub TestApplyAfterXmlComment() - VerifyXmlCommentEndConstructApplied( + Public Async Function TestApplyAfterXmlComment() As Task + Await VerifyXmlCommentEndConstructAppliedAsync( before:="Class C1 Sub M1() Dim x =