public void NoResultGivenMemberDescriptionAttribute_NoAnnotation()
        {
            const string testModuleName = "Test";
            const string inputCode      = @"
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = """ + testModuleName + @"""   ' (ignored)
Attribute VB_GlobalNameSpace = False              ' (ignored)
Attribute VB_Creatable = False                    ' (ignored)
Attribute VB_PredeclaredId = False                ' Must be False
Attribute VB_Exposed = False                      ' Must be False
Option Explicit

Sub DoSomething()
Attribute DoSomething.VB_Description = ""Does something""
End Sub
";

            var vbe = MockVbeBuilder.BuildFromSingleModule(inputCode, testModuleName, ComponentType.ClassModule, out _);

            using (var state = MockParser.CreateAndParse(vbe.Object))
            {
                var inspection        = new MissingAttributeInspection(state);
                var inspector         = InspectionsHelper.GetInspector(inspection);
                var inspectionResults = inspector.FindIssuesAsync(state, CancellationToken.None).Result;

                Assert.IsFalse(inspectionResults.Any());
            }
        }
        public void HasResultGivenPredeclaredIdAnnotation_WithoutAttribute()
        {
            const string testModuleName = "Test";
            const string inputCode      = @"
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = """ + testModuleName + @"""   ' (ignored)
Attribute VB_GlobalNameSpace = False              ' (ignored)
Attribute VB_Creatable = False                    ' (ignored)
Attribute VB_PredeclaredId = False                ' Must be False
Attribute VB_Exposed = False                      ' Must be False
Option Explicit
'@PredeclaredId
";

            var vbe = MockVbeBuilder.BuildFromSingleModule(inputCode, testModuleName, ComponentType.ClassModule, out _);

            using (var state = MockParser.CreateAndParse(vbe.Object))
            {
                var inspection        = new MissingAttributeInspection(state);
                var inspector         = InspectionsHelper.GetInspector(inspection);
                var inspectionResults = inspector.FindIssuesAsync(state, CancellationToken.None).Result;

                Assert.AreEqual(1, inspectionResults.Count());
            }
        }
        private IEnumerable <IInspectionResult> InspectionResults(string inputCode, ComponentType componentType = ComponentType.StandardModule)
        {
            var vbe = MockVbeBuilder.BuildFromSingleModule(inputCode, componentType, out _);

            using (var state = MockParser.CreateAndParse(vbe.Object))
            {
                var inspection = new MissingAttributeInspection(state);
                return(inspection.GetInspectionResults(CancellationToken.None));
            }
        }
        public void AddsMissingExposedAttribute()
        {
            const string testModuleName = "Test";
            const string inputCode      = @"
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = """ + testModuleName + @"""
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
'@Exposed
";
            const string expectedCode   = @"
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = """ + testModuleName + @"""
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
'@Exposed
";

            var vbe = MockVbeBuilder.BuildFromSingleModule(inputCode, testModuleName, ComponentType.ClassModule, out _);

            var state      = MockParser.CreateAndParse(vbe.Object);
            var inspection = new MissingAttributeInspection(state);
            var inspector  = InspectionsHelper.GetInspector(inspection);
            var result     = inspector.FindIssuesAsync(state, CancellationToken.None).Result?.SingleOrDefault();

            if (result?.Context.GetType() != typeof(VBAParser.AnnotationContext))
            {
                Assert.Inconclusive("Inspection failed to return a result.");
            }

            var fix = new SynchronizeAttributesQuickFix(state);

            fix.Fix(result);

            var rewriter = state.GetAttributeRewriter(result.QualifiedSelection.QualifiedName);
            var actual   = rewriter.GetText();

            Assert.AreEqual(expectedCode, actual);
        }