public void Analyzer_WithTestData_ShouldReportAttribute(TestData testData)
 {
     var expectedLocation = testData.ExpectedDiagnositicLocation;
     var expected = new DiagnosticResult
     {
         Id = "DebuggerStepThroughRemover",
         Message = $"Type 'TypeName' is decorated with DebuggerStepThrough attribute",
         Severity = DiagnosticSeverity.Warning,
         Locations =
             new[] {
                     new DiagnosticResultLocation("Test0.cs", expectedLocation.Line, expectedLocation.Character)
                 }
     };
     VerifyDiagnostic(testData.BrokenSource, expected);
 }
예제 #2
0
        public void Analyzer_With_LocationDiagnostic()
        {
            var original = @"
            using System;
            using System.Text;
            using System.Threading.Tasks;

            namespace ConsoleApplication1
            {
            class MyClass
            {
            async Task Method()
            {

            }
            }
            }";

            var result = @"
            using System;
            using System.Text;
            using System.Threading.Tasks;

            namespace ConsoleApplication1
            {
            class MyClass
            {
            async Task MethodAsync()
            {

            }
            }
            }";

            var expectedDiagnostic = new DiagnosticResult
            {
                Id = TestAnalyzer.DiagnosticId,
                Message = string.Format(TestAnalyzer.Message, "Method"),
                Severity = TestAnalyzer.Severity,
                Locations =
                    new[]
                    {
                        new DiagnosticResultLocation("Test0.cs", 10, 24)
                    }
            };

            VerifyDiagnostic(original, expectedDiagnostic);
            VerifyFix(original, result);
        }