private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken)
        {
            string contentWithoutSummary     = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<ClassName>
</ClassName>
";
            string contentWithSummary        = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<ClassName>
  <summary>
    Foo
  </summary>
</ClassName>
";
            string contentWithDefaultSummary = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<ClassName>
  <summary>
    Summary description for the ClassName class.
  </summary>
</ClassName>
";

            var test = new StyleCopDiagnosticVerifier <SA1608ElementDocumentationMustNotHaveDefaultSummary> .CSharpTest
            {
                TestCode      = source,
                XmlReferences =
                {
                    { "ClassWithoutSummary.xml",     contentWithoutSummary     },
                    { "ClassWithSummary.xml",        contentWithSummary        },
                    { "ClassWithDefaultSummary.xml", contentWithDefaultSummary },
                },
            };

            test.ExpectedDiagnostics.AddRange(expected);
            return(test.RunAsync(cancellationToken));
        }
Esempio n. 2
0
        private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken)
        {
            string contentClassWithTypeparamDoc     = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<TestClass>
  <summary>Test class</summary>
  <typeparam name=""T"">Param 1</typeparam>
</TestClass>
";
            string contentMethodWithTypeparamDoc    = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<TestClass>
  <TestMethod>
    <summary>Test class</summary>
    <typeparam name=""T"">Param 1</typeparam>
  </TestMethod>
</TestClass>
";
            string contentClassWithoutTypeparamDoc  = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<TestClass>
  <summary>Test class</summary>
</TestClass>
";
            string contentMethodWithoutTypeparamDoc = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<TestClass>
  <TestMethod>
    <summary>Test class</summary>
  </TestMethod>
</TestClass>
";
            string contentClassInheritdoc           = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<TestClass>
  <inheritdoc/>
</TestClass>
";
            string contentMethodWithInheritdoc      = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<TestClass>
  <TestMethod>
  <inheritdoc/>
  </TestMethod>
</TestClass>
";

            var test = new StyleCopDiagnosticVerifier <SA1618GenericTypeParametersMustBeDocumented> .CSharpTest
            {
                TestCode      = source,
                XmlReferences =
                {
                    { "ClassWithTypeparamDoc.xml",     contentClassWithTypeparamDoc     },
                    { "MethodWithTypeparamDoc.xml",    contentMethodWithTypeparamDoc    },
                    { "ClassWithoutTypeparamDoc.xml",  contentClassWithoutTypeparamDoc  },
                    { "MethodWithoutTypeparamDoc.xml", contentMethodWithoutTypeparamDoc },
                    { "ClassWithIneheritdoc.xml",      contentClassInheritdoc           },
                    { "MethodWithInheritdoc.xml",      contentMethodWithInheritdoc      },
                },
            };

            test.ExpectedDiagnostics.AddRange(expected);
            return(test.RunAsync(cancellationToken));
        }
Esempio n. 3
0
        private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken)
        {
            string contentWithoutElementDocumentation     = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<TestClass>
    <TestMethod>
        <summary>
            Foo
        </summary>
    </TestMethod>
</TestClass>
";
            string contentWithElementDocumentation        = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<TestClass>
    <TestMethod>
        <summary>
            Foo
        </summary>
        <param name=""param1"">Param 1</param>
        <param name=""param2"">Param 2</param>
        <param name=""param3"">Param 3</param>
    </TestMethod>
</TestClass>
";
            string contentWithPartialElementDocumentation = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<TestClass>
    <TestMethod>
        <summary>
            Foo
        </summary>
        <param name=""param2"">Param 2</param>
        <param name=""param3"">Param 3</param>
    </TestMethod>
</TestClass>
";
            string contentWithInheritedDocumentation      = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
 <TestClass>
    <TestMethod>
        <inheritdoc />
    </TestMethod>
 </TestClass>
 ";

            var test = new StyleCopDiagnosticVerifier <SA1611ElementParametersMustBeDocumented> .CSharpTest
            {
                TestCode      = source,
                XmlReferences =
                {
                    { "MissingElementDocumentation.xml",     contentWithoutElementDocumentation     },
                    { "WithElementDocumentation.xml",        contentWithElementDocumentation        },
                    { "WithPartialElementDocumentation.xml", contentWithPartialElementDocumentation },
                    { "InheritedDocumentation.xml",          contentWithInheritedDocumentation      },
                },
            };

            test.ExpectedDiagnostics.AddRange(expected);
            return(test.RunAsync(cancellationToken));
        }
        private static Task VerifyCSharpDiagnosticAsync(string source, string testSettings, DiagnosticResult[] expected, CancellationToken cancellationToken)
        {
            var test = new StyleCopDiagnosticVerifier <SA1601PartialElementsMustBeDocumented> .CSharpTest
            {
                TestCode = source,
                Settings = testSettings,
            };

            test.ExpectedDiagnostics.AddRange(expected);
            return(test.RunAsync(cancellationToken));
        }
Esempio n. 5
0
        private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken)
        {
            string contentWithSummary          = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<Class1>
  <MethodName>
    <summary>
      Sample method.
    </summary>
    <returns>
      A <see cref=""Task""/> representing the asynchronous operation.
    </returns>
  </MethodName>
</Class1>
";
            string contentWithInheritedSummary = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<Class1>
  <MethodName>
    <inheritdoc/>
  </MethodName>
</Class1>
";
            string contentWithEmptySummary     = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<Class1>
  <MethodName>
    <summary>
    </summary>
    <returns>
      A <see cref=""Task""/> representing the asynchronous operation.
    </returns>
  </MethodName>
</Class1>
";

            var test = new StyleCopDiagnosticVerifier <SA1606ElementDocumentationMustHaveSummaryText> .CSharpTest
            {
                TestCode      = source,
                XmlReferences =
                {
                    { "ClassWithSummary.xml",          contentWithSummary          },
                    { "ClassWithInheritedSummary.xml", contentWithInheritedSummary },
                    { "ClassWithEmptySummary.xml",     contentWithEmptySummary     },
                },
            };

            test.ExpectedDiagnostics.AddRange(expected);
            return(test.RunAsync(cancellationToken));
        }
        private static Task VerifyCSharpDiagnosticAsync(string source, string testSettings, DiagnosticResult[] expected, CancellationToken cancellationToken)
        {
            string contentWithoutSummary = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<ClassName>
</ClassName>
";
            string contentWithInheritdoc = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<ClassName>
  <inheritdoc/>
</ClassName>
";
            string contentWithSummary    = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<ClassName>
  <summary>
    Foo
  </summary>
</ClassName>
";
            string contentWithContent    = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<ClassName>
  <content>
    Foo
  </content>
</ClassName>
";

            var test = new StyleCopDiagnosticVerifier <SA1605PartialElementDocumentationMustHaveSummary> .CSharpTest
            {
                TestCode      = source,
                Settings      = testSettings,
                XmlReferences =
                {
                    { "ClassWithoutSummary.xml", contentWithoutSummary },
                    { "ClassWithInheritdoc.xml", contentWithInheritdoc },
                    { "ClassWithSummary.xml",    contentWithSummary    },
                    { "ClassWithContent.xml",    contentWithContent    },
                },
            };

            test.ExpectedDiagnostics.AddRange(expected);
            return(test.RunAsync(cancellationToken));
        }
        private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken)
        {
            string contentWithoutParamDocumentation     = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<ClassName>
    <Method>
        <summary>
            Foo
        </summary>
    </Method>
</ClassName>
";
            string contentWithParamDocumentation        = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<ClassName>
    <Method>
        <summary>
            Foo
        </summary>
        <param name=""foo"">Param 1</param>
        <param name=""bar"">Param 2</param>
    </Method>
</ClassName>
";
            string contentWithInvalidParamDocumentation = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<ClassName>
    <Method>
        <summary>
            Foo
        </summary>
        <param>Test</param>
        <param/>
        <param name="""">Test</param>
        <param name=""    "">Test</param>
    </Method>
</ClassName>
";
            string contentWithInheritedDocumentation    = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
 <ClassName>
    <Method>
        <inheritdoc />
        <param>Test</param>
        <param/>
        <param name="""">Test</param>
        <param name=""    "">Test</param>
    </Method>
 </ClassName>
 ";

            var test = new StyleCopDiagnosticVerifier <SA1613ElementParameterDocumentationMustDeclareParameterName> .CSharpTest
            {
                TestCode      = source,
                XmlReferences =
                {
                    { "MissingParamDocumentation.xml",     contentWithoutParamDocumentation     },
                    { "WithParamDocumentation.xml",        contentWithParamDocumentation        },
                    { "WithInvalidParamDocumentation.xml", contentWithInvalidParamDocumentation },
                    { "WithInheritedDocumentation.xml",    contentWithInheritedDocumentation    },
                },
            };

            test.ExpectedDiagnostics.AddRange(expected);
            return(test.RunAsync(cancellationToken));
        }
        private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken)
        {
            string contentWithoutDocumentation         = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<ClassName>
    <Method>
    </Method>
</ClassName>
";
            string contentWithoutParamDocumentation    = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<ClassName>
    <Method>
        <summary>
            Foo
        </summary>
    </Method>
</ClassName>
";
            string contentWithParamDocumentation       = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<ClassName>
    <Method>
        <summary>
            Foo
        </summary>
        <param name=""foo"">Test</param>
        <param name=""bar"">Test</param>
    </Method>
</ClassName>
";
            string contentWithEmptyParamDocumentation  = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<ClassName>
    <Method>
        <summary>
            Foo
        </summary>
        <param name=""foo""></param>
        <param name=""bar"">   
            
        </param>
    </Method>
</ClassName>
";
            string contentWithEmptyParamDocumentation2 = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<ClassName>
    <Method>
        <summary>
            Foo
        </summary>
        <param name=""foo""/>
        <param name=""bar"">
            <para>
                 
            </para>
        </param>
    </Method>
</ClassName>
";

            var test = new StyleCopDiagnosticVerifier <SA1614ElementParameterDocumentationMustHaveText> .CSharpTest
            {
                TestCode      = source,
                XmlReferences =
                {
                    { "NoDocumentation.xml",          contentWithoutDocumentation         },
                    { "NoParamDocumentation.xml",     contentWithoutParamDocumentation    },
                    { "ParamDocumentation.xml",       contentWithParamDocumentation       },
                    { "EmptyParamDocumentation.xml",  contentWithEmptyParamDocumentation  },
                    { "EmptyParamDocumentation2.xml", contentWithEmptyParamDocumentation2 },
                },
            };

            test.ExpectedDiagnostics.AddRange(expected);
            return(test.RunAsync(cancellationToken));
        }