private static Task VerifyCSharpDiagnosticAsync(OptionSetting?newlineAtEndOfFile, string source, DiagnosticResult[] expected, CancellationToken cancellationToken) { var test = new StyleCopCodeFixVerifier <SA1518UseLineEndingsCorrectlyAtEndOfFile, SA1518CodeFixProvider> .CSharpTest { TestCode = source, }; if (newlineAtEndOfFile != null) { test.Settings = GetSettings(newlineAtEndOfFile.Value); } test.ExpectedDiagnostics.AddRange(expected); return(test.RunAsync(cancellationToken)); }
private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expected, string fixedSource, CancellationToken cancellationToken) { string contentWithoutReturns = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <ClassName> <Method> <summary>Foo</summary> </Method> </ClassName> "; string contentWithReturns = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <ClassName> <Method> <summary>Foo</summary> <returns>Bar</returns> </Method> </ClassName> "; string contentWithInheritdocValue = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <ClassName> <Method> <inheritdoc/> </Method> </ClassName> "; var test = new StyleCopCodeFixVerifier <SA1617VoidReturnValueMustNotBeDocumented, SA1617CodeFixProvider> .CSharpTest { TestCode = source, FixedCode = fixedSource, XmlReferences = { { "MethodWithoutReturns.xml", contentWithoutReturns }, { "MethodWithReturns.xml", contentWithReturns }, { "MethodWithInheritdoc.xml", contentWithInheritdocValue }, }, }; if (source == fixedSource) { test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll; test.FixedState.MarkupHandling = MarkupMode.Allow; test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll; test.BatchFixedState.MarkupHandling = MarkupMode.Allow; } test.ExpectedDiagnostics.AddRange(expected); return(test.RunAsync(cancellationToken)); }
protected Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expected, string fixedSource, DiagnosticResult[] remainingDiagnostics, CancellationToken cancellationToken) { var test = new StyleCopCodeFixVerifier <FileHeaderAnalyzers, FileHeaderCodeFixProvider> .CSharpTest { TestCode = source, FixedCode = fixedSource, Settings = this.GetSettings(), }; test.Exclusions &= ~AnalysisExclusions.Suppression; test.ExpectedDiagnostics.AddRange(expected); test.RemainingDiagnostics.AddRange(remainingDiagnostics); test.DisabledDiagnostics.AddRange(this.GetDisabledDiagnostics()); test.ExplicitlyEnabledDiagnostics.AddRange(this.GetExplicitlyEnabledDiagnostics()); return(test.RunAsync(cancellationToken)); }
private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expected, string fixedSource, CancellationToken cancellationToken) { string contentWithReturns = @"<?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 contentWithInheritedReturns = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <Class1> <MethodName> <inheritdoc/> </MethodName> </Class1> "; string contentWithoutReturns = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <Class1> <MethodName> <summary> Sample method. </summary> </MethodName> </Class1> "; var test = new StyleCopCodeFixVerifier <SA1615ElementReturnValueMustBeDocumented, SA1615SA1616CodeFixProvider> .CSharpTest { TestCode = source, FixedCode = fixedSource, XmlReferences = { { "MethodWithReturns.xml", contentWithReturns }, { "MethodWithInheritedReturns.xml", contentWithInheritedReturns }, { "MethodWithoutReturns.xml", contentWithoutReturns }, }, }; test.ExpectedDiagnostics.AddRange(expected); return(test.RunAsync(cancellationToken)); }
private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) { var test = new StyleCopCodeFixVerifier <SA1206DeclarationKeywordsMustFollowOrder, SA1206CodeFixProvider> .CSharpTest { TestCode = source, SolutionTransforms = { (solution, projectId) => { var parseOptions = (CSharpParseOptions)solution.GetProject(projectId).ParseOptions; return(solution.WithProjectParseOptions(projectId, parseOptions.WithLanguageVersion(LanguageVersion.Latest))); }, }, }; test.ExpectedDiagnostics.AddRange(expected); return(test.RunAsync(cancellationToken)); }
private static StyleCopCodeFixVerifier <SA1643DestructorSummaryDocumentationMustBeginWithStandardText, SA1642SA1643CodeFixProvider> .CSharpTest CreateTest(DiagnosticResult[] expected) { string contentValidSummary = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <TestClass> <Destructor> <summary>Finalizes an instance of the <see cref=""TestClass""/> class.</summary> </Destructor> </TestClass> "; string contentMissingSummary = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <TestClass> <Destructor> </Destructor> </TestClass> "; string contentEmptySummary = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <TestClass> <Destructor> <summary></summary> </Destructor> </TestClass> "; string contentInvalidSummary = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <TestClass> <Destructor> <summary>Creates the <see cref=""TestClass""/> class.</summary> </Destructor> </TestClass> "; var test = new StyleCopCodeFixVerifier <SA1643DestructorSummaryDocumentationMustBeginWithStandardText, SA1642SA1643CodeFixProvider> .CSharpTest { XmlReferences = { { "ValidSummary.xml", contentValidSummary }, { "MissingSummary.xml", contentMissingSummary }, { "EmptySummary.xml", contentEmptySummary }, { "InvalidSummary.xml", contentInvalidSummary }, }, }; test.ExpectedDiagnostics.AddRange(expected); return(test); }
private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expected, string fixedSource, CancellationToken cancellationToken) { string contentWithValue = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <ClassName> <Property> <summary>Foo</summary> <value>Bar</value> </Property> </ClassName> "; string contentWithoutValue = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <ClassName> <Property> <summary>Foo</summary> </Property> </ClassName> "; string contentWithInheritdocValue = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <ClassName> <Property> <inheritdoc/> </Property> </ClassName> "; var test = new StyleCopCodeFixVerifier <SA1609PropertyDocumentationMustHaveValue, SA1609SA1610CodeFixProvider> .CSharpTest { TestCode = source, FixedCode = fixedSource, XmlReferences = { { "PropertyWithValue.xml", contentWithValue }, { "PropertyWithoutValue.xml", contentWithoutValue }, { "PropertyWithInheritdoc.xml", contentWithInheritdocValue }, }, }; test.ExpectedDiagnostics.AddRange(expected); return(test.RunAsync(cancellationToken)); }
private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expected, string fixedSource, CancellationToken cancellationToken) { const string CombinedUsingDirectivesTestSettings = @" { ""settings"": { ""orderingRules"": { ""systemUsingDirectivesFirst"": false } } } "; var test = new StyleCopCodeFixVerifier <SA1210UsingDirectivesMustBeOrderedAlphabeticallyByNamespace, UsingCodeFixProvider> .CSharpTest { TestCode = source, FixedCode = fixedSource, Settings = CombinedUsingDirectivesTestSettings, }; test.ExpectedDiagnostics.AddRange(expected); return(test.RunAsync(cancellationToken)); }
protected static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) => StyleCopCodeFixVerifier <FileHeaderAnalyzers, FileHeaderCodeFixProvider> .Diagnostic(descriptor);
private static DiagnosticResult Diagnostic() => StyleCopCodeFixVerifier <SA1027UseTabsCorrectly, SA1027CodeFixProvider> .Diagnostic();
private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expected, string fixedSource, bool offerEmptyFixer, CancellationToken cancellationToken) { string contentWithoutDocumentation = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <ClassName> <Method> </Method> </ClassName> "; string contentWithoutReturns = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <ClassName> <Method> <summary> Foo </summary> </Method> </ClassName> "; string contentWithReturns = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <ClassName> <Method> <summary> Foo </summary> <returns>Test</returns> </Method> </ClassName> "; string contentWithEmptyReturns = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <ClassName> <Method> <summary> Foo </summary> <returns> </returns> </Method> </ClassName> "; string contentWithEmptyReturns2 = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <ClassName> <Method> <summary> Foo </summary> <returns /> </Method> </ClassName> "; string contentWithEmptyReturns3 = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <ClassName> <Method> <summary> Foo </summary> <returns></returns> </Method> </ClassName> "; var test = new StyleCopCodeFixVerifier <SA1616ElementReturnValueDocumentationMustHaveText, SA1615SA1616CodeFixProvider> .CSharpTest { TestCode = source, FixedCode = fixedSource, XmlReferences = { { "NoDocumentation.xml", contentWithoutDocumentation }, { "WithoutReturns.xml", contentWithoutReturns }, { "WithReturns.xml", contentWithReturns }, { "WithEmptyReturns.xml", contentWithEmptyReturns }, { "WithEmptyReturns2.xml", contentWithEmptyReturns2 }, { "WithEmptyReturns3.xml", contentWithEmptyReturns3 }, }, }; if (source == fixedSource) { test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll; test.FixedState.MarkupHandling = MarkupMode.Allow; test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll; test.BatchFixedState.MarkupHandling = MarkupMode.Allow; if (offerEmptyFixer) { test.NumberOfIncrementalIterations = 1; test.NumberOfFixAllIterations = 1; } } test.ExpectedDiagnostics.AddRange(expected); return(test.RunAsync(cancellationToken)); }
private static DiagnosticResult Diagnostic() => StyleCopCodeFixVerifier <SA1206DeclarationKeywordsMustFollowOrder, SA1206CodeFixProvider> .Diagnostic();
private static DiagnosticResult Diagnostic() => StyleCopCodeFixVerifier <SA1217UsingStaticDirectivesMustBeOrderedAlphabetically, UsingCodeFixProvider> .Diagnostic();
private static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) => StyleCopCodeFixVerifier <SA1200UsingDirectivesMustBePlacedCorrectly, UsingCodeFixProvider> .Diagnostic(descriptor);
private static StyleCopCodeFixVerifier <SA1642ConstructorSummaryDocumentationMustBeginWithStandardText, SA1642SA1643CodeFixProvider> .CSharpTest CreateTest(string testSettings, DiagnosticResult[] expected) { string contentValidSummary = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <TestClass> <TestClass> <summary>Initializes a new instance of the <see cref=""TestClass""/> class.</summary> </TestClass> </TestClass> "; string contentMissingSummary = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <TestClass> <TestClass> </TestClass> </TestClass> "; string contentEmptySummary = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <TestClass> <TestClass> <summary></summary> </TestClass> </TestClass> "; string contentInvalidSummary = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <TestClass> <TestClass> <summary>Creates the <see cref=""TestClass""/> class.</summary> </TestClass> </TestClass> "; string contentInvalidReference = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <TestClass> <TestClass> <summary>Initializes a new instance of the <see cref=""WrongClass""/> class.</summary> </TestClass> </TestClass> "; string contentNoReference = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <TestClass> <TestClass> <summary>Initializes a new instance of the <see /> class.</summary> </TestClass> </TestClass> "; string contentInvalidSecondPart = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <TestClass> <TestClass> <summary>Initializes a new instance of the <see cref=""TestClass""/>.</summary> </TestClass> </TestClass> "; var test = new StyleCopCodeFixVerifier <SA1642ConstructorSummaryDocumentationMustBeginWithStandardText, SA1642SA1643CodeFixProvider> .CSharpTest { XmlReferences = { { "ValidSummary.xml", contentValidSummary }, { "MissingSummary.xml", contentMissingSummary }, { "EmptySummary.xml", contentEmptySummary }, { "InvalidSummary.xml", contentInvalidSummary }, { "InvalidReference.xml", contentInvalidReference }, { "NoReference.xml", contentNoReference }, { "InvalidSecondPart.xml", contentInvalidSecondPart }, }, }; test.ExpectedDiagnostics.AddRange(expected); if (testSettings != null) { test.Settings = testSettings; } return(test); }
private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expected, string fixedSource, bool offerEmptyFixer, CancellationToken cancellationToken) { string contentWithValue = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <ClassName> <Property> <summary>Foo</summary> <value>Bar</value> </Property> </ClassName> "; string contentWithoutValue = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <ClassName> <Property> <summary>Foo</summary> </Property> </ClassName> "; string contentWithEmptyValue = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <ClassName> <Property> <summary>Foo</summary> <value> </value> </Property> </ClassName> "; string contentWithInheritdocValue = @"<?xml version=""1.0"" encoding=""utf-8"" ?> <ClassName> <Property> <inheritdoc/> </Property> </ClassName> "; var test = new StyleCopCodeFixVerifier<SA1610PropertyDocumentationMustHaveValueText, SA1609SA1610CodeFixProvider>.CSharpTest { TestCode = source, FixedCode = fixedSource, XmlReferences = { { "PropertyWithValue.xml", contentWithValue }, { "PropertyWithoutValue.xml", contentWithoutValue }, { "PropertyWithEmptyValue.xml", contentWithEmptyValue }, { "PropertyWithInheritdoc.xml", contentWithInheritdocValue }, }, }; if (source == fixedSource) { test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll; test.FixedState.MarkupHandling = MarkupMode.Allow; test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll; test.BatchFixedState.MarkupHandling = MarkupMode.Allow; if (offerEmptyFixer) { test.NumberOfIncrementalIterations = 1; test.NumberOfFixAllIterations = 1; } } test.ExpectedDiagnostics.AddRange(expected); return test.RunAsync(cancellationToken); }
internal static Task VerifyCSharpFixAsync(LanguageVersion languageVersion, string oldFileName, string source, string testSettings, DiagnosticResult[] expected, string newFileName, string fixedSource, CancellationToken cancellationToken) { var test = new StyleCopCodeFixVerifier <SA1649FileNameMustMatchTypeName, SA1649CodeFixProvider> .CSharpTest(languageVersion) { TestSources = { (oldFileName, source) },