public void RemoveAnnotationForStandaloneAnnotationRemovesEntireLineOnLastLine() { const string inputCode = @" Option Explicit 'Strange indent comment '@PredeclaredId"; const string expectedCode = @" Option Explicit 'Strange indent comment"; string actualCode; var(component, rewriteSession, state) = TestSetup(inputCode); using (state) { var moduleDeclaration = state.DeclarationFinder .UserDeclarations(DeclarationType.ProceduralModule) .First(); var annotationToRemove = moduleDeclaration.Annotations.First(); var annotationUpdater = new AnnotationUpdater(); annotationUpdater.RemoveAnnotation(rewriteSession, annotationToRemove); rewriteSession.TryRewrite(); actualCode = component.CodeModule.Content(); } Assert.AreEqual(expectedCode, actualCode); }
public void RemoveAnnotationWorksForLastAnnotation() { const string inputCode = @"'@PredeclaredId Option Explicit '@Folder ""folder"" Private Sub FooBar() End Sub '@Obsolete @Description ""Desc"" @DefaultMember Public Sub Foo(bar As String) bar = vbNullString End Sub "; const string expectedCode = @"'@PredeclaredId Option Explicit '@Folder ""folder"" Private Sub FooBar() End Sub '@Obsolete @Description ""Desc"" Public Sub Foo(bar As String) bar = vbNullString End Sub "; string actualCode; var(component, rewriteSession, state) = TestSetup(inputCode); using (state) { var fooDeclaration = state.DeclarationFinder .UserDeclarations(DeclarationType.Procedure) .First(decl => decl.IdentifierName == "Foo"); var annotationToRemove = fooDeclaration.Annotations.Last(); var annotationUpdater = new AnnotationUpdater(); annotationUpdater.RemoveAnnotation(rewriteSession, annotationToRemove); rewriteSession.TryRewrite(); actualCode = component.CodeModule.Content(); } Assert.AreEqual(expectedCode, actualCode); }