Example #1
0
        public void ObsoleteTypeHint_QuickFixWorks_PropertyGet_StringTypeHint()
        {
            const string inputCode =
                @"Public Property Get Foo$(ByVal fizz As Integer)
    Foo = ""test""
End Property";

            const string expectedCode =
                @"Public Property Get Foo(ByVal fizz As Integer) As String
    Foo = ""test""
End Property";

            var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out var component);

            using (var state = MockParser.CreateAndParse(vbe.Object))
            {
                var inspection        = new ObsoleteTypeHintInspection(state);
                var inspectionResults = inspection.GetInspectionResults();

                var fix = new RemoveTypeHintsQuickFix(state);
                foreach (var result in inspectionResults)
                {
                    fix.Fix(result);
                }

                Assert.AreEqual(expectedCode, state.GetRewriter(component).GetText());
            }
        }
        public void ObsoleteTypeHint_QuickFixWorks_Constant_StringTypeHint()
        {
            const string inputCode =
                @"Public Sub Foo()
    Const buzz$ = """"
End Sub";

            const string expectedCode =
                @"Public Sub Foo()
    Const buzz As String = """"
End Sub";

            var vbe   = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out var component);
            var state = MockParser.CreateAndParse(vbe.Object);

            var inspection        = new ObsoleteTypeHintInspection(state);
            var inspectionResults = inspection.GetInspectionResults();

            var fix = new RemoveTypeHintsQuickFix(state);

            foreach (var result in inspectionResults)
            {
                fix.Fix(result);
            }

            Assert.AreEqual(expectedCode, state.GetRewriter(component).GetText());
        }
Example #3
0
        public void ObsoleteTypeHint_QuickFixWorks_Field_DecimalTypeHint()
        {
            const string inputCode =
                @"Public Foo@";

            const string expectedCode =
                @"Public Foo As Decimal";

            var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out var component);

            using (var state = MockParser.CreateAndParse(vbe.Object))
            {
                var inspection        = new ObsoleteTypeHintInspection(state);
                var inspectionResults = inspection.GetInspectionResults();

                var fix = new RemoveTypeHintsQuickFix(state);
                foreach (var result in inspectionResults)
                {
                    fix.Fix(result);
                }

                Assert.AreEqual(expectedCode, state.GetRewriter(component).GetText());
            }
        }