diff --git a/.editorconfig b/.editorconfig index e660180db..3f333c552 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,5 +1,13 @@ root = true +[*.{csproj,props,targets}] +indent_style = space +indent_size = 2 + +[*.yml] +indent_style = space +indent_size = 2 + [*.cs] charset = utf-8-bom insert_final_newline = true @@ -8,6 +16,8 @@ indent_size = 4 # Sort using and Import directives with System.* appearing first dotnet_sort_system_directives_first = true +dotnet_separate_import_directive_groups = false +csharp_using_directive_placement = inside_namespace:none # Always use "this." and "Me." when applicable; let StyleCop Analyzers provide the warning and fix dotnet_style_qualification_for_field = true:none diff --git a/.nuget/packages.config b/.nuget/packages.config index bc0964b13..d409bf15b 100644 --- a/.nuget/packages.config +++ b/.nuget/packages.config @@ -1,8 +1,7 @@  - - + - - + + \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c0c793e45..8917cb3a6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,6 +7,12 @@ for issues suitable if you are unfamiliar with roslyn. You can also help by filing issues, participating in discussions and doing code review. +## Building prerequisites + +* Visual Studio 2017 (Community Edition or higher) is required for building this repository. +* The version of the [.NET Core SDK](https://dotnet.microsoft.com/download/dotnet-core) as specified in the global.json file at the root of this repo. + Use the init script at the root of the repo to conveniently acquire and install the right version. + ## Implementing a diagnostic 1. To start working on a diagnostic, add a comment to the issue indicating you are working on implementing it. @@ -23,7 +29,3 @@ You can also help by filing issues, participating in discussions and doing code 2. A new issue was created for implementing tests for the item (e.g. #176). 3. Evidence was given that the feature is currently operational, and the code appears to be a solid starting point for other contributors to continue the implementation effort. - -## Building - -Visual Studio 2017 (Community Edition or higher) is required for building this repository. diff --git a/LICENSE b/LICENSE index d2ec097a3..5b50c0966 100644 --- a/LICENSE +++ b/LICENSE @@ -1,69 +1,21 @@ -Copyright (c) Tunnel Vision Laboratories, LLC. All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -these files except in compliance with the License. You may obtain a copy of the -License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software distributed -under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -CONDITIONS OF ANY KIND, either express or implied. See the License for the -specific language governing permissions and limitations under the License. - ---- - -This project uses other open source projects, which are used under the terms -of the following license(s). - -.NET Compiler Platform ("Roslyn") - - Copyright Microsoft. - - Licensed under the Apache License, Version 2.0 (the "License"); you may not use - these files except in compliance with the License. You may obtain a copy of the - License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software distributed - under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - CONDITIONS OF ANY KIND, either express or implied. See the License for the - specific language governing permissions and limitations under the License. - -Code Cracker - - Copyright 2014 Giovanni Bassi and Elemar Jr. - - Licensed under the Apache License, Version 2.0 (the "License"); you may not use - these files except in compliance with the License. You may obtain a copy of the - License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software distributed - under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - CONDITIONS OF ANY KIND, either express or implied. See the License for the - specific language governing permissions and limitations under the License. - -LightJson - - Copyright (c) 2017 Marcos López C. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. +MIT License + +Copyright (c) Tunnel Vision Laboratories, LLC + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/NuGet.config b/NuGet.config index 3b82964e7..e72a4de73 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,11 +1,13 @@  - - - + + + + + - + diff --git a/README.md b/README.md index e52299e24..b9a2ec69c 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,9 @@ Not all versions of StyleCop.Analyzers support all features of each C# language | C# version | StyleCop.Analyzers version | Visual Studio version | |------------|----------------------------|-----------------------| -| 1.0 - 6.0 | v1.0.2 or higher | VS2015+ | -| 7.0 - 7.3 | v1.1.0-beta or higher | VS2017 | +| 1.0 - 6.0 | v1.0.2 or higher | VS2015+ | +| 7.0 - 7.3 | v1.1.0-beta or higher | VS2017+ | +| 8.0 | v1.2.0-beta or higher | VS2019 | ## Installation diff --git a/StyleCop.Analyzers/Directory.Build.props b/StyleCop.Analyzers/Directory.Build.props index d0c608bd2..f3a08336b 100644 --- a/StyleCop.Analyzers/Directory.Build.props +++ b/StyleCop.Analyzers/Directory.Build.props @@ -10,8 +10,10 @@ - 7.2 - strict + 10 + enable + 99 + true @@ -20,7 +22,8 @@ - portable + full + portable true @@ -37,6 +40,10 @@ $(NoWarn),1573,1591,1712 + + 3.11.0-beta1.23472.1 + + @@ -44,7 +51,28 @@ - + + + + + + + + + + + + + + + + + + + + + + diff --git a/StyleCop.Analyzers/Directory.Build.targets b/StyleCop.Analyzers/Directory.Build.targets index 862c5c1c8..f3adcdfc6 100644 --- a/StyleCop.Analyzers/Directory.Build.targets +++ b/StyleCop.Analyzers/Directory.Build.targets @@ -1,21 +1,6 @@ - - - - - - - - - - - - - - - diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/FileHeaderCodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/FileHeaderCodeFixProvider.cs index 0b0386faf..5e076a3fc 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/FileHeaderCodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/FileHeaderCodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -66,6 +68,9 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context) return SpecializedTasks.CompletedTask; } + private static string GetFileName(Document document) + => Path.GetFileName(document.FilePath ?? document.Name); + private static async Task GetTransformedDocumentAsync(Document document, CancellationToken cancellationToken) { return document.WithSyntaxRoot(await GetTransformedSyntaxRootAsync(document, cancellationToken).ConfigureAwait(false)); @@ -74,13 +79,13 @@ private static async Task GetTransformedDocumentAsync(Document documen private static async Task GetTransformedSyntaxRootAsync(Document document, CancellationToken cancellationToken) { var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); - var settings = document.Project.AnalyzerOptions.GetStyleCopSettings(cancellationToken); + var settings = document.Project.AnalyzerOptions.GetStyleCopSettings(root.SyntaxTree, cancellationToken); var fileHeader = FileHeaderHelpers.ParseFileHeader(root); SyntaxNode newSyntaxRoot; if (fileHeader.IsMissing) { - newSyntaxRoot = AddHeader(document, root, document.Name, settings); + newSyntaxRoot = AddHeader(document, root, GetFileName(document), settings); } else { @@ -144,9 +149,9 @@ private static SyntaxNode ReplaceWellFormedMultiLineCommentHeader(Document docum // Pad line that used to be next to a /* triviaStringParts[0] = commentIndentation + interlinePadding + " " + triviaStringParts[0]; StringBuilder sb = StringBuilderPool.Allocate(); - string fileName = Path.GetFileName(document.FilePath); + string fileName = GetFileName(document); var copyrightText = GetCopyrightText(commentIndentation + interlinePadding, settings.DocumentationRules.GetCopyrightText(fileName), newLineText); - var newHeader = WrapInXmlComment(commentIndentation + interlinePadding, copyrightText, document.Name, settings, newLineText); + var newHeader = WrapInXmlComment(commentIndentation + interlinePadding, copyrightText, fileName, settings, newLineText); sb.Append(commentIndentation); sb.Append("/*"); @@ -310,13 +315,13 @@ private static SyntaxNode ReplaceHeader(Document document, SyntaxNode root, Styl string newLineText = document.Project.Solution.Workspace.Options.GetOption(FormattingOptions.NewLine, LanguageNames.CSharp); var newLineTrivia = SyntaxFactory.EndOfLine(newLineText); - var newHeaderTrivia = CreateNewHeader(leadingSpaces + "//", document.Name, settings, newLineText); + var newHeaderTrivia = CreateNewHeader(leadingSpaces + "//", GetFileName(document), settings, newLineText); if (!isMalformedHeader && copyrightTriviaIndex.HasValue) { // Does the copyright element have leading whitespace? If so remove it. if ((copyrightTriviaIndex.Value > 0) && trivia[copyrightTriviaIndex.Value - 1].IsKind(SyntaxKind.WhitespaceTrivia)) { - copyrightTriviaIndex = copyrightTriviaIndex - 1; + copyrightTriviaIndex--; trivia = trivia.RemoveAt(copyrightTriviaIndex.Value); } @@ -444,12 +449,12 @@ private static SyntaxTriviaList RemoveHeaderDecorationLines(SyntaxTriviaList tri for (int i = 0; i < trivia.Count; i++) { var triviaLine = trivia[i]; - if (triviaLine.Kind() == SyntaxKind.SingleLineCommentTrivia && triviaLine.ToFullString().Contains(settings.DocumentationRules.HeaderDecoration)) + if (triviaLine.IsKind(SyntaxKind.SingleLineCommentTrivia) && triviaLine.ToFullString().Contains(settings.DocumentationRules.HeaderDecoration)) { decorationRemovalList.Add(i); // also remove the line break - if (i + 1 < trivia.Count && trivia[i + 1].Kind() == SyntaxKind.EndOfLineTrivia) + if (i + 1 < trivia.Count && trivia[i + 1].IsKind(SyntaxKind.EndOfLineTrivia)) { decorationRemovalList.Add(i + 1); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/InheritdocCodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/InheritdocCodeFixProvider.cs index f5dd35aea..24ce9ac74 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/InheritdocCodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/InheritdocCodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -90,36 +92,36 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) context.RegisterCodeFix( CodeAction.Create( DocumentationResources.InheritdocCodeFix, - cancellationToken => GetTransformedDocumentAsync(context.Document, diagnostic, root, identifierToken, cancellationToken), + cancellationToken => GetTransformedDocumentAsync(context.Document, root, identifierToken, cancellationToken), nameof(InheritdocCodeFixProvider)), diagnostic); } } - private static async Task GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, SyntaxNode root, SyntaxToken identifierToken, CancellationToken cancellationToken) + private static async Task GetTransformedDocumentAsync(Document document, SyntaxNode root, SyntaxToken identifierToken, CancellationToken cancellationToken) { SemanticModel semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); switch (identifierToken.Parent.Kind()) { case SyntaxKind.PropertyDeclaration: case SyntaxKind.EventDeclaration: - return GetTransformedDocumentForBasePropertyDeclaration(document, diagnostic, root, semanticModel, (BasePropertyDeclarationSyntax)identifierToken.Parent, cancellationToken); + return GetTransformedDocumentForBasePropertyDeclaration(document, root, semanticModel, (BasePropertyDeclarationSyntax)identifierToken.Parent, cancellationToken); case SyntaxKind.MethodDeclaration: - return GetTransformedDocumentForMethodDeclaration(document, diagnostic, root, semanticModel, (MethodDeclarationSyntax)identifierToken.Parent, cancellationToken); + return GetTransformedDocumentForMethodDeclaration(document, root, semanticModel, (MethodDeclarationSyntax)identifierToken.Parent, cancellationToken); case SyntaxKind.VariableDeclarator: - return GetTransformedDocumentForEventFieldDeclaration(document, diagnostic, root, semanticModel, (EventFieldDeclarationSyntax)identifierToken.Parent.Parent.Parent, cancellationToken); + return GetTransformedDocumentForEventFieldDeclaration(document, root, semanticModel, (EventFieldDeclarationSyntax)identifierToken.Parent.Parent.Parent, cancellationToken); case SyntaxKind.IndexerDeclaration: - return GetTransformedDocumentForIndexerDeclaration(document, diagnostic, root, semanticModel, (IndexerDeclarationSyntax)identifierToken.Parent, cancellationToken); + return GetTransformedDocumentForIndexerDeclaration(document, root, semanticModel, (IndexerDeclarationSyntax)identifierToken.Parent, cancellationToken); default: return document; } } - private static Document GetTransformedDocumentForBasePropertyDeclaration(Document document, Diagnostic diagnostic, SyntaxNode root, SemanticModel semanticModel, BasePropertyDeclarationSyntax basePropertyDeclaration, CancellationToken cancellationToken) + private static Document GetTransformedDocumentForBasePropertyDeclaration(Document document, SyntaxNode root, SemanticModel semanticModel, BasePropertyDeclarationSyntax basePropertyDeclaration, CancellationToken cancellationToken) { if (basePropertyDeclaration.ExplicitInterfaceSpecifier == null && !basePropertyDeclaration.Modifiers.Any(SyntaxKind.OverrideKeyword)) { @@ -130,10 +132,10 @@ private static Document GetTransformedDocumentForBasePropertyDeclaration(Documen } } - return InsertInheritdocComment(document, diagnostic, root, basePropertyDeclaration, cancellationToken); + return InsertInheritdocComment(document, root, basePropertyDeclaration, cancellationToken); } - private static Document GetTransformedDocumentForMethodDeclaration(Document document, Diagnostic diagnostic, SyntaxNode root, SemanticModel semanticModel, MethodDeclarationSyntax methodDeclaration, CancellationToken cancellationToken) + private static Document GetTransformedDocumentForMethodDeclaration(Document document, SyntaxNode root, SemanticModel semanticModel, MethodDeclarationSyntax methodDeclaration, CancellationToken cancellationToken) { if (methodDeclaration.ExplicitInterfaceSpecifier == null && !methodDeclaration.Modifiers.Any(SyntaxKind.OverrideKeyword)) { @@ -144,10 +146,10 @@ private static Document GetTransformedDocumentForMethodDeclaration(Document docu } } - return InsertInheritdocComment(document, diagnostic, root, methodDeclaration, cancellationToken); + return InsertInheritdocComment(document, root, methodDeclaration, cancellationToken); } - private static Document GetTransformedDocumentForEventFieldDeclaration(Document document, Diagnostic diagnostic, SyntaxNode root, SemanticModel semanticModel, EventFieldDeclarationSyntax eventFieldDeclaration, CancellationToken cancellationToken) + private static Document GetTransformedDocumentForEventFieldDeclaration(Document document, SyntaxNode root, SemanticModel semanticModel, EventFieldDeclarationSyntax eventFieldDeclaration, CancellationToken cancellationToken) { if (!eventFieldDeclaration.Modifiers.Any(SyntaxKind.OverrideKeyword)) { @@ -164,10 +166,10 @@ private static Document GetTransformedDocumentForEventFieldDeclaration(Document } } - return InsertInheritdocComment(document, diagnostic, root, eventFieldDeclaration, cancellationToken); + return InsertInheritdocComment(document, root, eventFieldDeclaration, cancellationToken); } - private static Document GetTransformedDocumentForIndexerDeclaration(Document document, Diagnostic diagnostic, SyntaxNode root, SemanticModel semanticModel, IndexerDeclarationSyntax indexerDeclaration, CancellationToken cancellationToken) + private static Document GetTransformedDocumentForIndexerDeclaration(Document document, SyntaxNode root, SemanticModel semanticModel, IndexerDeclarationSyntax indexerDeclaration, CancellationToken cancellationToken) { if (indexerDeclaration.ExplicitInterfaceSpecifier == null && !indexerDeclaration.Modifiers.Any(SyntaxKind.OverrideKeyword)) { @@ -178,11 +180,14 @@ private static Document GetTransformedDocumentForIndexerDeclaration(Document doc } } - return InsertInheritdocComment(document, diagnostic, root, indexerDeclaration, cancellationToken); + return InsertInheritdocComment(document, root, indexerDeclaration, cancellationToken); } - private static Document InsertInheritdocComment(Document document, Diagnostic diagnostic, SyntaxNode root, SyntaxNode syntaxNode, CancellationToken cancellationToken) + private static Document InsertInheritdocComment(Document document, SyntaxNode root, SyntaxNode syntaxNode, CancellationToken cancellationToken) { + // Currently unused + _ = cancellationToken; + SyntaxTriviaList leadingTrivia = syntaxNode.GetLeadingTrivia(); int insertionIndex = leadingTrivia.Count; while (insertionIndex > 0 && !leadingTrivia[insertionIndex - 1].HasBuiltinEndLine()) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/PropertySummaryDocumentationCodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/PropertySummaryDocumentationCodeFixProvider.cs index 540b2c99c..bf6b4487c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/PropertySummaryDocumentationCodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/PropertySummaryDocumentationCodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -14,14 +16,13 @@ namespace StyleCop.Analyzers.DocumentationRules using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using StyleCop.Analyzers.Helpers; - using StyleCop.Analyzers.Helpers.ObjectPools; /// /// Implements the code fix for property summary documentation. /// [ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(PropertySummaryDocumentationCodeFixProvider))] [Shared] - public class PropertySummaryDocumentationCodeFixProvider : CodeFixProvider + internal class PropertySummaryDocumentationCodeFixProvider : CodeFixProvider { /// public override ImmutableArray FixableDiagnosticIds { get; } = @@ -62,7 +63,7 @@ private static async Task GetTransformedDocumentAsync(Document documen var documentation = node.GetDocumentationCommentTriviaSyntax(); var summaryElement = (XmlElementSyntax)documentation.Content.GetFirstXmlElement(XmlCommentHelper.SummaryXmlTag); - var textElement = (XmlTextSyntax)summaryElement.Content.FirstOrDefault(); + var textElement = XmlCommentHelper.TryGetFirstTextElementWithContent(summaryElement); if (textElement == null) { return document; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1600CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1600CodeFixProvider.cs index 04ec8da93..6480d6594 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1600CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1600CodeFixProvider.cs @@ -1,9 +1,10 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { - using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Composition; @@ -59,7 +60,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) context.RegisterCodeFix( CodeAction.Create( DocumentationResources.ConstructorDocumentationCodeFix, - cancellationToken => GetConstructorOrDestructorDocumentationTransformedDocumentAsync(context.Document, diagnostic, root, (BaseMethodDeclarationSyntax)identifierToken.Parent, cancellationToken), + cancellationToken => GetConstructorOrDestructorDocumentationTransformedDocumentAsync(context.Document, root, (BaseMethodDeclarationSyntax)identifierToken.Parent, cancellationToken), nameof(SA1600CodeFixProvider)), diagnostic); break; @@ -72,7 +73,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) context.RegisterCodeFix( CodeAction.Create( DocumentationResources.MethodDocumentationCodeFix, - cancellationToken => GetMethodDocumentationTransformedDocumentAsync(context.Document, diagnostic, root, semanticModel, (MethodDeclarationSyntax)identifierToken.Parent, cancellationToken), + cancellationToken => GetMethodDocumentationTransformedDocumentAsync(context.Document, root, semanticModel, (MethodDeclarationSyntax)identifierToken.Parent, cancellationToken), nameof(SA1600CodeFixProvider)), diagnostic); } @@ -98,7 +99,7 @@ private static bool IsCoveredByInheritDoc(SemanticModel semanticModel, MethodDec return (declaredSymbol != null) && NamedTypeHelpers.IsImplementingAnInterfaceMember(declaredSymbol); } - private static Task GetConstructorOrDestructorDocumentationTransformedDocumentAsync(Document document, Diagnostic diagnostic, SyntaxNode root, BaseMethodDeclarationSyntax declaration, CancellationToken cancellationToken) + private static Task GetConstructorOrDestructorDocumentationTransformedDocumentAsync(Document document, SyntaxNode root, BaseMethodDeclarationSyntax declaration, CancellationToken cancellationToken) { SyntaxTriviaList leadingTrivia = declaration.GetLeadingTrivia(); int insertionIndex = GetInsertionIndex(ref leadingTrivia); @@ -136,7 +137,7 @@ private static Task GetConstructorOrDestructorDocumentationTransformed return Task.FromResult(document.WithSyntaxRoot(root.ReplaceNode(declaration, newElement))); } - private static Task GetMethodDocumentationTransformedDocumentAsync(Document document, Diagnostic diagnostic, SyntaxNode root, SemanticModel semanticModel, MethodDeclarationSyntax methodDeclaration, CancellationToken cancellationToken) + private static Task GetMethodDocumentationTransformedDocumentAsync(Document document, SyntaxNode root, SemanticModel semanticModel, MethodDeclarationSyntax methodDeclaration, CancellationToken cancellationToken) { SyntaxTriviaList leadingTrivia = methodDeclaration.GetLeadingTrivia(); int insertionIndex = GetInsertionIndex(ref leadingTrivia); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1609SA1610CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1609SA1610CodeFixProvider.cs index 3a8c9e861..8082963b6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1609SA1610CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1609SA1610CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -174,7 +176,7 @@ private bool TryRemoveSummaryPrefix(ref SyntaxList summaryContent } // Find the token containing the prefix, such as "Gets or sets " - SyntaxToken prefixToken = default(SyntaxToken); + SyntaxToken prefixToken = default; foreach (SyntaxToken textToken in firstText.TextTokens) { if (textToken.IsMissing) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1615SA1616CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1615SA1616CodeFixProvider.cs index d7039072d..f3b40d918 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1615SA1616CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1615SA1616CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1617CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1617CodeFixProvider.cs index f8f77f933..75e76316c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1617CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1617CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1626CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1626CodeFixProvider.cs index 4c6c54893..189f05a3b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1626CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1626CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -53,7 +55,6 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context) private static async Task GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) { - var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); TextChange textChange = new TextChange(new TextSpan(diagnostic.Location.SourceSpan.Start, 1), string.Empty); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1629CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1629CodeFixProvider.cs index 432845636..223cc203e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1629CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1629CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -52,7 +54,8 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context) private static async Task GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) { var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); - var newText = text.WithChanges(new TextChange(new TextSpan(diagnostic.Location.SourceSpan.Start, 0), ".")); + bool replaceChar = diagnostic.Properties.ContainsKey(SA1629DocumentationTextMustEndWithAPeriod.ReplaceCharKey); + var newText = text.WithChanges(new TextChange(new TextSpan(diagnostic.Location.SourceSpan.Start, replaceChar ? 1 : 0), ".")); return document.WithText(newText); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1642SA1643CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1642SA1643CodeFixProvider.cs index 2dee644d6..716937ebd 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1642SA1643CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1642SA1643CodeFixProvider.cs @@ -1,12 +1,14 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { using System; using System.Collections.Immutable; using System.Composition; - using System.Globalization; + using System.Diagnostics; using System.Linq; using System.Text.RegularExpressions; using System.Threading; @@ -18,6 +20,7 @@ namespace StyleCop.Analyzers.DocumentationRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Formatting; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; /// /// Implements a code fix for @@ -81,9 +84,9 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) internal static ImmutableArray GenerateStandardText(Document document, BaseMethodDeclarationSyntax methodDeclaration, BaseTypeDeclarationSyntax typeDeclaration, CancellationToken cancellationToken) { - bool isStruct = typeDeclaration.IsKind(SyntaxKind.StructDeclaration); - var settings = document.Project.AnalyzerOptions.GetStyleCopSettings(cancellationToken); - var culture = new CultureInfo(settings.DocumentationRules.DocumentationCulture); + bool isStruct = typeDeclaration.IsKind(SyntaxKind.StructDeclaration) || typeDeclaration.IsKind(SyntaxKindEx.RecordStructDeclaration); + var settings = document.Project.AnalyzerOptions.GetStyleCopSettings(methodDeclaration.SyntaxTree, cancellationToken); + var culture = settings.DocumentationRules.DocumentationCultureInfo; var resourceManager = DocumentationResources.ResourceManager; if (methodDeclaration is ConstructorDeclarationSyntax) @@ -117,17 +120,19 @@ internal static ImmutableArray GenerateStandardText(Document document, B } } + internal static SyntaxList BuildStandardTextSyntaxList(BaseTypeDeclarationSyntax typeDeclaration, string preText, string postText) + { + TypeParameterListSyntax typeParameterList = GetTypeParameterList(typeDeclaration); + + return XmlSyntaxFactory.List( + XmlSyntaxFactory.Text(preText), + BuildSeeElement(typeDeclaration.Identifier, typeParameterList), + XmlSyntaxFactory.Text(postText.EndsWith(".") ? postText : (postText + "."))); + } + internal static SyntaxList BuildStandardTextSyntaxList(BaseTypeDeclarationSyntax typeDeclaration, string newLineText, string preText, string postText) { - TypeParameterListSyntax typeParameterList; - if (typeDeclaration is ClassDeclarationSyntax classDeclaration) - { - typeParameterList = classDeclaration.TypeParameterList; - } - else - { - typeParameterList = (typeDeclaration as StructDeclarationSyntax)?.TypeParameterList; - } + TypeParameterListSyntax typeParameterList = GetTypeParameterList(typeDeclaration); return XmlSyntaxFactory.List( XmlSyntaxFactory.NewLine(newLineText), @@ -136,6 +141,28 @@ internal static SyntaxList BuildStandardTextSyntaxList(BaseTypeDe XmlSyntaxFactory.Text(postText.EndsWith(".") ? postText : (postText + "."))); } + private static TypeParameterListSyntax GetTypeParameterList(BaseTypeDeclarationSyntax typeDeclaration) + { + if (typeDeclaration is ClassDeclarationSyntax classDeclaration) + { + return classDeclaration.TypeParameterList; + } + + if (typeDeclaration is StructDeclarationSyntax structDeclaration) + { + return structDeclaration.TypeParameterList; + } + + if (RecordDeclarationSyntaxWrapper.IsInstance(typeDeclaration)) + { + var recordDeclaration = (RecordDeclarationSyntaxWrapper)typeDeclaration; + return recordDeclaration.TypeParameterList; + } + + Debug.Assert(false, $"Unhandled type {typeDeclaration.Kind()}"); + return null; + } + private static Task GetTransformedDocumentAsync(Document document, SyntaxNode root, XmlElementSyntax node, CancellationToken cancellationToken) { var typeDeclaration = node.FirstAncestorOrSelf(); @@ -143,11 +170,9 @@ private static Task GetTransformedDocumentAsync(Document document, Syn var standardText = GenerateStandardText(document, declarationSyntax, typeDeclaration, cancellationToken); - string newLineText = document.Project.Solution.Workspace.Options.GetOption(FormattingOptions.NewLine, LanguageNames.CSharp); - string trailingString = string.Empty; - var newContent = RemoveMalformattedStandardText(node.Content, typeDeclaration.Identifier, standardText[0], standardText[1], ref trailingString); + var newContent = RemoveMalformattedStandardText(node.Content, standardText[0], standardText[1], ref trailingString); if (newContent.Count == 1 && newContent[0] is XmlTextSyntax xmlText) { @@ -157,7 +182,17 @@ private static Task GetTransformedDocumentAsync(Document document, Syn } } - var list = BuildStandardTextSyntaxList(typeDeclaration, newLineText, standardText[0], standardText[1] + trailingString); + SyntaxList list; + if (IsMultiLine(node)) + { + string newLineText = document.Project.Solution.Workspace.Options.GetOption(FormattingOptions.NewLine, LanguageNames.CSharp); + list = BuildStandardTextSyntaxList(typeDeclaration, newLineText, standardText[0], standardText[1] + trailingString); + } + else + { + list = BuildStandardTextSyntaxList(typeDeclaration, standardText[0], standardText[1] + trailingString); + } + newContent = newContent.InsertRange(0, list); newContent = RemoveTrailingEmptyLines(newContent); @@ -171,30 +206,23 @@ private static Task GetTransformedDocumentAsync(Document document, Syn return Task.FromResult(newDocument); } + private static bool IsMultiLine(XmlElementSyntax node) + { + var lineSpan = node.GetLineSpan(); + return lineSpan.StartLinePosition.Line != lineSpan.EndLinePosition.Line; + } + private static Task GetTransformedDocumentAsync(Document document, SyntaxNode root, XmlEmptyElementSyntax node) { var typeDeclaration = node.FirstAncestorOrSelf(); - var declarationSyntax = node.FirstAncestorOrSelf(); - bool isStruct = typeDeclaration.IsKind(SyntaxKind.StructDeclaration); - - TypeParameterListSyntax typeParameterList; - if (typeDeclaration is ClassDeclarationSyntax classDeclaration) - { - typeParameterList = classDeclaration.TypeParameterList; - } - else - { - typeParameterList = (typeDeclaration as StructDeclarationSyntax)?.TypeParameterList; - } + var typeParameterList = GetTypeParameterList(typeDeclaration); var newRoot = root.ReplaceNode(node, BuildSeeElement(typeDeclaration.Identifier, typeParameterList)); - var newDocument = document.WithSyntaxRoot(newRoot); - return Task.FromResult(newDocument); } - private static SyntaxList RemoveMalformattedStandardText(SyntaxList content, SyntaxToken identifier, string preText, string postText, ref string trailingString) + private static SyntaxList RemoveMalformattedStandardText(SyntaxList content, string preText, string postText, ref string trailingString) { var regex = new Regex(@"^\s*" + Regex.Escape(preText) + "[^ ]+" + Regex.Escape(postText)); var item = content.OfType().FirstOrDefault(); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1649CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1649CodeFixProvider.cs index 06b359353..09089b456 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1649CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1649CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1651CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1651CodeFixProvider.cs index e7eb36763..e30f77d8b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1651CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/DocumentationRules/SA1651CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/CustomBatchFixAllProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/CustomBatchFixAllProvider.cs index d074e6290..3fbc40e28 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/CustomBatchFixAllProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/CustomBatchFixAllProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/CustomFixAllProviders.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/CustomFixAllProviders.cs index f29941a21..e874b9349 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/CustomFixAllProviders.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/CustomFixAllProviders.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/DocumentBasedFixAllProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/DocumentBasedFixAllProvider.cs index d18f73751..af8cdd098 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/DocumentBasedFixAllProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/DocumentBasedFixAllProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/FixAllContextHelper.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/FixAllContextHelper.cs index bbc1799be..59c0db505 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/FixAllContextHelper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/FixAllContextHelper.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { @@ -12,7 +14,6 @@ namespace StyleCop.Analyzers.Helpers using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeFixes; - using Microsoft.CodeAnalysis.Diagnostics; internal static class FixAllContextHelper { @@ -56,7 +57,8 @@ public static async Task diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/IndentationHelper.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/IndentationHelper.cs index c8a22b318..5786af80f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/IndentationHelper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/IndentationHelper.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/QueryIndentationHelpers.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/QueryIndentationHelpers.cs index 48e468b61..d2c2cac69 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/QueryIndentationHelpers.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/QueryIndentationHelpers.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/RenameHelper.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/RenameHelper.cs index f5cc9adc0..c3cbdd62b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/RenameHelper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/RenameHelper.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { @@ -162,8 +164,7 @@ public static SyntaxNode GetParentDeclaration(SyntaxToken token) return parent; default: - var declarationParent = parent as MemberDeclarationSyntax; - if (declarationParent != null) + if (parent is MemberDeclarationSyntax declarationParent) { return declarationParent; } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/TaskHelper.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/TaskHelper.cs index 41d6d2f4e..26f9a851a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/TaskHelper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/TaskHelper.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1500CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1500CodeFixProvider.cs index 09bbb207e..b16c739be 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1500CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1500CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -16,6 +18,7 @@ namespace StyleCop.Analyzers.LayoutRules using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Text; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.Settings.ObjectModel; /// @@ -55,15 +58,15 @@ private static async Task GetTransformedDocumentAsync(Document documen { var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, cancellationToken); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, cancellationToken); var braceToken = syntaxRoot.FindToken(diagnostic.Location.SourceSpan.Start); - var tokenReplacements = GenerateBraceFixes(document, settings.Indentation, ImmutableArray.Create(braceToken)); + var tokenReplacements = GenerateBraceFixes(settings, ImmutableArray.Create(braceToken)); var newSyntaxRoot = syntaxRoot.ReplaceTokens(tokenReplacements.Keys, (originalToken, rewrittenToken) => tokenReplacements[originalToken]); return document.WithSyntaxRoot(newSyntaxRoot); } - private static Dictionary GenerateBraceFixes(Document document, IndentationSettings indentationSettings, ImmutableArray braceTokens) + private static Dictionary GenerateBraceFixes(StyleCopSettings settings, ImmutableArray braceTokens) { var tokenReplacements = new Dictionary(); @@ -72,7 +75,7 @@ private static Dictionary GenerateBraceFixes(Document var braceLine = LocationHelpers.GetLineSpan(braceToken).StartLinePosition.Line; var braceReplacementToken = braceToken; - var indentationSteps = DetermineIndentationSteps(indentationSettings, braceToken); + var indentationSteps = DetermineIndentationSteps(settings.Indentation, braceToken); var previousToken = braceToken.GetPreviousToken(); @@ -102,19 +105,23 @@ private static Dictionary GenerateBraceFixes(Document AddReplacement(tokenReplacements, previousToken, previousToken.WithTrailingTrivia(previousTokenNewTrailingTrivia)); } - braceReplacementToken = braceReplacementToken.WithLeadingTrivia(IndentationHelper.GenerateWhitespaceTrivia(indentationSettings, indentationSteps)); + braceReplacementToken = braceReplacementToken.WithLeadingTrivia(IndentationHelper.GenerateWhitespaceTrivia(settings.Indentation, indentationSteps)); } // Check if we need to apply a fix after the brace. No fix is needed when: // - The closing brace is followed by a semi-colon or closing paren // - The closing brace is the last token in the file + // - The closing brace is followed by the while expression of a do/while loop and the + // allowDoWhileOnClosingBrace setting is enabled. var nextToken = braceToken.GetNextToken(); var nextTokenLine = nextToken.IsKind(SyntaxKind.None) ? -1 : LocationHelpers.GetLineSpan(nextToken).StartLinePosition.Line; var isMultiDimensionArrayInitializer = braceToken.IsKind(SyntaxKind.OpenBraceToken) && braceToken.Parent.IsKind(SyntaxKind.ArrayInitializerExpression) && braceToken.Parent.Parent.IsKind(SyntaxKind.ArrayInitializerExpression); + var allowDoWhileOnClosingBrace = settings.LayoutRules.AllowDoWhileOnClosingBrace && nextToken.IsKind(SyntaxKind.WhileKeyword) && (braceToken.Parent?.IsKind(SyntaxKind.Block) ?? false) && (braceToken.Parent.Parent?.IsKind(SyntaxKind.DoStatement) ?? false); if ((nextTokenLine == braceLine) && (!braceToken.IsKind(SyntaxKind.CloseBraceToken) || !IsValidFollowingToken(nextToken)) && - !isMultiDimensionArrayInitializer) + !isMultiDimensionArrayInitializer && + !allowDoWhileOnClosingBrace) { var sharedTrivia = nextToken.LeadingTrivia.WithoutTrailingWhitespace(); var newTrailingTrivia = braceReplacementToken.TrailingTrivia @@ -135,7 +142,7 @@ private static Dictionary GenerateBraceFixes(Document newIndentationSteps = Math.Max(0, newIndentationSteps - 1); } - AddReplacement(tokenReplacements, nextToken, nextToken.WithLeadingTrivia(IndentationHelper.GenerateWhitespaceTrivia(indentationSettings, newIndentationSteps))); + AddReplacement(tokenReplacements, nextToken, nextToken.WithLeadingTrivia(IndentationHelper.GenerateWhitespaceTrivia(settings.Indentation, newIndentationSteps))); } braceReplacementToken = braceReplacementToken.WithTrailingTrivia(newTrailingTrivia); @@ -159,6 +166,7 @@ private static bool IsAccessorWithSingleLineBlock(SyntaxToken previousToken, Syn { case SyntaxKind.GetKeyword: case SyntaxKind.SetKeyword: + case SyntaxKindEx.InitKeyword: case SyntaxKind.AddKeyword: case SyntaxKind.RemoveKeyword: break; @@ -282,9 +290,9 @@ protected override async Task FixAllInDocumentAsync(FixAllContext fi .OrderBy(token => token.SpanStart) .ToImmutableArray(); - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, fixAllContext.CancellationToken); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, fixAllContext.CancellationToken); - var tokenReplacements = GenerateBraceFixes(document, settings.Indentation, tokens); + var tokenReplacements = GenerateBraceFixes(settings, tokens); return syntaxRoot.ReplaceTokens(tokenReplacements.Keys, (originalToken, rewrittenToken) => tokenReplacements[originalToken]); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1501CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1501CodeFixProvider.cs index 0df9b0182..592c958c5 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1501CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1501CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -58,7 +60,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context) private static async Task GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) { var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, cancellationToken); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, cancellationToken); if (!(syntaxRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true) is StatementSyntax statement)) { return document; @@ -301,8 +303,8 @@ protected override async Task FixAllInDocumentAsync(FixAllContext fi } var tokenReplaceMap = new Dictionary(); - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, fixAllContext.CancellationToken); SyntaxNode syntaxRoot = await document.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, fixAllContext.CancellationToken); foreach (var diagnostic in diagnostics.Sort(DiagnosticComparer.Instance)) { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1502CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1502CodeFixProvider.cs index feaaace70..f24bd818e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1502CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1502CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -53,7 +55,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context) private async Task GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) { var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, cancellationToken); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, cancellationToken); var newDocument = this.CreateCodeFix(document, settings.Indentation, diagnostic, syntaxRoot); return newDocument; @@ -69,6 +71,8 @@ private Document CreateCodeFix(Document document, IndentationSettings indentatio case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.StructDeclaration: + case SyntaxKindEx.RecordDeclaration: + case SyntaxKindEx.RecordStructDeclaration: case SyntaxKind.EnumDeclaration: newSyntaxRoot = this.RegisterBaseTypeDeclarationCodeFix(syntaxRoot, (BaseTypeDeclarationSyntax)node, indentationSettings); break; @@ -117,11 +121,6 @@ private SyntaxNode RegisterLocalFunctionStatementCodeFix(SyntaxNode syntaxRoot, return this.ReformatElement(syntaxRoot, node, node.Body.OpenBraceToken, node.Body.CloseBraceToken, indentationSettings); } - private SyntaxNode RegisterEnumDeclarationCodeFix(SyntaxNode syntaxRoot, EnumDeclarationSyntax node, IndentationSettings indentationSettings) - { - return this.ReformatElement(syntaxRoot, node, node.OpenBraceToken, node.CloseBraceToken, indentationSettings); - } - private SyntaxNode RegisterNamespaceDeclarationCodeFix(SyntaxNode syntaxRoot, NamespaceDeclarationSyntax node, IndentationSettings indentationSettings) { return this.ReformatElement(syntaxRoot, node, node.OpenBraceToken, node.CloseBraceToken, indentationSettings); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1503CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1503CodeFixProvider.cs index b6b8878aa..b28dc8323 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1503CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1503CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -64,6 +66,9 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) private static Task GetTransformedDocumentAsync(Document document, SyntaxNode root, StatementSyntax node, CancellationToken cancellationToken) { + // Currently unused + _ = cancellationToken; + var newSyntaxRoot = root.ReplaceNode(node, SyntaxFactory.Block(node)); return Task.FromResult(document.WithSyntaxRoot(newSyntaxRoot)); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1504CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1504CodeFixProvider.cs index ec12d3d41..51c7acb51 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1504CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1504CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -109,7 +111,7 @@ private static bool IsAllowedTrivia(SyntaxTrivia trivia) private static async Task GetTransformedDocumentForSingleLineAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) { var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, cancellationToken); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, cancellationToken); var node = syntaxRoot.FindNode(diagnostic.Location.SourceSpan); var accessorList = GetAccessorList(node); @@ -188,7 +190,7 @@ private static BlockSyntax ReformatBodyAsSingleLine(BlockSyntax body) private static async Task GetTransformedDocumentForMutipleLinesAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) { var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, cancellationToken); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, cancellationToken); var node = syntaxRoot.FindNode(diagnostic.Location.SourceSpan); var accessorList = GetAccessorList(node); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1505CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1505CodeFixProvider.cs index 0b0489a88..71f6082ea 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1505CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1505CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1506CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1506CodeFixProvider.cs index a4939ea23..259a1a401 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1506CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1506CodeFixProvider.cs @@ -1,10 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { using System.Collections.Immutable; using System.Composition; + using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; @@ -27,7 +30,7 @@ internal class SA1506CodeFixProvider : CodeFixProvider /// public override FixAllProvider GetFixAllProvider() { - return CustomFixAllProviders.BatchFixer; + return FixAll.Instance; } /// @@ -48,53 +51,72 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context) private static async Task GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) { - var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); + var newRoot = await GetTransformedDocumentAsync(document, ImmutableArray.Create(diagnostic), cancellationToken).ConfigureAwait(false); + return document.WithSyntaxRoot(newRoot); + } - var token = syntaxRoot.FindToken(diagnostic.Location.SourceSpan.Start); - var triviaList = token.LeadingTrivia; + private static async Task GetTransformedDocumentAsync(Document document, ImmutableArray diagnostics, CancellationToken cancellationToken) + { + var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); + return syntaxRoot.ReplaceTokens( + diagnostics.Select(diagnostic => syntaxRoot.FindToken(diagnostic.Location.SourceSpan.Start)), + (originalToken, rewrittenToken) => + { + var triviaList = rewrittenToken.LeadingTrivia; - var index = triviaList.IndexOf(SyntaxKind.SingleLineDocumentationCommentTrivia); + var index = triviaList.IndexOf(SyntaxKind.SingleLineDocumentationCommentTrivia); - int currentLineStart = index + 1; - bool onBlankLine = true; - for (int currentIndex = currentLineStart; currentIndex < triviaList.Count; currentIndex++) - { - switch (triviaList[currentIndex].Kind()) - { - case SyntaxKind.EndOfLineTrivia: - if (onBlankLine) - { - triviaList = triviaList.RemoveRange(currentLineStart, currentIndex - currentLineStart + 1); - currentIndex = currentLineStart - 1; - continue; - } - else + int currentLineStart = index + 1; + bool onBlankLine = true; + for (int currentIndex = currentLineStart; currentIndex < triviaList.Count; currentIndex++) { - currentLineStart = currentIndex + 1; - onBlankLine = true; - break; - } + switch (triviaList[currentIndex].Kind()) + { + case SyntaxKind.EndOfLineTrivia: + if (onBlankLine) + { + triviaList = triviaList.RemoveRange(currentLineStart, currentIndex - currentLineStart + 1); + currentIndex = currentLineStart - 1; + continue; + } + else + { + currentLineStart = currentIndex + 1; + onBlankLine = true; + break; + } - case SyntaxKind.WhitespaceTrivia: - break; + case SyntaxKind.WhitespaceTrivia: + break; - default: - if (triviaList[currentIndex].HasBuiltinEndLine()) - { - currentLineStart = currentIndex + 1; - onBlankLine = true; - break; + default: + if (triviaList[currentIndex].HasBuiltinEndLine()) + { + currentLineStart = currentIndex + 1; + onBlankLine = true; + break; + } + else + { + onBlankLine = false; + break; + } + } } - else - { - onBlankLine = false; - break; - } - } - } - var newSyntaxRoot = syntaxRoot.ReplaceToken(token, token.WithLeadingTrivia(triviaList)); - return document.WithSyntaxRoot(newSyntaxRoot); + return rewrittenToken.WithLeadingTrivia(triviaList); + }); + } + + private class FixAll : DocumentBasedFixAllProvider + { + public static FixAllProvider Instance { get; } = + new FixAll(); + + protected override string CodeActionTitle => LayoutResources.SA1506CodeFix; + + protected override async Task FixAllInDocumentAsync(FixAllContext fixAllContext, Document document, ImmutableArray diagnostics) + => await GetTransformedDocumentAsync(document, diagnostics, fixAllContext.CancellationToken).ConfigureAwait(false); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1507CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1507CodeFixProvider.cs index 7c892ef63..142faed69 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1507CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1507CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1508CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1508CodeFixProvider.cs index 771c5e653..81b56580d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1508CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1508CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1509CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1509CodeFixProvider.cs index 92cf21af6..26e937214 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1509CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1509CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -29,7 +31,7 @@ internal class SA1509CodeFixProvider : CodeFixProvider /// public override FixAllProvider GetFixAllProvider() { - return CustomFixAllProviders.BatchFixer; + return FixAll.Instance; } /// @@ -40,7 +42,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context) context.RegisterCodeFix( CodeAction.Create( LayoutResources.SA1509CodeFix, - token => this.GetTransformedDocumentAsync(context.Document, diagnostic, token), + token => GetTransformedDocumentAsync(context.Document, diagnostic, token), nameof(SA1509CodeFixProvider)), diagnostic); } @@ -48,25 +50,33 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context) return SpecializedTasks.CompletedTask; } - private async Task GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) + private static async Task GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) { - var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); - - var openBrace = syntaxRoot.FindToken(diagnostic.Location.SourceSpan.Start); - var leadingTrivia = openBrace.LeadingTrivia; + var newRoot = await GetTransformedDocumentAsync(document, ImmutableArray.Create(diagnostic), cancellationToken).ConfigureAwait(false); + return document.WithSyntaxRoot(newRoot); + } - var newTriviaList = SyntaxFactory.TriviaList(); + private static async Task GetTransformedDocumentAsync(Document document, ImmutableArray diagnostics, CancellationToken cancellationToken) + { + var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); + return syntaxRoot.ReplaceTokens( + diagnostics.Select(diagnostic => syntaxRoot.FindToken(diagnostic.Location.SourceSpan.Start)), + (originalToken, rewrittenToken) => + { + var openBrace = rewrittenToken; + var leadingTrivia = openBrace.LeadingTrivia; - var previousEmptyLines = this.GetPreviousEmptyLines(openBrace).ToList(); - newTriviaList = newTriviaList.AddRange(leadingTrivia.Except(previousEmptyLines)); + var newTriviaList = SyntaxFactory.TriviaList(); - var newOpenBrace = openBrace.WithLeadingTrivia(newTriviaList); - var newSyntaxRoot = syntaxRoot.ReplaceToken(openBrace, newOpenBrace); + var previousEmptyLines = GetPreviousEmptyLines(openBrace).ToList(); + newTriviaList = newTriviaList.AddRange(leadingTrivia.Except(previousEmptyLines)); - return document.WithSyntaxRoot(newSyntaxRoot); + var newOpenBrace = openBrace.WithLeadingTrivia(newTriviaList); + return newOpenBrace; + }); } - private IEnumerable GetPreviousEmptyLines(SyntaxToken openBrace) + private static IEnumerable GetPreviousEmptyLines(SyntaxToken openBrace) { var result = new List(); @@ -92,5 +102,16 @@ private IEnumerable GetPreviousEmptyLines(SyntaxToken openBrace) return result; } + + private class FixAll : DocumentBasedFixAllProvider + { + public static FixAllProvider Instance { get; } = + new FixAll(); + + protected override string CodeActionTitle => LayoutResources.SA1509CodeFix; + + protected override async Task FixAllInDocumentAsync(FixAllContext fixAllContext, Document document, ImmutableArray diagnostics) + => await GetTransformedDocumentAsync(document, diagnostics, fixAllContext.CancellationToken).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1510CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1510CodeFixProvider.cs index aa404b655..c265f1f63 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1510CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1510CodeFixProvider.cs @@ -1,10 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { using System.Collections.Immutable; using System.Composition; + using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; @@ -26,7 +29,7 @@ internal class SA1510CodeFixProvider : CodeFixProvider /// public override FixAllProvider GetFixAllProvider() { - return CustomFixAllProviders.BatchFixer; + return FixAll.Instance; } /// @@ -46,13 +49,31 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context) } private static async Task GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) + { + var newRoot = await GetTransformedDocumentAsync(document, ImmutableArray.Create(diagnostic), cancellationToken).ConfigureAwait(false); + return document.WithSyntaxRoot(newRoot); + } + + private static async Task GetTransformedDocumentAsync(Document document, ImmutableArray diagnostics, CancellationToken cancellationToken) { var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); + return syntaxRoot.ReplaceTokens( + diagnostics.Select(diagnostic => syntaxRoot.FindToken(diagnostic.Location.SourceSpan.Start)), + (originalToken, rewrittenToken) => + { + return rewrittenToken.WithoutLeadingBlankLines(); + }); + } + + private class FixAll : DocumentBasedFixAllProvider + { + public static FixAllProvider Instance { get; } = + new FixAll(); - var token = syntaxRoot.FindToken(diagnostic.Location.SourceSpan.Start); + protected override string CodeActionTitle => LayoutResources.SA1510CodeFix; - var newSyntaxRoot = syntaxRoot.ReplaceToken(token, token.WithoutLeadingBlankLines()); - return document.WithSyntaxRoot(newSyntaxRoot); + protected override async Task FixAllInDocumentAsync(FixAllContext fixAllContext, Document document, ImmutableArray diagnostics) + => await GetTransformedDocumentAsync(document, diagnostics, fixAllContext.CancellationToken).ConfigureAwait(false); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1511CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1511CodeFixProvider.cs index e3ab05c10..0a67ff2c7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1511CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1511CodeFixProvider.cs @@ -1,10 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { using System.Collections.Immutable; using System.Composition; + using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; @@ -26,7 +29,7 @@ internal class SA1511CodeFixProvider : CodeFixProvider /// public override FixAllProvider GetFixAllProvider() { - return CustomFixAllProviders.BatchFixer; + return FixAll.Instance; } /// @@ -46,13 +49,31 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context) } private static async Task GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) + { + var newRoot = await GetTransformedDocumentAsync(document, ImmutableArray.Create(diagnostic), cancellationToken).ConfigureAwait(false); + return document.WithSyntaxRoot(newRoot); + } + + private static async Task GetTransformedDocumentAsync(Document document, ImmutableArray diagnostics, CancellationToken cancellationToken) { var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); + return syntaxRoot.ReplaceTokens( + diagnostics.Select(diagnostic => syntaxRoot.FindToken(diagnostic.Location.SourceSpan.Start)), + (originalToken, rewrittenToken) => + { + return rewrittenToken.WithoutLeadingBlankLines(); + }); + } + + private class FixAll : DocumentBasedFixAllProvider + { + public static FixAllProvider Instance { get; } = + new FixAll(); - var whileToken = syntaxRoot.FindToken(diagnostic.Location.SourceSpan.Start); + protected override string CodeActionTitle => LayoutResources.SA1511CodeFix; - var newSyntaxRoot = syntaxRoot.ReplaceToken(whileToken, whileToken.WithoutLeadingBlankLines()); - return document.WithSyntaxRoot(newSyntaxRoot); + protected override async Task FixAllInDocumentAsync(FixAllContext fixAllContext, Document document, ImmutableArray diagnostics) + => await GetTransformedDocumentAsync(document, diagnostics, fixAllContext.CancellationToken).ConfigureAwait(false); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1512CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1512CodeFixProvider.cs index 4737a3ce1..edbcea566 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1512CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1512CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1513CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1513CodeFixProvider.cs index 80e81fd91..bea1d10e9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1513CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1513CodeFixProvider.cs @@ -1,10 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { using System.Collections.Immutable; using System.Composition; + using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; @@ -30,7 +33,7 @@ internal class SA1513CodeFixProvider : CodeFixProvider /// public override FixAllProvider GetFixAllProvider() { - return CustomFixAllProviders.BatchFixer; + return FixAll.Instance; } /// @@ -51,15 +54,32 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context) private static async Task GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) { - var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); - var token = syntaxRoot.FindToken(diagnostic.Location.SourceSpan.End); + var newRoot = await GetTransformedDocumentAsync(document, ImmutableArray.Create(diagnostic), cancellationToken).ConfigureAwait(false); + return document.WithSyntaxRoot(newRoot); + } + + private static async Task GetTransformedDocumentAsync(Document document, ImmutableArray diagnostics, CancellationToken cancellationToken) + { + var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); + return root.ReplaceTokens( + diagnostics.Select(diagnostic => root.FindToken(diagnostic.Location.SourceSpan.End)), + (originalToken, rewrittenToken) => + { + var endOfLineTrivia = rewrittenToken.GetPrecedingEndOfLineTrivia(); + var newTrivia = rewrittenToken.LeadingTrivia.Insert(0, endOfLineTrivia); + return rewrittenToken.WithLeadingTrivia(newTrivia); + }); + } + + private class FixAll : DocumentBasedFixAllProvider + { + public static FixAllProvider Instance { get; } = + new FixAll(); - var newTrivia = token.LeadingTrivia.Insert(0, SyntaxFactory.CarriageReturnLineFeed); - var newToken = token.WithLeadingTrivia(newTrivia); - var newSyntaxRoot = syntaxRoot.ReplaceToken(token, newToken); - var newDocument = document.WithSyntaxRoot(newSyntaxRoot); + protected override string CodeActionTitle => LayoutResources.SA1513CodeFix; - return newDocument; + protected override async Task FixAllInDocumentAsync(FixAllContext fixAllContext, Document document, ImmutableArray diagnostics) + => await GetTransformedDocumentAsync(document, diagnostics, fixAllContext.CancellationToken).ConfigureAwait(false); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1514CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1514CodeFixProvider.cs index a50f9c3e8..80d604ffe 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1514CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1514CodeFixProvider.cs @@ -1,10 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { using System.Collections.Immutable; using System.Composition; + using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; @@ -27,7 +30,7 @@ internal class SA1514CodeFixProvider : CodeFixProvider /// public override FixAllProvider GetFixAllProvider() { - return CustomFixAllProviders.BatchFixer; + return FixAll.Instance; } /// @@ -47,23 +50,44 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context) } private static async Task GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) + { + var newRoot = await GetTransformedDocumentAsync(document, ImmutableArray.Create(diagnostic), cancellationToken).ConfigureAwait(false); + return document.WithSyntaxRoot(newRoot); + } + + private static async Task GetTransformedDocumentAsync(Document document, ImmutableArray diagnostics, CancellationToken cancellationToken) { var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); - var documentationHeader = syntaxRoot.FindTrivia(diagnostic.Location.SourceSpan.Start); - var triviaList = documentationHeader.Token.LeadingTrivia; - var documentationHeaderIndex = triviaList.IndexOf(documentationHeader); + var documentationHeaders = diagnostics.Select(diagnostic => syntaxRoot.FindTrivia(diagnostic.Location.SourceSpan.Start)).ToArray(); + return syntaxRoot.ReplaceTokens( + documentationHeaders.Select(header => header.Token), + (originalToken, rewrittenToken) => + { + var triviaList = rewrittenToken.LeadingTrivia; + var documentationHeaderIndex = originalToken.LeadingTrivia.IndexOf(originalToken.LeadingTrivia.First(documentationHeaders.Contains)); - // Keep any leading whitespace with the documentation header - var index = documentationHeaderIndex - 1; - while ((index >= 0) && triviaList[index].IsKind(SyntaxKind.WhitespaceTrivia)) - { - index--; - } + // Keep any leading whitespace with the documentation header + var index = documentationHeaderIndex - 1; + while ((index >= 0) && triviaList[index].IsKind(SyntaxKind.WhitespaceTrivia)) + { + index--; + } + + var newLeadingTrivia = rewrittenToken.LeadingTrivia.Insert(index + 1, SyntaxFactory.CarriageReturnLineFeed); + return rewrittenToken.WithLeadingTrivia(newLeadingTrivia); + }); + } + + private class FixAll : DocumentBasedFixAllProvider + { + public static FixAllProvider Instance { get; } = + new FixAll(); + + protected override string CodeActionTitle => LayoutResources.SA1514CodeFix; - var newLeadingTrivia = documentationHeader.Token.LeadingTrivia.Insert(index + 1, SyntaxFactory.CarriageReturnLineFeed); - var newSyntaxRoot = syntaxRoot.ReplaceToken(documentationHeader.Token, documentationHeader.Token.WithLeadingTrivia(newLeadingTrivia)); - return document.WithSyntaxRoot(newSyntaxRoot); + protected override async Task FixAllInDocumentAsync(FixAllContext fixAllContext, Document document, ImmutableArray diagnostics) + => await GetTransformedDocumentAsync(document, diagnostics, fixAllContext.CancellationToken).ConfigureAwait(false); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1515CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1515CodeFixProvider.cs index 633dee914..d4d914a32 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1515CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1515CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1516CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1516CodeFixProvider.cs index bb87c6d4e..b8d7940fa 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1516CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1516CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -78,6 +80,9 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) private static Task GetTransformedDocumentAsync(Document document, SyntaxNode syntaxRoot, Diagnostic diagnostic, bool insertBlankLine, CancellationToken cancellationToken) { + // Currently unused + _ = cancellationToken; + var node = syntaxRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true); node = GetRelevantNode(node); @@ -142,6 +147,16 @@ private static SyntaxNode GetRelevantNode(SyntaxNode innerNode) return currentNode; } + if (currentNode is AttributeListSyntax) + { + return currentNode; + } + + if (currentNode is ExternAliasDirectiveSyntax) + { + return currentNode; + } + currentNode = currentNode.Parent; } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1517CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1517CodeFixProvider.cs index c53240cce..9f13ba80c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1517CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1517CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1518CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1518CodeFixProvider.cs index 59f3d40f7..6ad31f1db 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1518CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/LayoutRules/SA1518CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -32,9 +34,10 @@ public override FixAllProvider GetFixAllProvider() } /// - public override Task RegisterCodeFixesAsync(CodeFixContext context) + public override async Task RegisterCodeFixesAsync(CodeFixContext context) { - var settings = SettingsHelper.GetStyleCopSettings(context.Document.Project.AnalyzerOptions, context.CancellationToken); + var syntaxTree = await context.Document.GetSyntaxTreeAsync(context.CancellationToken).ConfigureAwait(false); + var settings = SettingsHelper.GetStyleCopSettings(context.Document.Project.AnalyzerOptions, syntaxTree, context.CancellationToken); foreach (var diagnostic in context.Diagnostics) { context.RegisterCodeFix( @@ -44,8 +47,6 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context) nameof(SA1518CodeFixProvider)), diagnostic); } - - return SpecializedTasks.CompletedTask; } /// @@ -78,7 +79,8 @@ protected override async Task FixAllInDocumentAsync(FixAllContext fi return null; } - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, fixAllContext.CancellationToken); + var syntaxTree = await document.GetSyntaxTreeAsync(fixAllContext.CancellationToken).ConfigureAwait(false); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxTree, fixAllContext.CancellationToken); Document updatedDocument = await FixEndOfFileAsync(document, diagnostics[0], settings.LayoutRules.NewlineAtEndOfFile, fixAllContext.CancellationToken).ConfigureAwait(false); return await updatedDocument.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1119CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1119CodeFixProvider.cs index f5959c1a0..0c2034f1c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1119CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1119CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { @@ -74,7 +76,8 @@ private static SyntaxNode GetReplacement(ParenthesizedExpressionSyntax oldNode) if (!leadingTrivia.Any()) { var previousToken = oldNode.OpenParenToken.GetPreviousToken(); - if (TriviaHelper.IndexOfTrailingWhitespace(previousToken.TrailingTrivia) == -1) + if (!(previousToken.IsKind(SyntaxKind.OpenParenToken) || previousToken.IsKind(SyntaxKind.CloseParenToken)) + && (TriviaHelper.IndexOfTrailingWhitespace(previousToken.TrailingTrivia) == -1)) { leadingTrivia = SyntaxFactory.TriviaList(SyntaxFactory.Space); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1400CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1400CodeFixProvider.cs index b09b6561e..eb895617d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1400CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1400CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { @@ -13,6 +15,7 @@ namespace StyleCop.Analyzers.MaintainabilityRules using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; /// /// Implements a code fix for . @@ -82,6 +85,11 @@ private static Task GetTransformedDocumentAsync(Document document, Syn updatedDeclarationNode = HandleStructDeclaration((StructDeclarationSyntax)declarationNode); break; + case SyntaxKindEx.RecordDeclaration: + case SyntaxKindEx.RecordStructDeclaration: + updatedDeclarationNode = HandleRecordDeclaration((RecordDeclarationSyntaxWrapper)declarationNode); + break; + case SyntaxKind.DelegateDeclaration: updatedDeclarationNode = HandleDelegateDeclaration((DelegateDeclarationSyntax)declarationNode); break; @@ -194,6 +202,23 @@ private static SyntaxNode HandleStructDeclaration(StructDeclarationSyntax node) .WithoutFormatting(); } + private static SyntaxNode HandleRecordDeclaration(RecordDeclarationSyntaxWrapper node) + { + SyntaxToken triviaToken = node.Keyword; + if (triviaToken.IsMissing) + { + return null; + } + + SyntaxKind defaultVisibility = IsNestedType(node) ? SyntaxKind.PrivateKeyword : SyntaxKind.InternalKeyword; + SyntaxTokenList modifiers = DeclarationModifiersHelper.AddModifier(node.Modifiers, ref triviaToken, defaultVisibility); + return node + .WithKeyword(triviaToken) + .WithModifiers(modifiers) + .SyntaxNode + .WithoutFormatting(); + } + private static SyntaxNode HandleDelegateDeclaration(DelegateDeclarationSyntax node) { SyntaxToken triviaToken = node.DelegateKeyword; @@ -355,6 +380,8 @@ private static SyntaxNode FindParentDeclarationNode(SyntaxNode node) case SyntaxKind.InterfaceDeclaration: case SyntaxKind.EnumDeclaration: case SyntaxKind.StructDeclaration: + case SyntaxKindEx.RecordDeclaration: + case SyntaxKindEx.RecordStructDeclaration: case SyntaxKind.DelegateDeclaration: case SyntaxKind.EventDeclaration: case SyntaxKind.EventFieldDeclaration: diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1402CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1402CodeFixProvider.cs index 9eb16a898..2f1d0740e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1402CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1402CodeFixProvider.cs @@ -1,8 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { + using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Composition; @@ -14,6 +17,7 @@ namespace StyleCop.Analyzers.MaintainabilityRules using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; /// /// Implements a code fix for . @@ -64,7 +68,7 @@ private static async Task GetTransformedSolutionAsync(Document documen DocumentId extractedDocumentId = DocumentId.CreateNewId(document.Project.Id); string suffix; FileNameHelpers.GetFileNameAndSuffix(document.Name, out suffix); - var settings = document.Project.AnalyzerOptions.GetStyleCopSettings(cancellationToken); + var settings = document.Project.AnalyzerOptions.GetStyleCopSettings(root.SyntaxTree, cancellationToken); string extractedDocumentName = FileNameHelpers.GetConventionalFileName(memberDeclarationSyntax, settings.DocumentationRules.FileNamingConvention) + suffix; List nodesToRemoveFromExtracted = new List(); @@ -86,9 +90,15 @@ private static async Task GetTransformedSolutionAsync(Document documen case SyntaxKind.InterfaceDeclaration: case SyntaxKind.EnumDeclaration: case SyntaxKind.DelegateDeclaration: + case SyntaxKindEx.RecordDeclaration: + case SyntaxKindEx.RecordStructDeclaration: nodesToRemoveFromExtracted.Add(child); break; + case SyntaxKindEx.FileScopedNamespaceDeclaration: + // Only one file-scoped namespace is allowed per syntax tree + throw new InvalidOperationException("This location is not reachable"); + default: break; } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1404CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1404CodeFixProvider.cs index 1b85242ad..eda639640 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1404CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1404CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { @@ -50,7 +52,8 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) CodeAction.Create( MaintainabilityResources.SA1404CodeFix, token => AddJustificationToAttributeAsync(context.Document, root, attribute), - nameof(SA1404CodeFixProvider) + "-Add"), diagnostic); + nameof(SA1404CodeFixProvider) + "-Add"), + diagnostic); return; } @@ -60,7 +63,8 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) CodeAction.Create( MaintainabilityResources.SA1404CodeFix, token => UpdateValueOfArgumentAsync(context.Document, root, argument), - nameof(SA1404CodeFixProvider) + "-Update"), diagnostic); + nameof(SA1404CodeFixProvider) + "-Update"), + diagnostic); return; } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1407SA1408CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1407SA1408CodeFixProvider.cs index 508be3b72..f4dd7a710 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1407SA1408CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1407SA1408CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1407SA1408FixAllProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1407SA1408FixAllProvider.cs index 816d1923b..79a549386 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1407SA1408FixAllProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1407SA1408FixAllProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { @@ -37,14 +39,14 @@ protected override async Task FixAllInDocumentAsync(FixAllContext fi nodes.Add(node); } - return root.ReplaceNodes(nodes, (originalNode, rewrittenNode) => AddParentheses(originalNode, rewrittenNode)); + return root.ReplaceNodes(nodes, (originalNode, rewrittenNode) => AddParentheses(rewrittenNode)); } - private static SyntaxNode AddParentheses(SyntaxNode originalNode, SyntaxNode rewrittenNode) + private static SyntaxNode AddParentheses(SyntaxNode node) { - if (!(rewrittenNode is BinaryExpressionSyntax syntax)) + if (!(node is BinaryExpressionSyntax syntax)) { - return rewrittenNode; + return node; } BinaryExpressionSyntax trimmedSyntax = syntax.WithoutTrivia(); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1410SA1411CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1410SA1411CodeFixProvider.cs index 5d4581233..44baa92dd 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1410SA1411CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1410SA1411CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1412CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1412CodeFixProvider.cs index 2b63d8a02..e27a9499c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1412CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1412CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1412FixAllProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1412FixAllProvider.cs index 1383aab17..7acba25b7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1412FixAllProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1412FixAllProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1413CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1413CodeFixProvider.cs index d77894a99..c1bafdacf 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1413CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/MaintainabilityRules/SA1413CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/RenameToLowerCaseCodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/RenameToLowerCaseCodeFixProvider.cs index ce4b87bf3..8356c0a84 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/RenameToLowerCaseCodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/RenameToLowerCaseCodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/RenameToUpperCaseCodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/RenameToUpperCaseCodeFixProvider.cs index 64da69570..e7581fc74 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/RenameToUpperCaseCodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/RenameToUpperCaseCodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { @@ -14,6 +16,7 @@ namespace StyleCop.Analyzers.NamingRules using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; /// /// Implements a code fix for all analyzers that require a symbol to be upper case. @@ -56,14 +59,20 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) { var token = root.FindToken(diagnostic.Location.SourceSpan.Start); var tokenText = token.ValueText.TrimStart('_'); + if (tokenText == string.Empty) + { + // Skip this one, since we can't create a new identifier from this + continue; + } + var baseName = char.ToUpper(tokenText[0]) + tokenText.Substring(1); var newName = baseName; var memberSyntax = RenameHelper.GetParentDeclaration(token); - if (memberSyntax is NamespaceDeclarationSyntax) + if (BaseNamespaceDeclarationSyntaxWrapper.IsInstance(memberSyntax)) { // namespaces are not symbols. So we are just renaming the namespace - Func> renameNamespace = cancellationToken => + Task RenameNamespace(CancellationToken cancellationToken) { IdentifierNameSyntax identifierSyntax = (IdentifierNameSyntax)token.Parent; @@ -71,12 +80,12 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) var newRoot = root.ReplaceNode(identifierSyntax, newIdentifierSyntax); return Task.FromResult(context.Document.WithSyntaxRoot(newRoot)); - }; + } context.RegisterCodeFix( CodeAction.Create( string.Format(NamingResources.RenameToCodeFix, newName), - renameNamespace, + (Func>)RenameNamespace, nameof(RenameToUpperCaseCodeFixProvider) + "_" + diagnostic.Id), diagnostic); } @@ -96,7 +105,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) && !await RenameHelper.IsValidNewMemberNameAsync(semanticModel, declaredSymbol, newName, context.CancellationToken).ConfigureAwait(false)) { usedSuffix = true; - newName = newName + Suffix; + newName += Suffix; } int index = 0; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1302CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1302CodeFixProvider.cs index bb8851555..e5cbfe84b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1302CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1302CodeFixProvider.cs @@ -1,11 +1,12 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { using System.Collections.Immutable; using System.Composition; - using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; @@ -28,6 +29,13 @@ internal class SA1302CodeFixProvider : CodeFixProvider public override ImmutableArray FixableDiagnosticIds { get; } = ImmutableArray.Create(SA1302InterfaceNamesMustBeginWithI.DiagnosticId); + /// + public override FixAllProvider GetFixAllProvider() + { + // Fix All is not yet supported + return null; + } + /// public override Task RegisterCodeFixesAsync(CodeFixContext context) { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1308CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1308CodeFixProvider.cs index bbb090443..8b1992b4e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1308CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1308CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1309CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1309CodeFixProvider.cs index d25a67ba7..834134dfc 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1309CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1309CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1310CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1310CodeFixProvider.cs index 64c32a6e7..f22d8a6ee 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1310CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1310CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1314CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1314CodeFixProvider.cs index db5f324c7..63c2fa507 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1314CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1314CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { @@ -26,6 +28,13 @@ internal class SA1314CodeFixProvider : CodeFixProvider public override ImmutableArray FixableDiagnosticIds { get; } = ImmutableArray.Create(SA1314TypeParameterNamesMustBeginWithT.DiagnosticId); + /// + public override FixAllProvider GetFixAllProvider() + { + // Fix All is not yet supported + return null; + } + /// public override Task RegisterCodeFixesAsync(CodeFixContext context) { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1316CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1316CodeFixProvider.cs new file mode 100644 index 000000000..b6377ef4a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SA1316CodeFixProvider.cs @@ -0,0 +1,65 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.NamingRules +{ + using System.Collections.Immutable; + using System.Composition; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CodeActions; + using Microsoft.CodeAnalysis.CodeFixes; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Helpers; + + /// + /// Implements a code fix for . + /// + [ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(SA1316CodeFixProvider))] + [Shared] + internal class SA1316CodeFixProvider : CodeFixProvider + { + /// + public override ImmutableArray FixableDiagnosticIds { get; } = + ImmutableArray.Create(SA1316TupleElementNamesShouldUseCorrectCasing.DiagnosticId); + + /// + public override FixAllProvider GetFixAllProvider() + { + // Fix All is not yet supported + return null; + } + + /// + public override Task RegisterCodeFixesAsync(CodeFixContext context) + { + foreach (var diagnostic in context.Diagnostics) + { + if (diagnostic.Properties.TryGetValue(SA1316TupleElementNamesShouldUseCorrectCasing.ExpectedTupleElementNameKey, out string fixedTupleElementName)) + { + context.RegisterCodeFix( + CodeAction.Create( + NamingResources.SA1316CodeFix, + cancellationToken => GetTransformedDocumentAsync(context.Document, diagnostic, fixedTupleElementName, cancellationToken), + nameof(SA1316CodeFixProvider)), + diagnostic); + } + } + + return SpecializedTasks.CompletedTask; + } + + private static async Task GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, string fixedTupleElementName, CancellationToken cancellationToken) + { + var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); + + var identifierToken = syntaxRoot.FindToken(diagnostic.Location.SourceSpan.Start); + + var newSyntaxRoot = syntaxRoot.ReplaceToken(identifierToken, SyntaxFactory.Identifier(fixedTupleElementName).WithTriviaFrom(identifierToken)); + return document.WithSyntaxRoot(newSyntaxRoot); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SX1309CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SX1309CodeFixProvider.cs index 97b2f4445..8e0563f3b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SX1309CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/NamingRules/SX1309CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/ElementOrderCodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/ElementOrderCodeFixProvider.cs index f1285613b..808f1bd2a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/ElementOrderCodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/ElementOrderCodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { @@ -15,6 +17,7 @@ namespace StyleCop.Analyzers.OrderingRules using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.Settings.ObjectModel; /// @@ -57,9 +60,9 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context) private static async Task GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) { - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, cancellationToken); - var elementOrder = settings.OrderingRules.ElementOrder; var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, cancellationToken); + var elementOrder = settings.OrderingRules.ElementOrder; var memberDeclaration = syntaxRoot.FindNode(diagnostic.Location.SourceSpan).FirstAncestorOrSelf(); if (memberDeclaration == null) @@ -82,9 +85,9 @@ private static SyntaxNode UpdateSyntaxRoot(MemberDeclarationSyntax memberDeclara return HandleTypeDeclaration(memberToMove, (TypeDeclarationSyntax)parentDeclaration, elementOrder, syntaxRoot, indentationSettings); } - if (parentDeclaration is NamespaceDeclarationSyntax) + if (BaseNamespaceDeclarationSyntaxWrapper.IsInstance(parentDeclaration)) { - return HandleNamespaceDeclaration(memberToMove, (NamespaceDeclarationSyntax)parentDeclaration, elementOrder, syntaxRoot, indentationSettings); + return HandleBaseNamespaceDeclaration(memberToMove, (BaseNamespaceDeclarationSyntaxWrapper)parentDeclaration, elementOrder, syntaxRoot, indentationSettings); } if (parentDeclaration is CompilationUnitSyntax) @@ -105,7 +108,7 @@ private static SyntaxNode HandleCompilationUnitDeclaration(MemberOrderHelper mem return OrderMember(memberOrder, compilationUnitDeclaration.Members, elementOrder, syntaxRoot, indentationSettings); } - private static SyntaxNode HandleNamespaceDeclaration(MemberOrderHelper memberOrder, NamespaceDeclarationSyntax namespaceDeclaration, ImmutableArray elementOrder, SyntaxNode syntaxRoot, IndentationSettings indentationSettings) + private static SyntaxNode HandleBaseNamespaceDeclaration(MemberOrderHelper memberOrder, BaseNamespaceDeclarationSyntaxWrapper namespaceDeclaration, ImmutableArray elementOrder, SyntaxNode syntaxRoot, IndentationSettings indentationSettings) { return OrderMember(memberOrder, namespaceDeclaration.Members, elementOrder, syntaxRoot, indentationSettings); } @@ -113,7 +116,7 @@ private static SyntaxNode HandleNamespaceDeclaration(MemberOrderHelper memberOrd private static SyntaxNode OrderMember(MemberOrderHelper memberOrder, SyntaxList members, ImmutableArray elementOrder, SyntaxNode syntaxRoot, IndentationSettings indentationSettings) { var memberIndex = members.IndexOf(memberOrder.Member); - MemberOrderHelper target = default(MemberOrderHelper); + MemberOrderHelper target = default; for (var i = memberIndex - 1; i >= 0; --i) { @@ -263,9 +266,9 @@ protected override async Task FixAllInDocumentAsync(FixAllContext fi return null; } - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, fixAllContext.CancellationToken); + var syntaxRoot = await document.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, fixAllContext.CancellationToken); var elementOrder = settings.OrderingRules.ElementOrder; - var syntaxRoot = await document.GetSyntaxRootAsync().ConfigureAwait(false); var trackedDiagnosticMembers = new List(); foreach (var diagnostic in diagnostics) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/SA1205CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/SA1205CodeFixProvider.cs index 094811b21..f58727a68 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/SA1205CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/SA1205CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { @@ -13,6 +15,7 @@ namespace StyleCop.Analyzers.OrderingRules using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; /// /// Implements code fixes for . @@ -25,6 +28,7 @@ internal class SA1205CodeFixProvider : CodeFixProvider private static readonly ImmutableArray InternalAccessibilityKeywords = ImmutableArray.Create(SyntaxKind.InternalKeyword); private static readonly ImmutableArray ProtectedAccessibilityKeywords = ImmutableArray.Create(SyntaxKind.ProtectedKeyword); private static readonly ImmutableArray ProtectedOrInternalAccessibilityKeywords = ImmutableArray.Create(SyntaxKind.ProtectedKeyword, SyntaxKind.InternalKeyword); + private static readonly ImmutableArray ProtectedAndInternalAccessibilityKeywords = ImmutableArray.Create(SyntaxKind.PrivateKeyword, SyntaxKind.ProtectedKeyword); private static readonly ImmutableArray PrivateAccessibilityKeywords = ImmutableArray.Create(SyntaxKind.PrivateKeyword); private static readonly ImmutableArray UnexpectedAccessibilityKeywords = ImmutableArray.Create(); @@ -88,6 +92,8 @@ private static ImmutableArray GetMissingAccessModifiers(Accessibilit return ProtectedAccessibilityKeywords; case Accessibility.ProtectedOrInternal: return ProtectedOrInternalAccessibilityKeywords; + case Accessibility.ProtectedAndInternal: + return ProtectedAndInternalAccessibilityKeywords; case Accessibility.Private: return PrivateAccessibilityKeywords; default: @@ -108,6 +114,9 @@ private static TypeDeclarationSyntax ReplaceModifiers(TypeDeclarationSyntax node return ((InterfaceDeclarationSyntax)node).WithModifiers(modifiers); case SyntaxKind.StructDeclaration: return ((StructDeclarationSyntax)node).WithModifiers(modifiers); + case SyntaxKindEx.RecordDeclaration: + case SyntaxKindEx.RecordStructDeclaration: + return ((RecordDeclarationSyntaxWrapper)node).WithModifiers(modifiers); } return node; @@ -125,6 +134,9 @@ private static TypeDeclarationSyntax ReplaceKeyword(TypeDeclarationSyntax node, return ((InterfaceDeclarationSyntax)node).WithKeyword(keyword); case SyntaxKind.StructDeclaration: return ((StructDeclarationSyntax)node).WithKeyword(keyword); + case SyntaxKindEx.RecordDeclaration: + case SyntaxKindEx.RecordStructDeclaration: + return ((RecordDeclarationSyntaxWrapper)node).WithKeyword(keyword); } return node; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/SA1206CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/SA1206CodeFixProvider.cs index 04b749dd1..e3a9a2b8c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/SA1206CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/SA1206CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { @@ -95,7 +97,8 @@ private static SyntaxTokenList FullySortModifiers(SyntaxTokenList modifiers) return AdjustTrivia( accessModifiers .Concat(staticModifiers) - .Concat(otherModifiers), modifiers); + .Concat(otherModifiers), + modifiers); } /// diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/SA1207CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/SA1207CodeFixProvider.cs index 9e0a427e7..9f01e64a0 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/SA1207CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/SA1207CodeFixProvider.cs @@ -1,10 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { using System.Collections.Immutable; using System.Composition; + using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; @@ -59,21 +62,23 @@ private static async Task GetTransformedDocumentAsync(Document documen return document; } - var newDeclarationNode = originalDeclarationNode.ReplaceTokens(childTokens, ComputeReplacementToken); + bool hasInternalKeyword = childTokens.Any(token => token.IsKind(SyntaxKind.InternalKeyword)); + var newDeclarationNode = originalDeclarationNode.ReplaceTokens(childTokens, (originalToken, rewrittenToken) => ComputeReplacementToken(originalToken, rewrittenToken, hasInternalKeyword)); var newSyntaxRoot = syntaxRoot.ReplaceNode(originalDeclarationNode, newDeclarationNode); return document.WithSyntaxRoot(newSyntaxRoot); } - private static SyntaxToken ComputeReplacementToken(SyntaxToken originalToken, SyntaxToken rewrittenToken) + private static SyntaxToken ComputeReplacementToken(SyntaxToken originalToken, SyntaxToken rewrittenToken, bool hasInternalKeyword) { - if (originalToken.IsKind(SyntaxKind.InternalKeyword)) + if (originalToken.IsKind(SyntaxKind.InternalKeyword) + || originalToken.IsKind(SyntaxKind.PrivateKeyword)) { return SyntaxFactory.Token(SyntaxKind.ProtectedKeyword).WithTriviaFrom(rewrittenToken); } else if (originalToken.IsKind(SyntaxKind.ProtectedKeyword)) { - return SyntaxFactory.Token(SyntaxKind.InternalKeyword).WithTriviaFrom(rewrittenToken); + return SyntaxFactory.Token(hasInternalKeyword ? SyntaxKind.InternalKeyword : SyntaxKind.PrivateKeyword).WithTriviaFrom(rewrittenToken); } else { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/SA1212SA1213CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/SA1212SA1213CodeFixProvider.cs index b69d89af7..c7df8d124 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/SA1212SA1213CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/SA1212SA1213CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/UsingCodeFixProvider.SourceMap.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/UsingCodeFixProvider.SourceMap.cs index 3acb210e0..364680b6b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/UsingCodeFixProvider.SourceMap.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/UsingCodeFixProvider.SourceMap.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { @@ -10,6 +12,7 @@ namespace StyleCop.Analyzers.OrderingRules using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; + using StyleCop.Analyzers.Lightup; /// /// Implements a code fix for all misaligned using statements. @@ -123,12 +126,12 @@ internal TreeTextSpan GetContainingSpan(SyntaxNode node) private static void ProcessNodeMembers(TreeTextSpan.Builder builder, SyntaxList members) { - foreach (var namespaceDeclaration in members.OfType()) + foreach (var namespaceDeclaration in members.Where(member => BaseNamespaceDeclarationSyntaxWrapper.IsInstance(member))) { var childBuilder = builder.AddChild(namespaceDeclaration.FullSpan.Start); childBuilder.SetEnd(namespaceDeclaration.FullSpan.End); - ProcessNodeMembers(childBuilder, namespaceDeclaration.Members); + ProcessNodeMembers(childBuilder, ((BaseNamespaceDeclarationSyntaxWrapper)namespaceDeclaration).Members); } } @@ -146,7 +149,7 @@ private static void BuildDirectiveTriviaMaps(CompilationUnitSyntax compilationUn switch (directiveTrivia.Kind()) { case SyntaxKind.IfDirectiveTrivia: - AddNewDirectiveTriviaSpan(conditionalBuilder, conditionalStack, directiveTrivia); + AddNewDirectiveTriviaSpan(conditionalStack, directiveTrivia); break; case SyntaxKind.ElifDirectiveTrivia: @@ -154,19 +157,19 @@ private static void BuildDirectiveTriviaMaps(CompilationUnitSyntax compilationUn var previousSpan = conditionalStack.Pop(); previousSpan.SetEnd(directiveTrivia.FullSpan.Start); - AddNewDirectiveTriviaSpan(conditionalBuilder, conditionalStack, directiveTrivia); + AddNewDirectiveTriviaSpan(conditionalStack, directiveTrivia); break; case SyntaxKind.EndIfDirectiveTrivia: - CloseDirectiveTriviaSpan(conditionalBuilder, conditionalStack, directiveTrivia); + CloseDirectiveTriviaSpan(conditionalStack, directiveTrivia); break; case SyntaxKind.RegionDirectiveTrivia: - AddNewDirectiveTriviaSpan(regionBuilder, regionStack, directiveTrivia); + AddNewDirectiveTriviaSpan(regionStack, directiveTrivia); break; case SyntaxKind.EndRegionDirectiveTrivia: - CloseDirectiveTriviaSpan(regionBuilder, regionStack, directiveTrivia); + CloseDirectiveTriviaSpan(regionStack, directiveTrivia); break; case SyntaxKind.PragmaWarningDirectiveTrivia: @@ -192,14 +195,14 @@ private static TreeTextSpan.Builder SetupBuilder(CompilationUnitSyntax compilati return rootBuilder; } - private static void AddNewDirectiveTriviaSpan(TreeTextSpan.Builder spanBuilder, Stack spanStack, DirectiveTriviaSyntax directiveTrivia) + private static void AddNewDirectiveTriviaSpan(Stack spanStack, DirectiveTriviaSyntax directiveTrivia) { var parent = spanStack.Peek(); var newDirectiveSpan = parent.AddChild(directiveTrivia.FullSpan.Start); spanStack.Push(newDirectiveSpan); } - private static void CloseDirectiveTriviaSpan(TreeTextSpan.Builder spanBuilder, Stack spanStack, DirectiveTriviaSyntax directiveTrivia) + private static void CloseDirectiveTriviaSpan(Stack spanStack, DirectiveTriviaSyntax directiveTrivia) { var previousSpan = spanStack.Pop(); previousSpan.SetEnd(directiveTrivia.FullSpan.End); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/UsingCodeFixProvider.TreeTextSpan.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/UsingCodeFixProvider.TreeTextSpan.cs index 37c5634dc..8abd78c18 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/UsingCodeFixProvider.TreeTextSpan.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/UsingCodeFixProvider.TreeTextSpan.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { @@ -158,7 +160,7 @@ internal TreeTextSpan GetContainingSpan(TextSpan textSpan) internal class Builder { private readonly List children = new List(); - private int start; + private readonly int start; private int end = int.MaxValue; /// diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/UsingCodeFixProvider.UsingsSorter.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/UsingCodeFixProvider.UsingsSorter.cs index 4d0b96f79..d2d2e865c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/UsingCodeFixProvider.UsingsSorter.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/UsingCodeFixProvider.UsingsSorter.cs @@ -1,18 +1,20 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { using System; using System.Collections.Generic; using System.Collections.Immutable; - using System.Globalization; using System.Linq; using System.Threading; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.Settings.ObjectModel; /// @@ -35,6 +37,7 @@ private class UsingsSorter private readonly Dictionary> systemUsings = new Dictionary>(); private readonly Dictionary> namespaceUsings = new Dictionary>(); private readonly Dictionary> aliases = new Dictionary>(); + private readonly Dictionary> systemStaticImports = new Dictionary>(); private readonly Dictionary> staticImports = new Dictionary>(); public UsingsSorter(StyleCopSettings settings, SemanticModel semanticModel, CompilationUnitSyntax compilationUnit, ImmutableArray fileHeader) @@ -76,6 +79,11 @@ public List GetContainedUsings(TreeTextSpan directiveSpan) result.AddRange(usingsList); } + if (this.systemStaticImports.TryGetValue(directiveSpan, out usingsList)) + { + result.AddRange(usingsList); + } + if (this.staticImports.TryGetValue(directiveSpan, out usingsList)) { result.AddRange(usingsList); @@ -84,13 +92,14 @@ public List GetContainedUsings(TreeTextSpan directiveSpan) return result; } - public SyntaxList GenerateGroupedUsings(TreeTextSpan directiveSpan, string indentation, bool withTrailingBlankLine, bool qualifyNames) + public SyntaxList GenerateGroupedUsings(TreeTextSpan directiveSpan, string indentation, bool withLeadingBlankLine, bool withTrailingBlankLine, bool qualifyNames) { var usingList = new List(); List triviaToMove = new List(); usingList.AddRange(this.GenerateUsings(this.systemUsings, directiveSpan, indentation, triviaToMove, qualifyNames)); usingList.AddRange(this.GenerateUsings(this.namespaceUsings, directiveSpan, indentation, triviaToMove, qualifyNames)); + usingList.AddRange(this.GenerateUsings(this.systemStaticImports, directiveSpan, indentation, triviaToMove, qualifyNames)); usingList.AddRange(this.GenerateUsings(this.staticImports, directiveSpan, indentation, triviaToMove, qualifyNames)); usingList.AddRange(this.GenerateUsings(this.aliases, directiveSpan, indentation, triviaToMove, qualifyNames)); @@ -100,6 +109,12 @@ public SyntaxList GenerateGroupedUsings(TreeTextSpan direc usingList[0] = usingList[0].WithLeadingTrivia(newLeadingTrivia); } + if (withLeadingBlankLine && usingList.Count > 0) + { + var firstUsing = usingList[0]; + usingList[0] = firstUsing.WithLeadingTrivia(firstUsing.GetLeadingTrivia().Insert(0, SyntaxFactory.CarriageReturnLineFeed)); + } + if (withTrailingBlankLine && (usingList.Count > 0)) { var lastUsing = usingList[usingList.Count - 1]; @@ -109,13 +124,14 @@ public SyntaxList GenerateGroupedUsings(TreeTextSpan direc return SyntaxFactory.List(usingList); } - public SyntaxList GenerateGroupedUsings(List usingsList, string indentation, bool withTrailingBlankLine, bool qualifyNames) + public SyntaxList GenerateGroupedUsings(List usingsList, string indentation, bool withLeadingBlankLine, bool withTrailingBlankLine, bool qualifyNames) { var usingList = new List(); List triviaToMove = new List(); usingList.AddRange(this.GenerateUsings(this.systemUsings, usingsList, indentation, triviaToMove, qualifyNames)); usingList.AddRange(this.GenerateUsings(this.namespaceUsings, usingsList, indentation, triviaToMove, qualifyNames)); + usingList.AddRange(this.GenerateUsings(this.systemStaticImports, usingsList, indentation, triviaToMove, qualifyNames)); usingList.AddRange(this.GenerateUsings(this.staticImports, usingsList, indentation, triviaToMove, qualifyNames)); usingList.AddRange(this.GenerateUsings(this.aliases, usingsList, indentation, triviaToMove, qualifyNames)); @@ -125,6 +141,12 @@ public SyntaxList GenerateGroupedUsings(List 0) + { + var firstUsing = usingList[0]; + usingList[0] = firstUsing.WithLeadingTrivia(firstUsing.GetLeadingTrivia().Insert(0, SyntaxFactory.CarriageReturnLineFeed)); + } + if (withTrailingBlankLine && (usingList.Count > 0)) { var lastUsing = usingList[usingList.Count - 1]; @@ -357,15 +379,19 @@ private UsingDirectiveSyntax QualifyUsingDirective(UsingDirectiveSyntax usingDir rewrittenName = replacement.WithTriviaFrom(originalName); break; } - else if (symbol is INamedTypeSymbol) + else if (symbol is INamedTypeSymbol namedTypeSymbol) { // TODO: Preserve inner trivia // TODO: simplify after qualification string fullName; - if (SpecialTypeHelper.IsPredefinedType(((INamedTypeSymbol)symbol).OriginalDefinition.SpecialType)) + if (SpecialTypeHelper.IsPredefinedType(namedTypeSymbol.OriginalDefinition.SpecialType)) { fullName = "global::System." + symbol.Name; } + else if (namedTypeSymbol.IsTupleType()) + { + fullName = namedTypeSymbol.TupleUnderlyingTypeOrSelf().ToFullyQualifiedValueTupleDisplayString(); + } else { fullName = symbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); @@ -419,22 +445,35 @@ private int CompareUsings(UsingDirectiveSyntax left, UsingDirectiveSyntax right) return NameSyntaxHelpers.Compare(left.Name, right.Name); } + private bool IsSeparatedStaticSystemUsing(UsingDirectiveSyntax syntax) + { + if (!this.separateSystemDirectives) + { + return false; + } + + return this.StartsWithSystemUsingDirectiveIdentifier(syntax.Name); + } + private bool IsSeparatedSystemUsing(UsingDirectiveSyntax syntax) { if (!this.separateSystemDirectives - || (syntax.Alias != null) - || syntax.StaticKeyword.IsKind(SyntaxKind.StaticKeyword) || syntax.HasNamespaceAliasQualifier()) { return false; } - if (!(this.semanticModel.GetSymbolInfo(syntax.Name).Symbol is INamespaceSymbol namespaceSymbol)) + return this.StartsWithSystemUsingDirectiveIdentifier(syntax.Name); + } + + private bool StartsWithSystemUsingDirectiveIdentifier(NameSyntax name) + { + if (!(this.semanticModel.GetSymbolInfo(name).Symbol is INamespaceOrTypeSymbol namespaceOrTypeSymbol)) { return false; } - var namespaceTypeName = namespaceSymbol.ToDisplayString(FullNamespaceDisplayFormat); + var namespaceTypeName = namespaceOrTypeSymbol.ToDisplayString(FullNamespaceDisplayFormat); var firstPart = namespaceTypeName.Split('.')[0]; return string.Equals(SystemUsingDirectiveIdentifier, firstPart, StringComparison.Ordinal); @@ -442,10 +481,10 @@ private bool IsSeparatedSystemUsing(UsingDirectiveSyntax syntax) private void ProcessMembers(SyntaxList members) { - foreach (var namespaceDeclaration in members.OfType()) + foreach (var namespaceDeclaration in members.Where(member => BaseNamespaceDeclarationSyntaxWrapper.IsInstance(member))) { - this.ProcessUsingDirectives(namespaceDeclaration.Usings); - this.ProcessMembers(namespaceDeclaration.Members); + this.ProcessUsingDirectives(((BaseNamespaceDeclarationSyntaxWrapper)namespaceDeclaration).Usings); + this.ProcessMembers(((BaseNamespaceDeclarationSyntaxWrapper)namespaceDeclaration).Members); } } @@ -459,9 +498,16 @@ private void ProcessUsingDirectives(SyntaxList usingDirect { this.AddUsingDirective(this.aliases, usingDirective, containingSpan); } - else if (!usingDirective.StaticKeyword.IsKind(SyntaxKind.None)) + else if (usingDirective.StaticKeyword.IsKind(SyntaxKind.StaticKeyword)) { - this.AddUsingDirective(this.staticImports, usingDirective, containingSpan); + if (this.IsSeparatedStaticSystemUsing(usingDirective)) + { + this.AddUsingDirective(this.systemStaticImports, usingDirective, containingSpan); + } + else + { + this.AddUsingDirective(this.staticImports, usingDirective, containingSpan); + } } else if (this.IsSeparatedSystemUsing(usingDirective)) { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/UsingCodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/UsingCodeFixProvider.cs index b824d3ce9..93366215b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/UsingCodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/UsingCodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { @@ -16,6 +18,7 @@ namespace StyleCop.Analyzers.OrderingRules using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.Settings.ObjectModel; /// @@ -29,7 +32,9 @@ internal sealed partial class UsingCodeFixProvider : CodeFixProvider private static readonly List EmptyUsingsList = new List(); private static readonly SyntaxAnnotation UsingCodeFixAnnotation = new SyntaxAnnotation(nameof(UsingCodeFixAnnotation)); - private static readonly SymbolDisplayFormat FullNamespaceDisplayFormat = SymbolDisplayFormat.FullyQualifiedFormat.WithGlobalNamespaceStyle(SymbolDisplayGlobalNamespaceStyle.Omitted); + private static readonly SymbolDisplayFormat FullNamespaceDisplayFormat = SymbolDisplayFormat.FullyQualifiedFormat + .WithGlobalNamespaceStyle(SymbolDisplayGlobalNamespaceStyle.Omitted) + .WithMiscellaneousOptions(SymbolDisplayMiscellaneousOptions.EscapeKeywordIdentifiers); /// public override ImmutableArray FixableDiagnosticIds { get; } = @@ -78,8 +83,8 @@ private static async Task GetTransformedDocumentAsync(Document documen var fileHeader = GetFileHeader(syntaxRoot); var compilationUnit = (CompilationUnitSyntax)syntaxRoot; - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, cancellationToken); var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, semanticModel.SyntaxTree, cancellationToken); var usingDirectivesPlacement = forcePreservePlacement ? UsingDirectivesPlacement.Preserve : DeterminePlacement(compilationUnit, settings); var usingsHelper = new UsingsSorter(settings, semanticModel, compilationUnit, fileHeader); @@ -132,9 +137,14 @@ private static string DetermineIndentation(CompilationUnitSyntax compilationUnit if (usingDirectivesPlacement == UsingDirectivesPlacement.InsideNamespace) { - var rootNamespace = compilationUnit.Members.OfType().First(); + var rootNamespace = compilationUnit.Members.First(member => BaseNamespaceDeclarationSyntaxWrapper.IsInstance(member)); var indentationLevel = IndentationHelper.GetIndentationSteps(indentationSettings, rootNamespace); - usingsIndentation = IndentationHelper.GenerateIndentationString(indentationSettings, indentationLevel + 1); + if (!rootNamespace.IsKind(SyntaxKindEx.FileScopedNamespaceDeclaration)) + { + indentationLevel++; + } + + usingsIndentation = IndentationHelper.GenerateIndentationString(indentationSettings, indentationLevel); } else { @@ -183,9 +193,9 @@ private static int CountNamespaces(SyntaxList members) { var result = 0; - foreach (var namespaceDeclaration in members.OfType()) + foreach (var namespaceDeclaration in members.Where(member => BaseNamespaceDeclarationSyntaxWrapper.IsInstance(member))) { - result += 1 + CountNamespaces(namespaceDeclaration.Members); + result += 1 + CountNamespaces(((BaseNamespaceDeclarationSyntaxWrapper)namespaceDeclaration).Members); } return result; @@ -217,8 +227,9 @@ private static void BuildReplaceMapForNamespaces(UsingsSorter usingsHelper, Dict } var indentation = IndentationHelper.GenerateIndentationString(indentationSettings, indentationSteps); + var withLeadingBlankLine = usingList[0].Parent.IsKind(SyntaxKindEx.FileScopedNamespaceDeclaration); - var modifiedUsings = usingsHelper.GenerateGroupedUsings(usingList, indentation, false, qualifyNames); + var modifiedUsings = usingsHelper.GenerateGroupedUsings(usingList, indentation, withLeadingBlankLine, withTrailingBlankLine: false, qualifyNames); for (var i = 0; i < usingList.Count; i++) { @@ -246,7 +257,7 @@ private static void BuildReplaceMapForConditionalDirectives(UsingsSorter usingsH var indentation = IndentationHelper.GenerateIndentationString(indentationSettings, indentationSteps); - var modifiedUsings = usingsHelper.GenerateGroupedUsings(childSpan, indentation, false, qualifyNames: false); + var modifiedUsings = usingsHelper.GenerateGroupedUsings(childSpan, indentation, false, false, qualifyNames: false); for (var i = 0; i < originalUsings.Count; i++) { @@ -265,10 +276,11 @@ private static int CompareSpanStart(UsingDirectiveSyntax left, UsingDirectiveSyn private static SyntaxNode AddUsingsToNamespace(SyntaxNode newSyntaxRoot, UsingsSorter usingsHelper, string usingsIndentation, bool hasConditionalDirectives) { - var rootNamespace = ((CompilationUnitSyntax)newSyntaxRoot).Members.OfType().First(); + var rootNamespace = (BaseNamespaceDeclarationSyntaxWrapper)((CompilationUnitSyntax)newSyntaxRoot).Members.First(member => BaseNamespaceDeclarationSyntaxWrapper.IsInstance(member)); + var withLeadingBlankLine = rootNamespace.SyntaxNode.IsKind(SyntaxKindEx.FileScopedNamespaceDeclaration); var withTrailingBlankLine = hasConditionalDirectives || rootNamespace.Members.Any() || rootNamespace.Externs.Any(); - var groupedUsings = usingsHelper.GenerateGroupedUsings(TreeTextSpan.Empty, usingsIndentation, withTrailingBlankLine, qualifyNames: false); + var groupedUsings = usingsHelper.GenerateGroupedUsings(TreeTextSpan.Empty, usingsIndentation, withLeadingBlankLine, withTrailingBlankLine, qualifyNames: false); groupedUsings = groupedUsings.AddRange(rootNamespace.Usings); var newRootNamespace = rootNamespace.WithUsings(groupedUsings); @@ -282,7 +294,7 @@ private static SyntaxNode AddUsingsToCompilationRoot(SyntaxNode newSyntaxRoot, U var newCompilationUnit = (CompilationUnitSyntax)newSyntaxRoot; var withTrailingBlankLine = hasConditionalDirectives || newCompilationUnit.AttributeLists.Any() || newCompilationUnit.Members.Any() || newCompilationUnit.Externs.Any(); - var groupedUsings = usingsHelper.GenerateGroupedUsings(TreeTextSpan.Empty, usingsIndentation, withTrailingBlankLine, qualifyNames: true); + var groupedUsings = usingsHelper.GenerateGroupedUsings(TreeTextSpan.Empty, usingsIndentation, withLeadingBlankLine: false, withTrailingBlankLine, qualifyNames: true); groupedUsings = groupedUsings.AddRange(newCompilationUnit.Usings); newSyntaxRoot = newCompilationUnit.WithUsings(groupedUsings); @@ -478,7 +490,7 @@ public override SyntaxTrivia VisitTrivia(SyntaxTrivia trivia) { if (this.fileHeader.Contains(trivia)) { - return default(SyntaxTrivia); + return default; } return base.VisitTrivia(trivia); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Properties/AssemblyInfo.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Properties/AssemblyInfo.cs index b8f32f289..05d80f9a6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Properties/AssemblyInfo.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Properties/AssemblyInfo.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable using System; using System.Runtime.CompilerServices; @@ -14,4 +16,9 @@ [assembly: InternalsVisibleTo("StyleCop.Analyzers.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] [assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp7, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp8, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp9, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp10, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp11, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp12, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] [assembly: InternalsVisibleTo("StyleCopTester, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/PublicAPI.Shipped.txt b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/PublicAPI.Shipped.txt new file mode 100644 index 000000000..e69de29bb diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/PublicAPI.Unshipped.txt b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/PublicAPI.Unshipped.txt new file mode 100644 index 000000000..e69de29bb diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/IndentationCodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/IndentationCodeFixProvider.cs index 04c28e100..1569b8dbd 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/IndentationCodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/IndentationCodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -61,14 +63,14 @@ private static bool TryGetTextChange(Diagnostic diagnostic, SyntaxNode syntaxRoo string replacement; if (!diagnostic.Properties.TryGetValue(SA1137ElementsShouldHaveTheSameIndentation.ExpectedIndentationKey, out replacement)) { - textChange = default(TextChange); + textChange = default; return false; } var trivia = syntaxRoot.FindTrivia(diagnostic.Location.SourceSpan.Start); TextSpan originalSpan; - if (trivia == default(SyntaxTrivia)) + if (trivia == default) { // The warning was reported on a token because the line is not indented originalSpan = new TextSpan(diagnostic.Location.SourceSpan.Start, 0); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/RemoveRegionCodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/RemoveRegionCodeFixProvider.cs index 975a7599f..a3b374185 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/RemoveRegionCodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/RemoveRegionCodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/RemoveRegionFixAllProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/RemoveRegionFixAllProvider.cs index b56c7eeed..314b84cfe 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/RemoveRegionFixAllProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/RemoveRegionFixAllProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1100CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1100CodeFixProvider.cs index d375eab7e..65fbdb130 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1100CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1100CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1101CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1101CodeFixProvider.cs index 5bec2f707..5e445f418 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1101CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1101CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1102CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1102CodeFixProvider.cs index b0c9a0745..bece491ab 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1102CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1102CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -52,7 +54,7 @@ private static async Task GetTransformedDocumentAsync(Document documen var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var token = syntaxRoot.FindToken(diagnostic.Location.SourceSpan.Start); - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, cancellationToken); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, cancellationToken); var indentationTrivia = QueryIndentationHelpers.GetQueryIndentationTrivia(settings.Indentation, token); var precedingToken = token.GetPreviousToken(); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1103CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1103CodeFixProvider.cs index b58e1c6aa..dc634ec81 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1103CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1103CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -118,7 +120,7 @@ private static async Task GetTransformedDocumentForMultipleLinesAsync( var nodeList = CreateQueryNodeList(queryExpression); - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, cancellationToken); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, cancellationToken); var indentationTrivia = QueryIndentationHelpers.GetQueryIndentationTrivia(settings.Indentation, queryExpression); for (var i = 1; i < nodeList.Length; i++) @@ -153,7 +155,11 @@ private static ImmutableArray CreateQueryNodeList(QueryExpressionSyn private static void ProcessQueryBody(QueryBodySyntax body, List queryNodes) { queryNodes.AddRange(body.Clauses); - queryNodes.Add(body.SelectOrGroup); + + if (!body.SelectOrGroup.IsMissing) + { + queryNodes.Add(body.SelectOrGroup); + } if (body.Continuation != null) { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1104SA1105CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1104SA1105CodeFixProvider.cs index d97b58526..fd8ffb8c4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1104SA1105CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1104SA1105CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -54,7 +56,7 @@ private static async Task GetTransformedDocumentAsync(Document documen var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var token = syntaxRoot.FindToken(diagnostic.Location.SourceSpan.Start); - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, cancellationToken); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, cancellationToken); var indentationTrivia = QueryIndentationHelpers.GetQueryIndentationTrivia(settings.Indentation, token); var precedingToken = token.GetPreviousToken(); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1106CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1106CodeFixProvider.cs index e86943d4c..ddce6d839 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1106CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1106CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1107CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1107CodeFixProvider.cs index f690931f4..228cd2243 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1107CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1107CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1107FixAllProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1107FixAllProvider.cs index 3c0ad9082..55b4f9f33 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1107FixAllProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1107FixAllProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1116CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1116CodeFixProvider.cs index 6ebfb1d46..9bafce580 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1116CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1116CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -70,7 +72,7 @@ private static async Task GetTransformedDocumentAsync(Document documen } } - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, cancellationToken); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, tree, cancellationToken); SyntaxTriviaList newTrivia = SyntaxFactory.TriviaList( SyntaxFactory.CarriageReturnLineFeed, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1120CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1120CodeFixProvider.cs index 05c2d0c52..c7b7bccaf 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1120CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1120CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -80,7 +82,7 @@ private static async Task GetTransformedDocumentAsync(Document documen } // Replace all roots with an empty node - var newRoot = root.ReplaceTrivia(triviaToRemove, (original, rewritten) => default(SyntaxTrivia)); + var newRoot = root.ReplaceTrivia(triviaToRemove, (original, rewritten) => default); Document updatedDocument = document.WithSyntaxRoot(newRoot); return updatedDocument; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1121CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1121CodeFixProvider.cs index 098204171..fbe74b25a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1121CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1121CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1122CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1122CodeFixProvider.cs index 5a994141b..09be377f3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1122CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1122CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1127CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1127CodeFixProvider.cs index 43fbf9193..c0ea7a3f7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1127CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1127CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -60,7 +62,7 @@ private static async Task GetTransformedDocumentAsync(Document documen var afterEndToken = endToken.GetNextToken(); var parentIndentation = GetParentIndentation(whereToken); - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, cancellationToken); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, cancellationToken); var indentationTrivia = SyntaxFactory.Whitespace(parentIndentation + IndentationHelper.GenerateIndentationString(settings.Indentation, 1)); var replaceMap = new Dictionary() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1128CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1128CodeFixProvider.cs index 328889413..09b4230f7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1128CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1128CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -55,7 +57,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context) private static async Task GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) { var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, cancellationToken); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, cancellationToken); var newLine = FormattingHelper.GetNewLineTrivia(document); var constructorInitializer = (ConstructorInitializerSyntax)syntaxRoot.FindNode(diagnostic.Location.SourceSpan); @@ -108,7 +110,7 @@ protected override async Task FixAllInDocumentAsync(FixAllContext fi } var syntaxRoot = await document.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false); - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, fixAllContext.CancellationToken); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, fixAllContext.CancellationToken); var newLine = FormattingHelper.GetNewLineTrivia(document); var nodes = diagnostics.Select(diagnostic => syntaxRoot.FindNode(diagnostic.Location.SourceSpan).Parent); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1129CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1129CodeFixProvider.cs index c93affbe8..fea369877 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1129CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1129CodeFixProvider.cs @@ -1,11 +1,14 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { using System; using System.Collections.Immutable; using System.Composition; + using System.Diagnostics; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -14,7 +17,9 @@ namespace StyleCop.Analyzers.ReadabilityRules using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; + using Microsoft.CodeAnalysis.Editing; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; /// /// Implements a code fix for . @@ -53,44 +58,80 @@ private static async Task GetTransformedDocumentAsync(Document documen var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); var newExpression = syntaxRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true); - var newSyntaxRoot = syntaxRoot.ReplaceNode(newExpression, GetReplacementNode(newExpression, semanticModel, cancellationToken)); + var newSyntaxRoot = syntaxRoot.ReplaceNode(newExpression, GetReplacementNode(document.Project, newExpression, semanticModel, cancellationToken)); return document.WithSyntaxRoot(newSyntaxRoot); } - private static SyntaxNode GetReplacementNode(SyntaxNode node, SemanticModel semanticModel, CancellationToken cancellationToken) + private static SyntaxNode GetReplacementNode(Project project, SyntaxNode node, SemanticModel semanticModel, CancellationToken cancellationToken) { - var newExpression = (ObjectCreationExpressionSyntax)node; + var newExpression = (BaseObjectCreationExpressionSyntaxWrapper)node; + + var symbolInfo = semanticModel.GetSymbolInfo(newExpression, cancellationToken); + var namedTypeSymbol = (symbolInfo.Symbol as IMethodSymbol)?.ContainingType; - var symbolInfo = semanticModel.GetSymbolInfo(newExpression.Type, cancellationToken); - var namedTypeSymbol = symbolInfo.Symbol as INamedTypeSymbol; + var type = GetOrCreateTypeSyntax(project, newExpression, namedTypeSymbol); - SyntaxNode replacement = null; - string memberName = null; + SyntaxNode replacement; - if (IsType(namedTypeSymbol)) + if (IsType(namedTypeSymbol) + || namedTypeSymbol?.SpecialType == SpecialType.System_IntPtr + || namedTypeSymbol?.SpecialType == SpecialType.System_UIntPtr + || IsType(namedTypeSymbol)) { if (IsDefaultParameterValue(newExpression)) { - replacement = SyntaxFactory.DefaultExpression(newExpression.Type); + replacement = SyntaxFactory.DefaultExpression(type); } else { - replacement = ConstructMemberAccessSyntax(newExpression.Type, nameof(CancellationToken.None)); + string fieldName; + if (IsType(namedTypeSymbol)) + { + fieldName = nameof(CancellationToken.None); + } + else if (namedTypeSymbol.SpecialType == SpecialType.System_IntPtr) + { + fieldName = nameof(IntPtr.Zero); + } + else if (namedTypeSymbol.SpecialType == SpecialType.System_UIntPtr) + { + fieldName = nameof(IntPtr.Zero); + } + else + { + Debug.Assert(IsType(namedTypeSymbol), "Assertion failed: IsType(namedTypeSymbol)"); + fieldName = nameof(Guid.Empty); + } + + replacement = ConstructMemberAccessSyntax(type, fieldName); } } - else if (IsEnumWithDefaultMember(namedTypeSymbol, out memberName)) + else if (IsEnumWithDefaultMember(namedTypeSymbol, out string memberName)) { - replacement = ConstructMemberAccessSyntax(newExpression.Type, memberName); + replacement = ConstructMemberAccessSyntax(type, memberName); } else { - replacement = SyntaxFactory.DefaultExpression(newExpression.Type); + replacement = SyntaxFactory.DefaultExpression(type); } return replacement - .WithLeadingTrivia(newExpression.GetLeadingTrivia()) - .WithTrailingTrivia(newExpression.GetTrailingTrivia()); + .WithLeadingTrivia(newExpression.SyntaxNode.GetLeadingTrivia()) + .WithTrailingTrivia(newExpression.SyntaxNode.GetTrailingTrivia()); + } + + private static TypeSyntax GetOrCreateTypeSyntax(Project project, BaseObjectCreationExpressionSyntaxWrapper baseObjectCreationExpression, INamedTypeSymbol constructedType) + { + if (baseObjectCreationExpression.SyntaxNode is ObjectCreationExpressionSyntax objectCreationExpressionSyntax) + { + return objectCreationExpressionSyntax.Type; + } + else + { + SyntaxGenerator generator = SyntaxGenerator.GetGenerator(project); + return (TypeSyntax)generator.TypeExpression(constructedType); + } } /// @@ -124,9 +165,9 @@ private static bool IsType(INamedTypeSymbol namedTypeSymbol) return true; } - private static bool IsDefaultParameterValue(ObjectCreationExpressionSyntax expression) + private static bool IsDefaultParameterValue(BaseObjectCreationExpressionSyntaxWrapper expression) { - if (expression.Parent.Parent is ParameterSyntax parameterSyntax) + if (expression.SyntaxNode.Parent.Parent is ParameterSyntax parameterSyntax) { return parameterSyntax.Parent.Parent is BaseMethodDeclarationSyntax; } @@ -173,6 +214,11 @@ private static bool IsEnumWithDefaultMember(INamedTypeSymbol namedTypeSymbol, ou /// A new member access expression. private static SyntaxNode ConstructMemberAccessSyntax(TypeSyntax typeSyntax, string memberName) { + // NOTE: This creates the correct source code when applied, but these are not necessarily the syntax + // nodes that the compiler would create from that source code. For example, the type syntax can + // contain QualifiedName nodes, whereas the compiler would have created SimpleMemberAccessExpression instead. + // This means that the validation that happens in the tests need to be turned off for some tests. + // We could have transformed the nodes to match, but we keep the code simple instead. return SyntaxFactory.MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, typeSyntax, @@ -199,7 +245,7 @@ protected override async Task FixAllInDocumentAsync(FixAllContext fi var nodes = diagnostics.Select(diagnostic => syntaxRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true)); - return syntaxRoot.ReplaceNodes(nodes, (originalNode, rewrittenNode) => GetReplacementNode(rewrittenNode, semanticModel, fixAllContext.CancellationToken)); + return syntaxRoot.ReplaceNodes(nodes, (originalNode, rewrittenNode) => GetReplacementNode(document.Project, rewrittenNode, semanticModel, fixAllContext.CancellationToken)); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1130CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1130CodeFixProvider.cs index 9d66d8cc4..616797082 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1130CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1130CodeFixProvider.cs @@ -1,9 +1,10 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { - using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Composition; @@ -71,11 +72,12 @@ private static async Task CanFixAsync(CodeFixContext context, Diagnostic d private static SyntaxNode ReplaceWithLambda(SemanticModel semanticModel, AnonymousMethodExpressionSyntax anonymousMethod) { var parameterList = anonymousMethod.ParameterList; - SyntaxNode lambdaExpression; + ExpressionSyntax lambdaExpression; + SyntaxToken arrowToken; if (parameterList == null) { - ImmutableArray argumentList = default(ImmutableArray); + ImmutableArray argumentList = ImmutableArray.Empty; switch (anonymousMethod.Parent.Kind()) { @@ -89,15 +91,38 @@ private static SyntaxNode ReplaceWithLambda(SemanticModel semanticModel, Anonymo case SyntaxKind.AddAssignmentExpression: case SyntaxKind.SubtractAssignmentExpression: - var list = GetAssignmentArgumentList(semanticModel, anonymousMethod); + { + var list = GetAssignmentArgumentList(semanticModel, anonymousMethod); + if (list == null) + { + return null; + } + + argumentList = list.Value; + break; + } - if (list == null) + case SyntaxKind.ArrowExpressionClause: + case SyntaxKind.ReturnStatement: + argumentList = GetMemberReturnTypeArgumentList(semanticModel, anonymousMethod); + if (argumentList.IsEmpty) { return null; } - argumentList = list.Value; break; + + case SyntaxKind.CastExpression: + { + var list = GetCastTypeArgumentList(semanticModel, anonymousMethod); + if (list == null) + { + return null; + } + + argumentList = list.Value; + break; + } } List parameters = GenerateUniqueParameterNames(semanticModel, anonymousMethod, argumentList); @@ -107,12 +132,17 @@ private static SyntaxNode ReplaceWithLambda(SemanticModel semanticModel, Anonymo : SyntaxFactory.SeparatedList(); parameterList = SyntaxFactory.ParameterList(newList) - .WithLeadingTrivia(anonymousMethod.DelegateKeyword.LeadingTrivia) + .WithLeadingTrivia(anonymousMethod.DelegateKeyword.LeadingTrivia); + + arrowToken = SyntaxFactory.Token(SyntaxKind.EqualsGreaterThanToken) .WithTrailingTrivia(anonymousMethod.DelegateKeyword.TrailingTrivia); } else { parameterList = parameterList.WithLeadingTrivia(anonymousMethod.DelegateKeyword.TrailingTrivia); + + arrowToken = SyntaxFactory.Token(SyntaxKind.EqualsGreaterThanToken) + .WithTrailingTrivia(SyntaxFactory.ElasticSpace); } foreach (var parameter in parameterList.Parameters) @@ -123,9 +153,6 @@ private static SyntaxNode ReplaceWithLambda(SemanticModel semanticModel, Anonymo } } - var arrowToken = SyntaxFactory.Token(SyntaxKind.EqualsGreaterThanToken) - .WithTrailingTrivia(SyntaxFactory.ElasticSpace); - if (parameterList.Parameters.Count == 1) { var parameterSyntax = RemoveType(parameterList.Parameters[0]); @@ -151,6 +178,13 @@ private static SyntaxNode ReplaceWithLambda(SemanticModel semanticModel, Anonymo lambdaExpression = SyntaxFactory.ParenthesizedLambdaExpression(anonymousMethod.AsyncKeyword, parameterListSyntax, arrowToken, anonymousMethod.Body); } + if (anonymousMethod.Parent.IsKind(SyntaxKind.CastExpression)) + { + // In this case, the lambda needs enclosing parenthesis to be syntactically correct + lambdaExpression = SyntaxFactory.ParenthesizedExpression(lambdaExpression); + } + + // TODO: No tests require this annotation. Can it be removed? return lambdaExpression .WithAdditionalAnnotations(Formatter.Annotation); } @@ -162,7 +196,7 @@ private static ImmutableArray GetMethodInvocationArgumentList(SemanticMo var originalInvocableExpression = argumentListSyntax.Parent; var originalSymbolInfo = semanticModel.GetSymbolInfo(originalInvocableExpression); - var argumentIndex = argumentListSyntax.Arguments.IndexOf(argumentSyntax); + var argumentIndex = SA1130UseLambdaSyntax.FindParameterIndex(originalSymbolInfo, argumentSyntax, argumentListSyntax); var parameterList = SA1130UseLambdaSyntax.GetDelegateParameterList(originalSymbolInfo.Symbol, argumentIndex); return parameterList.Parameters.Select(p => p.Identifier.ToString()).ToImmutableArray(); } @@ -193,6 +227,27 @@ private static ImmutableArray GetEqualsArgumentList(SemanticModel semant return namedTypeSymbol.DelegateInvokeMethod.Parameters.Select(ps => ps.Name).ToImmutableArray(); } + private static ImmutableArray GetMemberReturnTypeArgumentList(SemanticModel semanticModel, AnonymousMethodExpressionSyntax anonymousMethod) + { + var enclosingSymbol = semanticModel.GetEnclosingSymbol(anonymousMethod.Parent.SpanStart); + return !(((IMethodSymbol)enclosingSymbol).ReturnType is INamedTypeSymbol returnType) ? ImmutableArray.Empty : returnType.DelegateInvokeMethod.Parameters.Select(ps => ps.Name).ToImmutableArray(); + } + + private static ImmutableArray? GetCastTypeArgumentList(SemanticModel semanticModel, AnonymousMethodExpressionSyntax anonymousMethod) + { + var castExpression = (CastExpressionSyntax)anonymousMethod.Parent; + + var symbol = semanticModel.GetSymbolInfo(castExpression.Type); + var namedTypeSymbol = symbol.Symbol as INamedTypeSymbol; + var parameters = namedTypeSymbol?.DelegateInvokeMethod?.Parameters; + if (parameters == null) + { + return null; + } + + return parameters.Value.Select(ps => ps.Name).ToImmutableArray(); + } + private static List GenerateUniqueParameterNames(SemanticModel semanticModel, AnonymousMethodExpressionSyntax anonymousMethod, ImmutableArray argumentNames) { var parameters = new List(); @@ -286,7 +341,7 @@ protected override async Task FixAllInDocumentAsync(FixAllContext fi return rewrittenNode; } - return newNode; + return newNode.WithoutFormatting(); }); } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1131CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1131CodeFixProvider.cs index 49b694e1c..02d9bc576 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1131CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1131CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -64,33 +66,48 @@ private static async Task GetTransformedDocumentAsync(Document documen private static BinaryExpressionSyntax TransformExpression(BinaryExpressionSyntax binaryExpression) { + // NOTE: This code also changes the syntax node kind, besides the operator token. The modified source code would + // have been the same without this, but we do this to make tests pass with the default CodeActionValidationMode. var newLeft = binaryExpression.Right.WithTriviaFrom(binaryExpression.Left); var newRight = binaryExpression.Left.WithTriviaFrom(binaryExpression.Right); - return binaryExpression.WithLeft(newLeft).WithRight(newRight).WithOperatorToken(GetCorrectOperatorToken(binaryExpression.OperatorToken)); + GetReplacementInfo(binaryExpression.OperatorToken, out var newOperatorToken, out var newNodeKind); + return SyntaxFactory.BinaryExpression(newNodeKind, newLeft, newOperatorToken, newRight); } - private static SyntaxToken GetCorrectOperatorToken(SyntaxToken operatorToken) + private static void GetReplacementInfo(SyntaxToken operatorToken, out SyntaxToken newToken, out SyntaxKind newNodeKind) { switch (operatorToken.Kind()) { case SyntaxKind.EqualsEqualsToken: case SyntaxKind.ExclamationEqualsToken: - return operatorToken; + newToken = operatorToken; + newNodeKind = operatorToken.Parent.Kind(); + break; case SyntaxKind.GreaterThanToken: - return SyntaxFactory.Token(operatorToken.LeadingTrivia, SyntaxKind.LessThanToken, operatorToken.TrailingTrivia); + newToken = SyntaxFactory.Token(operatorToken.LeadingTrivia, SyntaxKind.LessThanToken, operatorToken.TrailingTrivia); + newNodeKind = SyntaxKind.LessThanExpression; + break; case SyntaxKind.GreaterThanEqualsToken: - return SyntaxFactory.Token(operatorToken.LeadingTrivia, SyntaxKind.LessThanEqualsToken, operatorToken.TrailingTrivia); + newToken = SyntaxFactory.Token(operatorToken.LeadingTrivia, SyntaxKind.LessThanEqualsToken, operatorToken.TrailingTrivia); + newNodeKind = SyntaxKind.LessThanOrEqualExpression; + break; case SyntaxKind.LessThanToken: - return SyntaxFactory.Token(operatorToken.LeadingTrivia, SyntaxKind.GreaterThanToken, operatorToken.TrailingTrivia); + newToken = SyntaxFactory.Token(operatorToken.LeadingTrivia, SyntaxKind.GreaterThanToken, operatorToken.TrailingTrivia); + newNodeKind = SyntaxKind.GreaterThanExpression; + break; case SyntaxKind.LessThanEqualsToken: - return SyntaxFactory.Token(operatorToken.LeadingTrivia, SyntaxKind.GreaterThanEqualsToken, operatorToken.TrailingTrivia); + newToken = SyntaxFactory.Token(operatorToken.LeadingTrivia, SyntaxKind.GreaterThanEqualsToken, operatorToken.TrailingTrivia); + newNodeKind = SyntaxKind.GreaterThanOrEqualExpression; + break; default: - return SyntaxFactory.Token(SyntaxKind.None); + newToken = SyntaxFactory.Token(SyntaxKind.None); + newNodeKind = (SyntaxKind)operatorToken.Parent.RawKind; + break; } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1132CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1132CodeFixProvider.cs index e68a38149..8dcdee5b2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1132CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1132CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1133CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1133CodeFixProvider.cs index 3c6ad17b6..ebb9a6a56 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1133CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1133CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -59,7 +61,7 @@ private static async Task GetTransformedDocumentAsync(Document documen var nodeInSourceSpan = syntaxRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true); AttributeListSyntax attributeList = nodeInSourceSpan.FirstAncestorOrSelf(); - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, cancellationToken); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, cancellationToken); var indentationSteps = IndentationHelper.GetIndentationSteps(settings.Indentation, attributeList); var indentationTrivia = IndentationHelper.GenerateWhitespaceTrivia(settings.Indentation, indentationSteps); @@ -111,10 +113,12 @@ protected override async Task FixAllInDocumentAsync(FixAllContext fi return null; } - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, fixAllContext.CancellationToken); var syntaxRoot = await document.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, fixAllContext.CancellationToken); - var nodes = diagnostics.Select(diagnostic => syntaxRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true).FirstAncestorOrSelf()); + // 🐉 Need to eagerly evaluate this with ToList() to ensure nodes are not garbage collected between the + // call to TrackNodes and subsequent enumeration. + var nodes = diagnostics.Select(diagnostic => syntaxRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true).FirstAncestorOrSelf()).ToList(); var newRoot = syntaxRoot.TrackNodes(nodes); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1134CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1134CodeFixProvider.cs index daf349312..5fb8ea893 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1134CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1134CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -34,25 +36,29 @@ public override FixAllProvider GetFixAllProvider() } /// - public override Task RegisterCodeFixesAsync(CodeFixContext context) + public override async Task RegisterCodeFixesAsync(CodeFixContext context) { + var syntaxRoot = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false); + foreach (var diagnostic in context.Diagnostics) { - context.RegisterCodeFix( - CodeAction.Create( - ReadabilityResources.SA1134CodeFix, - cancellationToken => GetTransformedDocumentAsync(context.Document, diagnostic, cancellationToken), - nameof(SA1134CodeFixProvider)), - diagnostic); + // Do not offer the code fix if the error is found at an invalid node (like IncompleteMemberSyntax) + if (syntaxRoot.FindNode(diagnostic.Location.SourceSpan) is AttributeListSyntax) + { + context.RegisterCodeFix( + CodeAction.Create( + ReadabilityResources.SA1134CodeFix, + cancellationToken => GetTransformedDocumentAsync(context.Document, diagnostic, cancellationToken), + nameof(SA1134CodeFixProvider)), + diagnostic); + } } - - return SpecializedTasks.CompletedTask; } private static async Task GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) { var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, cancellationToken); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, cancellationToken); var tokensToReplace = new Dictionary(); AddTokensToReplaceToMap(tokensToReplace, syntaxRoot, diagnostic, settings); @@ -109,7 +115,7 @@ protected override async Task FixAllInDocumentAsync(FixAllContext fi } var syntaxRoot = await document.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false); - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, fixAllContext.CancellationToken); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, fixAllContext.CancellationToken); var tokensToReplace = new Dictionary(); foreach (var diagnostic in diagnostics) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1135CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1135CodeFixProvider.cs index 07936bee3..7b6128988 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1135CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1135CodeFixProvider.cs @@ -1,8 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { + using System.Collections.Generic; using System.Collections.Immutable; using System.Composition; using System.Linq; @@ -63,7 +66,76 @@ private static async Task GetTransformedDocumentAsync(Document documen private static SyntaxNode GetReplacementNode(SemanticModel semanticModel, UsingDirectiveSyntax node, CancellationToken cancellationToken) { SymbolInfo symbolInfo = semanticModel.GetSymbolInfo(node.Name, cancellationToken); - return node.WithName(SyntaxFactory.ParseName(symbolInfo.Symbol.ToString())); + var symbolNameSyntax = SyntaxFactory.ParseName(symbolInfo.Symbol.ToQualifiedString(node.Name)); + + var newName = GetReplacementName(symbolNameSyntax, node.Name); + return node.WithName((NameSyntax)newName); + } + + private static TypeSyntax GetReplacementName(TypeSyntax symbolNameSyntax, TypeSyntax nameSyntax) + { + switch (nameSyntax.Kind()) + { + case SyntaxKind.GenericName: + return GetReplacementGenericName(symbolNameSyntax, (GenericNameSyntax)nameSyntax); + + case SyntaxKind.QualifiedName: + return GetReplacementQualifiedName((QualifiedNameSyntax)symbolNameSyntax, (QualifiedNameSyntax)nameSyntax); + + default: + return symbolNameSyntax; + } + } + + private static NameSyntax GetReplacementGenericName(TypeSyntax symbolNameSyntax, GenericNameSyntax genericNameSyntax) + { + var symbolQualifiedNameSyntax = symbolNameSyntax as QualifiedNameSyntax; + var symbolGenericNameSyntax = (GenericNameSyntax)(symbolQualifiedNameSyntax?.Right ?? symbolNameSyntax); + + TypeArgumentListSyntax newTypeArgumentList = GetReplacementTypeArgumentList(symbolGenericNameSyntax, genericNameSyntax); + + if (symbolQualifiedNameSyntax != null) + { + var newRightPart = ((GenericNameSyntax)symbolQualifiedNameSyntax.Right).WithTypeArgumentList(newTypeArgumentList); + return symbolQualifiedNameSyntax.WithRight(newRightPart); + } + + return genericNameSyntax.WithTypeArgumentList(newTypeArgumentList); + } + + private static TypeArgumentListSyntax GetReplacementTypeArgumentList(GenericNameSyntax symbolGenericNameSyntax, GenericNameSyntax genericNameSyntax) + { + var replacements = new Dictionary(); + for (var i = 0; i < genericNameSyntax.TypeArgumentList.Arguments.Count; i++) + { + var argument = genericNameSyntax.TypeArgumentList.Arguments[i]; + + if (!argument.IsKind(SyntaxKind.PredefinedType)) + { + var symbolArgument = symbolGenericNameSyntax.TypeArgumentList.Arguments[i]; + + var replacementArgument = GetReplacementName(symbolArgument, argument) + .WithLeadingTrivia(argument.GetLeadingTrivia()) + .WithTrailingTrivia(argument.GetTrailingTrivia()); + + replacements.Add(argument, replacementArgument); + } + } + + var newTypeArgumentList = genericNameSyntax.TypeArgumentList.ReplaceNodes(replacements.Keys, (original, maybeRewritten) => replacements[original]); + return newTypeArgumentList; + } + + private static NameSyntax GetReplacementQualifiedName(QualifiedNameSyntax symbolNameSyntax, QualifiedNameSyntax nameSyntax) + { + if (nameSyntax.Right.IsKind(SyntaxKind.GenericName)) + { + return GetReplacementGenericName(symbolNameSyntax, (GenericNameSyntax)nameSyntax.Right); + } + else + { + return symbolNameSyntax; + } } private class FixAll : DocumentBasedFixAllProvider diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1136CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1136CodeFixProvider.cs index d03cbd837..114d839a1 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1136CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1136CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -51,7 +53,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context) private static async Task GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) { var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, cancellationToken); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, cancellationToken); var enumMemberDeclaration = (EnumMemberDeclarationSyntax)syntaxRoot.FindNode(diagnostic.Location.SourceSpan); var enumDeclaration = (EnumDeclarationSyntax)enumMemberDeclaration.Parent; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1139CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1139CodeFixProvider.cs index c7f8c39a0..0a1ceb8c0 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1139CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1139CodeFixProvider.cs @@ -1,9 +1,10 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { - using System.Collections.Generic; using System.Collections.Immutable; using System.Composition; using System.Linq; @@ -14,7 +15,6 @@ namespace StyleCop.Analyzers.ReadabilityRules using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; - using Microsoft.CodeAnalysis.Text; using StyleCop.Analyzers.Helpers; /// @@ -44,10 +44,13 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context) return SpecializedTasks.CompletedTask; } + /// + public override FixAllProvider GetFixAllProvider() + => CustomFixAllProviders.BatchFixer; + private static async Task GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) { var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); - var oldSemanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); if (!(syntaxRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true) is CastExpressionSyntax node)) { @@ -68,9 +71,18 @@ private static SyntaxNode GenerateReplacementNode(CastExpressionSyntax node) (LiteralExpressionSyntax)plusMinusSyntax.Operand.WalkDownParentheses(); var typeToken = node.Type.GetFirstToken(); var replacementLiteral = literalExpressionSyntax.WithLiteralSuffix(typeToken.Kind()); + + var newLeadingTrivia = SyntaxFactory.TriviaList(node.GetLeadingTrivia().Concat(node.CloseParenToken.TrailingTrivia).Concat(node.Expression.GetLeadingTrivia())) + .WithoutLeadingWhitespace() + .WithoutTrailingWhitespace(); + + if (newLeadingTrivia.Count != 0) + { + newLeadingTrivia = newLeadingTrivia.Add(SyntaxFactory.Space); + } + var replacementNode = node.Expression.ReplaceNode(literalExpressionSyntax, replacementLiteral) - .WithLeadingTrivia(node.GetLeadingTrivia().Concat(node.CloseParenToken.TrailingTrivia).Concat(node.Expression.GetLeadingTrivia())) - .WithTrailingTrivia(node.Expression.GetTrailingTrivia().Concat(node.GetTrailingTrivia())); + .WithLeadingTrivia(newLeadingTrivia); return replacementNode; } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1141CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1141CodeFixProvider.cs new file mode 100644 index 000000000..9159a72ed --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1141CodeFixProvider.cs @@ -0,0 +1,178 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.ReadabilityRules +{ + using System; + using System.Collections.Immutable; + using System.Composition; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CodeActions; + using Microsoft.CodeAnalysis.CodeFixes; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using Microsoft.CodeAnalysis.Simplification; + using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; + + [ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(SA1141CodeFixProvider))] + [Shared] + internal class SA1141CodeFixProvider : CodeFixProvider + { + /// + public override ImmutableArray FixableDiagnosticIds { get; } = + ImmutableArray.Create(SA1141UseTupleSyntax.DiagnosticId); + + /// + public override FixAllProvider GetFixAllProvider() + { + // Fix All is not yet supported + return null; + } + + /// + public override Task RegisterCodeFixesAsync(CodeFixContext context) + { + foreach (var diagnostic in context.Diagnostics) + { + context.RegisterCodeFix( + CodeAction.Create( + ReadabilityResources.SA1141CodeFix, + cancellationToken => GetTransformedDocumentAsync(context.Document, diagnostic, cancellationToken), + nameof(SA1141CodeFixProvider)), + diagnostic); + } + + return SpecializedTasks.CompletedTask; + } + + private static async Task GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) + { + var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); + var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); + + var node = syntaxRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true); + if (node.IsKind(SyntaxKind.SimpleMemberAccessExpression)) + { + // get the invocation node when processing ValueTuple.Create, as that needs to be replaced. + node = node.Parent; + } + + var newNode = GetReplacementNode(semanticModel, node); + + // doing our own formatting, as the default formatting for operators is incompatible with StyleCop.Analyzers. + var separatorRewriter = new SeparatorRewriter(); + newNode = separatorRewriter.Visit(newNode); + + switch (node.Parent.Kind()) + { + case SyntaxKind.MethodDeclaration: + case SyntaxKind.Parameter: + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.IndexerDeclaration: + case SyntaxKind.DelegateDeclaration: + newNode = newNode.WithTrailingTrivia(SyntaxFactory.Space); + break; + } + + var newSyntaxRoot = syntaxRoot.ReplaceNode(node, newNode.WithAdditionalAnnotations(Simplifier.Annotation)); + return document.WithSyntaxRoot(newSyntaxRoot.WithoutFormatting()); + } + + private static SyntaxNode GetReplacementNode(SemanticModel semanticModel, SyntaxNode node) + { + switch (node) + { + case QualifiedNameSyntax qualifiedNameSyntax: + return TransformGenericNameToTuple(semanticModel, (GenericNameSyntax)qualifiedNameSyntax.Right); + + case GenericNameSyntax genericNameSyntax: + return TransformGenericNameToTuple(semanticModel, genericNameSyntax); + + case ObjectCreationExpressionSyntax objectCreationExpression: + return TransformArgumentListToTuple(semanticModel, objectCreationExpression.ArgumentList.Arguments); + + case InvocationExpressionSyntax invocationExpressionSyntax: + return TransformArgumentListToTuple(semanticModel, invocationExpressionSyntax.ArgumentList.Arguments); + + default: + return node; + } + } + + private static SyntaxNode TransformGenericNameToTuple(SemanticModel semanticModel, GenericNameSyntax genericName) + { + var implementationType = typeof(SeparatedSyntaxListWrapper<>.AutoWrapSeparatedSyntaxList<>).MakeGenericType(typeof(TupleElementSyntaxWrapper), SyntaxWrapperHelper.GetWrappedType(typeof(TupleElementSyntaxWrapper))); + var tupleElements = (SeparatedSyntaxListWrapper)Activator.CreateInstance(implementationType); + + foreach (var typeArgument in genericName.TypeArgumentList.Arguments) + { + if (IsValueTuple(semanticModel, typeArgument)) + { + var tupleTypeSyntax = (TypeSyntax)GetReplacementNode(semanticModel, typeArgument); + tupleElements = tupleElements.Add(SyntaxFactoryEx.TupleElement(tupleTypeSyntax)); + } + else + { + tupleElements = tupleElements.Add(SyntaxFactoryEx.TupleElement(typeArgument)); + } + } + + return SyntaxFactoryEx.TupleType(tupleElements); + } + + private static SyntaxNode TransformArgumentListToTuple(SemanticModel semanticModel, SeparatedSyntaxList arguments) + { + SeparatedSyntaxList processedArguments = default; + + for (var i = 0; i < arguments.Count; i++) + { + var argument = arguments[i]; + + var argumentTypeInfo = semanticModel.GetTypeInfo(argument.Expression); + if (!Equals(argumentTypeInfo.Type, argumentTypeInfo.ConvertedType)) + { + var expectedType = SyntaxFactory.ParseTypeName(argumentTypeInfo.ConvertedType.ToDisplayString()); + argument = argument.WithExpression(SyntaxFactory.CastExpression(expectedType, argument.Expression)); + } + + processedArguments = processedArguments.Add(argument); + } + + return SyntaxFactoryEx.TupleExpression(processedArguments); + } + + private static bool IsValueTuple(SemanticModel semanticModel, TypeSyntax typeSyntax) + { + if (typeSyntax.IsKind(SyntaxKindEx.TupleType)) + { + return false; + } + + var symbolInfo = semanticModel.GetSymbolInfo(typeSyntax); + return (symbolInfo.Symbol is ITypeSymbol typeSymbol) && typeSymbol.IsTupleType(); + } + + private class SeparatorRewriter : CSharpSyntaxRewriter + { + public SeparatorRewriter() + : base(false) + { + } + + public override SyntaxToken VisitToken(SyntaxToken token) + { + if (token.IsKind(SyntaxKind.CommaToken)) + { + token = token.WithTrailingTrivia(SyntaxFactory.Space); + } + + return base.VisitToken(token); + } + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1142CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1142CodeFixProvider.cs new file mode 100644 index 000000000..4e9b2a2d4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SA1142CodeFixProvider.cs @@ -0,0 +1,92 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.ReadabilityRules +{ + using System.Collections.Generic; + using System.Collections.Immutable; + using System.Composition; + using System.Linq; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CodeActions; + using Microsoft.CodeAnalysis.CodeFixes; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; + + [ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(SA1142CodeFixProvider))] + [Shared] + internal class SA1142CodeFixProvider : CodeFixProvider + { + /// + public override ImmutableArray FixableDiagnosticIds { get; } = + ImmutableArray.Create(SA1142ReferToTupleElementsByName.DiagnosticId); + + public override FixAllProvider GetFixAllProvider() => FixAll.Instance; + + /// + public override Task RegisterCodeFixesAsync(CodeFixContext context) + { + foreach (var diagnostic in context.Diagnostics) + { + context.RegisterCodeFix( + CodeAction.Create( + ReadabilityResources.SA1142CodeFix, + cancellationToken => GetTransformedDocumentAsync(context.Document, diagnostic, cancellationToken), + nameof(SA1141CodeFixProvider)), + diagnostic); + } + + return SpecializedTasks.CompletedTask; + } + + private static async Task GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) + { + var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); + var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); + + var node = syntaxRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true); + var replacementNode = GetReplacementNode(semanticModel, node); + + var newSyntaxRoot = syntaxRoot.ReplaceNode(node, replacementNode); + return document.WithSyntaxRoot(newSyntaxRoot); + } + + private static SyntaxNode GetReplacementNode(SemanticModel semanticModel, SyntaxNode fieldName) + { + var fieldSymbol = (IFieldSymbol)semanticModel.GetSymbolInfo(fieldName.Parent).Symbol; + var fieldNameSymbol = fieldSymbol.ContainingType.GetMembers().OfType().Single(fs => !Equals(fs, fieldSymbol) && Equals(fs.CorrespondingTupleField(), fieldSymbol)); + + return SyntaxFactory.IdentifierName(fieldNameSymbol.Name).WithTriviaFrom(fieldName); + } + + private class FixAll : DocumentBasedFixAllProvider + { + public static FixAllProvider Instance { get; } = new FixAll(); + + /// + protected override string CodeActionTitle => ReadabilityResources.SA1142CodeFix; + + /// + protected override async Task FixAllInDocumentAsync(FixAllContext fixAllContext, Document document, ImmutableArray diagnostics) + { + var syntaxRoot = await document.GetSyntaxRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false); + var semanticModel = await document.GetSemanticModelAsync(fixAllContext.CancellationToken).ConfigureAwait(false); + + var replaceMap = new Dictionary(); + + foreach (var diagnostic in diagnostics) + { + var node = syntaxRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true); + replaceMap[node] = GetReplacementNode(semanticModel, node); + } + + return syntaxRoot.ReplaceNodes(replaceMap.Keys, (original, rewritten) => replaceMap[original]); + } + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SX1101CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SX1101CodeFixProvider.cs index 7a763c89f..a8ba58718 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SX1101CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/ReadabilityRules/SX1101CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Settings/SettingsFileCodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Settings/SettingsFileCodeFixProvider.cs index 5225e02c3..b1a91252a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Settings/SettingsFileCodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Settings/SettingsFileCodeFixProvider.cs @@ -1,9 +1,10 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Settings { - using System; using System.Collections.Immutable; using System.Composition; using System.Linq; @@ -79,7 +80,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context) context.RegisterCodeFix( CodeAction.Create( SettingsResources.SettingsFileCodeFix, - cancellationToken => GetTransformedSolutionAsync(context.Document, diagnostic, cancellationToken), + cancellationToken => GetTransformedSolutionAsync(context.Document, cancellationToken), nameof(SettingsFileCodeFixProvider)), diagnostic); } @@ -94,8 +95,11 @@ public override FixAllProvider GetFixAllProvider() return null; } - private static Task GetTransformedSolutionAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) + private static Task GetTransformedSolutionAsync(Document document, CancellationToken cancellationToken) { + // Currently unused + _ = cancellationToken; + var project = document.Project; var solution = project.Solution; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1003CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1003CodeFixProvider.cs index 0f31834ac..c0d3ecd73 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1003CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1003CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1004CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1004CodeFixProvider.cs index 216c93f65..237353f97 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1004CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1004CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -55,10 +57,10 @@ private static async Task GetTransformedDocumentAsync(Document documen { var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); - return document.WithText(text.WithChanges(GetTextChange(root, text, diagnostic))); + return document.WithText(text.WithChanges(GetTextChange(root, diagnostic))); } - private static TextChange GetTextChange(SyntaxNode root, SourceText sourceText, Diagnostic diagnostic) + private static TextChange GetTextChange(SyntaxNode root, Diagnostic diagnostic) { var token = root.FindToken(diagnostic.Location.SourceSpan.Start, findInsideTrivia: true); switch (token.Kind()) @@ -93,7 +95,7 @@ protected override async Task FixAllInDocumentAsync(FixAllContext fi List changes = new List(); foreach (var diagnostic in diagnostics) { - changes.Add(GetTextChange(root, text, diagnostic)); + changes.Add(GetTextChange(root, diagnostic)); } changes.Sort((left, right) => left.Span.Start.CompareTo(right.Span.Start)); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1005CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1005CodeFixProvider.cs index 3741358fa..a75d85f8f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1005CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1005CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1018CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1018CodeFixProvider.cs index e9338a319..c77796c34 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1018CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1018CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1025CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1025CodeFixProvider.cs index 5d8434230..6c12e8bdb 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1025CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1025CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1027CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1027CodeFixProvider.cs index 4429ddf55..8eacf22e4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1027CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1027CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -52,7 +54,8 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context) private static async Task GetTransformedDocumentAsync(Document document, Diagnostic diagnostic, CancellationToken cancellationToken) { - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, cancellationToken); + var syntaxTree = await document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxTree, cancellationToken); SourceText sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false); return document.WithText(sourceText.WithChanges(FixDiagnostic(settings.Indentation, sourceText, diagnostic))); } @@ -86,7 +89,7 @@ private static TextChange FixDiagnostic(IndentationSettings indentationSettings, { if (useTabs) { - replacement.Length = replacement.Length - spaceCount; + replacement.Length -= spaceCount; replacement.Append('\t'); spaceCount = 0; } @@ -113,7 +116,7 @@ private static TextChange FixDiagnostic(IndentationSettings indentationSettings, if (offsetWithinTabColumn == 0) { // We reached a tab stop. - replacement.Length = replacement.Length - spaceCount; + replacement.Length -= spaceCount; replacement.Append('\t'); spaceCount = 0; } @@ -157,7 +160,8 @@ protected override async Task FixAllInDocumentAsync(FixAllContext fi return null; } - var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, fixAllContext.CancellationToken); + SyntaxTree tree = await document.GetSyntaxTreeAsync(fixAllContext.CancellationToken).ConfigureAwait(false); + var settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, tree, fixAllContext.CancellationToken); SourceText sourceText = await document.GetTextAsync(fixAllContext.CancellationToken).ConfigureAwait(false); List changes = new List(); @@ -168,7 +172,6 @@ protected override async Task FixAllInDocumentAsync(FixAllContext fi changes.Sort((left, right) => left.Span.Start.CompareTo(right.Span.Start)); - SyntaxTree tree = await document.GetSyntaxTreeAsync(fixAllContext.CancellationToken).ConfigureAwait(false); return await tree.WithChangedText(sourceText.WithChanges(changes)).GetRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false); } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1028CodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1028CodeFixProvider.cs index b9b5251fe..a0e2756f2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1028CodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/SA1028CodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/TokenSpacingCodeFixProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/TokenSpacingCodeFixProvider.cs index e0170e4ff..82f9364ad 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/TokenSpacingCodeFixProvider.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/SpacingRules/TokenSpacingCodeFixProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -239,9 +241,10 @@ private static void UpdateReplaceMap(Dictionary replac case TokenSpacingProperties.ActionRemove: triviaList = token.TrailingTrivia.AddRange(nextToken.LeadingTrivia); + bool preserveLayout = layout == TokenSpacingProperties.LayoutPreserve; UpdateReplaceMap(replaceMap, token, t => t.WithTrailingTrivia()); - UpdateReplaceMap(replaceMap, nextToken, t => t.WithLeadingTrivia(triviaList.WithoutLeadingWhitespace(true))); + UpdateReplaceMap(replaceMap, nextToken, t => t.WithLeadingTrivia(triviaList.WithoutLeadingWhitespace(endOfLineIsWhitespace: !preserveLayout))); break; } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/StyleCop.Analyzers.CodeFixes.csproj b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/StyleCop.Analyzers.CodeFixes.csproj index 923bbd463..98fd499ae 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/StyleCop.Analyzers.CodeFixes.csproj +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/StyleCop.Analyzers.CodeFixes.csproj @@ -30,12 +30,7 @@ true - ..\..\build\keys\StyleCopAnalyzers.snk - ..\..\build\keys\StyleCopAnalyzers.dev.snk - - - - $(DefineConstants);DEVELOPMENT_KEY + ..\..\build\keys\StyleCopAnalyzers.snk diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/StyleCop.Analyzers.Metadata.nuspec b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/StyleCop.Analyzers.Metadata.nuspec index cf4fbbc49..1d3f170a6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/StyleCop.Analyzers.Metadata.nuspec +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/StyleCop.Analyzers.Metadata.nuspec @@ -6,7 +6,7 @@ $id$ Sam Harwell et. al. Sam Harwell - https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/$GitCommitIdShort$/LICENSE + MIT https://github.com/DotNetAnalyzers/StyleCopAnalyzers false An implementation of StyleCop's rules using Roslyn analyzers and code fixes diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/StyleCop.Analyzers.nuspec b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/StyleCop.Analyzers.nuspec index 23e07ffba..30ebef83f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/StyleCop.Analyzers.nuspec +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/StyleCop.Analyzers.nuspec @@ -6,7 +6,7 @@ $id$ Sam Harwell et. al. Sam Harwell - https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/$GitCommitIdShort$/LICENSE + MIT https://github.com/DotNetAnalyzers/StyleCopAnalyzers false An implementation of StyleCop's rules using Roslyn analyzers and code fixes @@ -29,12 +29,15 @@ + + + - + diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/rulesets/StyleCopAnalyzersDefault.ruleset b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/rulesets/StyleCopAnalyzersDefault.ruleset new file mode 100644 index 000000000..84807c49f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/rulesets/StyleCopAnalyzersDefault.ruleset @@ -0,0 +1,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/GeneratorSyntaxExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/GeneratorSyntaxExtensions.cs new file mode 100644 index 000000000..58e151ec8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/GeneratorSyntaxExtensions.cs @@ -0,0 +1,18 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.CodeGeneration +{ + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + + internal static class GeneratorSyntaxExtensions + { + public static TSyntax WithLeadingBlankLine(this TSyntax syntax) + where TSyntax : SyntaxNode + { + return syntax.WithLeadingTrivia(SyntaxFactory.TriviaList( + SyntaxFactory.PreprocessingMessage(XmlSyntaxFactory.CrLf))); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/OperationLightupGenerator.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/OperationLightupGenerator.cs new file mode 100644 index 000000000..ef0b54ee4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/OperationLightupGenerator.cs @@ -0,0 +1,1212 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.CodeGeneration +{ + using System; + using System.Collections.Generic; + using System.Collections.Immutable; + using System.Collections.ObjectModel; + using System.Globalization; + using System.IO; + using System.Linq; + using System.Text; + using System.Xml.Linq; + using System.Xml.XPath; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + [Generator] + internal sealed class OperationLightupGenerator : IIncrementalGenerator + { + public void Initialize(IncrementalGeneratorInitializationContext context) + { + var operationInterfacesFiles = context.AdditionalTextsProvider.Where(static x => Path.GetFileName(x.Path) == "OperationInterfaces.xml"); + context.RegisterSourceOutput(operationInterfacesFiles, this.Execute); + } + + private void Execute(SourceProductionContext context, AdditionalText operationInterfacesFile) + { + var operationInterfacesText = operationInterfacesFile.GetText(context.CancellationToken); + if (operationInterfacesText is null) + { + throw new InvalidOperationException("Failed to read OperationInterfaces.xml"); + } + + var operationInterfaces = XDocument.Parse(operationInterfacesText.ToString()); + this.GenerateOperationInterfaces(in context, operationInterfaces); + } + + private void GenerateOperationInterfaces(in SourceProductionContext context, XDocument operationInterfaces) + { + var tree = operationInterfaces.XPathSelectElement("/Tree"); + if (tree is null) + { + throw new InvalidOperationException("Failed to find the IOperation root."); + } + + var documentData = new DocumentData(operationInterfaces); + foreach (var pair in documentData.Interfaces) + { + this.GenerateOperationInterface(in context, pair.Value); + } + + this.GenerateOperationWrapperHelper(in context, documentData.Interfaces.Values.ToImmutableArray()); + this.GenerateOperationKindEx(in context, documentData.Interfaces.Values.ToImmutableArray()); + } + + private void GenerateOperationInterface(in SourceProductionContext context, InterfaceData node) + { + var members = SyntaxFactory.List(); + + // internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IArgumentOperation"; + members = members.Add(SyntaxFactory.FieldDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.InternalKeyword), SyntaxFactory.Token(SyntaxKind.ConstKeyword)), + declaration: SyntaxFactory.VariableDeclaration( + type: SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.StringKeyword)), + variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator( + identifier: SyntaxFactory.Identifier("WrappedTypeName"), + argumentList: null, + initializer: SyntaxFactory.EqualsValueClause(SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal($"{node.Namespace}.{node.InterfaceName}")))))))); + + if (node.InterfaceName != "IOperation") + { + // private static readonly Type WrappedType; + members = members.Add(SyntaxFactory.FieldDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PrivateKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword), SyntaxFactory.Token(SyntaxKind.ReadOnlyKeyword)), + declaration: SyntaxFactory.VariableDeclaration( + type: SyntaxFactory.IdentifierName("Type"), + variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator("WrappedType"))))); + } + + foreach (var property in node.Properties) + { + if (property.IsSkipped || !property.NeedsAccessor) + { + continue; + } + + // private static readonly Func ConstructorAccessor; + members = members.Add(SyntaxFactory.FieldDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PrivateKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword), SyntaxFactory.Token(SyntaxKind.ReadOnlyKeyword)), + declaration: SyntaxFactory.VariableDeclaration( + type: SyntaxFactory.GenericName( + identifier: SyntaxFactory.Identifier("Func"), + typeArgumentList: SyntaxFactory.TypeArgumentList(SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.IdentifierName("IOperation"), + property.AccessorResultType, + }))), + variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator(property.AccessorName))))); + } + + // private readonly IOperation operation; + members = members.Add(SyntaxFactory.FieldDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PrivateKeyword), SyntaxFactory.Token(SyntaxKind.ReadOnlyKeyword)), + declaration: SyntaxFactory.VariableDeclaration( + type: SyntaxFactory.IdentifierName("IOperation"), + variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator("operation"))))); + + var staticCtorStatements = SyntaxFactory.List(); + + if (node.InterfaceName != "IOperation") + { + staticCtorStatements = staticCtorStatements.Add( + SyntaxFactory.ExpressionStatement(SyntaxFactory.AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + left: SyntaxFactory.IdentifierName("WrappedType"), + right: SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("OperationWrapperHelper"), + name: SyntaxFactory.IdentifierName("GetWrappedType")), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument( + SyntaxFactory.TypeOfExpression(SyntaxFactory.IdentifierName(node.WrapperName))))))))); + } + + foreach (var property in node.Properties) + { + if (property.IsSkipped || !property.NeedsAccessor) + { + continue; + } + + SimpleNameSyntax helperName; + if (property.IsDerivedOperationArray) + { + // CreateOperationListPropertyAccessor + helperName = SyntaxFactory.GenericName( + identifier: SyntaxFactory.Identifier("CreateOperationListPropertyAccessor"), + typeArgumentList: SyntaxFactory.TypeArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.IdentifierName("IOperation")))); + } + else + { + // CreateOperationPropertyAccessor + helperName = SyntaxFactory.GenericName( + identifier: SyntaxFactory.Identifier("CreateOperationPropertyAccessor"), + typeArgumentList: SyntaxFactory.TypeArgumentList(SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.IdentifierName("IOperation"), + property.AccessorResultType, + }))); + } + + // ConstructorAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Constructor)); + ExpressionSyntax wrappedType = node.InterfaceName == "IOperation" + ? SyntaxFactory.TypeOfExpression(SyntaxFactory.IdentifierName("IOperation")) + : SyntaxFactory.IdentifierName("WrappedType"); + staticCtorStatements = staticCtorStatements.Add(SyntaxFactory.ExpressionStatement(SyntaxFactory.AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + left: SyntaxFactory.IdentifierName(property.AccessorName), + right: SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("LightupHelpers"), + name: helperName), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.Argument(wrappedType), + SyntaxFactory.Argument(SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.IdentifierName("nameof"), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument(SyntaxFactory.IdentifierName(property.Name)))))), + })))))); + } + + // static IArgumentOperationWrapper() + // { + // WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IObjectCreationOperationWrapper)); + // } + members = members.Add(SyntaxFactory.ConstructorDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.StaticKeyword)), + identifier: SyntaxFactory.Identifier(node.WrapperName), + parameterList: SyntaxFactory.ParameterList(), + initializer: null, + body: SyntaxFactory.Block(staticCtorStatements), + expressionBody: null)); + + // private IArgumentOperationWrapper(IOperation operation) + // { + // this.operation = operation; + // } + members = members.Add(SyntaxFactory.ConstructorDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PrivateKeyword)), + identifier: SyntaxFactory.Identifier(node.WrapperName), + parameterList: SyntaxFactory.ParameterList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Parameter( + attributeLists: default, + modifiers: default, + type: SyntaxFactory.IdentifierName("IOperation"), + identifier: SyntaxFactory.Identifier("operation"), + @default: null))), + initializer: null, + body: SyntaxFactory.Block( + SyntaxFactory.ExpressionStatement(SyntaxFactory.AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + left: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.ThisExpression(), + name: SyntaxFactory.IdentifierName("operation")), + right: SyntaxFactory.IdentifierName("operation")))), + expressionBody: null)); + + // public IOperation WrappedOperation => this.operation; + members = members.Add(SyntaxFactory.PropertyDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword)), + type: SyntaxFactory.IdentifierName("IOperation"), + explicitInterfaceSpecifier: null, + identifier: SyntaxFactory.Identifier("WrappedOperation"), + accessorList: null, + expressionBody: SyntaxFactory.ArrowExpressionClause(SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.ThisExpression(), + name: SyntaxFactory.IdentifierName("operation"))), + initializer: null, + semicolonToken: SyntaxFactory.Token(SyntaxKind.SemicolonToken))); + + if (node.InterfaceName != "IOperation") + { + // public ITypeSymbol Type => this.WrappedOperation.Type; + members = members.Add(SyntaxFactory.PropertyDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword)), + type: SyntaxFactory.IdentifierName("ITypeSymbol"), + explicitInterfaceSpecifier: null, + identifier: SyntaxFactory.Identifier("Type"), + accessorList: null, + expressionBody: SyntaxFactory.ArrowExpressionClause(SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.ThisExpression(), + name: SyntaxFactory.IdentifierName("WrappedOperation")), + name: SyntaxFactory.IdentifierName("Type"))), + initializer: null, + semicolonToken: SyntaxFactory.Token(SyntaxKind.SemicolonToken))); + } + + foreach (var property in node.Properties) + { + if (property.IsSkipped) + { + // Generate a NotImplementedException for public properties that do not have a supported type + if (property.IsPublicProperty) + { + // public object Constructor => throw new NotImplementedException("Property 'Type.Property' has unsupported type 'Type'"); + members = members.Add(SyntaxFactory.PropertyDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword)), + type: SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.ObjectKeyword)), + explicitInterfaceSpecifier: null, + identifier: SyntaxFactory.Identifier(property.Name), + accessorList: null, + expressionBody: SyntaxFactory.ArrowExpressionClause(SyntaxFactory.ThrowExpression(SyntaxFactory.ObjectCreationExpression( + type: SyntaxFactory.IdentifierName(nameof(NotImplementedException)), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument( + SyntaxFactory.LiteralExpression( + SyntaxKind.StringLiteralExpression, + SyntaxFactory.Literal($"Property '{node.InterfaceName}.{property.Name}' has unsupported type '{property.Type}'"))))), + initializer: null))), + initializer: null, + semicolonToken: SyntaxFactory.Token(SyntaxKind.SemicolonToken))); + } + + continue; + } + + var propertyType = property.NeedsWrapper ? SyntaxFactory.IdentifierName(property.Type + "Wrapper") : property.AccessorResultType; + + // The value is accessed in one of the following ways: + // ConstructorAccessor(this.WrappedOperation) + // this.WrappedOperation.Constructor + ExpressionSyntax evaluatedAccessor; + if (property.NeedsAccessor) + { + evaluatedAccessor = SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.IdentifierName(property.AccessorName), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.ThisExpression(), + name: SyntaxFactory.IdentifierName("WrappedOperation")))))); + } + else + { + evaluatedAccessor = SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.ThisExpression(), + name: SyntaxFactory.IdentifierName("WrappedOperation")), + name: SyntaxFactory.IdentifierName(property.Name)); + } + + ExpressionSyntax convertedResult; + if (property.NeedsWrapper) + { + // IObjectOrCollectionInitializerOperationWrapper.FromOperation(...) + convertedResult = SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: propertyType, + name: SyntaxFactory.IdentifierName("FromOperation")), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument(evaluatedAccessor)))); + } + else + { + convertedResult = evaluatedAccessor; + } + + // public IMethodSymbol Constructor => ConstructorAccessor(this.WrappedOperation); + members = members.Add(SyntaxFactory.PropertyDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword)), + type: propertyType, + explicitInterfaceSpecifier: null, + identifier: SyntaxFactory.Identifier(property.Name), + accessorList: null, + expressionBody: SyntaxFactory.ArrowExpressionClause(convertedResult), + initializer: null, + semicolonToken: SyntaxFactory.Token(SyntaxKind.SemicolonToken))); + } + + foreach (var baseDefinition in node.InheritedInterfaces) + { + // For now, don't inherit properties from IOperationWrapper + var inheritedProperties = baseDefinition.InterfaceName != "IOperation" ? baseDefinition.Properties : ImmutableArray.Empty; + foreach (var property in inheritedProperties) + { + if (node.Properties.Any(derivedProperty => derivedProperty.Name == property.Name && derivedProperty.IsNew)) + { + continue; + } + + if (!property.IsPublicProperty) + { + continue; + } + + var propertyType = property.IsSkipped + ? SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.ObjectKeyword)) + : property.NeedsWrapper ? SyntaxFactory.IdentifierName(property.Type + "Wrapper") : property.AccessorResultType; + + // public IOperation Instance => ((IMemberReferenceOperationWrapper)this).Instance; + members = members.Add(SyntaxFactory.PropertyDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword)), + type: propertyType, + explicitInterfaceSpecifier: null, + identifier: SyntaxFactory.Identifier(property.Name), + accessorList: null, + expressionBody: SyntaxFactory.ArrowExpressionClause(SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.ParenthesizedExpression(SyntaxFactory.CastExpression( + type: SyntaxFactory.IdentifierName(baseDefinition.WrapperName), + expression: SyntaxFactory.ThisExpression())), + name: SyntaxFactory.IdentifierName(property.Name))), + initializer: null, + semicolonToken: SyntaxFactory.Token(SyntaxKind.SemicolonToken))); + } + + // public static explicit operator IFieldReferenceOperationWrapper(IMemberReferenceOperationWrapper wrapper) + // => FromOperation(wrapper.WrappedOperation); + members = members.Add(SyntaxFactory.ConversionOperatorDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword)), + implicitOrExplicitKeyword: SyntaxFactory.Token(SyntaxKind.ExplicitKeyword), + operatorKeyword: SyntaxFactory.Token(SyntaxKind.OperatorKeyword), + type: SyntaxFactory.IdentifierName(node.WrapperName), + parameterList: SyntaxFactory.ParameterList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Parameter( + attributeLists: default, + modifiers: default, + type: SyntaxFactory.IdentifierName(baseDefinition.WrapperName), + identifier: SyntaxFactory.Identifier("wrapper"), + @default: null))), + body: null, + expressionBody: SyntaxFactory.ArrowExpressionClause(SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.IdentifierName("FromOperation"), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument( + SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("wrapper"), + name: SyntaxFactory.IdentifierName("WrappedOperation"))))))), + semicolonToken: SyntaxFactory.Token(SyntaxKind.SemicolonToken))); + + // public static implicit operator IMemberReferenceOperationWrapper(IFieldReferenceOperationWrapper wrapper) + // => IMemberReferenceOperationWrapper.FromUpcast(wrapper.WrappedOperation); + members = members.Add(SyntaxFactory.ConversionOperatorDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword)), + implicitOrExplicitKeyword: SyntaxFactory.Token(SyntaxKind.ImplicitKeyword), + operatorKeyword: SyntaxFactory.Token(SyntaxKind.OperatorKeyword), + type: SyntaxFactory.IdentifierName(baseDefinition.WrapperName), + parameterList: SyntaxFactory.ParameterList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Parameter( + attributeLists: default, + modifiers: default, + type: SyntaxFactory.IdentifierName(node.WrapperName), + identifier: SyntaxFactory.Identifier("wrapper"), + @default: null))), + body: null, + expressionBody: SyntaxFactory.ArrowExpressionClause(SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName(baseDefinition.WrapperName), + name: SyntaxFactory.IdentifierName("FromUpcast")), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument( + SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("wrapper"), + name: SyntaxFactory.IdentifierName("WrappedOperation"))))))), + semicolonToken: SyntaxFactory.Token(SyntaxKind.SemicolonToken))); + } + + // public static IArgumentOperationWrapper FromOperation(IOperation operation) + // { + // if (operation == null) + // { + // return default; + // } + // + // if (!IsInstance(operation)) + // { + // throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + // } + // + // return new IArgumentOperationWrapper(operation); + // } + var fromOperationStatements = new List(); + fromOperationStatements.Add(SyntaxFactory.IfStatement( + condition: SyntaxFactory.BinaryExpression( + SyntaxKind.EqualsExpression, + left: SyntaxFactory.IdentifierName("operation"), + right: SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)), + statement: SyntaxFactory.Block( + SyntaxFactory.ReturnStatement(SyntaxFactory.LiteralExpression(SyntaxKind.DefaultLiteralExpression))))); + + if (node.InterfaceName != "IOperation") + { + fromOperationStatements.Add(SyntaxFactory.IfStatement( + condition: SyntaxFactory.PrefixUnaryExpression( + SyntaxKind.LogicalNotExpression, + operand: SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.IdentifierName("IsInstance"), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument(SyntaxFactory.IdentifierName("operation")))))), + statement: SyntaxFactory.Block( + SyntaxFactory.ThrowStatement(SyntaxFactory.ObjectCreationExpression( + type: SyntaxFactory.IdentifierName("InvalidCastException"), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument( + SyntaxFactory.InterpolatedStringExpression( + SyntaxFactory.Token(SyntaxKind.InterpolatedStringStartToken), + SyntaxFactory.List(new InterpolatedStringContentSyntax[] + { + SyntaxFactory.InterpolatedStringText(SyntaxFactory.Token( + leading: default, + SyntaxKind.InterpolatedStringTextToken, + "Cannot cast '", + "Cannot cast '", + trailing: default)), + SyntaxFactory.Interpolation(SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("operation"), + name: SyntaxFactory.IdentifierName("GetType")), + argumentList: SyntaxFactory.ArgumentList()), + name: SyntaxFactory.IdentifierName("FullName"))), + SyntaxFactory.InterpolatedStringText(SyntaxFactory.Token( + leading: default, + SyntaxKind.InterpolatedStringTextToken, + "' to '", + "' to '", + trailing: default)), + SyntaxFactory.Interpolation(SyntaxFactory.IdentifierName("WrappedTypeName")), + SyntaxFactory.InterpolatedStringText(SyntaxFactory.Token( + leading: default, + SyntaxKind.InterpolatedStringTextToken, + "'", + "'", + trailing: default)), + }))))), + initializer: null))))); + } + + fromOperationStatements.Add(SyntaxFactory.ReturnStatement(SyntaxFactory.ObjectCreationExpression( + type: SyntaxFactory.IdentifierName(node.WrapperName), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument(SyntaxFactory.IdentifierName("operation")))), + initializer: null))); + + members = members.Add(SyntaxFactory.MethodDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword)), + returnType: SyntaxFactory.IdentifierName(node.WrapperName), + explicitInterfaceSpecifier: null, + identifier: SyntaxFactory.Identifier("FromOperation"), + typeParameterList: null, + parameterList: SyntaxFactory.ParameterList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Parameter( + attributeLists: default, + modifiers: default, + type: SyntaxFactory.IdentifierName("IOperation"), + identifier: SyntaxFactory.Identifier("operation"), + @default: null))), + constraintClauses: default, + body: SyntaxFactory.Block(fromOperationStatements), + expressionBody: null)); + + // public static bool IsInstance(IOperation operation) + // { + // return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + // } + ExpressionSyntax isInstanceExpression = SyntaxFactory.BinaryExpression( + SyntaxKind.NotEqualsExpression, + left: SyntaxFactory.IdentifierName("operation"), + right: SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)); + if (node.InterfaceName != "IOperation") + { + isInstanceExpression = SyntaxFactory.BinaryExpression( + SyntaxKind.LogicalAndExpression, + left: isInstanceExpression, + right: SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("LightupHelpers"), + name: SyntaxFactory.IdentifierName("CanWrapOperation")), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.Argument(SyntaxFactory.IdentifierName("operation")), + SyntaxFactory.Argument(SyntaxFactory.IdentifierName("WrappedType")), + })))); + } + + members = members.Add(SyntaxFactory.MethodDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword)), + returnType: SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.BoolKeyword)), + explicitInterfaceSpecifier: null, + identifier: SyntaxFactory.Identifier("IsInstance"), + typeParameterList: null, + parameterList: SyntaxFactory.ParameterList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Parameter( + attributeLists: default, + modifiers: default, + type: SyntaxFactory.IdentifierName("IOperation"), + identifier: SyntaxFactory.Identifier("operation"), + @default: null))), + constraintClauses: default, + body: SyntaxFactory.Block(SyntaxFactory.ReturnStatement(isInstanceExpression)), + expressionBody: null)); + + if (node.IsAbstract) + { + // internal static IMemberReferenceOperationWrapper FromUpcast(IOperation operation) + // { + // return new IMemberReferenceOperationWrapper(operation); + // } + members = members.Add(SyntaxFactory.MethodDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.InternalKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword)), + returnType: SyntaxFactory.IdentifierName(node.WrapperName), + explicitInterfaceSpecifier: null, + identifier: SyntaxFactory.Identifier("FromUpcast"), + typeParameterList: null, + parameterList: SyntaxFactory.ParameterList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Parameter( + attributeLists: default, + modifiers: default, + type: SyntaxFactory.IdentifierName("IOperation"), + identifier: SyntaxFactory.Identifier("operation"), + @default: null))), + constraintClauses: default, + body: SyntaxFactory.Block( + SyntaxFactory.ReturnStatement(SyntaxFactory.ObjectCreationExpression( + type: SyntaxFactory.IdentifierName(node.WrapperName), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument(SyntaxFactory.IdentifierName("operation")))), + initializer: null))), + expressionBody: null)); + } + + var wrapperStruct = SyntaxFactory.StructDeclaration( + attributeLists: default, + modifiers: SyntaxTokenList.Create(SyntaxFactory.Token(SyntaxKind.InternalKeyword)).Add(SyntaxFactory.Token(SyntaxKind.ReadOnlyKeyword)), + identifier: SyntaxFactory.Identifier(node.WrapperName), + typeParameterList: null, + baseList: null, + constraintClauses: default, + members: members); + + var usingDirectives = new List(); + usingDirectives.Add(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("System"))); + if (node.InterfaceName == "IOperation") + { + usingDirectives.Add(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("System.Collections.Generic"))); + } + + usingDirectives.Add(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("System.Collections.Immutable"))); + usingDirectives.Add(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("Microsoft.CodeAnalysis"))); + + var wrapperNamespace = SyntaxFactory.NamespaceDeclaration( + name: SyntaxFactory.ParseName("StyleCop.Analyzers.Lightup"), + externs: default, + usings: SyntaxFactory.List(usingDirectives), + members: SyntaxFactory.SingletonList(wrapperStruct)); + + wrapperNamespace = wrapperNamespace + .NormalizeWhitespace() + .WithLeadingTrivia( + SyntaxFactory.Comment("// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved."), + SyntaxFactory.CarriageReturnLineFeed, + SyntaxFactory.Comment("// Licensed under the MIT License. See LICENSE in the project root for license information."), + SyntaxFactory.CarriageReturnLineFeed, + SyntaxFactory.CarriageReturnLineFeed) + .WithTrailingTrivia( + SyntaxFactory.CarriageReturnLineFeed); + + context.AddSource(node.WrapperName + ".g.cs", wrapperNamespace.GetText(Encoding.UTF8)); + } + + private void GenerateOperationWrapperHelper(in SourceProductionContext context, ImmutableArray wrapperTypes) + { + // private static readonly ImmutableDictionary WrappedTypes; + var wrappedTypes = SyntaxFactory.FieldDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PrivateKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword), SyntaxFactory.Token(SyntaxKind.ReadOnlyKeyword)), + declaration: SyntaxFactory.VariableDeclaration( + type: SyntaxFactory.GenericName( + identifier: SyntaxFactory.Identifier("ImmutableDictionary"), + typeArgumentList: SyntaxFactory.TypeArgumentList( + SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.IdentifierName("Type"), + SyntaxFactory.IdentifierName("Type"), + }))), + variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator(SyntaxFactory.Identifier("WrappedTypes"))))); + + // var codeAnalysisAssembly = typeof(SyntaxNode).GetTypeInfo().Assembly; + // var builder = ImmutableDictionary.CreateBuilder(); + var staticCtorStatements = SyntaxFactory.List() + .Add(SyntaxFactory.LocalDeclarationStatement(SyntaxFactory.VariableDeclaration( + type: SyntaxFactory.IdentifierName("var"), + variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator( + identifier: SyntaxFactory.Identifier("codeAnalysisAssembly"), + argumentList: null, + initializer: SyntaxFactory.EqualsValueClause( + SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.InvocationExpression( + SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.TypeOfExpression(SyntaxFactory.IdentifierName("SyntaxNode")), + name: SyntaxFactory.IdentifierName("GetTypeInfo"))), + name: SyntaxFactory.IdentifierName("Assembly")))))))) + .Add(SyntaxFactory.LocalDeclarationStatement(SyntaxFactory.VariableDeclaration( + type: SyntaxFactory.IdentifierName("var"), + variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator( + identifier: SyntaxFactory.Identifier("builder"), + argumentList: null, + initializer: SyntaxFactory.EqualsValueClause( + SyntaxFactory.InvocationExpression( + SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("ImmutableDictionary"), + name: SyntaxFactory.GenericName( + identifier: SyntaxFactory.Identifier("CreateBuilder"), + typeArgumentList: SyntaxFactory.TypeArgumentList( + SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.IdentifierName("Type"), + SyntaxFactory.IdentifierName("Type"), + }))))))))))); + + foreach (var node in wrapperTypes) + { + // For the base IOperation node: + // builder.Add(typeof(IArgumentOperationWrapper), typeof(IOperation)); + // + // For all other nodes: + // builder.Add(typeof(IArgumentOperationWrapper), codeAnalysisAssembly.GetType(IArgumentOperationWrapper.WrappedTypeName)); + ArgumentSyntax typeArgument; + if (node.InterfaceName == "IOperation") + { + typeArgument = SyntaxFactory.Argument(SyntaxFactory.TypeOfExpression(SyntaxFactory.IdentifierName("IOperation"))); + } + else + { + typeArgument = SyntaxFactory.Argument( + SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("codeAnalysisAssembly"), + name: SyntaxFactory.IdentifierName("GetType")), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument( + SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName(node.WrapperName), + name: SyntaxFactory.IdentifierName("WrappedTypeName"))))))); + } + + staticCtorStatements = staticCtorStatements.Add(SyntaxFactory.ExpressionStatement( + SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("builder"), + name: SyntaxFactory.IdentifierName("Add")), + argumentList: SyntaxFactory.ArgumentList( + SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.Argument(SyntaxFactory.TypeOfExpression(SyntaxFactory.IdentifierName(node.WrapperName))), + typeArgument, + }))))); + } + + // WrappedTypes = builder.ToImmutable(); + staticCtorStatements = staticCtorStatements.Add(SyntaxFactory.ExpressionStatement( + SyntaxFactory.AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + left: SyntaxFactory.IdentifierName("WrappedTypes"), + right: SyntaxFactory.InvocationExpression( + SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("builder"), + name: SyntaxFactory.IdentifierName("ToImmutable")))))); + + var staticCtor = SyntaxFactory.ConstructorDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.StaticKeyword)), + identifier: SyntaxFactory.Identifier("OperationWrapperHelper"), + parameterList: SyntaxFactory.ParameterList(), + initializer: null, + body: SyntaxFactory.Block(staticCtorStatements), + expressionBody: null); + + // /// + // /// Gets the type that is wrapped by the given wrapper. + // /// + // /// Type of the wrapper for which the wrapped type should be retrieved. + // /// The wrapped type, or null if there is no info. + // internal static Type GetWrappedType(Type wrapperType) + // { + // if (WrappedTypes.TryGetValue(wrapperType, out Type wrappedType)) + // { + // return wrappedType; + // } + // + // return null; + // } + var getWrappedType = SyntaxFactory.MethodDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.InternalKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword)), + returnType: SyntaxFactory.IdentifierName("Type"), + explicitInterfaceSpecifier: null, + identifier: SyntaxFactory.Identifier("GetWrappedType"), + typeParameterList: null, + parameterList: SyntaxFactory.ParameterList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Parameter( + attributeLists: default, + modifiers: default, + type: SyntaxFactory.IdentifierName("Type"), + identifier: SyntaxFactory.Identifier("wrapperType"), + @default: null))), + constraintClauses: default, + body: SyntaxFactory.Block( + SyntaxFactory.IfStatement( + condition: SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("WrappedTypes"), + name: SyntaxFactory.IdentifierName("TryGetValue")), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.Argument(SyntaxFactory.IdentifierName("wrapperType")), + SyntaxFactory.Argument( + nameColon: null, + refKindKeyword: SyntaxFactory.Token(SyntaxKind.OutKeyword), + expression: SyntaxFactory.DeclarationExpression( + type: SyntaxFactory.IdentifierName("Type"), + designation: SyntaxFactory.SingleVariableDesignation(SyntaxFactory.Identifier("wrappedType")))), + }))), + statement: SyntaxFactory.Block( + SyntaxFactory.ReturnStatement(SyntaxFactory.IdentifierName("wrappedType")))), + SyntaxFactory.ReturnStatement(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))), + expressionBody: null); + + getWrappedType = getWrappedType.WithLeadingTrivia(SyntaxFactory.TriviaList( + SyntaxFactory.Trivia(SyntaxFactory.DocumentationComment( + SyntaxFactory.XmlText(" "), + SyntaxFactory.XmlSummaryElement( + SyntaxFactory.XmlText(XmlSyntaxFactory.XmlCarriageReturnLineFeedWithContinuation), + SyntaxFactory.XmlText(" Gets the type that is wrapped by the given wrapper."), + SyntaxFactory.XmlText(XmlSyntaxFactory.XmlCarriageReturnLineFeedWithContinuation), + SyntaxFactory.XmlText(" ")), + SyntaxFactory.XmlText(XmlSyntaxFactory.XmlCarriageReturnLineFeedWithContinuation), + SyntaxFactory.XmlText(" "), + SyntaxFactory.XmlParamElement( + "wrapperType", + SyntaxFactory.XmlText("Type of the wrapper for which the wrapped type should be retrieved.")), + SyntaxFactory.XmlText(XmlSyntaxFactory.XmlCarriageReturnLineFeedWithContinuation), + SyntaxFactory.XmlText(" "), + SyntaxFactory.XmlReturnsElement( + SyntaxFactory.XmlText("The wrapped type, or null if there is no info.")), + SyntaxFactory.XmlText(XmlSyntaxFactory.XmlCarriageReturnLineFeedWithContinuation).WithoutTrailingTrivia())))); + + var wrapperHelperClass = SyntaxFactory.ClassDeclaration( + attributeLists: default, + modifiers: SyntaxTokenList.Create(SyntaxFactory.Token(SyntaxKind.InternalKeyword)).Add(SyntaxFactory.Token(SyntaxKind.StaticKeyword)), + identifier: SyntaxFactory.Identifier("OperationWrapperHelper"), + typeParameterList: null, + baseList: null, + constraintClauses: default, + members: SyntaxFactory.List() + .Add(wrappedTypes) + .Add(staticCtor) + .Add(getWrappedType)); + var wrapperNamespace = SyntaxFactory.NamespaceDeclaration( + name: SyntaxFactory.ParseName("StyleCop.Analyzers.Lightup"), + externs: default, + usings: SyntaxFactory.List() + .Add(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("System"))) + .Add(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("System.Collections.Immutable"))) + .Add(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("System.Reflection"))) + .Add(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("Microsoft.CodeAnalysis"))), + members: SyntaxFactory.SingletonList(wrapperHelperClass)); + + wrapperNamespace = wrapperNamespace + .NormalizeWhitespace() + .WithLeadingTrivia( + SyntaxFactory.Comment("// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved."), + SyntaxFactory.CarriageReturnLineFeed, + SyntaxFactory.Comment("// Licensed under the MIT License. See LICENSE in the project root for license information."), + SyntaxFactory.CarriageReturnLineFeed, + SyntaxFactory.CarriageReturnLineFeed) + .WithTrailingTrivia( + SyntaxFactory.CarriageReturnLineFeed); + + context.AddSource("OperationWrapperHelper.g.cs", wrapperNamespace.GetText(Encoding.UTF8)); + } + + private void GenerateOperationKindEx(in SourceProductionContext context, ImmutableArray wrapperTypes) + { + var operationKinds = wrapperTypes + .SelectMany(type => type.OperationKinds) + .OrderBy(kind => kind.value) + .ToImmutableArray(); + + var members = SyntaxFactory.List(); + foreach (var operationKind in operationKinds) + { + // public const OperationKind FieldReference = (OperationKind)26; + members = members.Add(SyntaxFactory.FieldDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword), SyntaxFactory.Token(SyntaxKind.ConstKeyword)), + declaration: SyntaxFactory.VariableDeclaration( + type: SyntaxFactory.IdentifierName("OperationKind"), + variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator( + identifier: SyntaxFactory.Identifier(operationKind.name), + argumentList: null, + initializer: SyntaxFactory.EqualsValueClause(SyntaxFactory.CastExpression( + type: SyntaxFactory.IdentifierName("OperationKind"), + expression: SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal($"0x{operationKind.value:x}", operationKind.value))))))))); + } + + var operationKindExClass = SyntaxFactory.ClassDeclaration( + attributeLists: default, + modifiers: SyntaxTokenList.Create(SyntaxFactory.Token(SyntaxKind.InternalKeyword)).Add(SyntaxFactory.Token(SyntaxKind.StaticKeyword)), + identifier: SyntaxFactory.Identifier("OperationKindEx"), + typeParameterList: null, + baseList: null, + constraintClauses: default, + members: members); + var wrapperNamespace = SyntaxFactory.NamespaceDeclaration( + name: SyntaxFactory.ParseName("StyleCop.Analyzers.Lightup"), + externs: default, + usings: SyntaxFactory.List() + .Add(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("Microsoft.CodeAnalysis"))), + members: SyntaxFactory.SingletonList(operationKindExClass)); + + wrapperNamespace = wrapperNamespace + .NormalizeWhitespace() + .WithLeadingTrivia( + SyntaxFactory.Comment("// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved."), + SyntaxFactory.CarriageReturnLineFeed, + SyntaxFactory.Comment("// Licensed under the MIT License. See LICENSE in the project root for license information."), + SyntaxFactory.CarriageReturnLineFeed, + SyntaxFactory.CarriageReturnLineFeed) + .WithTrailingTrivia( + SyntaxFactory.CarriageReturnLineFeed); + + context.AddSource("OperationKindEx.g.cs", wrapperNamespace.GetText(Encoding.UTF8)); + } + + private sealed class DocumentData + { + public DocumentData(XDocument document) + { + var operationKinds = GetOperationKinds(document); + + var interfaces = new Dictionary(); + foreach (var node in document.XPathSelectElements("/Tree/AbstractNode")) + { + if (node.Attribute("Internal")?.Value == "true") + { + continue; + } + + if (!operationKinds.TryGetValue(node.RequiredAttribute("Name").Value, out var kinds)) + { + kinds = ImmutableArray<(string name, int value, string? extraDescription)>.Empty; + } + + var interfaceData = new InterfaceData(this, node, kinds); + interfaces.Add(interfaceData.InterfaceName, interfaceData); + } + + foreach (var node in document.XPathSelectElements("/Tree/Node")) + { + if (node.Attribute("Internal")?.Value == "true") + { + continue; + } + + if (!operationKinds.TryGetValue(node.RequiredAttribute("Name").Value, out var kinds)) + { + kinds = ImmutableArray<(string name, int value, string? extraDescription)>.Empty; + } + + var interfaceData = new InterfaceData(this, node, kinds); + interfaces.Add(interfaceData.InterfaceName, interfaceData); + } + + this.Interfaces = new ReadOnlyDictionary(interfaces); + } + + public ReadOnlyDictionary Interfaces { get; } + + private static ImmutableDictionary> GetOperationKinds(XDocument document) + { + var skippedOperationKinds = GetSkippedOperationKinds(document); + + var builder = ImmutableDictionary.CreateBuilder>(); + + int operationKind = 0; + foreach (var node in document.XPathSelectElements("/Tree/AbstractNode|/Tree/Node")) + { + if (node.Attribute("Internal")?.Value == "true") + { + continue; + } + + if (node.XPathSelectElement("OperationKind") is { } explicitKind) + { + if (node.Name == "AbstractNode" && explicitKind.Attribute("Include")?.Value != "true") + { + continue; + } + else if (explicitKind.Attribute("Include")?.Value == "false") + { + // The node is explicitly excluded + continue; + } + else if (explicitKind.XPathSelectElements("Entry").Any()) + { + var nodeBuilder = ImmutableArray.CreateBuilder<(string name, int value, string? extraDescription)>(); + foreach (var entry in explicitKind.XPathSelectElements("Entry")) + { + if (entry.Attribute("EditorBrowsable")?.Value == "false") + { + // Skip code generation for this operation kind + continue; + } + + int parsedValue = ParsePrefixHexValue(entry.RequiredAttribute("Value").Value); + nodeBuilder.Add((entry.RequiredAttribute("Name").Value, parsedValue, entry.Attribute("ExtraDescription")?.Value)); + } + + builder.Add(node.RequiredAttribute("Name").Value, nodeBuilder.ToImmutable()); + continue; + } + } + else if (node.Name == "AbstractNode") + { + // Abstract nodes without explicit Include="true" are skipped + continue; + } + + // Implicit operation kind + operationKind++; + while (skippedOperationKinds.Contains(operationKind)) + { + operationKind++; + } + + var nodeName = node.RequiredAttribute("Name").Value; + var kindName = nodeName.Substring("I".Length, nodeName.Length - "I".Length - "Operation".Length); + builder.Add(nodeName, ImmutableArray.Create((kindName, operationKind, (string?)null))); + } + + return builder.ToImmutable(); + } + + private static ImmutableHashSet GetSkippedOperationKinds(XDocument document) + { + var builder = ImmutableHashSet.CreateBuilder(); + foreach (var skippedKind in document.XPathSelectElements("/Tree/UnusedOperationKinds/Entry")) + { + builder.Add(ParsePrefixHexValue(skippedKind.RequiredAttribute("Value").Value)); + } + + foreach (var explicitKind in document.XPathSelectElements("/Tree/*/OperationKind/Entry")) + { + builder.Add(ParsePrefixHexValue(explicitKind.RequiredAttribute("Value").Value)); + } + + return builder.ToImmutable(); + } + + private static int ParsePrefixHexValue(string value) + { + if (!value.StartsWith("0x")) + { + throw new InvalidOperationException($"Unexpected number format: '{value}'"); + } + + return int.Parse(value.Substring("0x".Length), NumberStyles.AllowHexSpecifier); + } + } + + private sealed class InterfaceData + { + private readonly DocumentData documentData; + + public InterfaceData(DocumentData documentData, XElement node, ImmutableArray<(string name, int value, string? extraDescription)> operationKinds) + { + this.documentData = documentData; + + this.OperationKinds = operationKinds; + this.InterfaceName = node.RequiredAttribute("Name").Value; + + if (node.Attribute("Namespace") is { } namespaceNode) + { + if (namespaceNode.Value == string.Empty) + { + this.Namespace = "Microsoft.CodeAnalysis"; + } + else + { + this.Namespace = $"Microsoft.CodeAnalysis.{namespaceNode.Value}"; + } + } + else + { + this.Namespace = "Microsoft.CodeAnalysis.Operations"; + } + + this.Name = this.InterfaceName.Substring("I".Length, this.InterfaceName.Length - "I".Length - "Operation".Length); + this.WrapperName = this.InterfaceName + "Wrapper"; + this.BaseInterfaceName = node.Attribute("Base")?.Value; + this.IsAbstract = node.Name == "AbstractNode"; + this.Properties = node.XPathSelectElements("Property").Select(property => new PropertyData(property)).ToImmutableArray(); + } + + public ImmutableArray<(string name, int value, string? extraDescription)> OperationKinds { get; } + + public string InterfaceName { get; } + + public string Namespace { get; } + + public string Name { get; } + + public string WrapperName { get; } + + public string? BaseInterfaceName { get; } + + public bool IsAbstract { get; } + + public ImmutableArray Properties { get; } + + public InterfaceData? BaseInterface + { + get + { + if (this.BaseInterfaceName is not null + && this.documentData.Interfaces.TryGetValue(this.BaseInterfaceName, out var baseInterface)) + { + return baseInterface; + } + + return null; + } + } + + public IEnumerable InheritedInterfaces + { + get + { + var inheritedInterfaces = new List(); + for (var baseDefinition = this.BaseInterface; baseDefinition is not null; baseDefinition = baseDefinition.BaseInterface) + { + inheritedInterfaces.Add(baseDefinition); + } + + inheritedInterfaces.Reverse(); + return inheritedInterfaces; + } + } + } + + private sealed class PropertyData + { + public PropertyData(XElement node) + { + this.Name = node.RequiredAttribute("Name").Value; + this.AccessorName = this.Name + "Accessor"; + this.Type = node.RequiredAttribute("Type").Value; + + this.IsNew = node.Attribute("New")?.Value == "true"; + this.IsPublicProperty = node.Attribute("Internal")?.Value != "true"; + + this.IsSkipped = this.Type switch + { + "ArgumentKind" => true, + "BinaryOperatorKind" => true, + "BranchKind" => true, + "CaptureId" => true, + "CaseKind" => true, + "CommonConversion" => true, + "ForEachLoopOperationInfo" => true, + "IDiscardSymbol" => true, + "InstanceReferenceKind" => true, + "LoopKind" => true, + "PlaceholderKind" => true, + "UnaryOperatorKind" => true, + _ => !this.IsPublicProperty, + }; + + this.NeedsAccessor = this.Name switch + { + nameof(IOperation.Kind) => false, + nameof(IOperation.Syntax) => false, + nameof(IOperation.Type) => false, + nameof(IOperation.ConstantValue) => false, + _ => true, + }; + this.NeedsWrapper = IsAnyOperation(this.Type) && this.Type != "IOperation"; + this.IsDerivedOperationArray = IsAnyOperationArray(this.Type) && this.Type != "ImmutableArray"; + + if (this.IsDerivedOperationArray) + { + this.AccessorResultType = SyntaxFactory.GenericName( + identifier: SyntaxFactory.Identifier("ImmutableArray"), + typeArgumentList: SyntaxFactory.TypeArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.IdentifierName("IOperation")))); + } + else if (IsAnyOperation(this.Type)) + { + this.AccessorResultType = SyntaxFactory.IdentifierName("IOperation"); + } + else + { + this.AccessorResultType = SyntaxFactory.ParseTypeName(this.Type); + } + } + + public bool IsNew { get; } + + public bool IsPublicProperty { get; } + + public bool IsSkipped { get; } + + public string Name { get; } + + public string AccessorName { get; } + + public string Type { get; } + + public bool NeedsAccessor { get; } + + public bool NeedsWrapper { get; } + + public bool IsDerivedOperationArray { get; } + + public TypeSyntax AccessorResultType { get; } + + private static bool IsAnyOperation(string type) + { + return type.StartsWith("I") && type.EndsWith("Operation"); + } + + private static bool IsAnyOperationArray(string type) + { + return type.StartsWith("ImmutableArray"); + } + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/Properties/AssemblyInfo.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..4e10fddc8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/Properties/AssemblyInfo.cs @@ -0,0 +1,15 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: CLSCompliant(false)] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/PublicAPI.Shipped.txt b/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/PublicAPI.Shipped.txt new file mode 100644 index 000000000..e69de29bb diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/PublicAPI.Unshipped.txt b/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/PublicAPI.Unshipped.txt new file mode 100644 index 000000000..e69de29bb diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/RoslynHashCode.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/RoslynHashCode.cs new file mode 100644 index 000000000..7edbcff4c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/RoslynHashCode.cs @@ -0,0 +1,462 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. +// + +#nullable enable + +// NOTE: This code is derived from an implementation originally in dotnet/runtime: +// https://github.com/dotnet/runtime/blob/v5.0.3/src/libraries/System.Private.CoreLib/src/System/HashCode.cs +// +// See the commentary in https://github.com/dotnet/roslyn/pull/50156 for notes on incorporating changes made to the +// reference implementation. + +/* + +The xxHash32 implementation is based on the code published by Yann Collet: +https://raw.githubusercontent.com/Cyan4973/xxHash/5c174cfa4e45a42f94082dc0d4539b39696afea1/xxhash.c + + xxHash - Fast Hash algorithm + Copyright (C) 2012-2016, Yann Collet + + BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + You can contact the author at : + - xxHash homepage: http://www.xxhash.com + - xxHash source repository : https://github.com/Cyan4973/xxHash + +*/ + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Security.Cryptography; + +namespace Analyzer.Utilities +{ + // xxHash32 is used for the hash code. + // https://github.com/Cyan4973/xxHash + + [SuppressMessage("Design", "CA1066:Implement IEquatable when overriding Object.Equals", Justification = "This type is not equatable.")] + [SuppressMessage("Performance", "CA1815:Override equals and operator equals on value types", Justification = "This type is not equatable.")] + [SuppressMessage("Usage", "CA2231:Overload operator equals on overriding value type Equals", Justification = "This type is not equatable.")] + internal struct RoslynHashCode + { + private static readonly uint s_seed = GenerateGlobalSeed(); + + private const uint Prime1 = 2654435761U; + private const uint Prime2 = 2246822519U; + private const uint Prime3 = 3266489917U; + private const uint Prime4 = 668265263U; + private const uint Prime5 = 374761393U; + + private uint _v1, _v2, _v3, _v4; + private uint _queue1, _queue2, _queue3; + private uint _length; + + private static uint GenerateGlobalSeed() + { + using var randomNumberGenerator = RandomNumberGenerator.Create(); + var array = new byte[sizeof(uint)]; + randomNumberGenerator.GetBytes(array); + return BitConverter.ToUInt32(array, 0); + } + + public static int Combine(T1 value1) + { + // Provide a way of diffusing bits from something with a limited + // input hash space. For example, many enums only have a few + // possible hashes, only using the bottom few bits of the code. Some + // collections are built on the assumption that hashes are spread + // over a larger space, so diffusing the bits may help the + // collection work more efficiently. + + var hc1 = (uint)(value1?.GetHashCode() ?? 0); + + var hash = MixEmptyState(); + hash += 4; + + hash = QueueRound(hash, hc1); + + hash = MixFinal(hash); + return (int)hash; + } + + public static int Combine(T1 value1, T2 value2) + { + var hc1 = (uint)(value1?.GetHashCode() ?? 0); + var hc2 = (uint)(value2?.GetHashCode() ?? 0); + + var hash = MixEmptyState(); + hash += 8; + + hash = QueueRound(hash, hc1); + hash = QueueRound(hash, hc2); + + hash = MixFinal(hash); + return (int)hash; + } + + public static int Combine(T1 value1, T2 value2, T3 value3) + { + var hc1 = (uint)(value1?.GetHashCode() ?? 0); + var hc2 = (uint)(value2?.GetHashCode() ?? 0); + var hc3 = (uint)(value3?.GetHashCode() ?? 0); + + var hash = MixEmptyState(); + hash += 12; + + hash = QueueRound(hash, hc1); + hash = QueueRound(hash, hc2); + hash = QueueRound(hash, hc3); + + hash = MixFinal(hash); + return (int)hash; + } + + public static int Combine(T1 value1, T2 value2, T3 value3, T4 value4) + { + var hc1 = (uint)(value1?.GetHashCode() ?? 0); + var hc2 = (uint)(value2?.GetHashCode() ?? 0); + var hc3 = (uint)(value3?.GetHashCode() ?? 0); + var hc4 = (uint)(value4?.GetHashCode() ?? 0); + + Initialize(out var v1, out var v2, out var v3, out var v4); + + v1 = Round(v1, hc1); + v2 = Round(v2, hc2); + v3 = Round(v3, hc3); + v4 = Round(v4, hc4); + + var hash = MixState(v1, v2, v3, v4); + hash += 16; + + hash = MixFinal(hash); + return (int)hash; + } + + public static int Combine(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5) + { + var hc1 = (uint)(value1?.GetHashCode() ?? 0); + var hc2 = (uint)(value2?.GetHashCode() ?? 0); + var hc3 = (uint)(value3?.GetHashCode() ?? 0); + var hc4 = (uint)(value4?.GetHashCode() ?? 0); + var hc5 = (uint)(value5?.GetHashCode() ?? 0); + + Initialize(out var v1, out var v2, out var v3, out var v4); + + v1 = Round(v1, hc1); + v2 = Round(v2, hc2); + v3 = Round(v3, hc3); + v4 = Round(v4, hc4); + + var hash = MixState(v1, v2, v3, v4); + hash += 20; + + hash = QueueRound(hash, hc5); + + hash = MixFinal(hash); + return (int)hash; + } + + public static int Combine(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6) + { + var hc1 = (uint)(value1?.GetHashCode() ?? 0); + var hc2 = (uint)(value2?.GetHashCode() ?? 0); + var hc3 = (uint)(value3?.GetHashCode() ?? 0); + var hc4 = (uint)(value4?.GetHashCode() ?? 0); + var hc5 = (uint)(value5?.GetHashCode() ?? 0); + var hc6 = (uint)(value6?.GetHashCode() ?? 0); + + Initialize(out var v1, out var v2, out var v3, out var v4); + + v1 = Round(v1, hc1); + v2 = Round(v2, hc2); + v3 = Round(v3, hc3); + v4 = Round(v4, hc4); + + var hash = MixState(v1, v2, v3, v4); + hash += 24; + + hash = QueueRound(hash, hc5); + hash = QueueRound(hash, hc6); + + hash = MixFinal(hash); + return (int)hash; + } + + public static int Combine(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7) + { + var hc1 = (uint)(value1?.GetHashCode() ?? 0); + var hc2 = (uint)(value2?.GetHashCode() ?? 0); + var hc3 = (uint)(value3?.GetHashCode() ?? 0); + var hc4 = (uint)(value4?.GetHashCode() ?? 0); + var hc5 = (uint)(value5?.GetHashCode() ?? 0); + var hc6 = (uint)(value6?.GetHashCode() ?? 0); + var hc7 = (uint)(value7?.GetHashCode() ?? 0); + + Initialize(out var v1, out var v2, out var v3, out var v4); + + v1 = Round(v1, hc1); + v2 = Round(v2, hc2); + v3 = Round(v3, hc3); + v4 = Round(v4, hc4); + + var hash = MixState(v1, v2, v3, v4); + hash += 28; + + hash = QueueRound(hash, hc5); + hash = QueueRound(hash, hc6); + hash = QueueRound(hash, hc7); + + hash = MixFinal(hash); + return (int)hash; + } + + public static int Combine(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8) + { + var hc1 = (uint)(value1?.GetHashCode() ?? 0); + var hc2 = (uint)(value2?.GetHashCode() ?? 0); + var hc3 = (uint)(value3?.GetHashCode() ?? 0); + var hc4 = (uint)(value4?.GetHashCode() ?? 0); + var hc5 = (uint)(value5?.GetHashCode() ?? 0); + var hc6 = (uint)(value6?.GetHashCode() ?? 0); + var hc7 = (uint)(value7?.GetHashCode() ?? 0); + var hc8 = (uint)(value8?.GetHashCode() ?? 0); + + Initialize(out var v1, out var v2, out var v3, out var v4); + + v1 = Round(v1, hc1); + v2 = Round(v2, hc2); + v3 = Round(v3, hc3); + v4 = Round(v4, hc4); + + v1 = Round(v1, hc5); + v2 = Round(v2, hc6); + v3 = Round(v3, hc7); + v4 = Round(v4, hc8); + + var hash = MixState(v1, v2, v3, v4); + hash += 32; + + hash = MixFinal(hash); + return (int)hash; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static void Initialize(out uint v1, out uint v2, out uint v3, out uint v4) + { + v1 = s_seed + Prime1 + Prime2; + v2 = s_seed + Prime2; + v3 = s_seed; + v4 = s_seed - Prime1; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static uint Round(uint hash, uint input) + { + return BitOperations.RotateLeft(hash + (input * Prime2), 13) * Prime1; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static uint QueueRound(uint hash, uint queuedValue) + { + return BitOperations.RotateLeft(hash + (queuedValue * Prime3), 17) * Prime4; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static uint MixState(uint v1, uint v2, uint v3, uint v4) + { + return BitOperations.RotateLeft(v1, 1) + BitOperations.RotateLeft(v2, 7) + BitOperations.RotateLeft(v3, 12) + BitOperations.RotateLeft(v4, 18); + } + + private static uint MixEmptyState() + { + return s_seed + Prime5; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static uint MixFinal(uint hash) + { + hash ^= hash >> 15; + hash *= Prime2; + hash ^= hash >> 13; + hash *= Prime3; + hash ^= hash >> 16; + return hash; + } + + public void Add(T value) + { + Add(value?.GetHashCode() ?? 0); + } + + public void Add(T value, IEqualityComparer? comparer) + { + Add(value is null ? 0 : (comparer?.GetHashCode(value) ?? value.GetHashCode())); + } + + private void Add(int value) + { + // The original xxHash works as follows: + // 0. Initialize immediately. We can't do this in a struct (no + // default ctor). + // 1. Accumulate blocks of length 16 (4 uints) into 4 accumulators. + // 2. Accumulate remaining blocks of length 4 (1 uint) into the + // hash. + // 3. Accumulate remaining blocks of length 1 into the hash. + + // There is no need for #3 as this type only accepts ints. _queue1, + // _queue2 and _queue3 are basically a buffer so that when + // ToHashCode is called we can execute #2 correctly. + + // We need to initialize the xxHash32 state (_v1 to _v4) lazily (see + // #0) nd the last place that can be done if you look at the + // original code is just before the first block of 16 bytes is mixed + // in. The xxHash32 state is never used for streams containing fewer + // than 16 bytes. + + // To see what's really going on here, have a look at the Combine + // methods. + + var val = (uint)value; + + // Storing the value of _length locally shaves of quite a few bytes + // in the resulting machine code. + var previousLength = _length++; + var position = previousLength % 4; + + // Switch can't be inlined. + + if (position == 0) + { + _queue1 = val; + } + else if (position == 1) + { + _queue2 = val; + } + else if (position == 2) + { + _queue3 = val; + } + else // position == 3 + { + if (previousLength == 3) + Initialize(out _v1, out _v2, out _v3, out _v4); + + _v1 = Round(_v1, _queue1); + _v2 = Round(_v2, _queue2); + _v3 = Round(_v3, _queue3); + _v4 = Round(_v4, val); + } + } + + public int ToHashCode() + { + // Storing the value of _length locally shaves of quite a few bytes + // in the resulting machine code. + var length = _length; + + // position refers to the *next* queue position in this method, so + // position == 1 means that _queue1 is populated; _queue2 would have + // been populated on the next call to Add. + var position = length % 4; + + // If the length is less than 4, _v1 to _v4 don't contain anything + // yet. xxHash32 treats this differently. + + var hash = length < 4 ? MixEmptyState() : MixState(_v1, _v2, _v3, _v4); + + // _length is incremented once per Add(Int32) and is therefore 4 + // times too small (xxHash length is in bytes, not ints). + + hash += length * 4; + + // Mix what remains in the queue + + // Switch can't be inlined right now, so use as few branches as + // possible by manually excluding impossible scenarios (position > 1 + // is always false if position is not > 0). + if (position > 0) + { + hash = QueueRound(hash, _queue1); + if (position > 1) + { + hash = QueueRound(hash, _queue2); + if (position > 2) + hash = QueueRound(hash, _queue3); + } + } + + hash = MixFinal(hash); + return (int)hash; + } + +#pragma warning disable CS0809 // Obsolete member overrides non-obsolete member +#pragma warning disable CA1065 // Do not raise exceptions in unexpected locations + // Obsolete member 'memberA' overrides non-obsolete member 'memberB'. + // Disallowing GetHashCode and Equals is by design + + // * We decided to not override GetHashCode() to produce the hash code + // as this would be weird, both naming-wise as well as from a + // behavioral standpoint (GetHashCode() should return the object's + // hash code, not the one being computed). + + // * Even though ToHashCode() can be called safely multiple times on + // this implementation, it is not part of the contract. If the + // implementation has to change in the future we don't want to worry + // about people who might have incorrectly used this type. + + [Obsolete("HashCode is a mutable struct and should not be compared with other HashCodes. Use ToHashCode to retrieve the computed hash code.", error: true)] + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => throw new NotSupportedException(SR.HashCode_HashCodeNotSupported); + + [Obsolete("HashCode is a mutable struct and should not be compared with other HashCodes.", error: true)] + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object? obj) => throw new NotSupportedException(SR.HashCode_EqualityNotSupported); +#pragma warning restore CA1065 // Do not raise exceptions in unexpected locations +#pragma warning restore CS0809 // Obsolete member overrides non-obsolete member + + private static class SR + { + public static string HashCode_HashCodeNotSupported = "HashCode is a mutable struct and should not be compared with other HashCodes. Use ToHashCode to retrieve the computed hash code."; + public static string HashCode_EqualityNotSupported = "HashCode is a mutable struct and should not be compared with other HashCodes."; + } + + private static class BitOperations + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static uint RotateLeft(uint value, int offset) + => (value << offset) | (value >> (32 - offset)); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ulong RotateLeft(ulong value, int offset) + => (value << offset) | (value >> (64 - offset)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.csproj b/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.csproj new file mode 100644 index 000000000..031e93489 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.csproj @@ -0,0 +1,24 @@ + + + + + netstandard2.0 + + + + ..\StyleCop.Analyzers.ruleset + + + + true + ..\..\build\keys\StyleCopAnalyzers.snk + + + + + + + + + + \ No newline at end of file diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/SyntaxLightupGenerator.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/SyntaxLightupGenerator.cs new file mode 100644 index 000000000..2f7987210 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/SyntaxLightupGenerator.cs @@ -0,0 +1,1599 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.CodeGeneration +{ + using System; + using System.Collections.Generic; + using System.Collections.Immutable; + using System.Diagnostics; + using System.Diagnostics.CodeAnalysis; + using System.IO; + using System.Linq; + using System.Text; + using System.Xml.Linq; + using System.Xml.XPath; + using Analyzer.Utilities; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + [Generator] + internal sealed class SyntaxLightupGenerator : IIncrementalGenerator + { + private enum NodeKind + { + Predefined, + Abstract, + Concrete, + } + + public void Initialize(IncrementalGeneratorInitializationContext context) + { + var referencedAssemblies = context.CompilationProvider.SelectMany( + static (compilation, cancellationToken) => + { + return compilation.SourceModule.ReferencedAssemblySymbols + .Where(reference => reference.Name is "Microsoft.CodeAnalysis" or "Microsoft.CodeAnalysis.CSharp"); + }); + + var existingTypesInReferences = referencedAssemblies.SelectMany( + static (reference, cancellationToken) => + { + var microsoftNamespace = reference.GlobalNamespace.GetNamespaceMembers().SingleOrDefault(symbol => symbol.Name == nameof(Microsoft)); + var microsoftCodeAnalysisNamespace = microsoftNamespace?.GetNamespaceMembers().SingleOrDefault(symbol => symbol.Name == nameof(Microsoft.CodeAnalysis)); + var microsoftCodeAnalysisCSharpNamespace = microsoftCodeAnalysisNamespace?.GetNamespaceMembers().SingleOrDefault(symbol => symbol.Name == nameof(Microsoft.CodeAnalysis.CSharp)); + var microsoftCodeAnalysisCSharpSyntaxNamespace = microsoftCodeAnalysisCSharpNamespace?.GetNamespaceMembers().SingleOrDefault(symbol => symbol.Name == nameof(Microsoft.CodeAnalysis.CSharp.Syntax)); + + var existingTypesBuilder = ImmutableArray.CreateBuilder(); + AddPublicTypesFromNamespace(microsoftNamespace, existingTypesBuilder); + AddPublicTypesFromNamespace(microsoftCodeAnalysisNamespace, existingTypesBuilder); + AddPublicTypesFromNamespace(microsoftCodeAnalysisCSharpNamespace, existingTypesBuilder); + AddPublicTypesFromNamespace(microsoftCodeAnalysisCSharpSyntaxNamespace, existingTypesBuilder); + + return existingTypesBuilder.ToImmutable(); + + static void AddPublicTypesFromNamespace(INamespaceSymbol? namespaceSymbol, ImmutableArray.Builder existingTypesBuilder) + { + if (namespaceSymbol is null) + { + return; + } + + foreach (var type in namespaceSymbol.GetTypeMembers()) + { + if (type is not { DeclaredAccessibility: Accessibility.Public }) + { + continue; + } + + existingTypesBuilder.Add(ExistingTypeData.FromNamedType(type, type.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat))); + } + } + }); + + var compilationData = existingTypesInReferences.Collect().Select( + static (existingTypes, cancellationToken) => + { + return new CompilationData( + ExistingTypesWrapper: new EquatableValue>( + existingTypes.ToImmutableDictionary(type => type.TypeName), + ImmutableDictionaryEqualityComparer.Default)); + }); + + var syntaxFiles = context.AdditionalTextsProvider.Where(static x => Path.GetFileName(x.Path) == "Syntax.xml"); + context.RegisterSourceOutput( + syntaxFiles.Combine(compilationData), + (context, value) => this.Execute(in context, value.Right, value.Left)); + } + + private void Execute(in SourceProductionContext context, CompilationData compilationData, AdditionalText syntaxFile) + { + var syntaxText = syntaxFile.GetText(context.CancellationToken); + if (syntaxText is null) + { + throw new InvalidOperationException("Failed to read Syntax.xml"); + } + + var syntaxData = new SyntaxData(compilationData, XDocument.Parse(syntaxText.ToString())); + this.GenerateSyntaxWrappers(in context, syntaxData); + this.GenerateSyntaxWrapperHelper(in context, syntaxData.Nodes); + } + + private void GenerateSyntaxWrappers(in SourceProductionContext context, SyntaxData syntaxData) + { + foreach (var node in syntaxData.Nodes) + { + this.GenerateSyntaxWrapper(in context, syntaxData, node); + } + } + + private void GenerateSyntaxWrapper(in SourceProductionContext context, SyntaxData syntaxData, NodeData nodeData) + { + if (nodeData.WrapperName is null) + { + // No need to generate a wrapper for this type + return; + } + + var concreteBase = syntaxData.TryGetConcreteBase(nodeData)?.Name ?? nameof(SyntaxNode); + + var members = SyntaxFactory.List(); + + // internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax"; + members = members.Add(SyntaxFactory.FieldDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.InternalKeyword), SyntaxFactory.Token(SyntaxKind.ConstKeyword)), + declaration: SyntaxFactory.VariableDeclaration( + type: SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.StringKeyword)), + variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator( + identifier: SyntaxFactory.Identifier("WrappedTypeName"), + argumentList: null, + initializer: SyntaxFactory.EqualsValueClause(SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal("Microsoft.CodeAnalysis.CSharp.Syntax." + nodeData.Name)))))))); + + // private static readonly Type WrappedType; + members = members.Add(SyntaxFactory.FieldDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PrivateKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword), SyntaxFactory.Token(SyntaxKind.ReadOnlyKeyword)), + declaration: SyntaxFactory.VariableDeclaration( + type: SyntaxFactory.IdentifierName("Type"), + variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator("WrappedType"))))); + + bool first = true; + foreach (var field in nodeData.Fields) + { + if (field.IsSkipped) + { + continue; + } + + if (field.IsOverride) + { + // The 'get' accessor is skipped for override fields + continue; + } + + // private static readonly Func FieldAccessor; + FieldDeclarationSyntax fieldAccessor = SyntaxFactory.FieldDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PrivateKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword), SyntaxFactory.Token(SyntaxKind.ReadOnlyKeyword)), + declaration: SyntaxFactory.VariableDeclaration( + type: SyntaxFactory.GenericName( + identifier: SyntaxFactory.Identifier("Func"), + typeArgumentList: SyntaxFactory.TypeArgumentList(SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.IdentifierName(concreteBase), + SyntaxFactory.ParseTypeName(field.GetAccessorResultType(syntaxData)), + }))), + variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator(field.AccessorName)))); + + if (first) + { + fieldAccessor = fieldAccessor.WithLeadingBlankLine(); + first = false; + } + + members = members.Add(fieldAccessor); + } + + foreach (var field in nodeData.Fields) + { + if (field.IsSkipped) + { + continue; + } + + // private static readonly Func WithFieldAccessor; + members = members.Add(SyntaxFactory.FieldDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PrivateKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword), SyntaxFactory.Token(SyntaxKind.ReadOnlyKeyword)), + declaration: SyntaxFactory.VariableDeclaration( + type: SyntaxFactory.GenericName( + identifier: SyntaxFactory.Identifier("Func"), + typeArgumentList: SyntaxFactory.TypeArgumentList(SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.IdentifierName(concreteBase), + SyntaxFactory.ParseTypeName(field.GetAccessorResultType(syntaxData)), + SyntaxFactory.IdentifierName(concreteBase), + }))), + variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator(field.WithAccessorName))))); + } + + // private readonly SyntaxNode node; + members = members.Add(SyntaxFactory.FieldDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PrivateKeyword), SyntaxFactory.Token(SyntaxKind.ReadOnlyKeyword)), + declaration: SyntaxFactory.VariableDeclaration( + type: SyntaxFactory.IdentifierName(concreteBase), + variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator("node")))).WithLeadingBlankLine()); + + // WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(SyntaxWrapper)); + var staticCtorStatements = SyntaxFactory.SingletonList( + SyntaxFactory.ExpressionStatement(SyntaxFactory.AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + left: SyntaxFactory.IdentifierName("WrappedType"), + right: SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("SyntaxWrapperHelper"), + name: SyntaxFactory.IdentifierName("GetWrappedType")), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument( + SyntaxFactory.TypeOfExpression(SyntaxFactory.IdentifierName(nodeData.WrapperName))))))))); + + foreach (var field in nodeData.Fields) + { + if (field.IsSkipped) + { + continue; + } + + if (field.IsOverride) + { + // The 'get' accessor is skipped for override fields + continue; + } + + SimpleNameSyntax helperName; + if (field.IsWrappedSeparatedSyntaxList(syntaxData, out var elementNode)) + { + Debug.Assert(elementNode.WrapperName is not null, $"Assertion failed: {nameof(elementNode)}.{nameof(elementNode.WrapperName)} is not null"); + + // CreateSeparatedSyntaxListPropertyAccessor + helperName = SyntaxFactory.GenericName( + identifier: SyntaxFactory.Identifier("CreateSeparatedSyntaxListPropertyAccessor"), + typeArgumentList: SyntaxFactory.TypeArgumentList(SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.IdentifierName(concreteBase), + SyntaxFactory.IdentifierName(elementNode.WrapperName), + }))); + } + else + { + // CreateSyntaxPropertyAccessor + helperName = SyntaxFactory.GenericName( + identifier: SyntaxFactory.Identifier("CreateSyntaxPropertyAccessor"), + typeArgumentList: SyntaxFactory.TypeArgumentList(SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.IdentifierName(concreteBase), + SyntaxFactory.ParseTypeName(field.GetAccessorResultType(syntaxData)), + }))); + } + + // ReturnTypeAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(ReturnType)); + staticCtorStatements = staticCtorStatements.Add(SyntaxFactory.ExpressionStatement(SyntaxFactory.AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + left: SyntaxFactory.IdentifierName(field.AccessorName), + right: SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("LightupHelpers"), + name: helperName), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.Argument(SyntaxFactory.IdentifierName("WrappedType")), + SyntaxFactory.Argument(SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.IdentifierName("nameof"), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument(SyntaxFactory.IdentifierName(field.Name)))))), + })))))); + } + + foreach (var field in nodeData.Fields) + { + if (field.IsSkipped) + { + continue; + } + + SimpleNameSyntax helperName; + if (field.IsWrappedSeparatedSyntaxList(syntaxData, out var elementNode)) + { + Debug.Assert(elementNode.WrapperName is not null, $"Assertion failed: {nameof(elementNode)}.{nameof(elementNode.WrapperName)} is not null"); + + // CreateSeparatedSyntaxListWithPropertyAccessor + helperName = SyntaxFactory.GenericName( + identifier: SyntaxFactory.Identifier("CreateSeparatedSyntaxListWithPropertyAccessor"), + typeArgumentList: SyntaxFactory.TypeArgumentList(SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.IdentifierName(concreteBase), + SyntaxFactory.IdentifierName(elementNode.WrapperName), + }))); + } + else + { + // CreateSyntaxWithPropertyAccessor + helperName = SyntaxFactory.GenericName( + identifier: SyntaxFactory.Identifier("CreateSyntaxWithPropertyAccessor"), + typeArgumentList: SyntaxFactory.TypeArgumentList(SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.IdentifierName(concreteBase), + SyntaxFactory.ParseTypeName(field.GetAccessorResultType(syntaxData)), + }))); + } + + // WithReturnTypeAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(ReturnType)); + staticCtorStatements = staticCtorStatements.Add(SyntaxFactory.ExpressionStatement(SyntaxFactory.AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + left: SyntaxFactory.IdentifierName(field.WithAccessorName), + right: SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("LightupHelpers"), + name: helperName), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.Argument(SyntaxFactory.IdentifierName("WrappedType")), + SyntaxFactory.Argument(SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.IdentifierName("nameof"), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument(SyntaxFactory.IdentifierName(field.Name)))))), + })))))); + } + + // static SyntaxWrapper() + // { + // WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(SyntaxWrapper)); + // } + members = members.Add(SyntaxFactory.ConstructorDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.StaticKeyword)), + identifier: SyntaxFactory.Identifier(nodeData.WrapperName), + parameterList: SyntaxFactory.ParameterList(), + initializer: null, + body: SyntaxFactory.Block(staticCtorStatements), + expressionBody: null).WithLeadingBlankLine()); + + // private SyntaxNodeWrapper(SyntaxNode node) + // { + // this.node = node; + // } + members = members.Add(SyntaxFactory.ConstructorDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PrivateKeyword)), + identifier: SyntaxFactory.Identifier(nodeData.WrapperName), + parameterList: SyntaxFactory.ParameterList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Parameter( + attributeLists: default, + modifiers: default, + type: SyntaxFactory.IdentifierName(concreteBase), + identifier: SyntaxFactory.Identifier("node"), + @default: null))), + initializer: null, + body: SyntaxFactory.Block( + SyntaxFactory.ExpressionStatement(SyntaxFactory.AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + left: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.ThisExpression(), + name: SyntaxFactory.IdentifierName("node")), + right: SyntaxFactory.IdentifierName("node")))), + expressionBody: null)); + + // public SyntaxNode SyntaxNode => this.node; + members = members.Add(SyntaxFactory.PropertyDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword)), + type: SyntaxFactory.IdentifierName(concreteBase), + explicitInterfaceSpecifier: null, + identifier: SyntaxFactory.Identifier("SyntaxNode"), + accessorList: null, + expressionBody: SyntaxFactory.ArrowExpressionClause(SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.ThisExpression(), + name: SyntaxFactory.IdentifierName("node"))), + initializer: null, + semicolonToken: SyntaxFactory.Token(SyntaxKind.SemicolonToken))); + + // public T Field + // { + // get + // { + // return ...; + // } + // } + first = true; + foreach (var field in nodeData.Fields) + { + if (field.IsSkipped) + { + continue; + } + + TypeSyntax propertyType = SyntaxFactory.ParseTypeName(field.GetAccessorResultType(syntaxData)); + ExpressionSyntax returnExpression; + if (field.IsOverride) + { + var declaringNode = field.GetDeclaringNode(syntaxData); + if (declaringNode.WrapperName is not null) + { + // ((CommonForEachStatementSyntaxWrapper)this).OpenParenToken + returnExpression = SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.ParenthesizedExpression( + SyntaxFactory.CastExpression( + type: SyntaxFactory.IdentifierName(declaringNode.WrapperName ?? declaringNode.Name), + expression: SyntaxFactory.ThisExpression())), + name: SyntaxFactory.IdentifierName(field.Name)); + } + else + { + // this.SyntaxNode.OpenParenToken + returnExpression = SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.ThisExpression(), + name: SyntaxFactory.IdentifierName("SyntaxNode")), + name: SyntaxFactory.IdentifierName(field.Name)); + + if (declaringNode.TryGetField(field.Name) is { IsExtensionField: true }) + { + // this.SyntaxNode.OpenParenToken() + returnExpression = SyntaxFactory.InvocationExpression( + expression: returnExpression, + argumentList: SyntaxFactory.ArgumentList()); + } + } + } + else if (field.IsWrappedSeparatedSyntaxList(syntaxData, out var elementNode)) + { + // PatternAccessor(this.SyntaxNode) + returnExpression = SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.IdentifierName(field.AccessorName), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument( + SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.ThisExpression(), + name: SyntaxFactory.IdentifierName("SyntaxNode")))))); + } + else if (syntaxData.TryGetNode(field.Type) is { } fieldNodeType) + { + // PatternAccessor(this.SyntaxNode) + returnExpression = SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.IdentifierName(field.AccessorName), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument( + SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.ThisExpression(), + name: SyntaxFactory.IdentifierName("SyntaxNode")))))); + + if (fieldNodeType.WrapperName is not null) + { + // (PatternSyntaxWrapper)... + propertyType = SyntaxFactory.IdentifierName(fieldNodeType.WrapperName); + returnExpression = SyntaxFactory.CastExpression( + type: SyntaxFactory.IdentifierName(fieldNodeType.WrapperName), + expression: returnExpression); + } + } + else + { + // PatternAccessor(this.SyntaxNode) + returnExpression = SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.IdentifierName(field.AccessorName), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument( + SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.ThisExpression(), + name: SyntaxFactory.IdentifierName("SyntaxNode")))))); + } + + // public T Field + // { + // get + // { + // return ...; + // } + // } + PropertyDeclarationSyntax property = SyntaxFactory.PropertyDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword)), + type: propertyType, + explicitInterfaceSpecifier: null, + identifier: SyntaxFactory.Identifier(field.Name), + accessorList: SyntaxFactory.AccessorList(SyntaxFactory.SingletonList(SyntaxFactory.AccessorDeclaration( + SyntaxKind.GetAccessorDeclaration, + SyntaxFactory.Block( + SyntaxFactory.ReturnStatement(returnExpression))))), + expressionBody: null, + initializer: null, + semicolonToken: default); + + if (first) + { + property = property.WithLeadingBlankLine(); + first = false; + } + + members = members.Add(property); + } + + for (var baseNode = syntaxData.TryGetNode(nodeData.BaseName); baseNode?.WrapperName is not null; baseNode = syntaxData.TryGetNode(baseNode.BaseName)) + { + // public static explicit operator SyntaxWrapper(BaseSyntaxWrapper node) + // { + // return (SyntaxWrapper)node.SyntaxNode; + // } + ConversionOperatorDeclarationSyntax wrapperConversion = SyntaxFactory.ConversionOperatorDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword)), + implicitOrExplicitKeyword: SyntaxFactory.Token(SyntaxKind.ExplicitKeyword), + operatorKeyword: SyntaxFactory.Token(SyntaxKind.OperatorKeyword), + type: SyntaxFactory.IdentifierName(nodeData.WrapperName), + parameterList: SyntaxFactory.ParameterList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Parameter( + attributeLists: default, + modifiers: default, + type: SyntaxFactory.IdentifierName(baseNode.WrapperName), + identifier: SyntaxFactory.Identifier("node"), + @default: null))), + body: SyntaxFactory.Block(SyntaxFactory.ReturnStatement( + SyntaxFactory.CastExpression( + type: SyntaxFactory.IdentifierName(nodeData.WrapperName), + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("node"), + name: SyntaxFactory.IdentifierName("SyntaxNode"))))), + expressionBody: null, + semicolonToken: default); + + if (first) + { + wrapperConversion = wrapperConversion.WithLeadingBlankLine(); + first = false; + } + + members = members.Add(wrapperConversion); + } + + // public static explicit operator WhenClauseSyntaxWrapper(SyntaxNode node) + // { + // if (node == null) + // { + // return default; + // } + // + // if (!IsInstance(node)) + // { + // throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + // } + // + // return new WhenClauseSyntaxWrapper((CSharpSyntaxNode)node); + // } + var nodeConversion = SyntaxFactory.ConversionOperatorDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword)), + implicitOrExplicitKeyword: SyntaxFactory.Token(SyntaxKind.ExplicitKeyword), + operatorKeyword: SyntaxFactory.Token(SyntaxKind.OperatorKeyword), + type: SyntaxFactory.IdentifierName(nodeData.WrapperName), + parameterList: SyntaxFactory.ParameterList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Parameter( + attributeLists: default, + modifiers: default, + type: SyntaxFactory.IdentifierName("SyntaxNode"), + identifier: SyntaxFactory.Identifier("node"), + @default: null))), + body: SyntaxFactory.Block( + SyntaxFactory.IfStatement( + condition: SyntaxFactory.BinaryExpression( + SyntaxKind.EqualsExpression, + left: SyntaxFactory.IdentifierName("node"), + right: SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)), + statement: SyntaxFactory.Block( + SyntaxFactory.ReturnStatement(SyntaxFactory.LiteralExpression(SyntaxKind.DefaultLiteralExpression)))), + SyntaxFactory.IfStatement( + condition: SyntaxFactory.PrefixUnaryExpression( + SyntaxKind.LogicalNotExpression, + operand: SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.IdentifierName("IsInstance"), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument(SyntaxFactory.IdentifierName("node")))))), + statement: SyntaxFactory.Block( + SyntaxFactory.ThrowStatement(SyntaxFactory.ObjectCreationExpression( + type: SyntaxFactory.IdentifierName("InvalidCastException"), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument( + SyntaxFactory.InterpolatedStringExpression( + SyntaxFactory.Token(SyntaxKind.InterpolatedStringStartToken), + SyntaxFactory.List(new InterpolatedStringContentSyntax[] + { + SyntaxFactory.InterpolatedStringText(SyntaxFactory.Token( + leading: default, + SyntaxKind.InterpolatedStringTextToken, + "Cannot cast '", + "Cannot cast '", + trailing: default)), + SyntaxFactory.Interpolation(SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("node"), + name: SyntaxFactory.IdentifierName("GetType")), + argumentList: SyntaxFactory.ArgumentList()), + name: SyntaxFactory.IdentifierName("FullName"))), + SyntaxFactory.InterpolatedStringText(SyntaxFactory.Token( + leading: default, + SyntaxKind.InterpolatedStringTextToken, + "' to '", + "' to '", + trailing: default)), + SyntaxFactory.Interpolation(SyntaxFactory.IdentifierName("WrappedTypeName")), + SyntaxFactory.InterpolatedStringText(SyntaxFactory.Token( + leading: default, + SyntaxKind.InterpolatedStringTextToken, + "'", + "'", + trailing: default)), + }))))), + initializer: null)))), + SyntaxFactory.ReturnStatement(SyntaxFactory.ObjectCreationExpression( + type: SyntaxFactory.IdentifierName(nodeData.WrapperName), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument( + SyntaxFactory.CastExpression( + type: SyntaxFactory.IdentifierName(concreteBase), + expression: SyntaxFactory.IdentifierName("node"))))), + initializer: null))), + expressionBody: null, + semicolonToken: default); + + if (first) + { + nodeConversion = nodeConversion.WithLeadingBlankLine(); + first = false; + } + + members = members.Add(nodeConversion); + + for (var baseNode = syntaxData.TryGetNode(nodeData.BaseName); baseNode?.WrapperName is not null; baseNode = syntaxData.TryGetNode(baseNode.BaseName)) + { + // public static implicit operator BaseSyntaxWrapper(SyntaxWrapper wrapper) + // { + // return BaseSyntaxWrapper.FromUpcast(wrapper.node); + // } + members = members.Add(SyntaxFactory.ConversionOperatorDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword)), + implicitOrExplicitKeyword: SyntaxFactory.Token(SyntaxKind.ImplicitKeyword), + operatorKeyword: SyntaxFactory.Token(SyntaxKind.OperatorKeyword), + type: SyntaxFactory.IdentifierName(baseNode.WrapperName), + parameterList: SyntaxFactory.ParameterList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Parameter( + attributeLists: default, + modifiers: default, + type: SyntaxFactory.IdentifierName(nodeData.WrapperName), + identifier: SyntaxFactory.Identifier("wrapper"), + @default: null))), + body: SyntaxFactory.Block(SyntaxFactory.ReturnStatement( + SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName(baseNode.WrapperName), + name: SyntaxFactory.IdentifierName("FromUpcast")), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument( + SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("wrapper"), + name: SyntaxFactory.IdentifierName("node")))))))), + expressionBody: null, + semicolonToken: default)); + } + + // public static implicit operator CSharpSyntaxNode(SyntaxWrapper wrapper) + // { + // return wrapper.node; + // } + members = members.Add(SyntaxFactory.ConversionOperatorDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword)), + implicitOrExplicitKeyword: SyntaxFactory.Token(SyntaxKind.ImplicitKeyword), + operatorKeyword: SyntaxFactory.Token(SyntaxKind.OperatorKeyword), + type: SyntaxFactory.IdentifierName(concreteBase), + parameterList: SyntaxFactory.ParameterList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Parameter( + attributeLists: default, + modifiers: default, + type: SyntaxFactory.IdentifierName(nodeData.WrapperName), + identifier: SyntaxFactory.Identifier("wrapper"), + @default: null))), + body: SyntaxFactory.Block(SyntaxFactory.ReturnStatement(SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("wrapper"), + name: SyntaxFactory.IdentifierName("node")))), + expressionBody: null, + semicolonToken: default)); + + // public static bool IsInstance(SyntaxNode node) + // { + // return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + // } + members = members.Add(SyntaxFactory.MethodDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword)), + returnType: SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.BoolKeyword)), + explicitInterfaceSpecifier: null, + identifier: SyntaxFactory.Identifier("IsInstance"), + typeParameterList: null, + parameterList: SyntaxFactory.ParameterList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Parameter( + attributeLists: default, + modifiers: default, + type: SyntaxFactory.IdentifierName("SyntaxNode"), + identifier: SyntaxFactory.Identifier("node"), + @default: null))), + constraintClauses: default, + body: SyntaxFactory.Block( + SyntaxFactory.ReturnStatement(SyntaxFactory.BinaryExpression( + SyntaxKind.LogicalAndExpression, + left: SyntaxFactory.BinaryExpression( + SyntaxKind.NotEqualsExpression, + left: SyntaxFactory.IdentifierName("node"), + right: SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)), + right: SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("LightupHelpers"), + name: SyntaxFactory.IdentifierName("CanWrapNode")), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.Argument(SyntaxFactory.IdentifierName("node")), + SyntaxFactory.Argument(SyntaxFactory.IdentifierName("WrappedType")), + })))))), + expressionBody: null)); + + foreach (var field in nodeData.Fields) + { + if (field.IsSkipped) + { + continue; + } + + string valueName = char.ToLowerInvariant(field.Name[0]) + field.Name.Substring(1); + + ExpressionSyntax convertedValue = SyntaxFactory.IdentifierName(valueName); + + TypeSyntax propertyType = SyntaxFactory.ParseTypeName(field.GetAccessorResultType(syntaxData)); + if (syntaxData.TryGetNode(field.Type) is { WrapperName: { } wrapperName }) + { + propertyType = SyntaxFactory.IdentifierName(wrapperName); + } + + ExpressionSyntax returnExpression = SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.IdentifierName(field.WithAccessorName), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.Argument(SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.ThisExpression(), + name: SyntaxFactory.IdentifierName("SyntaxNode"))), + SyntaxFactory.Argument(convertedValue), + }))); + + // public SyntaxWrapper WithField(T value) + // { + // return new SyntaxWrapper(...); + // } + members = members.Add(SyntaxFactory.MethodDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword)), + returnType: SyntaxFactory.IdentifierName(nodeData.WrapperName), + explicitInterfaceSpecifier: null, + identifier: SyntaxFactory.Identifier("With" + field.Name), + typeParameterList: null, + parameterList: SyntaxFactory.ParameterList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Parameter( + attributeLists: default, + modifiers: default, + type: propertyType, + identifier: SyntaxFactory.Identifier(valueName), + @default: null))), + constraintClauses: default, + body: SyntaxFactory.Block(SyntaxFactory.ReturnStatement( + SyntaxFactory.ObjectCreationExpression( + type: SyntaxFactory.IdentifierName(nodeData.WrapperName), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument(returnExpression))), + initializer: null))), + expressionBody: null, + semicolonToken: default)); + } + + if (nodeData.Kind == NodeKind.Abstract) + { + // internal static SyntaxWrapper FromUpcast(CSharpSyntaxNode node) + // { + // return new SyntaxWrapper(node); + // } + members = members.Add(SyntaxFactory.MethodDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.InternalKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword)), + returnType: SyntaxFactory.IdentifierName(nodeData.WrapperName), + explicitInterfaceSpecifier: null, + identifier: SyntaxFactory.Identifier("FromUpcast"), + typeParameterList: null, + parameterList: SyntaxFactory.ParameterList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Parameter( + attributeLists: default, + modifiers: default, + type: SyntaxFactory.IdentifierName(concreteBase), + identifier: SyntaxFactory.Identifier("node"), + @default: null))), + constraintClauses: default, + body: SyntaxFactory.Block( + SyntaxFactory.ReturnStatement(SyntaxFactory.ObjectCreationExpression( + type: SyntaxFactory.IdentifierName(nodeData.WrapperName), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument(SyntaxFactory.IdentifierName("node")))), + initializer: null))), + expressionBody: null)); + } + + var wrapperStruct = SyntaxFactory.StructDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.InternalKeyword), SyntaxFactory.Token(SyntaxKind.ReadOnlyKeyword), SyntaxFactory.Token(SyntaxKind.PartialKeyword)), + identifier: SyntaxFactory.Identifier(nodeData.WrapperName), + typeParameterList: null, + baseList: SyntaxFactory.BaseList(SyntaxFactory.SingletonSeparatedList( + SyntaxFactory.SimpleBaseType(SyntaxFactory.GenericName( + identifier: SyntaxFactory.Identifier("ISyntaxWrapper"), + typeArgumentList: SyntaxFactory.TypeArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.IdentifierName(concreteBase))))))), + constraintClauses: default, + members: members); + var wrapperNamespace = SyntaxFactory.NamespaceDeclaration( + name: SyntaxFactory.ParseName("StyleCop.Analyzers.Lightup"), + externs: default, + usings: SyntaxFactory.List() + .Add(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("System"))) + .Add(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("System.Collections.Immutable"))) + .Add(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("Microsoft.CodeAnalysis"))) + .Add(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("Microsoft.CodeAnalysis.CSharp"))) + .Add(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("Microsoft.CodeAnalysis.CSharp.Syntax"))), + members: SyntaxFactory.SingletonList(wrapperStruct)); + + wrapperNamespace = wrapperNamespace + .NormalizeWhitespace() + .WithLeadingTrivia( + SyntaxFactory.Comment("// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved."), + SyntaxFactory.CarriageReturnLineFeed, + SyntaxFactory.Comment("// Licensed under the MIT License. See LICENSE in the project root for license information."), + SyntaxFactory.CarriageReturnLineFeed, + SyntaxFactory.CarriageReturnLineFeed) + .WithTrailingTrivia( + SyntaxFactory.CarriageReturnLineFeed); + + context.AddSource(nodeData.WrapperName + ".g.cs", wrapperNamespace.GetText(Encoding.UTF8)); + } + + private void GenerateSyntaxWrapperHelper(in SourceProductionContext context, ImmutableArray wrapperTypes) + { + // private static readonly ImmutableDictionary WrappedTypes; + var wrappedTypes = SyntaxFactory.FieldDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PrivateKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword), SyntaxFactory.Token(SyntaxKind.ReadOnlyKeyword)), + declaration: SyntaxFactory.VariableDeclaration( + type: SyntaxFactory.GenericName( + identifier: SyntaxFactory.Identifier("ImmutableDictionary"), + typeArgumentList: SyntaxFactory.TypeArgumentList( + SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.IdentifierName("Type"), + SyntaxFactory.IdentifierName("Type"), + }))), + variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator(SyntaxFactory.Identifier("WrappedTypes"))))); + + // var csharpCodeAnalysisAssembly = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly; + // var builder = ImmutableDictionary.CreateBuilder(); + var staticCtorStatements = SyntaxFactory.List() + .Add(SyntaxFactory.LocalDeclarationStatement(SyntaxFactory.VariableDeclaration( + type: SyntaxFactory.IdentifierName("var"), + variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator( + identifier: SyntaxFactory.Identifier("csharpCodeAnalysisAssembly"), + argumentList: null, + initializer: SyntaxFactory.EqualsValueClause( + SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.InvocationExpression( + SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.TypeOfExpression(SyntaxFactory.IdentifierName("CSharpSyntaxNode")), + name: SyntaxFactory.IdentifierName("GetTypeInfo"))), + name: SyntaxFactory.IdentifierName("Assembly")))))))) + .Add(SyntaxFactory.LocalDeclarationStatement(SyntaxFactory.VariableDeclaration( + type: SyntaxFactory.IdentifierName("var"), + variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator( + identifier: SyntaxFactory.Identifier("builder"), + argumentList: null, + initializer: SyntaxFactory.EqualsValueClause( + SyntaxFactory.InvocationExpression( + SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("ImmutableDictionary"), + name: SyntaxFactory.GenericName( + identifier: SyntaxFactory.Identifier("CreateBuilder"), + typeArgumentList: SyntaxFactory.TypeArgumentList( + SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.IdentifierName("Type"), + SyntaxFactory.IdentifierName("Type"), + }))))))))))); + + foreach (var node in wrapperTypes.OrderBy(node => node.Name, StringComparer.OrdinalIgnoreCase)) + { + if (node.WrapperName is null) + { + continue; + } + + if (node.Name == nameof(CommonForEachStatementSyntax)) + { + // Prior to C# 7, ForEachStatementSyntax was the base type for all foreach statements. If + // the CommonForEachStatementSyntax type isn't found at runtime, we fall back to using this type instead. + // + // var forEachStatementSyntaxType = csharpCodeAnalysisAssembly.GetType(CommonForEachStatementSyntaxWrapper.WrappedTypeName) + // ?? csharpCodeAnalysisAssembly.GetType(CommonForEachStatementSyntaxWrapper.FallbackWrappedTypeName); + staticCtorStatements = staticCtorStatements.Add( + SyntaxFactory.LocalDeclarationStatement(SyntaxFactory.VariableDeclaration( + type: SyntaxFactory.IdentifierName("var"), + variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator( + identifier: SyntaxFactory.Identifier("forEachStatementSyntaxType"), + argumentList: null, + initializer: SyntaxFactory.EqualsValueClause( + SyntaxFactory.BinaryExpression( + SyntaxKind.CoalesceExpression, + left: SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("csharpCodeAnalysisAssembly"), + name: SyntaxFactory.IdentifierName("GetType")), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument( + SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName(node.WrapperName), + name: SyntaxFactory.IdentifierName("WrappedTypeName")))))), + right: SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("csharpCodeAnalysisAssembly"), + name: SyntaxFactory.IdentifierName("GetType")), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument( + SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName(node.WrapperName), + name: SyntaxFactory.IdentifierName("FallbackWrappedTypeName"))))))))))))); + + // builder.Add(typeof(CommonForEachStatementSyntaxWrapper), forEachStatementSyntaxType); + staticCtorStatements = staticCtorStatements.Add(SyntaxFactory.ExpressionStatement( + SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("builder"), + name: SyntaxFactory.IdentifierName("Add")), + argumentList: SyntaxFactory.ArgumentList( + SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.Argument(SyntaxFactory.TypeOfExpression(SyntaxFactory.IdentifierName(node.WrapperName))), + SyntaxFactory.Argument(SyntaxFactory.IdentifierName("forEachStatementSyntaxType")), + }))))); + + continue; + } + + if (node.Name == nameof(BaseObjectCreationExpressionSyntax)) + { + // Prior to C# 9, ObjectCreationExpressionSyntax was the base type for all object creation + // statements. If the BaseObjectCreationExpressionSyntax type isn't found at runtime, we fall back + // to using this type instead. + // + // var objectCreationExpressionSyntaxType = csharpCodeAnalysisAssembly.GetType(BaseObjectCreationExpressionSyntaxWrapper.WrappedTypeName) + // ?? csharpCodeAnalysisAssembly.GetType(BaseObjectCreationExpressionSyntaxWrapper.FallbackWrappedTypeName); + LocalDeclarationStatementSyntax localStatement = + SyntaxFactory.LocalDeclarationStatement(SyntaxFactory.VariableDeclaration( + type: SyntaxFactory.IdentifierName("var"), + variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator( + identifier: SyntaxFactory.Identifier("objectCreationExpressionSyntaxType"), + argumentList: null, + initializer: SyntaxFactory.EqualsValueClause( + SyntaxFactory.BinaryExpression( + SyntaxKind.CoalesceExpression, + left: SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("csharpCodeAnalysisAssembly"), + name: SyntaxFactory.IdentifierName("GetType")), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument( + SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName(node.WrapperName), + name: SyntaxFactory.IdentifierName("WrappedTypeName")))))), + right: SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("csharpCodeAnalysisAssembly"), + name: SyntaxFactory.IdentifierName("GetType")), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument( + SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName(node.WrapperName), + name: SyntaxFactory.IdentifierName("FallbackWrappedTypeName")))))))))))); + + // This is the first line of the statements that initialize 'builder', so start it with a blank line + staticCtorStatements = staticCtorStatements.Add(localStatement.WithLeadingBlankLine()); + + // builder.Add(typeof(BaseObjectCreationExpressionSyntaxWrapper), objectCreationExpressionSyntaxType); + staticCtorStatements = staticCtorStatements.Add(SyntaxFactory.ExpressionStatement( + SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("builder"), + name: SyntaxFactory.IdentifierName("Add")), + argumentList: SyntaxFactory.ArgumentList( + SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.Argument(SyntaxFactory.TypeOfExpression(SyntaxFactory.IdentifierName(node.WrapperName))), + SyntaxFactory.Argument(SyntaxFactory.IdentifierName("objectCreationExpressionSyntaxType")), + }))))); + + continue; + } + + if (node.Name == nameof(BaseNamespaceDeclarationSyntax)) + { + // Prior to C# 10, NamespaceDeclarationSyntax was the base type for all namespace declarations. + // If the BaseNamespaceDeclarationSyntax type isn't found at runtime, we fall back + // to using this type instead. + // + // var baseNamespaceDeclarationSyntaxType = csharpCodeAnalysisAssembly.GetType(BaseNamespaceDeclarationSyntaxWrapper.WrappedTypeName) + // ?? csharpCodeAnalysisAssembly.GetType(BaseNamespaceDeclarationSyntaxWrapper.WrappedTypeName); + LocalDeclarationStatementSyntax localStatement = + SyntaxFactory.LocalDeclarationStatement(SyntaxFactory.VariableDeclaration( + type: SyntaxFactory.IdentifierName("var"), + variables: SyntaxFactory.SingletonSeparatedList(SyntaxFactory.VariableDeclarator( + identifier: SyntaxFactory.Identifier("baseNamespaceDeclarationSyntaxType"), + argumentList: null, + initializer: SyntaxFactory.EqualsValueClause( + SyntaxFactory.BinaryExpression( + SyntaxKind.CoalesceExpression, + left: SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("csharpCodeAnalysisAssembly"), + name: SyntaxFactory.IdentifierName("GetType")), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument( + SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName(node.WrapperName), + name: SyntaxFactory.IdentifierName("WrappedTypeName")))))), + right: SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("csharpCodeAnalysisAssembly"), + name: SyntaxFactory.IdentifierName("GetType")), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument( + SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName(node.WrapperName), + name: SyntaxFactory.IdentifierName("FallbackWrappedTypeName")))))))))))); + + // This is the first line of the statements that initialize 'builder', so start it with a blank line + staticCtorStatements = staticCtorStatements.Add(localStatement.WithLeadingBlankLine()); + + // builder.Add(typeof(BaseNamespaceDeclarationSyntaxWrapper), baseNamespaceDeclarationSyntaxType); + staticCtorStatements = staticCtorStatements.Add(SyntaxFactory.ExpressionStatement( + SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("builder"), + name: SyntaxFactory.IdentifierName("Add")), + argumentList: SyntaxFactory.ArgumentList( + SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.Argument(SyntaxFactory.TypeOfExpression(SyntaxFactory.IdentifierName(node.WrapperName))), + SyntaxFactory.Argument(SyntaxFactory.IdentifierName("baseNamespaceDeclarationSyntaxType")), + }))))); + + continue; + } + + // builder.Add(typeof(ConstantPatternSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(ConstantPatternSyntaxWrapper.WrappedTypeName)); + staticCtorStatements = staticCtorStatements.Add(SyntaxFactory.ExpressionStatement( + SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("builder"), + name: SyntaxFactory.IdentifierName("Add")), + argumentList: SyntaxFactory.ArgumentList( + SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.Argument(SyntaxFactory.TypeOfExpression(SyntaxFactory.IdentifierName(node.WrapperName))), + SyntaxFactory.Argument( + SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("csharpCodeAnalysisAssembly"), + name: SyntaxFactory.IdentifierName("GetType")), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Argument( + SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName(node.WrapperName), + name: SyntaxFactory.IdentifierName("WrappedTypeName"))))))), + }))))); + } + + // WrappedTypes = builder.ToImmutable(); + staticCtorStatements = staticCtorStatements.Add(SyntaxFactory.ExpressionStatement( + SyntaxFactory.AssignmentExpression( + SyntaxKind.SimpleAssignmentExpression, + left: SyntaxFactory.IdentifierName("WrappedTypes"), + right: SyntaxFactory.InvocationExpression( + SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("builder"), + name: SyntaxFactory.IdentifierName("ToImmutable"))))).WithLeadingBlankLine()); + + var staticCtor = SyntaxFactory.ConstructorDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.StaticKeyword)), + identifier: SyntaxFactory.Identifier("SyntaxWrapperHelper"), + parameterList: SyntaxFactory.ParameterList(), + initializer: null, + body: SyntaxFactory.Block(staticCtorStatements), + expressionBody: null).WithLeadingBlankLine(); + + // /// + // /// Gets the type that is wrapped by the given wrapper. + // /// + // /// Type of the wrapper for which the wrapped type should be retrieved. + // /// The wrapped type, or null if there is no info. + // internal static Type GetWrappedType(Type wrapperType) + // { + // if (WrappedTypes.TryGetValue(wrapperType, out Type wrappedType)) + // { + // return wrappedType; + // } + // + // return null; + // } + var getWrappedType = SyntaxFactory.MethodDeclaration( + attributeLists: default, + modifiers: SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.InternalKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword)), + returnType: SyntaxFactory.IdentifierName("Type"), + explicitInterfaceSpecifier: null, + identifier: SyntaxFactory.Identifier("GetWrappedType"), + typeParameterList: null, + parameterList: SyntaxFactory.ParameterList(SyntaxFactory.SingletonSeparatedList(SyntaxFactory.Parameter( + attributeLists: default, + modifiers: default, + type: SyntaxFactory.IdentifierName("Type"), + identifier: SyntaxFactory.Identifier("wrapperType"), + @default: null))), + constraintClauses: default, + body: SyntaxFactory.Block( + SyntaxFactory.IfStatement( + condition: SyntaxFactory.InvocationExpression( + expression: SyntaxFactory.MemberAccessExpression( + SyntaxKind.SimpleMemberAccessExpression, + expression: SyntaxFactory.IdentifierName("WrappedTypes"), + name: SyntaxFactory.IdentifierName("TryGetValue")), + argumentList: SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList( + new[] + { + SyntaxFactory.Argument(SyntaxFactory.IdentifierName("wrapperType")), + SyntaxFactory.Argument( + nameColon: null, + refKindKeyword: SyntaxFactory.Token(SyntaxKind.OutKeyword), + expression: SyntaxFactory.DeclarationExpression( + type: SyntaxFactory.IdentifierName("Type"), + designation: SyntaxFactory.SingleVariableDesignation(SyntaxFactory.Identifier("wrappedType")))), + }))), + statement: SyntaxFactory.Block( + SyntaxFactory.ReturnStatement(SyntaxFactory.IdentifierName("wrappedType")))), + SyntaxFactory.ReturnStatement(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))), + expressionBody: null); + + getWrappedType = getWrappedType.WithLeadingTrivia(SyntaxFactory.TriviaList( + SyntaxFactory.Trivia(SyntaxFactory.DocumentationComment( + SyntaxFactory.XmlText(" "), + SyntaxFactory.XmlSummaryElement( + SyntaxFactory.XmlText(XmlSyntaxFactory.XmlCarriageReturnLineFeedWithContinuation), + SyntaxFactory.XmlText(" Gets the type that is wrapped by the given wrapper."), + SyntaxFactory.XmlText(XmlSyntaxFactory.XmlCarriageReturnLineFeedWithContinuation), + SyntaxFactory.XmlText(" ")), + SyntaxFactory.XmlText(XmlSyntaxFactory.XmlCarriageReturnLineFeedWithContinuation), + SyntaxFactory.XmlText(" "), + SyntaxFactory.XmlParamElement( + "wrapperType", + SyntaxFactory.XmlText("Type of the wrapper for which the wrapped type should be retrieved.")), + SyntaxFactory.XmlText(XmlSyntaxFactory.XmlCarriageReturnLineFeedWithContinuation), + SyntaxFactory.XmlText(" "), + SyntaxFactory.XmlReturnsElement( + SyntaxFactory.XmlText("The wrapped type, or null if there is no info.")), + SyntaxFactory.XmlText(XmlSyntaxFactory.XmlCarriageReturnLineFeedWithContinuation).WithoutTrailingTrivia())))); + + var wrapperHelperClass = SyntaxFactory.ClassDeclaration( + attributeLists: default, + modifiers: SyntaxTokenList.Create(SyntaxFactory.Token(SyntaxKind.InternalKeyword)).Add(SyntaxFactory.Token(SyntaxKind.StaticKeyword)), + identifier: SyntaxFactory.Identifier("SyntaxWrapperHelper"), + typeParameterList: null, + baseList: null, + constraintClauses: default, + members: SyntaxFactory.List() + .Add(wrappedTypes) + .Add(staticCtor) + .Add(getWrappedType)); + var wrapperNamespace = SyntaxFactory.NamespaceDeclaration( + name: SyntaxFactory.ParseName("StyleCop.Analyzers.Lightup"), + externs: default, + usings: SyntaxFactory.List() + .Add(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("System"))) + .Add(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("System.Collections.Immutable"))) + .Add(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("System.Reflection"))) + .Add(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("Microsoft.CodeAnalysis"))) + .Add(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("Microsoft.CodeAnalysis.CSharp"))), + members: SyntaxFactory.SingletonList(wrapperHelperClass)); + + wrapperNamespace = wrapperNamespace + .NormalizeWhitespace() + .WithLeadingTrivia( + SyntaxFactory.Comment("// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved."), + SyntaxFactory.CarriageReturnLineFeed, + SyntaxFactory.Comment("// Licensed under the MIT License. See LICENSE in the project root for license information."), + SyntaxFactory.CarriageReturnLineFeed, + SyntaxFactory.CarriageReturnLineFeed) + .WithTrailingTrivia( + SyntaxFactory.CarriageReturnLineFeed); + + context.AddSource("SyntaxWrapperHelper.g.cs", wrapperNamespace.GetText(Encoding.UTF8)); + } + + private sealed class SyntaxData + { + private readonly Dictionary nameToNode; + + public SyntaxData(CompilationData compilationData, XDocument document) + { + var nodesBuilder = ImmutableArray.CreateBuilder(); + if (document.XPathSelectElement("/Tree[@Root='SyntaxNode']") is { } tree) + { + foreach (var element in tree.XPathSelectElements("PredefinedNode|AbstractNode|Node")) + { + nodesBuilder.Add(new NodeData(compilationData, element)); + } + } + + this.Nodes = nodesBuilder.ToImmutable(); + this.nameToNode = this.Nodes.ToDictionary(node => node.Name); + } + + public ImmutableArray Nodes { get; } + + public NodeData? TryGetConcreteType(NodeData? node) + { + for (var current = node; current is not null; current = this.TryGetNode(current.BaseName)) + { + if (current.WrapperName is null) + { + // This is not a wrapper + return current; + } + } + + return null; + } + + public NodeData? TryGetConcreteBase(NodeData node) + { + return this.TryGetConcreteType(this.TryGetNode(node.BaseName)); + } + + public NodeData? TryGetNode(string name) + { + this.nameToNode.TryGetValue(name, out var node); + return node; + } + } + + private sealed class NodeData + { + public NodeData(CompilationData compilationData, XElement element) + { + this.Kind = element.Name.LocalName switch + { + "PredefinedNode" => NodeKind.Predefined, + "AbstractNode" => NodeKind.Abstract, + "Node" => NodeKind.Concrete, + _ => throw new NotSupportedException($"Unknown element name '{element.Name}'"), + }; + + this.Name = element.RequiredAttribute("Name").Value; + + this.ExistingType = compilationData.ExistingTypes.GetValueOrDefault($"Microsoft.CodeAnalysis.CSharp.Syntax.{this.Name}") + ?? compilationData.ExistingTypes.GetValueOrDefault($"Microsoft.CodeAnalysis.CSharp.{this.Name}") + ?? compilationData.ExistingTypes.GetValueOrDefault($"Microsoft.CodeAnalysis.{this.Name}"); + if (this.ExistingType is not null) + { + this.WrapperName = null; + } + else + { + this.WrapperName = this.Name + "Wrapper"; + } + + this.BaseName = element.RequiredAttribute("Base").Value; + this.Fields = element.XPathSelectElements("descendant::Field").Select(field => new FieldData(this, field)).ToImmutableArray(); + } + + public NodeKind Kind { get; } + + public string Name { get; } + + public ExistingTypeData? ExistingType { get; } + + public string? WrapperName { get; } + + public string BaseName { get; } + + public ImmutableArray Fields { get; } + + internal FieldData? TryGetField(string name) + { + return this.Fields.SingleOrDefault(field => field.Name == name); + } + } + + private sealed class FieldData + { + private readonly NodeData nodeData; + + public FieldData(NodeData nodeData, XElement element) + { + this.nodeData = nodeData; + + this.Name = element.RequiredAttribute("Name").Value; + + var type = element.RequiredAttribute("Type").Value; + this.Type = type switch + { + "SyntaxList" => nameof(SyntaxTokenList), + _ => type, + }; + + this.IsOverride = element.Attribute("Override")?.Value == "true"; + + this.AccessorName = this.Name + "Accessor"; + this.WithAccessorName = "With" + this.Name + "Accessor"; + } + + public bool IsSkipped => false; + + public string Name { get; } + + public string AccessorName { get; } + + public string WithAccessorName { get; } + + public string Type { get; } + + public bool IsOverride { get; } + + /// + /// Gets a value indicating whether this field is implemented as an extension method in the lightup layer. + /// + public bool IsExtensionField + { + get + { + return this.nodeData.ExistingType is not null + && !this.nodeData.ExistingType.MemberNames.Contains(this.Name); + } + } + + public NodeData GetDeclaringNode(SyntaxData syntaxData) + { + for (var current = this.nodeData; current is not null; current = syntaxData.TryGetNode(current.BaseName)) + { + var currentField = current.TryGetField(this.Name); + if (currentField is { IsOverride: false }) + { + return currentField.nodeData; + } + } + + throw new NotSupportedException("Unable to find declaring node."); + } + + public bool IsWrappedSeparatedSyntaxList(SyntaxData syntaxData, [NotNullWhen(true)] out NodeData? element) + { + if (this.Type.StartsWith("SeparatedSyntaxList<") && this.Type.EndsWith(">")) + { + var elementTypeName = this.Type.Substring("SeparatedSyntaxList<".Length, this.Type.Length - "SeparatedSyntaxList<".Length - ">".Length); + var elementTypeNode = syntaxData.TryGetNode(elementTypeName); + if (elementTypeNode is { WrapperName: not null }) + { + element = elementTypeNode; + return true; + } + } + + element = null; + return false; + } + + public string GetAccessorResultType(SyntaxData syntaxData) + { + var typeNode = syntaxData.TryGetNode(this.Type); + if (typeNode is not null) + { + return syntaxData.TryGetConcreteType(typeNode)?.Name ?? nameof(SyntaxNode); + } + + if (this.IsWrappedSeparatedSyntaxList(syntaxData, out var elementTypeNode)) + { + return $"SeparatedSyntaxListWrapper<{elementTypeNode.WrapperName}>"; + } + + return this.Type; + } + + public string? GetAccessorResultElementType(SyntaxData syntaxData) + { + if (this.IsWrappedSeparatedSyntaxList(syntaxData, out var elementTypeNode)) + { + return elementTypeNode.WrapperName; + } + + return null; + } + } + + private sealed record CompilationData(EquatableValue> ExistingTypesWrapper) + { + public ImmutableDictionary ExistingTypes => this.ExistingTypesWrapper.Value; + } + + private sealed record ExistingTypeData(string TypeName, EquatableValue> MemberNamesWrapper) + { + public ImmutableArray MemberNames => this.MemberNamesWrapper.Value; + + public static ExistingTypeData FromNamedType(INamedTypeSymbol namedType, string typeName) + { + var memberNames = ImmutableArray.CreateRange(namedType.GetMembers(), member => member.Name); + return new ExistingTypeData( + TypeName: typeName, + MemberNamesWrapper: new EquatableValue>(memberNames, ImmutableArrayEqualityComparer.Default)); + } + } + + private sealed class EquatableValue : IEquatable?> + { + public EquatableValue(T value, IEqualityComparer comparer) + { + this.Value = value; + this.Comparer = comparer; + } + + public T Value { get; } + + public IEqualityComparer Comparer { get; } + + public bool Equals(EquatableValue? other) + { + if (other is null) + { + return false; + } + + return this.Comparer.Equals(this.Value, other.Value); + } + } + + private sealed class ImmutableDictionaryEqualityComparer : IEqualityComparer?> + where TKey : notnull + { + public static ImmutableDictionaryEqualityComparer Default { get; } = new ImmutableDictionaryEqualityComparer(); + + public bool Equals(ImmutableDictionary? x, ImmutableDictionary? y) + { + if (x == y) + { + return true; + } + else if (x is null || y is null) + { + return false; + } + else if (x.Count != y.Count) + { + return false; + } + + var keyEqualityComparer = EqualityComparer.Default; + var valueEqualityComparer = EqualityComparer.Default; + + using var first = x.GetEnumerator(); + using var second = y.GetEnumerator(); + while (first.MoveNext() && second.MoveNext()) + { + if (!keyEqualityComparer.Equals(first.Current.Key, second.Current.Key) + || !valueEqualityComparer.Equals(first.Current.Value, second.Current.Value)) + { + return false; + } + } + + return true; + } + + public int GetHashCode(ImmutableDictionary? obj) + { + if (obj is null) + { + return 0; + } + + var hashCode = default(RoslynHashCode); + + var keyEqualityComparer = EqualityComparer.Default; + var valueEqualityComparer = EqualityComparer.Default; + foreach (var i in obj) + { + hashCode.Add(keyEqualityComparer.GetHashCode(i.Key)); + hashCode.Add(valueEqualityComparer.GetHashCode(i.Value)); + } + + return hashCode.ToHashCode(); + } + } + + private sealed class ImmutableArrayEqualityComparer : IEqualityComparer> + { + public static ImmutableArrayEqualityComparer Default { get; } = new ImmutableArrayEqualityComparer(); + + public bool Equals(ImmutableArray x, ImmutableArray y) + { + if (x == y) + { + return true; + } + else if (x == null || y == null) + { + return false; + } + else if (x.Length != y.Length) + { + return false; + } + + var equalityComparer = EqualityComparer.Default; + for (var i = 0; i < x.Length; i++) + { + if (!equalityComparer.Equals(x[i], y[i])) + { + return false; + } + } + + return true; + } + + public int GetHashCode(ImmutableArray obj) + { + if (obj == null) + { + return 0; + } + + var hashCode = default(RoslynHashCode); + + var equalityComparer = EqualityComparer.Default; + foreach (var i in obj) + { + hashCode.Add(equalityComparer.GetHashCode(i)); + } + + return hashCode.ToHashCode(); + } + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/XElementExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/XElementExtensions.cs new file mode 100644 index 000000000..f8fd96d90 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/XElementExtensions.cs @@ -0,0 +1,14 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.CodeGeneration +{ + using System; + using System.Xml.Linq; + + internal static class XElementExtensions + { + public static XAttribute RequiredAttribute(this XElement element, XName name) + => element.Attribute(name) ?? throw new InvalidOperationException($"Expected attribute '{name}'"); + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/XmlSyntaxFactory.cs b/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/XmlSyntaxFactory.cs new file mode 100644 index 000000000..4dc254249 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.CodeGeneration/XmlSyntaxFactory.cs @@ -0,0 +1,15 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.CodeGeneration +{ + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + + internal static class XmlSyntaxFactory + { + public const string CrLf = "\r\n"; + + public static SyntaxToken XmlCarriageReturnLineFeedWithContinuation { get; } = SyntaxFactory.XmlTextNewLine(CrLf, continueXmlDocumentationComment: true); + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Internal.ruleset b/StyleCop.Analyzers/StyleCop.Analyzers.Internal.ruleset index 538508caa..133bfd9d4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Internal.ruleset +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Internal.ruleset @@ -10,7 +10,15 @@ - - + + + + + + + + + + \ No newline at end of file diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.PrivateAnalyzers/DerivedTestGenerator.cs b/StyleCop.Analyzers/StyleCop.Analyzers.PrivateAnalyzers/DerivedTestGenerator.cs new file mode 100644 index 000000000..80339d951 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.PrivateAnalyzers/DerivedTestGenerator.cs @@ -0,0 +1,167 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.PrivateAnalyzers +{ + using System; + using System.Collections.Immutable; + using System.Linq; + using System.Text.RegularExpressions; + using Microsoft.CodeAnalysis; + + [Generator] + internal sealed class DerivedTestGenerator : IIncrementalGenerator + { + public void Initialize(IncrementalGeneratorInitializationContext context) + { + var testData = context.CompilationProvider.Select((compilation, cancellationToken) => + { + var currentAssemblyName = compilation.AssemblyName ?? string.Empty; + if (!Regex.IsMatch(currentAssemblyName, @"^StyleCop\.Analyzers\.Test\.CSharp\d+$")) + { + // This is not a test project where derived test classes are expected + return null; + } + + var currentVersion = int.Parse(currentAssemblyName["StyleCop.Analyzers.Test.CSharp".Length..]); + var currentTestString = "CSharp" + currentVersion; + var previousTestString = currentVersion switch + { + 7 => string.Empty, + _ => "CSharp" + (currentVersion - 1).ToString(), + }; + var previousAssemblyName = previousTestString switch + { + "" => "StyleCop.Analyzers.Test", + _ => "StyleCop.Analyzers.Test." + previousTestString, + }; + + return new TestData(previousTestString, previousAssemblyName, currentTestString, currentAssemblyName); + }); + + var testTypes = context.CompilationProvider.Combine(testData).SelectMany((compilationAndTestData, cancellationToken) => + { + var (compilation, testData) = compilationAndTestData; + if (testData is null) + { + return ImmutableArray.Empty; + } + + var previousAssembly = compilation.Assembly.Modules.First().ReferencedAssemblySymbols.First( + symbol => symbol.Identity.Name == testData.PreviousAssemblyName); + if (previousAssembly is null) + { + return ImmutableArray.Empty; + } + + var collector = new TestClassCollector(testData.PreviousTestString); + var previousTests = collector.Visit(previousAssembly); + return previousTests.ToImmutableArray(); + }); + + context.RegisterSourceOutput( + testTypes.Combine(testData), + (context, testTypeAndData) => + { + var (testType, testData) = testTypeAndData; + if (testData is null) + { + throw new InvalidOperationException("Not reachable"); + } + + string expectedTest; + if (testData.PreviousTestString is "") + { + expectedTest = testType.Replace(testData.PreviousAssemblyName, testData.CurrentAssemblyName).Replace("UnitTests", testData.CurrentTestString + "UnitTests"); + } + else + { + expectedTest = testType.Replace(testData.PreviousTestString, testData.CurrentTestString); + } + + var lastDot = testType.LastIndexOf('.'); + var baseNamespaceName = testType["global::".Length..lastDot]; + var baseTypeName = testType[(lastDot + 1)..]; + + lastDot = expectedTest.LastIndexOf('.'); + var namespaceName = expectedTest["global::".Length..lastDot]; + var typeName = expectedTest[(lastDot + 1)..]; + var content = + $@"// + +#nullable enable + +namespace {namespaceName}; + +using {baseNamespaceName}; + +public partial class {typeName} + : {baseTypeName} +{{ +}} +"; + + context.AddSource( + typeName + ".cs", + content); + }); + } + + private sealed record TestData(string PreviousTestString, string PreviousAssemblyName, string CurrentTestString, string CurrentAssemblyName); + + private sealed class TestClassCollector : SymbolVisitor> + { + private readonly string testString; + + public TestClassCollector(string testString) + { + this.testString = testString; + } + + public override ImmutableSortedSet Visit(ISymbol? symbol) + => base.Visit(symbol) ?? throw new InvalidOperationException("Not reachable"); + + public override ImmutableSortedSet? DefaultVisit(ISymbol symbol) + => ImmutableSortedSet.Empty; + + public override ImmutableSortedSet VisitAssembly(IAssemblySymbol symbol) + { + return this.Visit(symbol.GlobalNamespace); + } + + public override ImmutableSortedSet VisitNamespace(INamespaceSymbol symbol) + { + var result = ImmutableSortedSet.Empty; + foreach (var member in symbol.GetMembers()) + { + result = result.Union(this.Visit(member)!); + } + + return result; + } + + public override ImmutableSortedSet VisitNamedType(INamedTypeSymbol symbol) + { + if (this.testString is "") + { + if (symbol.Name.EndsWith("UnitTests")) + { + return ImmutableSortedSet.Create(symbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + } + else + { + return ImmutableSortedSet.Empty; + } + } + else if (symbol.Name.Contains(this.testString)) + { + return ImmutableSortedSet.Create(symbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + } + else + { + return ImmutableSortedSet.Empty; + } + } + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.PrivateAnalyzers/IncludeTestClassesAnalyzer.cs b/StyleCop.Analyzers/StyleCop.Analyzers.PrivateAnalyzers/IncludeTestClassesAnalyzer.cs new file mode 100644 index 000000000..411076769 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.PrivateAnalyzers/IncludeTestClassesAnalyzer.cs @@ -0,0 +1,156 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.PrivateAnalyzers; + +using System; +using System.Collections.Concurrent; +using System.Collections.Immutable; +using System.Linq; +using System.Text.RegularExpressions; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.Text; + +[DiagnosticAnalyzer(LanguageNames.CSharp)] +internal sealed class IncludeTestClassesAnalyzer : DiagnosticAnalyzer +{ + private static readonly DiagnosticDescriptor Descriptor = + new(PrivateDiagnosticIds.SP0001, "Include all test classes", "Expected test class '{0}' was not found", "Correctness", DiagnosticSeverity.Warning, isEnabledByDefault: true, customTags: new[] { "CompilationEnd" }); + + public override ImmutableArray SupportedDiagnostics { get; } = ImmutableArray.Create(Descriptor); + + public override void Initialize(AnalysisContext context) + { + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); + context.EnableConcurrentExecution(); + + context.RegisterCompilationStartAction(context => + { + var assemblyName = context.Compilation.AssemblyName ?? string.Empty; + if (!Regex.IsMatch(assemblyName, @"^StyleCop\.Analyzers\.Test\.CSharp\d+$")) + { + // This is not a test project where derived test classes are expected + return; + } + + // Map actual test class in current project to base type + var testClasses = new ConcurrentDictionary(); + + context.RegisterSymbolAction( + context => + { + var namedType = (INamedTypeSymbol)context.Symbol; + if (namedType.TypeKind != TypeKind.Class) + { + return; + } + + testClasses[namedType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)] = namedType.BaseType?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) ?? string.Empty; + }, + SymbolKind.NamedType); + + context.RegisterCompilationEndAction(context => + { + var currentVersion = int.Parse(assemblyName["StyleCop.Analyzers.Test.CSharp".Length..]); + var currentTestString = "CSharp" + currentVersion; + var previousTestString = currentVersion switch + { + 7 => string.Empty, + _ => "CSharp" + (currentVersion - 1).ToString(), + }; + var previousAssemblyName = previousTestString switch + { + "" => "StyleCop.Analyzers.Test", + _ => "StyleCop.Analyzers.Test." + previousTestString, + }; + + var previousAssembly = context.Compilation.Assembly.Modules.First().ReferencedAssemblySymbols.First( + symbol => symbol.Identity.Name == previousAssemblyName); + if (previousAssembly is null) + { + return; + } + + var reportingLocation = context.Compilation.SyntaxTrees.FirstOrDefault()?.GetLocation(new TextSpan(0, 0)) ?? Location.None; + var collector = new TestClassCollector(previousTestString); + var previousTests = collector.Visit(previousAssembly); + foreach (var previousTest in previousTests) + { + string expectedTest; + if (previousTestString is "") + { + expectedTest = previousTest.Replace(previousAssemblyName, assemblyName).Replace("UnitTests", currentTestString + "UnitTests"); + } + else + { + expectedTest = previousTest.Replace(previousTestString, currentTestString); + } + + if (testClasses.TryGetValue(expectedTest, out var actualTest) + && actualTest == previousTest) + { + continue; + } + + context.ReportDiagnostic(Diagnostic.Create(Descriptor, reportingLocation, expectedTest)); + } + }); + }); + } + + private sealed class TestClassCollector : SymbolVisitor> + { + private readonly string testString; + + public TestClassCollector(string testString) + { + this.testString = testString; + } + + public override ImmutableSortedSet Visit(ISymbol? symbol) + => base.Visit(symbol) ?? throw new InvalidOperationException("Not reachable"); + + public override ImmutableSortedSet? DefaultVisit(ISymbol symbol) + => ImmutableSortedSet.Empty; + + public override ImmutableSortedSet VisitAssembly(IAssemblySymbol symbol) + { + return this.Visit(symbol.GlobalNamespace); + } + + public override ImmutableSortedSet VisitNamespace(INamespaceSymbol symbol) + { + var result = ImmutableSortedSet.Empty; + foreach (var member in symbol.GetMembers()) + { + result = result.Union(this.Visit(member)!); + } + + return result; + } + + public override ImmutableSortedSet VisitNamedType(INamedTypeSymbol symbol) + { + if (this.testString is "") + { + if (symbol.Name.EndsWith("UnitTests")) + { + return ImmutableSortedSet.Create(symbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + } + else + { + return ImmutableSortedSet.Empty; + } + } + else if (symbol.Name.Contains(this.testString)) + { + return ImmutableSortedSet.Create(symbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + } + else + { + return ImmutableSortedSet.Empty; + } + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.PrivateAnalyzers/PrivateDiagnosticIds.cs b/StyleCop.Analyzers/StyleCop.Analyzers.PrivateAnalyzers/PrivateDiagnosticIds.cs new file mode 100644 index 000000000..87b1b134d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.PrivateAnalyzers/PrivateDiagnosticIds.cs @@ -0,0 +1,13 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.PrivateAnalyzers +{ + internal static class PrivateDiagnosticIds + { + /// + /// SP0001: Include all test classes. + /// + public const string SP0001 = nameof(SP0001); + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.PrivateAnalyzers/StyleCop.Analyzers.PrivateAnalyzers.csproj b/StyleCop.Analyzers/StyleCop.Analyzers.PrivateAnalyzers/StyleCop.Analyzers.PrivateAnalyzers.csproj new file mode 100644 index 000000000..603d4e261 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.PrivateAnalyzers/StyleCop.Analyzers.PrivateAnalyzers.csproj @@ -0,0 +1,31 @@ + + + + + netstandard2.0 + + $(NoWarn),RS2008 + + + + ..\StyleCop.Analyzers.ruleset + + + + true + ..\..\build\keys\StyleCopAnalyzers.snk + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.PrivateCodeFixes/StyleCop.Analyzers.PrivateCodeFixes.csproj b/StyleCop.Analyzers/StyleCop.Analyzers.PrivateCodeFixes/StyleCop.Analyzers.PrivateCodeFixes.csproj new file mode 100644 index 000000000..985221812 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.PrivateCodeFixes/StyleCop.Analyzers.PrivateCodeFixes.csproj @@ -0,0 +1,43 @@ + + + + + netstandard2.0 + + + + ..\StyleCop.Analyzers.ruleset + + + + true + ..\..\build\keys\StyleCopAnalyzers.snk + + + + + + + + + + + + + + + + + + + + $(GetTargetPathDependsOn);GetDependencyTargetPaths + + + + + + + + + \ No newline at end of file diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/App.config b/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/App.config index a9769c1eb..236660082 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/App.config +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/App.config @@ -4,19 +4,19 @@ - + - + - + diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/CodeFixStatus.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/CodeFixStatus.cs index 0104f1507..63611241d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/CodeFixStatus.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/CodeFixStatus.cs @@ -1,5 +1,5 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Status.Generator { @@ -9,7 +9,7 @@ namespace StyleCop.Analyzers.Status.Generator public enum CodeFixStatus { /// - /// This value indicates, that a code fix is implemented + /// This value indicates, that a code fix is implemented. /// Implemented, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/FixAllStatus.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/FixAllStatus.cs index aa3270ae9..6a88d18a9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/FixAllStatus.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/FixAllStatus.cs @@ -1,5 +1,5 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Status.Generator { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/Program.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/Program.cs index 453e680a4..83cd9eb0f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/Program.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/Program.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Status.Generator { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/SolutionReader.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/SolutionReader.cs index 317ae789e..2c7532798 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/SolutionReader.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/SolutionReader.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Status.Generator { using System; using System.Collections.Generic; using System.Collections.Immutable; - using System.IO; using System.Linq; using System.Reflection; using System.Text.RegularExpressions; @@ -24,7 +25,7 @@ namespace StyleCop.Analyzers.Status.Generator /// public class SolutionReader { - private static Regex diagnosticPathRegex = new Regex(@"(?[A-Za-z]+)Rules\\(?[A-Za-z0-9]+)\.cs$"); + private static readonly Regex DiagnosticPathRegex = new Regex(@"(?[A-Za-z]+)Rules\\(?[A-Za-z0-9]+)\.cs$"); private INamedTypeSymbol diagnosticAnalyzerTypeSymbol; private INamedTypeSymbol noCodeFixAttributeTypeSymbol; @@ -93,7 +94,7 @@ public async Task> GetDiagnosticsAsync() foreach (var syntaxTree in syntaxTrees) { - var match = diagnosticPathRegex.Match(syntaxTree.FilePath); + var match = DiagnosticPathRegex.Match(syntaxTree.FilePath); if (!match.Success) { continue; @@ -262,7 +263,7 @@ private string GetStatus(INamedTypeSymbol classSymbol, SyntaxNode root, Semantic // We use the fact that the only parameter that returns a boolean is the one we are interested in var enabledByDefaultParameter = from argument in initializer.ArgumentList.Arguments - where Equals(model.GetTypeInfo(argument.Expression).Type, this.booleanType) + where SymbolEqualityComparer.Default.Equals(model.GetTypeInfo(argument.Expression).Type, this.booleanType) select argument.Expression; var parameter = enabledByDefaultParameter.FirstOrDefault(); string parameterString = parameter.ToString(); @@ -287,7 +288,7 @@ private IEnumerable GetDescriptor(INamedTypeSymbol classSy return analyzer.SupportedDiagnostics; } - private (CodeFixStatus, FixAllStatus) GetCodeFixAndFixAllStatus(string diagnosticId, INamedTypeSymbol classSymbol, out string noCodeFixReason) + private (CodeFixStatus codeFixStatus, FixAllStatus fixAllStatus) GetCodeFixAndFixAllStatus(string diagnosticId, INamedTypeSymbol classSymbol, out string noCodeFixReason) { CodeFixStatus codeFixStatus; FixAllStatus fixAllStatus; @@ -296,7 +297,7 @@ private IEnumerable GetDescriptor(INamedTypeSymbol classSy var noCodeFixAttribute = classSymbol .GetAttributes() - .SingleOrDefault(x => Equals(x.AttributeClass, this.noCodeFixAttributeTypeSymbol)); + .SingleOrDefault(x => SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.noCodeFixAttributeTypeSymbol)); bool hasCodeFix = noCodeFixAttribute == null; if (!hasCodeFix) @@ -355,7 +356,7 @@ private bool InheritsFrom(INamedTypeSymbol declaration, INamedTypeSymbol possibl { while (declaration != null) { - if (declaration.Equals(possibleBaseType)) + if (SymbolEqualityComparer.Default.Equals(declaration, possibleBaseType)) { return true; } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/StyleCop.Analyzers.Status.Generator.csproj b/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/StyleCop.Analyzers.Status.Generator.csproj index a6d20a55b..203ffd6b8 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/StyleCop.Analyzers.Status.Generator.csproj +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/StyleCop.Analyzers.Status.Generator.csproj @@ -2,8 +2,9 @@ - net46 + net472 Exe + false true @@ -19,16 +20,12 @@ - - - - - - - - - - + + + + + + \ No newline at end of file diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/StyleCopDiagnostic.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/StyleCopDiagnostic.cs index 5aed5f686..9ca7b2d21 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/StyleCopDiagnostic.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Status.Generator/StyleCopDiagnostic.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Status.Generator { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/AnalyzerConfigurationCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/AnalyzerConfigurationCSharp10UnitTests.cs new file mode 100644 index 000000000..be7933740 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/AnalyzerConfigurationCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10 +{ + using StyleCop.Analyzers.Test.CSharp9; + + public partial class AnalyzerConfigurationCSharp10UnitTests : AnalyzerConfigurationCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/InheritdocCodeFixProviderCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/InheritdocCodeFixProviderCSharp10UnitTests.cs new file mode 100644 index 000000000..31aed48d6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/InheritdocCodeFixProviderCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class InheritdocCodeFixProviderCSharp10UnitTests : InheritdocCodeFixProviderCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/NoXmlFileHeaderCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/NoXmlFileHeaderCSharp10UnitTests.cs new file mode 100644 index 000000000..85ef880a2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/NoXmlFileHeaderCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class NoXmlFileHeaderCSharp10UnitTests : NoXmlFileHeaderCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1600CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1600CSharp10UnitTests.cs new file mode 100644 index 000000000..783384c6c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1600CSharp10UnitTests.cs @@ -0,0 +1,37 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.DocumentationRules.SA1600ElementsMustBeDocumented, + StyleCop.Analyzers.DocumentationRules.SA1600CodeFixProvider>; + + public partial class SA1600CSharp10UnitTests : SA1600CSharp9UnitTests + { + protected override DiagnosticResult[] GetExpectedResultTestRegressionMethodGlobalNamespace(string code) + { + if (code == "public void {|#0:TestMember|}() { }") + { + return new[] + { + // /0/Test0.cs(4,1): error CS0106: The modifier 'public' is not valid for this item + DiagnosticResult.CompilerError("CS0106").WithSpan(4, 1, 4, 7).WithArguments("public"), + + // /0/Test0.cs(4,1): error CS8805: Program using top-level statements must be an executable. + DiagnosticResult.CompilerError("CS8805").WithSpan(4, 1, 4, 29), + }; + } + + return new[] + { + DiagnosticResult.CompilerError("CS0116").WithMessage("A namespace cannot directly contain members such as fields, methods or statements").WithLocation(0), + Diagnostic().WithLocation(0), + }; + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1601CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1601CSharp10UnitTests.cs new file mode 100644 index 000000000..f181631bc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1601CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1601CSharp10UnitTests : SA1601CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1602CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1602CSharp10UnitTests.cs new file mode 100644 index 000000000..4701e458f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1602CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1602CSharp10UnitTests : SA1602CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1603CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1603CSharp10UnitTests.cs new file mode 100644 index 000000000..c83dab489 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1603CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1603CSharp10UnitTests : SA1603CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1604CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1604CSharp10UnitTests.cs new file mode 100644 index 000000000..bbd629353 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1604CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1604CSharp10UnitTests : SA1604CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1605CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1605CSharp10UnitTests.cs new file mode 100644 index 000000000..5b83cbceb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1605CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1605CSharp10UnitTests : SA1605CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1606CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1606CSharp10UnitTests.cs new file mode 100644 index 000000000..4d2df0096 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1606CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1606CSharp10UnitTests : SA1606CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1607CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1607CSharp10UnitTests.cs new file mode 100644 index 000000000..e7b081daf --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1607CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1607CSharp10UnitTests : SA1607CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1608CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1608CSharp10UnitTests.cs new file mode 100644 index 000000000..838279035 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1608CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1608CSharp10UnitTests : SA1608CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1609CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1609CSharp10UnitTests.cs new file mode 100644 index 000000000..bf1d64a94 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1609CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1609CSharp10UnitTests : SA1609CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1610CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1610CSharp10UnitTests.cs new file mode 100644 index 000000000..2d7013e2c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1610CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1610CSharp10UnitTests : SA1610CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1611CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1611CSharp10UnitTests.cs new file mode 100644 index 000000000..b3cc4f259 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1611CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1611CSharp10UnitTests : SA1611CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1612CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1612CSharp10UnitTests.cs new file mode 100644 index 000000000..35b9373cd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1612CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1612CSharp10UnitTests : SA1612CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1613CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1613CSharp10UnitTests.cs new file mode 100644 index 000000000..515bc86ca --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1613CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1613CSharp10UnitTests : SA1613CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1614CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1614CSharp10UnitTests.cs new file mode 100644 index 000000000..649a9f7ed --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1614CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1614CSharp10UnitTests : SA1614CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1615CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1615CSharp10UnitTests.cs new file mode 100644 index 000000000..2e198f90b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1615CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1615CSharp10UnitTests : SA1615CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1616CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1616CSharp10UnitTests.cs new file mode 100644 index 000000000..a18e80680 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1616CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1616CSharp10UnitTests : SA1616CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1617CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1617CSharp10UnitTests.cs new file mode 100644 index 000000000..fd7c0d26f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1617CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1617CSharp10UnitTests : SA1617CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1618CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1618CSharp10UnitTests.cs new file mode 100644 index 000000000..01d81abaf --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1618CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1618CSharp10UnitTests : SA1618CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1619CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1619CSharp10UnitTests.cs new file mode 100644 index 000000000..884a4a481 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1619CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1619CSharp10UnitTests : SA1619CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1620CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1620CSharp10UnitTests.cs new file mode 100644 index 000000000..6f6f3457c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1620CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1620CSharp10UnitTests : SA1620CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1621CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1621CSharp10UnitTests.cs new file mode 100644 index 000000000..746d9ae92 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1621CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1621CSharp10UnitTests : SA1621CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1622CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1622CSharp10UnitTests.cs new file mode 100644 index 000000000..8ce1f4ee1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1622CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1622CSharp10UnitTests : SA1622CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1623CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1623CSharp10UnitTests.cs new file mode 100644 index 000000000..9121a1b28 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1623CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1623CSharp10UnitTests : SA1623CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1624CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1624CSharp10UnitTests.cs new file mode 100644 index 000000000..b1560beb4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1624CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1624CSharp10UnitTests : SA1624CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1625CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1625CSharp10UnitTests.cs new file mode 100644 index 000000000..e0cbb1426 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1625CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1625CSharp10UnitTests : SA1625CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1626CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1626CSharp10UnitTests.cs new file mode 100644 index 000000000..a1d633e67 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1626CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1626CSharp10UnitTests : SA1626CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1627CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1627CSharp10UnitTests.cs new file mode 100644 index 000000000..3d3e9fefb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1627CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1627CSharp10UnitTests : SA1627CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1628CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1628CSharp10UnitTests.cs new file mode 100644 index 000000000..e474a9734 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1628CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1628CSharp10UnitTests : SA1628CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1629CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1629CSharp10UnitTests.cs new file mode 100644 index 000000000..9692c1af2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1629CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1629CSharp10UnitTests : SA1629CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1630CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1630CSharp10UnitTests.cs new file mode 100644 index 000000000..19052375e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1630CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1630CSharp10UnitTests : SA1630CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1631CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1631CSharp10UnitTests.cs new file mode 100644 index 000000000..a6c3ca533 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1631CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1631CSharp10UnitTests : SA1631CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1632CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1632CSharp10UnitTests.cs new file mode 100644 index 000000000..6032163fb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1632CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1632CSharp10UnitTests : SA1632CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1633CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1633CSharp10UnitTests.cs new file mode 100644 index 000000000..7868dc85b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1633CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1633CSharp10UnitTests : SA1633CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1634CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1634CSharp10UnitTests.cs new file mode 100644 index 000000000..7088a4b80 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1634CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1634CSharp10UnitTests : SA1634CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1635CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1635CSharp10UnitTests.cs new file mode 100644 index 000000000..34b6610a8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1635CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1635CSharp10UnitTests : SA1635CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1636CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1636CSharp10UnitTests.cs new file mode 100644 index 000000000..1ebdbc216 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1636CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1636CSharp10UnitTests : SA1636CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1637CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1637CSharp10UnitTests.cs new file mode 100644 index 000000000..d0fec2477 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1637CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1637CSharp10UnitTests : SA1637CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1638CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1638CSharp10UnitTests.cs new file mode 100644 index 000000000..54b7c9e73 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1638CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1638CSharp10UnitTests : SA1638CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1639CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1639CSharp10UnitTests.cs new file mode 100644 index 000000000..cc172dd86 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1639CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1639CSharp10UnitTests : SA1639CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1640CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1640CSharp10UnitTests.cs new file mode 100644 index 000000000..7ea88b544 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1640CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1640CSharp10UnitTests : SA1640CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1641CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1641CSharp10UnitTests.cs new file mode 100644 index 000000000..15d288ba3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1641CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1641CSharp10UnitTests : SA1641CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1642CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1642CSharp10UnitTests.cs new file mode 100644 index 000000000..7ef488359 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1642CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1642CSharp10UnitTests : SA1642CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1643CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1643CSharp10UnitTests.cs new file mode 100644 index 000000000..e509428e4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1643CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1643CSharp10UnitTests : SA1643CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1644CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1644CSharp10UnitTests.cs new file mode 100644 index 000000000..828614bab --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1644CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1644CSharp10UnitTests : SA1644CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1645CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1645CSharp10UnitTests.cs new file mode 100644 index 000000000..99d8ee9a4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1645CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1645CSharp10UnitTests : SA1645CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1646CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1646CSharp10UnitTests.cs new file mode 100644 index 000000000..e373d77cd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1646CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1646CSharp10UnitTests : SA1646CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1647CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1647CSharp10UnitTests.cs new file mode 100644 index 000000000..7ba17d887 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1647CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1647CSharp10UnitTests : SA1647CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1648CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1648CSharp10UnitTests.cs new file mode 100644 index 000000000..19ba51f70 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1648CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1648CSharp10UnitTests : SA1648CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1649CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1649CSharp10UnitTests.cs new file mode 100644 index 000000000..a101a19cc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1649CSharp10UnitTests.cs @@ -0,0 +1,51 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using System.Threading; + using System.Threading.Tasks; + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + using StyleCop.Analyzers.Test.Helpers; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier< + StyleCop.Analyzers.DocumentationRules.SA1649FileNameMustMatchTypeName>; + + public partial class SA1649CSharp10UnitTests : SA1649CSharp9UnitTests + { + /// + /// Verifies that the file name is based on the first type. + /// + /// The type keyword to use during the test. + /// A representing the asynchronous unit test. + [Theory] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + [WorkItem(3435, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3435")] + public async Task VerifyFirstTypeIsUsedWithFileScopedNamespacesAsync(string typeKeyword) + { + var testCode = $@"namespace TestNamespace; + +public enum IgnoredEnum {{ }} +public delegate void IgnoredDelegate(); + +{GetTypeDeclaration(typeKeyword, "TestType", diagnosticKey: 0)} + +{GetTypeDeclaration(typeKeyword, "TestType2")} +"; + var fixedCode = $@"namespace TestNamespace; + +public enum IgnoredEnum {{ }} +public delegate void IgnoredDelegate(); + +{GetTypeDeclaration(typeKeyword, "TestType")} + +{GetTypeDeclaration(typeKeyword, "TestType2")} +"; + + var expectedDiagnostic = Diagnostic().WithLocation(0); + await VerifyCSharpFixAsync("TestType2.cs", testCode, StyleCopSettings, expectedDiagnostic, "TestType.cs", fixedCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1650CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1650CSharp10UnitTests.cs new file mode 100644 index 000000000..ae453bd8e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1650CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1650CSharp10UnitTests : SA1650CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1651CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1651CSharp10UnitTests.cs new file mode 100644 index 000000000..706992834 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/DocumentationRules/SA1651CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp9.DocumentationRules; + + public partial class SA1651CSharp10UnitTests : SA1651CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/HelperTests/SymbolNameHelpersCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/HelperTests/SymbolNameHelpersCSharp10UnitTests.cs new file mode 100644 index 000000000..ded94a69a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/HelperTests/SymbolNameHelpersCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.HelperTests +{ + using StyleCop.Analyzers.Test.CSharp9.HelperTests; + + public partial class SymbolNameHelpersCSharp10UnitTests : SymbolNameHelpersCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1500CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1500CSharp10UnitTests.cs new file mode 100644 index 000000000..ba23ffeb2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1500CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp9.LayoutRules; + + public partial class SA1500CSharp10UnitTests : SA1500CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1501CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1501CSharp10UnitTests.cs new file mode 100644 index 000000000..fa12c38fe --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1501CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp9.LayoutRules; + + public partial class SA1501CSharp10UnitTests : SA1501CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1502CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1502CSharp10UnitTests.cs new file mode 100644 index 000000000..df35c4e36 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1502CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp9.LayoutRules; + + public partial class SA1502CSharp10UnitTests : SA1502CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1503CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1503CSharp10UnitTests.cs new file mode 100644 index 000000000..6ec436260 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1503CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp9.LayoutRules; + + public partial class SA1503CSharp10UnitTests : SA1503CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1504CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1504CSharp10UnitTests.cs new file mode 100644 index 000000000..0de0dccee --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1504CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp9.LayoutRules; + + public partial class SA1504CSharp10UnitTests : SA1504CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1505CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1505CSharp10UnitTests.cs new file mode 100644 index 000000000..4eebede41 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1505CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp9.LayoutRules; + + public partial class SA1505CSharp10UnitTests : SA1505CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1506CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1506CSharp10UnitTests.cs new file mode 100644 index 000000000..d6353bfed --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1506CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp9.LayoutRules; + + public partial class SA1506CSharp10UnitTests : SA1506CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1507CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1507CSharp10UnitTests.cs new file mode 100644 index 000000000..f7bbb8421 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1507CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp9.LayoutRules; + + public partial class SA1507CSharp10UnitTests : SA1507CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1508CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1508CSharp10UnitTests.cs new file mode 100644 index 000000000..c3f8022bd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1508CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp9.LayoutRules; + + public partial class SA1508CSharp10UnitTests : SA1508CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1509CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1509CSharp10UnitTests.cs new file mode 100644 index 000000000..bc06e4da2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1509CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp9.LayoutRules; + + public partial class SA1509CSharp10UnitTests : SA1509CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1510CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1510CSharp10UnitTests.cs new file mode 100644 index 000000000..97f4f2336 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1510CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp9.LayoutRules; + + public partial class SA1510CSharp10UnitTests : SA1510CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1511CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1511CSharp10UnitTests.cs new file mode 100644 index 000000000..5702eef06 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1511CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp9.LayoutRules; + + public partial class SA1511CSharp10UnitTests : SA1511CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1512CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1512CSharp10UnitTests.cs new file mode 100644 index 000000000..c8baa8d5b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1512CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp9.LayoutRules; + + public partial class SA1512CSharp10UnitTests : SA1512CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1513CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1513CSharp10UnitTests.cs new file mode 100644 index 000000000..847b78006 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1513CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp9.LayoutRules; + + public partial class SA1513CSharp10UnitTests : SA1513CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1514CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1514CSharp10UnitTests.cs new file mode 100644 index 000000000..2158131a4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1514CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp9.LayoutRules; + + public partial class SA1514CSharp10UnitTests : SA1514CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1515CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1515CSharp10UnitTests.cs new file mode 100644 index 000000000..08e518640 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1515CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp9.LayoutRules; + + public partial class SA1515CSharp10UnitTests : SA1515CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1516CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1516CSharp10UnitTests.cs new file mode 100644 index 000000000..60b9dfcf1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1516CSharp10UnitTests.cs @@ -0,0 +1,243 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp9.LayoutRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.LayoutRules.SA1516ElementsMustBeSeparatedByBlankLine, + StyleCop.Analyzers.LayoutRules.SA1516CodeFixProvider>; + + public partial class SA1516CSharp10UnitTests : SA1516CSharp9UnitTests + { + /// + /// Verifies that SA1516 is reported for usings and extern alias outside a file scoped namespace. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3512, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3512")] + public async Task TestThatDiagnosticIIsReportedOnUsingsAndExternAliasOutsideFileScopedNamespaceAsync() + { + var testCode = @"extern alias corlib; +[|using|] System; +using System.Linq; +using a = System.Collections; +[|namespace|] Foo; +"; + + var fixedCode = @"extern alias corlib; + +using System; +using System.Linq; +using a = System.Collections; + +namespace Foo; +"; + + await VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false); + } + + /// + /// Verifies that SA1516 is reported for usings inside a file scoped namespace. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3512, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3512")] + public async Task TestThatDiagnosticIIsReportedOnSpacingWithUsingsInsideFileScopedNamespaceAsync() + { + var testCode = @"namespace Foo; +[|using|] System; +using System.Linq; +using a = System.Collections; +"; + + var fixedCode = @"namespace Foo; + +using System; +using System.Linq; +using a = System.Collections; +"; + + await VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false); + } + + /// + /// Verifies that SA1516 is reported for member declarations inside a file scoped namespace. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3512, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3512")] + public async Task TestThatDiagnosticIIsReportedOnMemberDeclarationsInsideFileScopedNamespaceAsync() + { + var testCode = @"namespace Foo; +[|public|] class Bar +{ +} +[|public|] enum Foobar +{ +} +"; + + var fixedCode = @"namespace Foo; + +public class Bar +{ +} + +public enum Foobar +{ +} +"; + + await VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false); + } + + /// + /// Verifies that SA1516 is reported for usings and member declarations inside a file scoped namespace. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3512, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3512")] + public async Task TestThatDiagnosticIIsReportedOnUsingsAndMemberDeclarationsInsideFileScopedNamespaceAsync() + { + var testCode = @"namespace Foo; +[|using|] System; +using System.Linq; +using a = System.Collections; +[|public|] class Bar +{ +} +[|public|] enum Foobar +{ +} +"; + + var fixedCode = @"namespace Foo; + +using System; +using System.Linq; +using a = System.Collections; + +public class Bar +{ +} + +public enum Foobar +{ +} +"; + + await VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false); + } + + /// + /// Verifies that SA1516 is reported extern alias inside a file scoped namespace. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3512, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3512")] + public async Task TestThatDiagnosticIIsReportedOnExternAliasInsideFileScopedNamespaceAsync() + { + var testCode = @"namespace Foo; +[|extern|] alias corlib; +"; + + var fixedCode = @"namespace Foo; + +extern alias corlib; +"; + + await VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false); + } + + /// + /// Verifies that SA1516 is reported extern alias and usings inside a file scoped namespace. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3512, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3512")] + public async Task TestThatDiagnosticIIsReportedOnExternAliasAndUsingsInsideFileScopedNamespaceAsync() + { + var testCode = @"namespace Foo; +[|extern|] alias corlib; +[|using|] System; +using System.Linq; +using a = System.Collections; +"; + + var fixedCode = @"namespace Foo; + +extern alias corlib; + +using System; +using System.Linq; +using a = System.Collections; +"; + + await VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false); + } + + /// + /// Verifies that SA1516 is reported extern alias, usings and member declarations + /// inside a file scoped namespace. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3512, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3512")] + public async Task TestThatDiagnosticIIsReportedOnExternAliasUsingsAndMemberDeclarationsInsideFileScopedNamespaceAsync() + { + var testCode = @"namespace Foo; +[|extern|] alias corlib; +[|using|] System; +using System.Linq; +using a = System.Collections; +[|public|] class Bar +{ +} +[|public|] enum Foobar +{ +} +"; + + var fixedCode = @"namespace Foo; + +extern alias corlib; + +using System; +using System.Linq; +using a = System.Collections; + +public class Bar +{ +} + +public enum Foobar +{ +} +"; + + await VerifyCSharpFixAsync(testCode, fixedCode).ConfigureAwait(false); + } + + private static Task VerifyCSharpFixAsync(string testCode, string fixedCode) + { + var test = new CSharpTest + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net60, + TestState = + { + Sources = { testCode }, + }, + FixedCode = fixedCode, + }; + + return test.RunAsync(CancellationToken.None); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1516UsingGroupsCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1516UsingGroupsCSharp10UnitTests.cs new file mode 100644 index 000000000..255ab862b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1516UsingGroupsCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp9.LayoutRules; + + public partial class SA1516UsingGroupsCSharp10UnitTests : SA1516UsingGroupsCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1517CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1517CSharp10UnitTests.cs new file mode 100644 index 000000000..5513c3b2a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1517CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp9.LayoutRules; + + public partial class SA1517CSharp10UnitTests : SA1517CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1518CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1518CSharp10UnitTests.cs new file mode 100644 index 000000000..a7a5563d4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1518CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp9.LayoutRules; + + public partial class SA1518CSharp10UnitTests : SA1518CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1519CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1519CSharp10UnitTests.cs new file mode 100644 index 000000000..2b007881c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1519CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp9.LayoutRules; + + public partial class SA1519CSharp10UnitTests : SA1519CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1520CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1520CSharp10UnitTests.cs new file mode 100644 index 000000000..2d2a54d3f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/LayoutRules/SA1520CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp9.LayoutRules; + + public partial class SA1520CSharp10UnitTests : SA1520CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/AccessorDeclarationSyntaxExtensionsCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/AccessorDeclarationSyntaxExtensionsCSharp10UnitTests.cs new file mode 100644 index 000000000..4f66fd932 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/AccessorDeclarationSyntaxExtensionsCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class AccessorDeclarationSyntaxExtensionsCSharp10UnitTests : AccessorDeclarationSyntaxExtensionsCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/ArgumentSyntaxExtensionsCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/ArgumentSyntaxExtensionsCSharp10UnitTests.cs new file mode 100644 index 000000000..45a3677ec --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/ArgumentSyntaxExtensionsCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class ArgumentSyntaxExtensionsCSharp10UnitTests : ArgumentSyntaxExtensionsCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/BaseMethodDeclarationSyntaxExtensionsCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/BaseMethodDeclarationSyntaxExtensionsCSharp10UnitTests.cs new file mode 100644 index 000000000..5010eed07 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/BaseMethodDeclarationSyntaxExtensionsCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class BaseMethodDeclarationSyntaxExtensionsCSharp10UnitTests : BaseMethodDeclarationSyntaxExtensionsCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/CasePatternSwitchLabelSyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/CasePatternSwitchLabelSyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..af8ac34ee --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/CasePatternSwitchLabelSyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class CasePatternSwitchLabelSyntaxWrapperCSharp10UnitTests : CasePatternSwitchLabelSyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/CommonForEachStatementSyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/CommonForEachStatementSyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..3dae702a7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/CommonForEachStatementSyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class CommonForEachStatementSyntaxWrapperCSharp10UnitTests : CommonForEachStatementSyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/ConstantPatternSyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/ConstantPatternSyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..16987bde8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/ConstantPatternSyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class ConstantPatternSyntaxWrapperCSharp10UnitTests : ConstantPatternSyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/ConstructorDeclarationSyntaxExtensionsCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/ConstructorDeclarationSyntaxExtensionsCSharp10UnitTests.cs new file mode 100644 index 000000000..3b80d2340 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/ConstructorDeclarationSyntaxExtensionsCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class ConstructorDeclarationSyntaxExtensionsCSharp10UnitTests : ConstructorDeclarationSyntaxExtensionsCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/CrefParameterSyntaxExtensionsCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/CrefParameterSyntaxExtensionsCSharp10UnitTests.cs new file mode 100644 index 000000000..251e125ff --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/CrefParameterSyntaxExtensionsCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class CrefParameterSyntaxExtensionsCSharp10UnitTests : CrefParameterSyntaxExtensionsCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/DeclarationExpressionSyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/DeclarationExpressionSyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..ed7d29268 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/DeclarationExpressionSyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class DeclarationExpressionSyntaxWrapperCSharp10UnitTests : DeclarationExpressionSyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/DeclarationPatternSyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/DeclarationPatternSyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..22d52be00 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/DeclarationPatternSyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class DeclarationPatternSyntaxWrapperCSharp10UnitTests : DeclarationPatternSyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/DestructorDeclarationSyntaxExtensionsCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/DestructorDeclarationSyntaxExtensionsCSharp10UnitTests.cs new file mode 100644 index 000000000..48bf8ae2a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/DestructorDeclarationSyntaxExtensionsCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class DestructorDeclarationSyntaxExtensionsCSharp10UnitTests : DestructorDeclarationSyntaxExtensionsCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/DiscardDesignationSyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/DiscardDesignationSyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..433340753 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/DiscardDesignationSyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class DiscardDesignationSyntaxWrapperCSharp10UnitTests : DiscardDesignationSyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..b1223cbf5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp10UnitTests : ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/IsPatternExpressionSyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/IsPatternExpressionSyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..f77d04c6e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/IsPatternExpressionSyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class IsPatternExpressionSyntaxWrapperCSharp10UnitTests : IsPatternExpressionSyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/LanguageVersionExCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/LanguageVersionExCSharp10UnitTests.cs new file mode 100644 index 000000000..588d2707b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/LanguageVersionExCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class LanguageVersionExCSharp10UnitTests : LanguageVersionExCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/LightupHelpersCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/LightupHelpersCSharp10UnitTests.cs new file mode 100644 index 000000000..aa170127a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/LightupHelpersCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class LightupHelpersCSharp10UnitTests : LightupHelpersCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/LocalFunctionStatementSyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/LocalFunctionStatementSyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..8d26277c5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/LocalFunctionStatementSyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class LocalFunctionStatementSyntaxWrapperCSharp10UnitTests : LocalFunctionStatementSyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/MethodKindExCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/MethodKindExCSharp10UnitTests.cs new file mode 100644 index 000000000..3e1cc4bbb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/MethodKindExCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class MethodKindExCSharp10UnitTests : MethodKindExCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/OperationKindExCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/OperationKindExCSharp10UnitTests.cs new file mode 100644 index 000000000..51b4c1d86 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/OperationKindExCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class OperationKindExCSharp10UnitTests : OperationKindExCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/ParenthesizedVariableDesignationSyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/ParenthesizedVariableDesignationSyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..6164f1d10 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/ParenthesizedVariableDesignationSyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class ParenthesizedVariableDesignationSyntaxWrapperCSharp10UnitTests : ParenthesizedVariableDesignationSyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/PatternSyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/PatternSyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..dfc045407 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/PatternSyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class PatternSyntaxWrapperCSharp10UnitTests : PatternSyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/RefExpressionSyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/RefExpressionSyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..9b674cf20 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/RefExpressionSyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class RefExpressionSyntaxWrapperCSharp10UnitTests : RefExpressionSyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/RefTypeSyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/RefTypeSyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..7cb5a8b86 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/RefTypeSyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class RefTypeSyntaxWrapperCSharp10UnitTests : RefTypeSyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/SingleVariableDesignationSyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/SingleVariableDesignationSyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..c39a90481 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/SingleVariableDesignationSyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class SingleVariableDesignationSyntaxWrapperCSharp10UnitTests : SingleVariableDesignationSyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/StackAllocArrayCreationExpressionSyntaxExtensionsCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/StackAllocArrayCreationExpressionSyntaxExtensionsCSharp10UnitTests.cs new file mode 100644 index 000000000..107605bdc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/StackAllocArrayCreationExpressionSyntaxExtensionsCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class StackAllocArrayCreationExpressionSyntaxExtensionsCSharp10UnitTests : StackAllocArrayCreationExpressionSyntaxExtensionsCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/SwitchExpressionArmSyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/SwitchExpressionArmSyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..7abd614f4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/SwitchExpressionArmSyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class SwitchExpressionArmSyntaxWrapperCSharp10UnitTests : SwitchExpressionArmSyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/SwitchExpressionSyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/SwitchExpressionSyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..b87581074 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/SwitchExpressionSyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class SwitchExpressionSyntaxWrapperCSharp10UnitTests : SwitchExpressionSyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/SyntaxKindExCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/SyntaxKindExCSharp10UnitTests.cs new file mode 100644 index 000000000..eea401bc2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/SyntaxKindExCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class SyntaxKindExCSharp10UnitTests : SyntaxKindExCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/SyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/SyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..a52582640 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/SyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class SyntaxWrapperCSharp10UnitTests : SyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/SyntaxWrapperHelperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/SyntaxWrapperHelperCSharp10UnitTests.cs new file mode 100644 index 000000000..debb260ba --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/SyntaxWrapperHelperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class SyntaxWrapperHelperCSharp10UnitTests : SyntaxWrapperHelperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/ThrowExpressionSyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/ThrowExpressionSyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..a6690082b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/ThrowExpressionSyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class ThrowExpressionSyntaxWrapperCSharp10UnitTests : ThrowExpressionSyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/TupleElementSyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/TupleElementSyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..1a56b3659 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/TupleElementSyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class TupleElementSyntaxWrapperCSharp10UnitTests : TupleElementSyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/TupleExpressionSyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/TupleExpressionSyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..f784b1ad8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/TupleExpressionSyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class TupleExpressionSyntaxWrapperCSharp10UnitTests : TupleExpressionSyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/TupleTypeSyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/TupleTypeSyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..d8cd92c1c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/TupleTypeSyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class TupleTypeSyntaxWrapperCSharp10UnitTests : TupleTypeSyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/VariableDesignationSyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/VariableDesignationSyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..ae5058ba7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/VariableDesignationSyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class VariableDesignationSyntaxWrapperCSharp10UnitTests : VariableDesignationSyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/WhenClauseSyntaxWrapperCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/WhenClauseSyntaxWrapperCSharp10UnitTests.cs new file mode 100644 index 000000000..87ce423c0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Lightup/WhenClauseSyntaxWrapperCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Lightup +{ + using StyleCop.Analyzers.Test.CSharp9.Lightup; + + public partial class WhenClauseSyntaxWrapperCSharp10UnitTests : WhenClauseSyntaxWrapperCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1119CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1119CSharp10UnitTests.cs new file mode 100644 index 000000000..62d03cfcf --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1119CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules; + + public partial class SA1119CSharp10UnitTests : SA1119CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1400CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1400CSharp10UnitTests.cs new file mode 100644 index 000000000..bdaca4ec2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1400CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules; + + public partial class SA1400CSharp10UnitTests : SA1400CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1401CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1401CSharp10UnitTests.cs new file mode 100644 index 000000000..a57e97a6c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1401CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules; + + public partial class SA1401CSharp10UnitTests : SA1401CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForClassCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForClassCSharp10UnitTests.cs new file mode 100644 index 000000000..34ae80264 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForClassCSharp10UnitTests.cs @@ -0,0 +1,45 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules; + using Xunit; + + public partial class SA1402ForClassCSharp10UnitTests : SA1402ForClassCSharp9UnitTests + { + [Fact] + [WorkItem(3435, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3435")] + public async Task VerifyTwoClassesWithFileScopedNamespacesAsync() + { + var testCode = $@"namespace TestNamespace; + +public class TestClass1 {{ }} +public class {{|#0:TestClass2|}} {{ }} +"; + var fixedCode1 = $@"namespace TestNamespace; + +public class TestClass1 {{ }} +"; + var fixedCode2 = $@"namespace TestNamespace; +public class TestClass2 {{ }} +"; + + var expectedDiagnostic = this.Diagnostic().WithLocation(0); + await this.VerifyCSharpFixAsync( + testCode, + this.GetSettings(), + expectedDiagnostic, + new[] + { + ("/0/Test0.cs", fixedCode1), + ("TestClass2.cs", fixedCode2), + }, + CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForDelegateCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForDelegateCSharp10UnitTests.cs new file mode 100644 index 000000000..43b326ed3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForDelegateCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules; + + public partial class SA1402ForDelegateCSharp10UnitTests : SA1402ForDelegateCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForEnumCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForEnumCSharp10UnitTests.cs new file mode 100644 index 000000000..77ca161aa --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForEnumCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules; + + public partial class SA1402ForEnumCSharp10UnitTests : SA1402ForEnumCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForInterfaceCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForInterfaceCSharp10UnitTests.cs new file mode 100644 index 000000000..ccd0435db --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForInterfaceCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules; + + public partial class SA1402ForInterfaceCSharp10UnitTests : SA1402ForInterfaceCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForRecordCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForRecordCSharp10UnitTests.cs new file mode 100644 index 000000000..61eba973a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForRecordCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules; + + public partial class SA1402ForRecordCSharp10UnitTests : SA1402ForRecordCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForRecordClassCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForRecordClassCSharp10UnitTests.cs new file mode 100644 index 000000000..0898c1ea0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForRecordClassCSharp10UnitTests.cs @@ -0,0 +1,16 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.MaintainabilityRules; + + public class SA1402ForRecordClassCSharp10UnitTests : SA1402ForBlockDeclarationUnitTestsBase + { + public override string Keyword => "record class"; + + protected override string SettingKeyword => "class"; + + protected override bool IsConfiguredAsTopLevelTypeByDefault => true; + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForRecordStructCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForRecordStructCSharp10UnitTests.cs new file mode 100644 index 000000000..1a511dd6d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForRecordStructCSharp10UnitTests.cs @@ -0,0 +1,16 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.MaintainabilityRules; + + public class SA1402ForRecordStructCSharp10UnitTests : SA1402ForBlockDeclarationUnitTestsBase + { + public override string Keyword => "record struct"; + + protected override string SettingKeyword => "struct"; + + protected override bool IsConfiguredAsTopLevelTypeByDefault => false; + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForStructCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForStructCSharp10UnitTests.cs new file mode 100644 index 000000000..e8b5f20af --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1402ForStructCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules; + + public partial class SA1402ForStructCSharp10UnitTests : SA1402ForStructCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1403CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1403CSharp10UnitTests.cs new file mode 100644 index 000000000..40e23c30d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1403CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules; + + public partial class SA1403CSharp10UnitTests : SA1403CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1404CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1404CSharp10UnitTests.cs new file mode 100644 index 000000000..f2bf2f9c5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1404CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules; + + public partial class SA1404CSharp10UnitTests : SA1404CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1405CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1405CSharp10UnitTests.cs new file mode 100644 index 000000000..08ed65cad --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1405CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules; + + public partial class SA1405CSharp10UnitTests : SA1405CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1406CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1406CSharp10UnitTests.cs new file mode 100644 index 000000000..55e951ac2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1406CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules; + + public partial class SA1406CSharp10UnitTests : SA1406CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1407CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1407CSharp10UnitTests.cs new file mode 100644 index 000000000..68c38d7b7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1407CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules; + + public partial class SA1407CSharp10UnitTests : SA1407CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1408CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1408CSharp10UnitTests.cs new file mode 100644 index 000000000..d7b81f85a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1408CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules; + + public partial class SA1408CSharp10UnitTests : SA1408CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1409CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1409CSharp10UnitTests.cs new file mode 100644 index 000000000..ad01c00bd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1409CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules; + + public partial class SA1409CSharp10UnitTests : SA1409CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1410CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1410CSharp10UnitTests.cs new file mode 100644 index 000000000..1aac8afd0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1410CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules; + + public partial class SA1410CSharp10UnitTests : SA1410CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1411CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1411CSharp10UnitTests.cs new file mode 100644 index 000000000..1e50001b4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1411CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules; + + public partial class SA1411CSharp10UnitTests : SA1411CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1412CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1412CSharp10UnitTests.cs new file mode 100644 index 000000000..1f33ce3f1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1412CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules; + + public partial class SA1412CSharp10UnitTests : SA1412CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1413CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1413CSharp10UnitTests.cs new file mode 100644 index 000000000..ddfaa54ee --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1413CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules; + + public partial class SA1413CSharp10UnitTests : SA1413CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1414CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1414CSharp10UnitTests.cs new file mode 100644 index 000000000..7510c986b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/MaintainabilityRules/SA1414CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules; + + public partial class SA1414CSharp10UnitTests : SA1414CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1300CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1300CSharp10UnitTests.cs new file mode 100644 index 000000000..3796f58bb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1300CSharp10UnitTests.cs @@ -0,0 +1,99 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp10.NamingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp9.NamingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.NamingRules.SA1300ElementMustBeginWithUpperCaseLetter, + StyleCop.Analyzers.NamingRules.RenameToUpperCaseCodeFixProvider>; + + public partial class SA1300CSharp10UnitTests : SA1300CSharp9UnitTests + { + [Fact] + public async Task TestUpperCaseFileScopedNamespaceAsync() + { + var testCode = @"namespace Test;"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestLowerCaseFileScopedNamespaceAsync() + { + var testCode = @"namespace {|#0:test|};"; + + var fixedCode = @"namespace Test;"; + + DiagnosticResult expected = Diagnostic().WithArguments("test").WithLocation(0); + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestAllowedLowerCaseFileScopedNamespaceIsNotReportedAsync() + { + var customTestSettings = @" +{ + ""settings"": { + ""namingRules"": { + ""allowedNamespaceComponents"": [ ""eBay"" ] + } + } +} +"; + + var testCode = @"namespace eBay;"; + + await new CSharpTest + { + TestCode = testCode, + Settings = customTestSettings, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestLowerCaseComlicatedFileScopedNamespaceAsync() + { + var testCode = @"namespace {|#0:test|}.{|#1:foo|}.{|#2:bar|};"; + + var fixedCode = @"namespace Test.Foo.Bar;"; + + DiagnosticResult[] expected = new[] + { + Diagnostic().WithArguments("test").WithLocation(0), + Diagnostic().WithArguments("foo").WithLocation(1), + Diagnostic().WithArguments("bar").WithLocation(2), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestAllowedLowerCaseComplicatedFileScopedNamespaceIsNotReportedAsync() + { + var customTestSettings = @" +{ + ""settings"": { + ""namingRules"": { + ""allowedNamespaceComponents"": [ ""iPod"" ] + } + } +} +"; + + var testCode = @"namespace Apple.iPod.Library;"; + + await new CSharpTest + { + TestCode = testCode, + Settings = customTestSettings, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1301CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1301CSharp10UnitTests.cs new file mode 100644 index 000000000..a59d9e7ff --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1301CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp9.NamingRules; + + public partial class SA1301CSharp10UnitTests : SA1301CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1302CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1302CSharp10UnitTests.cs new file mode 100644 index 000000000..6a2ad27a4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1302CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp9.NamingRules; + + public partial class SA1302CSharp10UnitTests : SA1302CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1303CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1303CSharp10UnitTests.cs new file mode 100644 index 000000000..0e496b9bc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1303CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp9.NamingRules; + + public partial class SA1303CSharp10UnitTests : SA1303CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1304CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1304CSharp10UnitTests.cs new file mode 100644 index 000000000..ff286ea2f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1304CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp9.NamingRules; + + public partial class SA1304CSharp10UnitTests : SA1304CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1305CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1305CSharp10UnitTests.cs new file mode 100644 index 000000000..b341a89fd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1305CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp9.NamingRules; + + public partial class SA1305CSharp10UnitTests : SA1305CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1306CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1306CSharp10UnitTests.cs new file mode 100644 index 000000000..870812f34 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1306CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp9.NamingRules; + + public partial class SA1306CSharp10UnitTests : SA1306CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1307CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1307CSharp10UnitTests.cs new file mode 100644 index 000000000..ab5176bcc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1307CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp9.NamingRules; + + public partial class SA1307CSharp10UnitTests : SA1307CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1308CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1308CSharp10UnitTests.cs new file mode 100644 index 000000000..2ea68234e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1308CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp9.NamingRules; + + public partial class SA1308CSharp10UnitTests : SA1308CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1309CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1309CSharp10UnitTests.cs new file mode 100644 index 000000000..eb2b7d337 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1309CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp9.NamingRules; + + public partial class SA1309CSharp10UnitTests : SA1309CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1310CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1310CSharp10UnitTests.cs new file mode 100644 index 000000000..aaca81ece --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1310CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp9.NamingRules; + + public partial class SA1310CSharp10UnitTests : SA1310CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1311CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1311CSharp10UnitTests.cs new file mode 100644 index 000000000..5eba51bda --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1311CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp9.NamingRules; + + public partial class SA1311CSharp10UnitTests : SA1311CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1312CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1312CSharp10UnitTests.cs new file mode 100644 index 000000000..576d7565e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1312CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp9.NamingRules; + + public partial class SA1312CSharp10UnitTests : SA1312CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1313CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1313CSharp10UnitTests.cs new file mode 100644 index 000000000..d7e76a1ee --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1313CSharp10UnitTests.cs @@ -0,0 +1,46 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.NamingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp9.NamingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.NamingRules.SA1313ParameterNamesMustBeginWithLowerCaseLetter, + StyleCop.Analyzers.NamingRules.RenameToLowerCaseCodeFixProvider>; + + public partial class SA1313CSharp10UnitTests : SA1313CSharp9UnitTests + { + [Theory] + [WorkItem(3384, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3384")] + [InlineData("class")] + [InlineData("struct")] + public async Task TestRecordTypeAsync(string typeKind) + { + var testCode = $@" +public record {typeKind} R(int A) +{{ + public R(int [|A|], int [|B|]) + : this(A) + {{ + }} +}} +"; + + var fixedCode = $@" +public record {typeKind} R(int A) +{{ + public R(int a, int b) + : this(a) + {{ + }} +}} +"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1314CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1314CSharp10UnitTests.cs new file mode 100644 index 000000000..20c5f1ccf --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1314CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp9.NamingRules; + + public partial class SA1314CSharp10UnitTests : SA1314CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1316CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1316CSharp10UnitTests.cs new file mode 100644 index 000000000..87ce3e6f3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SA1316CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp9.NamingRules; + + public partial class SA1316CSharp10UnitTests : SA1316CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SX1309CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SX1309CSharp10UnitTests.cs new file mode 100644 index 000000000..2ded8a5dd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SX1309CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp9.NamingRules; + + public partial class SX1309CSharp10UnitTests : SX1309CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SX1309SCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SX1309SCSharp10UnitTests.cs new file mode 100644 index 000000000..b3b9d6c9a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/NamingRules/SX1309SCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp9.NamingRules; + + public partial class SX1309SCSharp10UnitTests : SX1309SCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1200CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1200CSharp10UnitTests.cs new file mode 100644 index 000000000..3ca1c97b9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1200CSharp10UnitTests.cs @@ -0,0 +1,44 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.OrderingRules; + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.OrderingRules.SA1200UsingDirectivesMustBePlacedCorrectly, + StyleCop.Analyzers.OrderingRules.UsingCodeFixProvider>; + + public partial class SA1200CSharp10UnitTests : SA1200CSharp9UnitTests + { + [Fact] + public async Task TestInvalidUsingStatementsInCompilationUnitWithFileScopedNamespaceAsync() + { + var testCode = @"{|#0:using System;|} +{|#1:using System.Threading;|} + +namespace TestNamespace; +"; + + var fixedTestCode = @"namespace TestNamespace; + +using System; +using System.Threading; +"; + + DiagnosticResult[] expectedResults = + { + Diagnostic(SA1200UsingDirectivesMustBePlacedCorrectly.DescriptorInside).WithLocation(0), + Diagnostic(SA1200UsingDirectivesMustBePlacedCorrectly.DescriptorInside).WithLocation(1), + }; + + await VerifyCSharpFixAsync(testCode, expectedResults, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1200OutsideNamespaceCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1200OutsideNamespaceCSharp10UnitTests.cs new file mode 100644 index 000000000..98b05c70b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1200OutsideNamespaceCSharp10UnitTests.cs @@ -0,0 +1,40 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.OrderingRules; + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + using Xunit; + + public partial class SA1200OutsideNamespaceCSharp10UnitTests : SA1200OutsideNamespaceCSharp9UnitTests + { + [Fact] + public async Task TestInvalidUsingStatementsInFileScopedNamespaceAsync() + { + var testCode = @"namespace TestNamespace; + +{|#0:using System;|} +{|#1:using System.Threading;|} +"; + var fixedTestCode = @"using System; +using System.Threading; + +namespace TestNamespace; +"; + + DiagnosticResult[] expectedResults = + { + Diagnostic(SA1200UsingDirectivesMustBePlacedCorrectly.DescriptorOutside).WithLocation(0), + Diagnostic(SA1200UsingDirectivesMustBePlacedCorrectly.DescriptorOutside).WithLocation(1), + }; + + await VerifyCSharpFixAsync(testCode, expectedResults, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1200PreserveCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1200PreserveCSharp10UnitTests.cs new file mode 100644 index 000000000..c6bbad99e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1200PreserveCSharp10UnitTests.cs @@ -0,0 +1,45 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + using Xunit; + + public partial class SA1200PreserveCSharp10UnitTests : SA1200PreserveCSharp9UnitTests + { + [Fact] + public async Task TestValidUsingStatementsInFileScopedNamespaceAsync() + { + var testCode = @"namespace TestNamespace; + +using System; +using System.Threading; +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that having using statements in the compilation unit will not diagnostics, even if they could be + /// moved inside a file-scoped namespace. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task TestIgnoredUsingStatementsInCompilationUnitWithFileScopedNamespaceAsync() + { + var testCode = @"using System; +using System.Threading; + +namespace TestNamespace; +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1201CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1201CSharp10UnitTests.cs new file mode 100644 index 000000000..88fe742ab --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1201CSharp10UnitTests.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.OrderingRules.SA1201ElementsMustAppearInTheCorrectOrder, + StyleCop.Analyzers.OrderingRules.ElementOrderCodeFixProvider>; + + public partial class SA1201CSharp10UnitTests : SA1201CSharp9UnitTests + { + [Fact] + public async Task TestOuterOrderCorrectOrderWithFileScopedNamespaceAsync() + { + string testCode = @"namespace Foo; + +public delegate void bar(); +public enum TestEnum { } +public interface IFoo { } +public struct FooStruct { } +public class FooClass { } +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestOuterOrderWrongOrderWithFileScopedNamespaceAsync() + { + string testCode = @" +namespace Foo; + +public enum TestEnum { } +public delegate void {|#0:bar|}(); +public interface IFoo { } +public class FooClass { } +public struct {|#1:FooStruct|} { } +"; + var expected = new[] + { + Diagnostic().WithLocation(0).WithArguments("delegate", "enum"), + Diagnostic().WithLocation(1).WithArguments("struct", "class"), + }; + + await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1202CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1202CSharp10UnitTests.cs new file mode 100644 index 000000000..5ce1ec304 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1202CSharp10UnitTests.cs @@ -0,0 +1,66 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.OrderingRules.SA1202ElementsMustBeOrderedByAccess, + StyleCop.Analyzers.OrderingRules.ElementOrderCodeFixProvider>; + + public partial class SA1202CSharp10UnitTests : SA1202CSharp9UnitTests + { + /// + /// Verifies that the analyzer will properly handle ordering within a file-scoped namespace. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task TestFileScopedNamespaceClassesAsync() + { + var testCode = @"namespace TestNamespace; + +enum TestEnum1 { } +public enum {|#0:TestEnum2|} { } +class TestClass1 { } +public class {|#1:TestClass2|} { } +"; + + DiagnosticResult[] expected = + { + Diagnostic().WithLocation(0).WithArguments("public", "internal"), + Diagnostic().WithLocation(1).WithArguments("public", "internal"), + }; + + var fixedCode = @"namespace TestNamespace; +public enum TestEnum2 { } + +enum TestEnum1 { } +public class TestClass2 { } +class TestClass1 { } +"; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestDefaultAccessModifierOrderWithFileScopedNamespaceAsync() + { + string testCode = @"namespace Foo; + +public class Class1 { } +internal class Class2 { } +class Class3 { } +internal class Class4 { } +class Class5 { } +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1203CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1203CSharp10UnitTests.cs new file mode 100644 index 000000000..56a3a16c0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1203CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + + public partial class SA1203CSharp10UnitTests : SA1203CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1204CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1204CSharp10UnitTests.cs new file mode 100644 index 000000000..49d67c477 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1204CSharp10UnitTests.cs @@ -0,0 +1,42 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using System.Threading; + using System.Threading.Tasks; + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.OrderingRules.SA1204StaticElementsMustAppearBeforeInstanceElements, + StyleCop.Analyzers.OrderingRules.ElementOrderCodeFixProvider>; + + public partial class SA1204CSharp10UnitTests : SA1204CSharp9UnitTests + { + /// + /// Verifies that the analyzer will properly handle ordering within a file-scoped namespace. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task TestFileScopedNamespaceClassesAsync() + { + var testCode = @"namespace TestNamespace; + +class TestClass1 { } +static class {|#0:TestClass2|} { } +"; + + var expected = Diagnostic().WithLocation(0); + + var fixedCode = @"namespace TestNamespace; +static class TestClass2 { } + +class TestClass1 { } +"; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1205CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1205CSharp10UnitTests.cs new file mode 100644 index 000000000..f1a7e41a8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1205CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + + public partial class SA1205CSharp10UnitTests : SA1205CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1206CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1206CSharp10UnitTests.cs new file mode 100644 index 000000000..5956409c1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1206CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + + public partial class SA1206CSharp10UnitTests : SA1206CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1206CodeFixProviderCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1206CodeFixProviderCSharp10UnitTests.cs new file mode 100644 index 000000000..a0d2bc536 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1206CodeFixProviderCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + + public partial class SA1206CodeFixProviderCSharp10UnitTests : SA1206CodeFixProviderCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1207CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1207CSharp10UnitTests.cs new file mode 100644 index 000000000..87fc8261c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1207CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + + public partial class SA1207CSharp10UnitTests : SA1207CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1208CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1208CSharp10UnitTests.cs new file mode 100644 index 000000000..4ad732086 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1208CSharp10UnitTests.cs @@ -0,0 +1,67 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using System.Threading; + using System.Threading.Tasks; + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.OrderingRules.SA1208SystemUsingDirectivesMustBePlacedBeforeOtherUsingDirectives, + StyleCop.Analyzers.OrderingRules.UsingCodeFixProvider>; + + public partial class SA1208CSharp10UnitTests : SA1208CSharp9UnitTests + { + [Fact] + [WorkItem(3437, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3437")] + public async Task TestWhenSystemUsingDirectivesAreNotOnTopInFileScopedNamespaceAsync() + { + await new CSharpTest + { + TestSources = + { + "namespace Xyz;", + "namespace AnotherNamespace;", + @" +namespace Test; + +using Xyz; +{|#0:using System;|} +{|#1:using System.IO;|} +using AnotherNamespace; +{|#2:using System.Threading.Tasks;|} + +class A +{ +}", + }, + FixedSources = + { + "namespace Xyz;", + "namespace AnotherNamespace;", + @" +namespace Test; + +using System; +using System.IO; +using System.Threading.Tasks; +using AnotherNamespace; +using Xyz; + +class A +{ +}", + }, + ExpectedDiagnostics = + { + Diagnostic().WithLocation(0).WithArguments("System", "Xyz"), + Diagnostic().WithLocation(1).WithArguments("System.IO", "Xyz"), + Diagnostic().WithLocation(2).WithArguments("System.Threading.Tasks", "Xyz"), + }, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1209CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1209CSharp10UnitTests.cs new file mode 100644 index 000000000..436808006 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1209CSharp10UnitTests.cs @@ -0,0 +1,51 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.OrderingRules.SA1209UsingAliasDirectivesMustBePlacedAfterOtherUsingDirectives, + StyleCop.Analyzers.OrderingRules.UsingCodeFixProvider>; + + public partial class SA1209CSharp10UnitTests : SA1209CSharp9UnitTests + { + [Fact] + [WorkItem(3439, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3439")] + public async Task TestWhenUsingAliasDirectivesAreNotPlacedCorrectlyInFileScopedNamespaceAsync() + { + var testCodeNamespace = @"namespace Test; + +using System.Net; +using System.Threading; +[|using L = System.Linq;|] +using System.IO; +using P = System.Threading.Tasks; + +class A +{ +} +"; + var fixedTestCodeNamespace = @"namespace Test; + +using System.IO; +using System.Net; +using System.Threading; +using L = System.Linq; +using P = System.Threading.Tasks; + +class A +{ +} +"; + + await VerifyCSharpFixAsync(testCodeNamespace, DiagnosticResult.EmptyDiagnosticResults, fixedTestCodeNamespace, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1210CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1210CSharp10UnitTests.cs new file mode 100644 index 000000000..a72bc73d6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1210CSharp10UnitTests.cs @@ -0,0 +1,57 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.OrderingRules.SA1210UsingDirectivesMustBeOrderedAlphabeticallyByNamespace, + StyleCop.Analyzers.OrderingRules.UsingCodeFixProvider>; + + public partial class SA1210CSharp10UnitTests : SA1210CSharp9UnitTests + { + [Fact] + public async Task TestUsingDirectivesInFileScopedNamespaceDeclarationAsync() + { + await new CSharpTest + { + TestSources = + { + @"namespace Foo; + +[|using System.Threading;|] +using System; +", + @"namespace Bar; + +[|using Foo;|] +using Bar; +[|using System.Threading;|] +using System; +", + }, + FixedSources = + { + @"namespace Foo; + +using System; +using System.Threading; +", + @"namespace Bar; + +using System; +using System.Threading; +using Bar; +using Foo; +", + }, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1210CombinedSystemDirectivesCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1210CombinedSystemDirectivesCSharp10UnitTests.cs new file mode 100644 index 000000000..ce2f0de2d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1210CombinedSystemDirectivesCSharp10UnitTests.cs @@ -0,0 +1,57 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using System.Threading; + using System.Threading.Tasks; + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.OrderingRules.SA1210UsingDirectivesMustBeOrderedAlphabeticallyByNamespace, + StyleCop.Analyzers.OrderingRules.UsingCodeFixProvider>; + + public partial class SA1210CombinedSystemDirectivesCSharp10UnitTests : SA1210CombinedSystemDirectivesCSharp9UnitTests + { + [Fact] + public async Task TestUsingDirectivesInFileScopedNamespaceDeclarationAsync() + { + await new CSharpTest + { + TestSources = + { + @"namespace Food; + +[|using System.Threading;|] +using System; +", + @"namespace Bar; + +[|using Food;|] +using Bar; +[|using System.Threading;|] +using System; +", + }, + FixedSources = + { + @"namespace Food; + +using System; +using System.Threading; +", + @"namespace Bar; + +using Bar; +using Food; +using System; +using System.Threading; +", + }, + Settings = CombinedUsingDirectivesTestSettings, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1211CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1211CSharp10UnitTests.cs new file mode 100644 index 000000000..ff4f4c376 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1211CSharp10UnitTests.cs @@ -0,0 +1,78 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using System.Threading; + using System.Threading.Tasks; + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.OrderingRules.SA1211UsingAliasDirectivesMustBeOrderedAlphabeticallyByAliasName, + StyleCop.Analyzers.OrderingRules.UsingCodeFixProvider>; + + public partial class SA1211CSharp10UnitTests : SA1211CSharp9UnitTests + { + [Fact] + public async Task TestUsingDirectivesOrderingInFileScopedNamespaceAsync() + { + await new CSharpTest + { + TestSources = + { + @"namespace Foo; + +using System; +using \u0069nt = System.Int32; +{|#0:using character = System.Char;|} +", + @"namespace Bar; + +using System; +using Stream = System.IO.Stream; +using StringBuilder = System.Text.StringBuilder; +using StringWriter = System.IO.StringWriter; +{|#1:using MemoryStream = System.IO.MemoryStream;|} +", + @"namespace Spam; + +using System; +using @int = System.Int32; +{|#2:using Character = System.Char;|} +", + }, + ExpectedDiagnostics = + { + Diagnostic().WithLocation(0).WithArguments("character", "int"), + Diagnostic().WithLocation(1).WithArguments("MemoryStream", "Stream"), + Diagnostic().WithLocation(2).WithArguments("Character", "int"), + }, + FixedSources = + { + @"namespace Foo; + +using System; +using character = System.Char; +using \u0069nt = System.Int32; +", + @"namespace Bar; + +using System; +using MemoryStream = System.IO.MemoryStream; +using Stream = System.IO.Stream; +using StringBuilder = System.Text.StringBuilder; +using StringWriter = System.IO.StringWriter; +", + @"namespace Spam; + +using System; +using Character = System.Char; +using @int = System.Int32; +", + }, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1212CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1212CSharp10UnitTests.cs new file mode 100644 index 000000000..c05a647a2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1212CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + + public partial class SA1212CSharp10UnitTests : SA1212CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1213CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1213CSharp10UnitTests.cs new file mode 100644 index 000000000..c54d7d31c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1213CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + + public partial class SA1213CSharp10UnitTests : SA1213CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1214CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1214CSharp10UnitTests.cs new file mode 100644 index 000000000..dff8980b7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1214CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + + public partial class SA1214CSharp10UnitTests : SA1214CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1215CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1215CSharp10UnitTests.cs new file mode 100644 index 000000000..bf32b0e15 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1215CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + + public partial class SA1215CSharp10UnitTests : SA1215CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1216CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1216CSharp10UnitTests.cs new file mode 100644 index 000000000..25d9817d3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1216CSharp10UnitTests.cs @@ -0,0 +1,63 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using System.Threading; + using System.Threading.Tasks; + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.OrderingRules.SA1216UsingStaticDirectivesMustBePlacedAtTheCorrectLocation, + StyleCop.Analyzers.OrderingRules.UsingCodeFixProvider>; + + public partial class SA1216CSharp10UnitTests : SA1216CSharp9UnitTests + { + [Fact] + public async Task TestUsingDirectivesOrderingInFileScopedNamespaceAsync() + { + await new CSharpTest + { + TestSources = + { + @"namespace Foo; + +{|#0:using static System.Math;|} +using Execute = System.Action; +using System; +", + @"namespace Bar; + +using Execute = System.Action; +{|#1:using static System.Array;|} +using static System.Math; +using System; +", + }, + ExpectedDiagnostics = + { + Diagnostic().WithLocation(0), + Diagnostic().WithLocation(1), + }, + FixedSources = + { + @"namespace Foo; + +using System; +using static System.Math; +using Execute = System.Action; +", + @"namespace Bar; + +using System; +using static System.Array; +using static System.Math; +using Execute = System.Action; +", + }, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1217CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1217CSharp10UnitTests.cs new file mode 100644 index 000000000..831319f1d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/SA1217CSharp10UnitTests.cs @@ -0,0 +1,65 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using System.Threading; + using System.Threading.Tasks; + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.OrderingRules.SA1217UsingStaticDirectivesMustBeOrderedAlphabetically, + StyleCop.Analyzers.OrderingRules.UsingCodeFixProvider>; + + public partial class SA1217CSharp10UnitTests : SA1217CSharp9UnitTests + { + [Fact] + public async Task TestUsingDirectivesOrderingInFileScopedNamespaceAsync() + { + await new CSharpTest + { + TestSources = + { + @"namespace Foo; + +using System; +using Execute = System.Action; +{|#0:using static System.Math;|} +using static System.Array; +", + @"namespace Bar; + +{|#1:using static System.Math;|} +using Execute = System.Action; +using static System.Array; +using System; +", + }, + ExpectedDiagnostics = + { + Diagnostic().WithLocation(0).WithArguments("System.Math", "System.Array"), + Diagnostic().WithLocation(1).WithArguments("System.Math", "System.Array"), + }, + FixedSources = + { + @"namespace Foo; + +using System; +using static System.Array; +using static System.Math; +using Execute = System.Action; +", + @"namespace Bar; + +using System; +using static System.Array; +using static System.Math; +using Execute = System.Action; +", + }, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/UsingCodeFixProviderCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/UsingCodeFixProviderCSharp10UnitTests.cs new file mode 100644 index 000000000..1a9c83eac --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/UsingCodeFixProviderCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + + public partial class UsingCodeFixProviderCSharp10UnitTests : UsingCodeFixProviderCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/UsingCodeFixProviderCombinedSystemDirectivesCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/UsingCodeFixProviderCombinedSystemDirectivesCSharp10UnitTests.cs new file mode 100644 index 000000000..4aa74814a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/UsingCodeFixProviderCombinedSystemDirectivesCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + + public partial class UsingCodeFixProviderCombinedSystemDirectivesCSharp10UnitTests : UsingCodeFixProviderCombinedSystemDirectivesCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/UsingCodeFixProviderGroupSeparationCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/UsingCodeFixProviderGroupSeparationCSharp10UnitTests.cs new file mode 100644 index 000000000..c223048b9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/UsingCodeFixProviderGroupSeparationCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + + public partial class UsingCodeFixProviderGroupSeparationCSharp10UnitTests : UsingCodeFixProviderGroupSeparationCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/UsingCodeFixProviderRegressionCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/UsingCodeFixProviderRegressionCSharp10UnitTests.cs new file mode 100644 index 000000000..569bcc146 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/OrderingRules/UsingCodeFixProviderRegressionCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp9.OrderingRules; + + public partial class UsingCodeFixProviderRegressionCSharp10UnitTests : UsingCodeFixProviderRegressionCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Properties/AssemblyInfo.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..0b50cd86e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Properties/AssemblyInfo.cs @@ -0,0 +1,14 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +using System; +using System.Runtime.InteropServices; + +[assembly: CLSCompliant(false)] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1100CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1100CSharp10UnitTests.cs new file mode 100644 index 000000000..65be2750e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1100CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1100CSharp10UnitTests : SA1100CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1101CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1101CSharp10UnitTests.cs new file mode 100644 index 000000000..30c1fa682 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1101CSharp10UnitTests.cs @@ -0,0 +1,35 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.ReadabilityRules.SA1101PrefixLocalCallsWithThis, + StyleCop.Analyzers.ReadabilityRules.SA1101CodeFixProvider>; + + public partial class SA1101CSharp10UnitTests : SA1101CSharp9UnitTests + { + [Fact] + [WorkItem(3472, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3472")] + public async Task TestExtendedPropertyPatternAsync() + { + var testCode = @"public class Test +{ + public Test Inner; + public string Value; + + public bool Method(Test arg) + { + return arg is { Inner.Value: """" }; + } +}"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1102CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1102CSharp10UnitTests.cs new file mode 100644 index 000000000..2b427c3d8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1102CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1102CSharp10UnitTests : SA1102CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1103CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1103CSharp10UnitTests.cs new file mode 100644 index 000000000..e9084f222 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1103CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1103CSharp10UnitTests : SA1103CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1104CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1104CSharp10UnitTests.cs new file mode 100644 index 000000000..4da434339 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1104CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1104CSharp10UnitTests : SA1104CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1105CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1105CSharp10UnitTests.cs new file mode 100644 index 000000000..d61c48777 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1105CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1105CSharp10UnitTests : SA1105CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1106CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1106CSharp10UnitTests.cs new file mode 100644 index 000000000..3e2037cc9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1106CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1106CSharp10UnitTests : SA1106CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1107CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1107CSharp10UnitTests.cs new file mode 100644 index 000000000..21a98655f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1107CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1107CSharp10UnitTests : SA1107CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1108CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1108CSharp10UnitTests.cs new file mode 100644 index 000000000..baf907237 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1108CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1108CSharp10UnitTests : SA1108CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1109CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1109CSharp10UnitTests.cs new file mode 100644 index 000000000..87350eeee --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1109CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1109CSharp10UnitTests : SA1109CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1110CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1110CSharp10UnitTests.cs new file mode 100644 index 000000000..4f20adcf0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1110CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1110CSharp10UnitTests : SA1110CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1111CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1111CSharp10UnitTests.cs new file mode 100644 index 000000000..59ddf2bd7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1111CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1111CSharp10UnitTests : SA1111CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1112CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1112CSharp10UnitTests.cs new file mode 100644 index 000000000..e9e55758d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1112CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1112CSharp10UnitTests : SA1112CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1113CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1113CSharp10UnitTests.cs new file mode 100644 index 000000000..f1f0f5f3f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1113CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1113CSharp10UnitTests : SA1113CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1114CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1114CSharp10UnitTests.cs new file mode 100644 index 000000000..6f96d7ba4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1114CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1114CSharp10UnitTests : SA1114CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1115CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1115CSharp10UnitTests.cs new file mode 100644 index 000000000..35b474629 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1115CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1115CSharp10UnitTests : SA1115CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1116CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1116CSharp10UnitTests.cs new file mode 100644 index 000000000..3583aa5b0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1116CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1116CSharp10UnitTests : SA1116CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1117CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1117CSharp10UnitTests.cs new file mode 100644 index 000000000..6bda75aef --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1117CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1117CSharp10UnitTests : SA1117CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1118CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1118CSharp10UnitTests.cs new file mode 100644 index 000000000..5e058ac48 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1118CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1118CSharp10UnitTests : SA1118CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1120CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1120CSharp10UnitTests.cs new file mode 100644 index 000000000..0a563797e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1120CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1120CSharp10UnitTests : SA1120CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1121CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1121CSharp10UnitTests.cs new file mode 100644 index 000000000..ef49e9a37 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1121CSharp10UnitTests.cs @@ -0,0 +1,46 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.ReadabilityRules.SA1121UseBuiltInTypeAlias, + StyleCop.Analyzers.ReadabilityRules.SA1121CodeFixProvider>; + + public partial class SA1121CSharp10UnitTests : SA1121CSharp9UnitTests + { + [Fact] + public async Task TestUsingNameChangeInFileScopedNamespaceAsync() + { + string oldSource = @"namespace Foo; + +using MyInt = System.UInt32; +class Bar +{ +{|#0:MyInt|} value = 3; +} +"; + string newSource = @"namespace Foo; + +using MyInt = System.UInt32; +class Bar +{ +uint value = 3; +} +"; + + await new CSharpTest + { + TestCode = oldSource, + ExpectedDiagnostics = { Diagnostic().WithLocation(0) }, + FixedCode = newSource, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1122CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1122CSharp10UnitTests.cs new file mode 100644 index 000000000..cccee3bb6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1122CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1122CSharp10UnitTests : SA1122CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1123CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1123CSharp10UnitTests.cs new file mode 100644 index 000000000..42040e17a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1123CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1123CSharp10UnitTests : SA1123CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1124CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1124CSharp10UnitTests.cs new file mode 100644 index 000000000..2a24233ca --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1124CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1124CSharp10UnitTests : SA1124CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1125CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1125CSharp10UnitTests.cs new file mode 100644 index 000000000..80b390729 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1125CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1125CSharp10UnitTests : SA1125CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1126CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1126CSharp10UnitTests.cs new file mode 100644 index 000000000..6bd22aee8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1126CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1126CSharp10UnitTests : SA1126CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1127CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1127CSharp10UnitTests.cs new file mode 100644 index 000000000..10a0c2436 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1127CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1127CSharp10UnitTests : SA1127CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1128CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1128CSharp10UnitTests.cs new file mode 100644 index 000000000..429b7fc5a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1128CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1128CSharp10UnitTests : SA1128CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1129CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1129CSharp10UnitTests.cs new file mode 100644 index 000000000..bd97ba2c9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1129CSharp10UnitTests.cs @@ -0,0 +1,93 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.ReadabilityRules.SA1129DoNotUseDefaultValueTypeConstructor, + StyleCop.Analyzers.ReadabilityRules.SA1129CodeFixProvider>; + + public partial class SA1129CSharp10UnitTests : SA1129CSharp9UnitTests + { + [Fact] + [WorkItem(3430, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3430")] + public async Task VerifyParameterlessStructConstructorAsync() + { + var testCode = @"struct S +{ + public S() { } + + internal static S F1() + { + S s = new S(); + return s; + } + + internal static S F2() + { + S s = new(); + return s; + } + + internal static S F3() => new S(); + + internal static S F4() => new(); +} +"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, testCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3430, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3430")] + public async Task VerifyParameterlessStructConstructorInMetadataAsync() + { + await new CSharpTest + { + TestState = + { + Sources = + { + @"class B +{ + internal static S F1() + { + S s = new S(); + return s; + } + + internal static S F2() + { + S s = new(); + return s; + } + + internal static S F3() => new S(); + + internal static S F4() => new(); +} +", + }, + AdditionalProjects = + { + ["Reference"] = + { + Sources = + { + @"public struct S { public S() { } }", + }, + }, + }, + AdditionalProjectReferences = { "Reference" }, + }, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1130CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1130CSharp10UnitTests.cs new file mode 100644 index 000000000..b016726c7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1130CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1130CSharp10UnitTests : SA1130CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1131CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1131CSharp10UnitTests.cs new file mode 100644 index 000000000..fbc5dff16 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1131CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1131CSharp10UnitTests : SA1131CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1132CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1132CSharp10UnitTests.cs new file mode 100644 index 000000000..26312a7c6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1132CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1132CSharp10UnitTests : SA1132CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1133CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1133CSharp10UnitTests.cs new file mode 100644 index 000000000..ad8ecc518 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1133CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1133CSharp10UnitTests : SA1133CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1134CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1134CSharp10UnitTests.cs new file mode 100644 index 000000000..93be7b460 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1134CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1134CSharp10UnitTests : SA1134CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1135CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1135CSharp10UnitTests.cs new file mode 100644 index 000000000..e6dc85620 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1135CSharp10UnitTests.cs @@ -0,0 +1,57 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.ReadabilityRules.SA1135UsingDirectivesMustBeQualified, + StyleCop.Analyzers.ReadabilityRules.SA1135CodeFixProvider>; + + public partial class SA1135CSharp10UnitTests : SA1135CSharp9UnitTests + { + [Fact] + [WorkItem(3415, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3415")] + public async Task TestFileScopedNamespaceAsync() + { + var testCode = @" +namespace TestNamespace +{ + using KeyValue = System.Collections.Generic.KeyValuePair; +} +"; + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + await new CSharpTest + { + TestState = + { + Sources = + { + @"namespace A.B.C { }", + @"namespace A.B.D; + +[|using C;|] +", + }, + }, + FixedState = + { + Sources = + { + @"namespace A.B.C { }", + @"namespace A.B.D; + +using A.B.C; +", + }, + }, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1136CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1136CSharp10UnitTests.cs new file mode 100644 index 000000000..9d08d322c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1136CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1136CSharp10UnitTests : SA1136CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1137CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1137CSharp10UnitTests.cs new file mode 100644 index 000000000..c0d8e2662 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1137CSharp10UnitTests.cs @@ -0,0 +1,170 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + using StyleCop.Analyzers.Test.Helpers; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.ReadabilityRules.SA1137ElementsShouldHaveTheSameIndentation, + StyleCop.Analyzers.ReadabilityRules.IndentationCodeFixProvider>; + + public partial class SA1137CSharp10UnitTests : SA1137CSharp9UnitTests + { + [Theory] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task TestFileScopedNamespaceDeclarationAsync(string baseTypeKind) + { + await new CSharpTest + { + TestSources = + { + $@" +using System; + +namespace Namespace0; + + [My] [My] {baseTypeKind} TypeName {{ }} +", + $@" +using System; + +namespace Namespace1; + + [My] +[| |][My] {baseTypeKind} TypeName {{ }} +", + $@" +using System; + +namespace Namespace2; + + [My] +[| |][My] + {baseTypeKind} TypeName {{ }} +", + $@" +using System; + +namespace Namespace3; + +[| |][My] +[| |][My] + {baseTypeKind} TypeName {{ }} +", + $@" +using System; + +namespace Namespace4; + + {baseTypeKind} TypeName1 {{ }} + +[| |][My] {baseTypeKind} TypeName2 {{ }} +", + $@" +using System; + +namespace Namespace5; + + {baseTypeKind} TypeName1 {{ }} + + [My] +[| |][My] {baseTypeKind} TypeName2 {{ }} +", + $@" +using System; + +namespace Namespace6; + + {baseTypeKind} TypeName1 {{ }} + +[| |][My] + [My] {baseTypeKind} TypeName2 {{ }} +", + $@" +using System; + +[AttributeUsage(AttributeTargets.All, AllowMultiple = true)] +class MyAttribute : Attribute {{ }} +", + }, + FixedSources = + { + $@" +using System; + +namespace Namespace0; + + [My] [My] {baseTypeKind} TypeName {{ }} +", + $@" +using System; + +namespace Namespace1; + + [My] + [My] {baseTypeKind} TypeName {{ }} +", + $@" +using System; + +namespace Namespace2; + + [My] + [My] + {baseTypeKind} TypeName {{ }} +", + $@" +using System; + +namespace Namespace3; + + [My] + [My] + {baseTypeKind} TypeName {{ }} +", + $@" +using System; + +namespace Namespace4; + + {baseTypeKind} TypeName1 {{ }} + + [My] {baseTypeKind} TypeName2 {{ }} +", + $@" +using System; + +namespace Namespace5; + + {baseTypeKind} TypeName1 {{ }} + + [My] + [My] {baseTypeKind} TypeName2 {{ }} +", + $@" +using System; + +namespace Namespace6; + + {baseTypeKind} TypeName1 {{ }} + + [My] + [My] {baseTypeKind} TypeName2 {{ }} +", + $@" +using System; + +[AttributeUsage(AttributeTargets.All, AllowMultiple = true)] +class MyAttribute : Attribute {{ }} +", + }, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1139CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1139CSharp10UnitTests.cs new file mode 100644 index 000000000..2e7b2e6dc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1139CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1139CSharp10UnitTests : SA1139CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1141CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1141CSharp10UnitTests.cs new file mode 100644 index 000000000..ba8e4bc25 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1141CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1141CSharp10UnitTests : SA1141CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1142CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1142CSharp10UnitTests.cs new file mode 100644 index 000000000..2667d72ec --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SA1142CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SA1142CSharp10UnitTests : SA1142CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SX1101CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SX1101CSharp10UnitTests.cs new file mode 100644 index 000000000..709ef958a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/ReadabilityRules/SX1101CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp9.ReadabilityRules; + + public partial class SX1101CSharp10UnitTests : SX1101CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Settings/SettingsCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Settings/SettingsCSharp10UnitTests.cs new file mode 100644 index 000000000..12a8acb20 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Settings/SettingsCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Settings +{ + using StyleCop.Analyzers.Test.CSharp9.Settings; + + public partial class SettingsCSharp10UnitTests : SettingsCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Settings/SettingsFileCodeFixProviderCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Settings/SettingsFileCodeFixProviderCSharp10UnitTests.cs new file mode 100644 index 000000000..1299dd5ab --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/Settings/SettingsFileCodeFixProviderCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.Settings +{ + using StyleCop.Analyzers.Test.CSharp9.Settings; + + public partial class SettingsFileCodeFixProviderCSharp10UnitTests : SettingsFileCodeFixProviderCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1000CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1000CSharp10UnitTests.cs new file mode 100644 index 000000000..4ea149535 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1000CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1000CSharp10UnitTests : SA1000CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1001CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1001CSharp10UnitTests.cs new file mode 100644 index 000000000..6d39da657 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1001CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1001CSharp10UnitTests : SA1001CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1002CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1002CSharp10UnitTests.cs new file mode 100644 index 000000000..fc096bc83 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1002CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1002CSharp10UnitTests : SA1002CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1003CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1003CSharp10UnitTests.cs new file mode 100644 index 000000000..ae1bcee2f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1003CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1003CSharp10UnitTests : SA1003CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1004CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1004CSharp10UnitTests.cs new file mode 100644 index 000000000..8a1e5dc27 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1004CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1004CSharp10UnitTests : SA1004CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1005CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1005CSharp10UnitTests.cs new file mode 100644 index 000000000..637a825ab --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1005CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1005CSharp10UnitTests : SA1005CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1006CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1006CSharp10UnitTests.cs new file mode 100644 index 000000000..fe38a82f5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1006CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1006CSharp10UnitTests : SA1006CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1007CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1007CSharp10UnitTests.cs new file mode 100644 index 000000000..7aa8fc7cb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1007CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1007CSharp10UnitTests : SA1007CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1008CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1008CSharp10UnitTests.cs new file mode 100644 index 000000000..9111642a0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1008CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1008CSharp10UnitTests : SA1008CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1009CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1009CSharp10UnitTests.cs new file mode 100644 index 000000000..3ad8c5f64 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1009CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1009CSharp10UnitTests : SA1009CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1010CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1010CSharp10UnitTests.cs new file mode 100644 index 000000000..a68aaa005 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1010CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1010CSharp10UnitTests : SA1010CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1011CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1011CSharp10UnitTests.cs new file mode 100644 index 000000000..7c6a011f1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1011CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1011CSharp10UnitTests : SA1011CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1012CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1012CSharp10UnitTests.cs new file mode 100644 index 000000000..a0f6fbeca --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1012CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1012CSharp10UnitTests : SA1012CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1013CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1013CSharp10UnitTests.cs new file mode 100644 index 000000000..7c22de145 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1013CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1013CSharp10UnitTests : SA1013CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1014CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1014CSharp10UnitTests.cs new file mode 100644 index 000000000..a6b6f1599 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1014CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1014CSharp10UnitTests : SA1014CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1015CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1015CSharp10UnitTests.cs new file mode 100644 index 000000000..33281fdce --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1015CSharp10UnitTests.cs @@ -0,0 +1,44 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1015ClosingGenericBracketsMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1015CSharp10UnitTests : SA1015CSharp9UnitTests + { + [Fact] + [WorkItem(3624, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3624")] + public async Task TestLambdaWithExplicitGenericReturnTypeAsync() + { + const string testCode = @"using System.Threading.Tasks; + +public class TestClass +{ + public void TestMethod() + { + var _ = Task|](int x) => Task.FromResult(x); + } +}"; + + const string fixedCode = @"using System.Threading.Tasks; + +public class TestClass +{ + public void TestMethod() + { + var _ = Task (int x) => Task.FromResult(x); + } +}"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1016CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1016CSharp10UnitTests.cs new file mode 100644 index 000000000..55cef2cba --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1016CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1016CSharp10UnitTests : SA1016CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1017CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1017CSharp10UnitTests.cs new file mode 100644 index 000000000..ddb538791 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1017CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1017CSharp10UnitTests : SA1017CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1018CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1018CSharp10UnitTests.cs new file mode 100644 index 000000000..89ad42ec7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1018CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1018CSharp10UnitTests : SA1018CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1019CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1019CSharp10UnitTests.cs new file mode 100644 index 000000000..510f4b7a9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1019CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1019CSharp10UnitTests : SA1019CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1020CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1020CSharp10UnitTests.cs new file mode 100644 index 000000000..358a4f9ec --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1020CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1020CSharp10UnitTests : SA1020CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1021CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1021CSharp10UnitTests.cs new file mode 100644 index 000000000..e2e934759 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1021CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1021CSharp10UnitTests : SA1021CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1022CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1022CSharp10UnitTests.cs new file mode 100644 index 000000000..74fb79c31 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1022CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1022CSharp10UnitTests : SA1022CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1023CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1023CSharp10UnitTests.cs new file mode 100644 index 000000000..b4fd263af --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1023CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1023CSharp10UnitTests : SA1023CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1024CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1024CSharp10UnitTests.cs new file mode 100644 index 000000000..a1024d769 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1024CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1024CSharp10UnitTests : SA1024CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1025CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1025CSharp10UnitTests.cs new file mode 100644 index 000000000..ec813bcc0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1025CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1025CSharp10UnitTests : SA1025CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1026CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1026CSharp10UnitTests.cs new file mode 100644 index 000000000..130c0f9db --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1026CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1026CSharp10UnitTests : SA1026CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1027AlternateIndentationCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1027AlternateIndentationCSharp10UnitTests.cs new file mode 100644 index 000000000..a62a9ca66 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1027AlternateIndentationCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1027AlternateIndentationCSharp10UnitTests : SA1027AlternateIndentationCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1027CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1027CSharp10UnitTests.cs new file mode 100644 index 000000000..18f2a3e99 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1027CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1027CSharp10UnitTests : SA1027CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1027UseTabsCSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1027UseTabsCSharp10UnitTests.cs new file mode 100644 index 000000000..54103d8cb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1027UseTabsCSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1027UseTabsCSharp10UnitTests : SA1027UseTabsCSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1028CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1028CSharp10UnitTests.cs new file mode 100644 index 000000000..8a8b07424 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpacingRules/SA1028CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpacingRules; + + public partial class SA1028CSharp10UnitTests : SA1028CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpecialRules/SA0001CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpecialRules/SA0001CSharp10UnitTests.cs new file mode 100644 index 000000000..aa6723152 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpecialRules/SA0001CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpecialRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpecialRules; + + public partial class SA0001CSharp10UnitTests : SA0001CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpecialRules/SA0002CSharp10UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpecialRules/SA0002CSharp10UnitTests.cs new file mode 100644 index 000000000..ac319bfb1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/SpecialRules/SA0002CSharp10UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp10.SpecialRules +{ + using StyleCop.Analyzers.Test.CSharp9.SpecialRules; + + public partial class SA0002CSharp10UnitTests : SA0002CSharp9UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/StyleCop.Analyzers.Test.CSharp10.csproj b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/StyleCop.Analyzers.Test.CSharp10.csproj new file mode 100644 index 000000000..34d936714 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/StyleCop.Analyzers.Test.CSharp10.csproj @@ -0,0 +1,36 @@ + + + + + net472 + false + true + true + + + + ..\StyleCop.Analyzers.Internal.ruleset + + + + true + ..\..\build\keys\TestingKey.snk + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/AnalyzerConfigurationCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/AnalyzerConfigurationCSharp11UnitTests.cs new file mode 100644 index 000000000..25fd38b43 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/AnalyzerConfigurationCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11 +{ + using StyleCop.Analyzers.Test.CSharp10; + + public partial class AnalyzerConfigurationCSharp11UnitTests : AnalyzerConfigurationCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/InheritdocCodeFixProviderCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/InheritdocCodeFixProviderCSharp11UnitTests.cs new file mode 100644 index 000000000..423f6df7d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/InheritdocCodeFixProviderCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class InheritdocCodeFixProviderCSharp11UnitTests : InheritdocCodeFixProviderCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/NoXmlFileHeaderCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/NoXmlFileHeaderCSharp11UnitTests.cs new file mode 100644 index 000000000..4c11bd3da --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/NoXmlFileHeaderCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class NoXmlFileHeaderCSharp11UnitTests : NoXmlFileHeaderCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1600CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1600CSharp11UnitTests.cs new file mode 100644 index 000000000..1d1777cda --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1600CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1600CSharp11UnitTests : SA1600CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1601CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1601CSharp11UnitTests.cs new file mode 100644 index 000000000..6d82b05ad --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1601CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1601CSharp11UnitTests : SA1601CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1602CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1602CSharp11UnitTests.cs new file mode 100644 index 000000000..077774a71 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1602CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1602CSharp11UnitTests : SA1602CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1603CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1603CSharp11UnitTests.cs new file mode 100644 index 000000000..e8a57aa97 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1603CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1603CSharp11UnitTests : SA1603CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1604CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1604CSharp11UnitTests.cs new file mode 100644 index 000000000..32d78f7c0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1604CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1604CSharp11UnitTests : SA1604CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1605CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1605CSharp11UnitTests.cs new file mode 100644 index 000000000..312e28bab --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1605CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1605CSharp11UnitTests : SA1605CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1606CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1606CSharp11UnitTests.cs new file mode 100644 index 000000000..786ac6e06 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1606CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1606CSharp11UnitTests : SA1606CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1607CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1607CSharp11UnitTests.cs new file mode 100644 index 000000000..5ad9cb910 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1607CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1607CSharp11UnitTests : SA1607CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1608CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1608CSharp11UnitTests.cs new file mode 100644 index 000000000..d2db803ca --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1608CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1608CSharp11UnitTests : SA1608CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1609CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1609CSharp11UnitTests.cs new file mode 100644 index 000000000..a6498b7d0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1609CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1609CSharp11UnitTests : SA1609CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1610CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1610CSharp11UnitTests.cs new file mode 100644 index 000000000..43bc82ad4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1610CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1610CSharp11UnitTests : SA1610CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1611CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1611CSharp11UnitTests.cs new file mode 100644 index 000000000..b9b3c5162 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1611CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1611CSharp11UnitTests : SA1611CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1612CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1612CSharp11UnitTests.cs new file mode 100644 index 000000000..f3dd55fad --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1612CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1612CSharp11UnitTests : SA1612CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1613CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1613CSharp11UnitTests.cs new file mode 100644 index 000000000..c96f335d0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1613CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1613CSharp11UnitTests : SA1613CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1614CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1614CSharp11UnitTests.cs new file mode 100644 index 000000000..42b500aba --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1614CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1614CSharp11UnitTests : SA1614CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1615CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1615CSharp11UnitTests.cs new file mode 100644 index 000000000..c30162419 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1615CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1615CSharp11UnitTests : SA1615CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1616CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1616CSharp11UnitTests.cs new file mode 100644 index 000000000..b011a44e3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1616CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1616CSharp11UnitTests : SA1616CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1617CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1617CSharp11UnitTests.cs new file mode 100644 index 000000000..6ce80dc08 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1617CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1617CSharp11UnitTests : SA1617CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1618CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1618CSharp11UnitTests.cs new file mode 100644 index 000000000..389dc5f5c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1618CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1618CSharp11UnitTests : SA1618CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1619CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1619CSharp11UnitTests.cs new file mode 100644 index 000000000..f6e31309c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1619CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1619CSharp11UnitTests : SA1619CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1620CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1620CSharp11UnitTests.cs new file mode 100644 index 000000000..c3ced9ac5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1620CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1620CSharp11UnitTests : SA1620CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1621CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1621CSharp11UnitTests.cs new file mode 100644 index 000000000..4a0ebe8dc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1621CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1621CSharp11UnitTests : SA1621CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1622CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1622CSharp11UnitTests.cs new file mode 100644 index 000000000..de9d051d6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1622CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1622CSharp11UnitTests : SA1622CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1623CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1623CSharp11UnitTests.cs new file mode 100644 index 000000000..12b17ba15 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1623CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1623CSharp11UnitTests : SA1623CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1624CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1624CSharp11UnitTests.cs new file mode 100644 index 000000000..d56e9bf11 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1624CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1624CSharp11UnitTests : SA1624CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1625CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1625CSharp11UnitTests.cs new file mode 100644 index 000000000..da0f6d502 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1625CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1625CSharp11UnitTests : SA1625CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1626CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1626CSharp11UnitTests.cs new file mode 100644 index 000000000..a450810b6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1626CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1626CSharp11UnitTests : SA1626CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1627CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1627CSharp11UnitTests.cs new file mode 100644 index 000000000..a5649738c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1627CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1627CSharp11UnitTests : SA1627CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1628CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1628CSharp11UnitTests.cs new file mode 100644 index 000000000..ac541ac47 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1628CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1628CSharp11UnitTests : SA1628CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1629CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1629CSharp11UnitTests.cs new file mode 100644 index 000000000..a77152cf8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1629CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1629CSharp11UnitTests : SA1629CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1630CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1630CSharp11UnitTests.cs new file mode 100644 index 000000000..83a0c8824 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1630CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1630CSharp11UnitTests : SA1630CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1631CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1631CSharp11UnitTests.cs new file mode 100644 index 000000000..b12b7c2a9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1631CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1631CSharp11UnitTests : SA1631CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1632CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1632CSharp11UnitTests.cs new file mode 100644 index 000000000..c00b8b8ac --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1632CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1632CSharp11UnitTests : SA1632CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1633CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1633CSharp11UnitTests.cs new file mode 100644 index 000000000..4634c075a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1633CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1633CSharp11UnitTests : SA1633CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1634CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1634CSharp11UnitTests.cs new file mode 100644 index 000000000..cd7f9209f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1634CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1634CSharp11UnitTests : SA1634CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1635CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1635CSharp11UnitTests.cs new file mode 100644 index 000000000..4cdb22ba5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1635CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1635CSharp11UnitTests : SA1635CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1636CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1636CSharp11UnitTests.cs new file mode 100644 index 000000000..003c38325 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1636CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1636CSharp11UnitTests : SA1636CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1637CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1637CSharp11UnitTests.cs new file mode 100644 index 000000000..8cba85f4d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1637CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1637CSharp11UnitTests : SA1637CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1638CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1638CSharp11UnitTests.cs new file mode 100644 index 000000000..d3efe648a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1638CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1638CSharp11UnitTests : SA1638CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1639CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1639CSharp11UnitTests.cs new file mode 100644 index 000000000..d7e1e0f72 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1639CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1639CSharp11UnitTests : SA1639CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1640CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1640CSharp11UnitTests.cs new file mode 100644 index 000000000..56320024e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1640CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1640CSharp11UnitTests : SA1640CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1641CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1641CSharp11UnitTests.cs new file mode 100644 index 000000000..c5d2185c0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1641CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1641CSharp11UnitTests : SA1641CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1642CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1642CSharp11UnitTests.cs new file mode 100644 index 000000000..e215494e2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1642CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1642CSharp11UnitTests : SA1642CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1643CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1643CSharp11UnitTests.cs new file mode 100644 index 000000000..d7596856c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1643CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1643CSharp11UnitTests : SA1643CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1644CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1644CSharp11UnitTests.cs new file mode 100644 index 000000000..049ff9ffc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1644CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1644CSharp11UnitTests : SA1644CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1645CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1645CSharp11UnitTests.cs new file mode 100644 index 000000000..2c2b03454 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1645CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1645CSharp11UnitTests : SA1645CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1646CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1646CSharp11UnitTests.cs new file mode 100644 index 000000000..17e1aa988 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1646CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1646CSharp11UnitTests : SA1646CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1647CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1647CSharp11UnitTests.cs new file mode 100644 index 000000000..5042fa79a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1647CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1647CSharp11UnitTests : SA1647CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1648CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1648CSharp11UnitTests.cs new file mode 100644 index 000000000..86f74283c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1648CSharp11UnitTests.cs @@ -0,0 +1,48 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + using Xunit; + + public partial class SA1648CSharp11UnitTests : SA1648CSharp10UnitTests + { + [WorkItem(3595, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3595")] + [Theory] + [InlineData("abstract void TestMethod();", "public void TestMethod() {}")] + [InlineData("abstract void TestMethod();", "void TestInterface.TestMethod() {}")] + [InlineData("virtual void TestMethod() {}", "public void TestMethod() {}")] + [InlineData("virtual void TestMethod() {}", "void TestInterface.TestMethod() {}")] + [InlineData("abstract int TestProperty { get; set; }", "public int TestProperty { get; set; }")] + [InlineData("abstract int TestProperty { get; set; }", "int TestInterface.TestProperty { get; set; }")] + [InlineData("virtual int TestProperty { get; set; }", "public int TestProperty { get; set; }")] + [InlineData("virtual int TestProperty { get; set; }", "int TestInterface.TestProperty { get; set; }")] + [InlineData("abstract event System.Action TestEvent;", "public event System.Action TestEvent;")] + [InlineData("abstract event System.Action TestEvent;", "event System.Action TestInterface.TestEvent { add {} remove {} }")] + [InlineData("virtual event System.Action TestEvent;", "public event System.Action TestEvent;")] + [InlineData("virtual event System.Action TestEvent;", "event System.Action TestInterface.TestEvent { add {} remove {} }")] + public async Task TestCorrectMemberInheritDocFromStaticAbstractOrVirtualMemberInInterfaceAsync(string interfaceMember, string classMember) + { + var testCode = $@" +public interface TestInterface +{{ + /// + /// A summary text. + /// + static {interfaceMember} +}} + +public class TestClass : TestInterface +{{ + /// + static {classMember} +}}"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1649CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1649CSharp11UnitTests.cs new file mode 100644 index 000000000..915c775fb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1649CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1649CSharp11UnitTests : SA1649CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1650CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1650CSharp11UnitTests.cs new file mode 100644 index 000000000..379885e98 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1650CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1650CSharp11UnitTests : SA1650CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1651CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1651CSharp11UnitTests.cs new file mode 100644 index 000000000..ccdf93be2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/DocumentationRules/SA1651CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp10.DocumentationRules; + + public partial class SA1651CSharp11UnitTests : SA1651CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/HelperTests/SymbolNameHelpersCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/HelperTests/SymbolNameHelpersCSharp11UnitTests.cs new file mode 100644 index 000000000..c80c8d62c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/HelperTests/SymbolNameHelpersCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.HelperTests +{ + using StyleCop.Analyzers.Test.CSharp10.HelperTests; + + public partial class SymbolNameHelpersCSharp11UnitTests : SymbolNameHelpersCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1500CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1500CSharp11UnitTests.cs new file mode 100644 index 000000000..7c024042b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1500CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp10.LayoutRules; + + public partial class SA1500CSharp11UnitTests : SA1500CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1501CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1501CSharp11UnitTests.cs new file mode 100644 index 000000000..5276d3144 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1501CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp10.LayoutRules; + + public partial class SA1501CSharp11UnitTests : SA1501CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1502CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1502CSharp11UnitTests.cs new file mode 100644 index 000000000..d4880527c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1502CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp10.LayoutRules; + + public partial class SA1502CSharp11UnitTests : SA1502CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1503CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1503CSharp11UnitTests.cs new file mode 100644 index 000000000..eda0fa3b2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1503CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp10.LayoutRules; + + public partial class SA1503CSharp11UnitTests : SA1503CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1504CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1504CSharp11UnitTests.cs new file mode 100644 index 000000000..a207d7545 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1504CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp10.LayoutRules; + + public partial class SA1504CSharp11UnitTests : SA1504CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1505CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1505CSharp11UnitTests.cs new file mode 100644 index 000000000..974c7afa1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1505CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp10.LayoutRules; + + public partial class SA1505CSharp11UnitTests : SA1505CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1506CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1506CSharp11UnitTests.cs new file mode 100644 index 000000000..441945f1d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1506CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp10.LayoutRules; + + public partial class SA1506CSharp11UnitTests : SA1506CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1507CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1507CSharp11UnitTests.cs new file mode 100644 index 000000000..2744a9373 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1507CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp10.LayoutRules; + + public partial class SA1507CSharp11UnitTests : SA1507CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1508CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1508CSharp11UnitTests.cs new file mode 100644 index 000000000..babb47e98 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1508CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp10.LayoutRules; + + public partial class SA1508CSharp11UnitTests : SA1508CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1509CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1509CSharp11UnitTests.cs new file mode 100644 index 000000000..8d2489205 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1509CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp10.LayoutRules; + + public partial class SA1509CSharp11UnitTests : SA1509CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1510CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1510CSharp11UnitTests.cs new file mode 100644 index 000000000..a6d929929 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1510CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp10.LayoutRules; + + public partial class SA1510CSharp11UnitTests : SA1510CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1511CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1511CSharp11UnitTests.cs new file mode 100644 index 000000000..244bc901a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1511CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp10.LayoutRules; + + public partial class SA1511CSharp11UnitTests : SA1511CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1512CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1512CSharp11UnitTests.cs new file mode 100644 index 000000000..00a43813a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1512CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp10.LayoutRules; + + public partial class SA1512CSharp11UnitTests : SA1512CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1513CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1513CSharp11UnitTests.cs new file mode 100644 index 000000000..df0c9200d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1513CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp10.LayoutRules; + + public partial class SA1513CSharp11UnitTests : SA1513CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1514CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1514CSharp11UnitTests.cs new file mode 100644 index 000000000..b700b085a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1514CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp10.LayoutRules; + + public partial class SA1514CSharp11UnitTests : SA1514CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1515CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1515CSharp11UnitTests.cs new file mode 100644 index 000000000..da5ab8b74 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1515CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp10.LayoutRules; + + public partial class SA1515CSharp11UnitTests : SA1515CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1516CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1516CSharp11UnitTests.cs new file mode 100644 index 000000000..06fa1b3c7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1516CSharp11UnitTests.cs @@ -0,0 +1,37 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp11.LayoutRules +{ + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp10.LayoutRules; + + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.LayoutRules.SA1516ElementsMustBeSeparatedByBlankLine, + StyleCop.Analyzers.LayoutRules.SA1516CodeFixProvider>; + + public partial class SA1516CSharp11UnitTests : SA1516CSharp10UnitTests + { + protected override DiagnosticResult[] GetExpectedResultTestUsingAndGlobalStatementSpacingInTopLevelProgram() + { + // NOTE: Roslyn bug fix. Earlier versions made diagnostics be reported twice. + return new[] + { + // /0/Test0.cs(3,1): warning SA1516: Elements should be separated by blank line + Diagnostic().WithLocation(0), + }; + } + + protected override DiagnosticResult[] GetExpectedResultTestGlobalStatementAndRecordSpacingInTopLevelProgram() + { + // NOTE: Roslyn bug fix. Earlier versions made diagnostics be reported twice. + return new[] + { + // /0/Test0.cs(2,1): warning SA1516: Elements should be separated by blank line + Diagnostic().WithLocation(0), + }; + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1516UsingGroupsCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1516UsingGroupsCSharp11UnitTests.cs new file mode 100644 index 000000000..05584e523 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1516UsingGroupsCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp10.LayoutRules; + + public partial class SA1516UsingGroupsCSharp11UnitTests : SA1516UsingGroupsCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1517CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1517CSharp11UnitTests.cs new file mode 100644 index 000000000..d16626d11 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1517CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp10.LayoutRules; + + public partial class SA1517CSharp11UnitTests : SA1517CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1518CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1518CSharp11UnitTests.cs new file mode 100644 index 000000000..505e85cab --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1518CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp10.LayoutRules; + + public partial class SA1518CSharp11UnitTests : SA1518CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1519CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1519CSharp11UnitTests.cs new file mode 100644 index 000000000..ee67d0ea7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1519CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp10.LayoutRules; + + public partial class SA1519CSharp11UnitTests : SA1519CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1520CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1520CSharp11UnitTests.cs new file mode 100644 index 000000000..936a3c0e9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/LayoutRules/SA1520CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp10.LayoutRules; + + public partial class SA1520CSharp11UnitTests : SA1520CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/AccessorDeclarationSyntaxExtensionsCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/AccessorDeclarationSyntaxExtensionsCSharp11UnitTests.cs new file mode 100644 index 000000000..3241a9c76 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/AccessorDeclarationSyntaxExtensionsCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class AccessorDeclarationSyntaxExtensionsCSharp11UnitTests : AccessorDeclarationSyntaxExtensionsCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/ArgumentSyntaxExtensionsCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/ArgumentSyntaxExtensionsCSharp11UnitTests.cs new file mode 100644 index 000000000..2821de803 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/ArgumentSyntaxExtensionsCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class ArgumentSyntaxExtensionsCSharp11UnitTests : ArgumentSyntaxExtensionsCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/BaseMethodDeclarationSyntaxExtensionsCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/BaseMethodDeclarationSyntaxExtensionsCSharp11UnitTests.cs new file mode 100644 index 000000000..dfbe6bedf --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/BaseMethodDeclarationSyntaxExtensionsCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class BaseMethodDeclarationSyntaxExtensionsCSharp11UnitTests : BaseMethodDeclarationSyntaxExtensionsCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/CasePatternSwitchLabelSyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/CasePatternSwitchLabelSyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..76a48d44b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/CasePatternSwitchLabelSyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class CasePatternSwitchLabelSyntaxWrapperCSharp11UnitTests : CasePatternSwitchLabelSyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/CommonForEachStatementSyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/CommonForEachStatementSyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..74adc3ca7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/CommonForEachStatementSyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class CommonForEachStatementSyntaxWrapperCSharp11UnitTests : CommonForEachStatementSyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/ConstantPatternSyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/ConstantPatternSyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..d3a19b254 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/ConstantPatternSyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class ConstantPatternSyntaxWrapperCSharp11UnitTests : ConstantPatternSyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/ConstructorDeclarationSyntaxExtensionsCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/ConstructorDeclarationSyntaxExtensionsCSharp11UnitTests.cs new file mode 100644 index 000000000..33000cee6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/ConstructorDeclarationSyntaxExtensionsCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class ConstructorDeclarationSyntaxExtensionsCSharp11UnitTests : ConstructorDeclarationSyntaxExtensionsCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/CrefParameterSyntaxExtensionsCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/CrefParameterSyntaxExtensionsCSharp11UnitTests.cs new file mode 100644 index 000000000..b5b5160fa --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/CrefParameterSyntaxExtensionsCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class CrefParameterSyntaxExtensionsCSharp11UnitTests : CrefParameterSyntaxExtensionsCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/DeclarationExpressionSyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/DeclarationExpressionSyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..f033abcc8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/DeclarationExpressionSyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class DeclarationExpressionSyntaxWrapperCSharp11UnitTests : DeclarationExpressionSyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/DeclarationPatternSyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/DeclarationPatternSyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..805d1bcc1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/DeclarationPatternSyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class DeclarationPatternSyntaxWrapperCSharp11UnitTests : DeclarationPatternSyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/DestructorDeclarationSyntaxExtensionsCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/DestructorDeclarationSyntaxExtensionsCSharp11UnitTests.cs new file mode 100644 index 000000000..897fdf4dd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/DestructorDeclarationSyntaxExtensionsCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class DestructorDeclarationSyntaxExtensionsCSharp11UnitTests : DestructorDeclarationSyntaxExtensionsCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/DiscardDesignationSyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/DiscardDesignationSyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..b7b3b300b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/DiscardDesignationSyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class DiscardDesignationSyntaxWrapperCSharp11UnitTests : DiscardDesignationSyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..b3d13c4aa --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp11UnitTests : ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/IsPatternExpressionSyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/IsPatternExpressionSyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..1fa3fd92e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/IsPatternExpressionSyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class IsPatternExpressionSyntaxWrapperCSharp11UnitTests : IsPatternExpressionSyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/LanguageVersionExCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/LanguageVersionExCSharp11UnitTests.cs new file mode 100644 index 000000000..0ba0a966f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/LanguageVersionExCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class LanguageVersionExCSharp11UnitTests : LanguageVersionExCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/LightupHelpersCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/LightupHelpersCSharp11UnitTests.cs new file mode 100644 index 000000000..08b7a1526 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/LightupHelpersCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class LightupHelpersCSharp11UnitTests : LightupHelpersCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/LocalFunctionStatementSyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/LocalFunctionStatementSyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..ff0444c51 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/LocalFunctionStatementSyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class LocalFunctionStatementSyntaxWrapperCSharp11UnitTests : LocalFunctionStatementSyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/MethodKindExCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/MethodKindExCSharp11UnitTests.cs new file mode 100644 index 000000000..3958819dc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/MethodKindExCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class MethodKindExCSharp11UnitTests : MethodKindExCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/OperationKindExCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/OperationKindExCSharp11UnitTests.cs new file mode 100644 index 000000000..813b6fc4b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/OperationKindExCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class OperationKindExCSharp11UnitTests : OperationKindExCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/ParenthesizedVariableDesignationSyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/ParenthesizedVariableDesignationSyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..9736a00c7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/ParenthesizedVariableDesignationSyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class ParenthesizedVariableDesignationSyntaxWrapperCSharp11UnitTests : ParenthesizedVariableDesignationSyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/PatternSyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/PatternSyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..8d676e8fc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/PatternSyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class PatternSyntaxWrapperCSharp11UnitTests : PatternSyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/RefExpressionSyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/RefExpressionSyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..8dac8896e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/RefExpressionSyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class RefExpressionSyntaxWrapperCSharp11UnitTests : RefExpressionSyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/RefTypeSyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/RefTypeSyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..6d9c874d7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/RefTypeSyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class RefTypeSyntaxWrapperCSharp11UnitTests : RefTypeSyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/SingleVariableDesignationSyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/SingleVariableDesignationSyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..2f79b34f0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/SingleVariableDesignationSyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class SingleVariableDesignationSyntaxWrapperCSharp11UnitTests : SingleVariableDesignationSyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/StackAllocArrayCreationExpressionSyntaxExtensionsCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/StackAllocArrayCreationExpressionSyntaxExtensionsCSharp11UnitTests.cs new file mode 100644 index 000000000..021172d15 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/StackAllocArrayCreationExpressionSyntaxExtensionsCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class StackAllocArrayCreationExpressionSyntaxExtensionsCSharp11UnitTests : StackAllocArrayCreationExpressionSyntaxExtensionsCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/SwitchExpressionArmSyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/SwitchExpressionArmSyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..4607432a2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/SwitchExpressionArmSyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class SwitchExpressionArmSyntaxWrapperCSharp11UnitTests : SwitchExpressionArmSyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/SwitchExpressionSyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/SwitchExpressionSyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..ef200b66e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/SwitchExpressionSyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class SwitchExpressionSyntaxWrapperCSharp11UnitTests : SwitchExpressionSyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/SyntaxKindExCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/SyntaxKindExCSharp11UnitTests.cs new file mode 100644 index 000000000..b3a842316 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/SyntaxKindExCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class SyntaxKindExCSharp11UnitTests : SyntaxKindExCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/SyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/SyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..ae46ee183 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/SyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class SyntaxWrapperCSharp11UnitTests : SyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/SyntaxWrapperHelperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/SyntaxWrapperHelperCSharp11UnitTests.cs new file mode 100644 index 000000000..fe7176158 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/SyntaxWrapperHelperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class SyntaxWrapperHelperCSharp11UnitTests : SyntaxWrapperHelperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/ThrowExpressionSyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/ThrowExpressionSyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..be104d46b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/ThrowExpressionSyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class ThrowExpressionSyntaxWrapperCSharp11UnitTests : ThrowExpressionSyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/TupleElementSyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/TupleElementSyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..9e9fc4eca --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/TupleElementSyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class TupleElementSyntaxWrapperCSharp11UnitTests : TupleElementSyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/TupleExpressionSyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/TupleExpressionSyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..498b22c70 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/TupleExpressionSyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class TupleExpressionSyntaxWrapperCSharp11UnitTests : TupleExpressionSyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/TupleTypeSyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/TupleTypeSyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..7f8bb3ea9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/TupleTypeSyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class TupleTypeSyntaxWrapperCSharp11UnitTests : TupleTypeSyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/VariableDesignationSyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/VariableDesignationSyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..45003497d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/VariableDesignationSyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class VariableDesignationSyntaxWrapperCSharp11UnitTests : VariableDesignationSyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/WhenClauseSyntaxWrapperCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/WhenClauseSyntaxWrapperCSharp11UnitTests.cs new file mode 100644 index 000000000..9bf2f34e4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Lightup/WhenClauseSyntaxWrapperCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Lightup +{ + using StyleCop.Analyzers.Test.CSharp10.Lightup; + + public partial class WhenClauseSyntaxWrapperCSharp11UnitTests : WhenClauseSyntaxWrapperCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1119CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1119CSharp11UnitTests.cs new file mode 100644 index 000000000..20b460a89 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1119CSharp11UnitTests.cs @@ -0,0 +1,26 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + + public partial class SA1119CSharp11UnitTests : SA1119CSharp10UnitTests + { + // In earlier Roslyn versions, we ended up with an extra space between the opening brace + // and the identifier. Does not happen anymore. + protected override string GetFixedCodeTestParenthesisInInterpolatedStringThatShouldBeRemoved() + { + return @"class Foo +{ + public void Bar() + { + bool flag = false; + string data = $""{flag}""; + } +}"; + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1400CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1400CSharp11UnitTests.cs new file mode 100644 index 000000000..755bfcfc1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1400CSharp11UnitTests.cs @@ -0,0 +1,28 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + using StyleCop.Analyzers.Test.Helpers; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.MaintainabilityRules.SA1400AccessModifierMustBeDeclared, + StyleCop.Analyzers.MaintainabilityRules.SA1400CodeFixProvider>; + + public partial class SA1400CSharp11UnitTests : SA1400CSharp10UnitTests + { + [Theory] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + [WorkItem(3588, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3588")] + public async Task TestTypeDeclarationWithFileModifierAsync(string typeName) + { + var testCode = $@"file {typeName} TypeName {{ }}"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1401CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1401CSharp11UnitTests.cs new file mode 100644 index 000000000..4f79097d8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1401CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + + public partial class SA1401CSharp11UnitTests : SA1401CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForClassCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForClassCSharp11UnitTests.cs new file mode 100644 index 000000000..e57806802 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForClassCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + + public partial class SA1402ForClassCSharp11UnitTests : SA1402ForClassCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForDelegateCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForDelegateCSharp11UnitTests.cs new file mode 100644 index 000000000..d832ca32a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForDelegateCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + + public partial class SA1402ForDelegateCSharp11UnitTests : SA1402ForDelegateCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForEnumCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForEnumCSharp11UnitTests.cs new file mode 100644 index 000000000..c8704cd43 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForEnumCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + + public partial class SA1402ForEnumCSharp11UnitTests : SA1402ForEnumCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForInterfaceCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForInterfaceCSharp11UnitTests.cs new file mode 100644 index 000000000..231b4a135 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForInterfaceCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + + public partial class SA1402ForInterfaceCSharp11UnitTests : SA1402ForInterfaceCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForRecordCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForRecordCSharp11UnitTests.cs new file mode 100644 index 000000000..dde412102 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForRecordCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + + public partial class SA1402ForRecordCSharp11UnitTests : SA1402ForRecordCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForRecordClassCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForRecordClassCSharp11UnitTests.cs new file mode 100644 index 000000000..33b95102b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForRecordClassCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + + public partial class SA1402ForRecordClassCSharp11UnitTests : SA1402ForRecordClassCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForRecordStructCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForRecordStructCSharp11UnitTests.cs new file mode 100644 index 000000000..687501446 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForRecordStructCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + + public partial class SA1402ForRecordStructCSharp11UnitTests : SA1402ForRecordStructCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForStructCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForStructCSharp11UnitTests.cs new file mode 100644 index 000000000..44d5b33c3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1402ForStructCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + + public partial class SA1402ForStructCSharp11UnitTests : SA1402ForStructCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1403CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1403CSharp11UnitTests.cs new file mode 100644 index 000000000..fbc49ba94 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1403CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + + public partial class SA1403CSharp11UnitTests : SA1403CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1404CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1404CSharp11UnitTests.cs new file mode 100644 index 000000000..0f7019680 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1404CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + + public partial class SA1404CSharp11UnitTests : SA1404CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1405CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1405CSharp11UnitTests.cs new file mode 100644 index 000000000..57fc1f851 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1405CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + + public partial class SA1405CSharp11UnitTests : SA1405CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1406CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1406CSharp11UnitTests.cs new file mode 100644 index 000000000..b510ced38 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1406CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + + public partial class SA1406CSharp11UnitTests : SA1406CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1407CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1407CSharp11UnitTests.cs new file mode 100644 index 000000000..4af501d55 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1407CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + + public partial class SA1407CSharp11UnitTests : SA1407CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1408CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1408CSharp11UnitTests.cs new file mode 100644 index 000000000..c3dfcb00e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1408CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + + public partial class SA1408CSharp11UnitTests : SA1408CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1409CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1409CSharp11UnitTests.cs new file mode 100644 index 000000000..1cea2eefc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1409CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + + public partial class SA1409CSharp11UnitTests : SA1409CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1410CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1410CSharp11UnitTests.cs new file mode 100644 index 000000000..0fa7f698c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1410CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + + public partial class SA1410CSharp11UnitTests : SA1410CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1411CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1411CSharp11UnitTests.cs new file mode 100644 index 000000000..3efae1fde --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1411CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + + public partial class SA1411CSharp11UnitTests : SA1411CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1412CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1412CSharp11UnitTests.cs new file mode 100644 index 000000000..ad5c310d2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1412CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + + public partial class SA1412CSharp11UnitTests : SA1412CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1413CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1413CSharp11UnitTests.cs new file mode 100644 index 000000000..f8b27288c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1413CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + + public partial class SA1413CSharp11UnitTests : SA1413CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1414CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1414CSharp11UnitTests.cs new file mode 100644 index 000000000..265f7ce5d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/MaintainabilityRules/SA1414CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.MaintainabilityRules; + + public partial class SA1414CSharp11UnitTests : SA1414CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1300CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1300CSharp11UnitTests.cs new file mode 100644 index 000000000..f22ea6dda --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1300CSharp11UnitTests.cs @@ -0,0 +1,26 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp11.NamingRules +{ + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp10.NamingRules; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.NamingRules.SA1300ElementMustBeginWithUpperCaseLetter, + StyleCop.Analyzers.NamingRules.RenameToUpperCaseCodeFixProvider>; + + public partial class SA1300CSharp11UnitTests : SA1300CSharp10UnitTests + { + protected override DiagnosticResult[] GetExpectedResultTestPositionalRecord1() + { + // NOTE: Roslyn bug fix. Earlier versions made diagnostics be reported twice. + return new[] + { + // /0/Test0.cs(2,15): warning SA1300: Element 'r' should begin with an uppercase letter + Diagnostic().WithLocation(0).WithArguments("r"), + }; + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1301CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1301CSharp11UnitTests.cs new file mode 100644 index 000000000..06434a76f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1301CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp10.NamingRules; + + public partial class SA1301CSharp11UnitTests : SA1301CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1302CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1302CSharp11UnitTests.cs new file mode 100644 index 000000000..3750ced23 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1302CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp10.NamingRules; + + public partial class SA1302CSharp11UnitTests : SA1302CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1303CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1303CSharp11UnitTests.cs new file mode 100644 index 000000000..4b27f5902 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1303CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp10.NamingRules; + + public partial class SA1303CSharp11UnitTests : SA1303CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1304CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1304CSharp11UnitTests.cs new file mode 100644 index 000000000..120285c8c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1304CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp10.NamingRules; + + public partial class SA1304CSharp11UnitTests : SA1304CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1305CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1305CSharp11UnitTests.cs new file mode 100644 index 000000000..9863d8e88 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1305CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp10.NamingRules; + + public partial class SA1305CSharp11UnitTests : SA1305CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1306CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1306CSharp11UnitTests.cs new file mode 100644 index 000000000..d47013a39 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1306CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp10.NamingRules; + + public partial class SA1306CSharp11UnitTests : SA1306CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1307CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1307CSharp11UnitTests.cs new file mode 100644 index 000000000..84f2e4d0d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1307CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp10.NamingRules; + + public partial class SA1307CSharp11UnitTests : SA1307CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1308CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1308CSharp11UnitTests.cs new file mode 100644 index 000000000..7594a40f4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1308CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp10.NamingRules; + + public partial class SA1308CSharp11UnitTests : SA1308CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1309CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1309CSharp11UnitTests.cs new file mode 100644 index 000000000..9f9c95268 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1309CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp10.NamingRules; + + public partial class SA1309CSharp11UnitTests : SA1309CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1310CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1310CSharp11UnitTests.cs new file mode 100644 index 000000000..15b36cf09 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1310CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp10.NamingRules; + + public partial class SA1310CSharp11UnitTests : SA1310CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1311CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1311CSharp11UnitTests.cs new file mode 100644 index 000000000..8b4fc8d3d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1311CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp10.NamingRules; + + public partial class SA1311CSharp11UnitTests : SA1311CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1312CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1312CSharp11UnitTests.cs new file mode 100644 index 000000000..8c8bbf371 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1312CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp10.NamingRules; + + public partial class SA1312CSharp11UnitTests : SA1312CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1313CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1313CSharp11UnitTests.cs new file mode 100644 index 000000000..9c76946c7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1313CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp10.NamingRules; + + public partial class SA1313CSharp11UnitTests : SA1313CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1314CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1314CSharp11UnitTests.cs new file mode 100644 index 000000000..2d4dcd032 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1314CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp10.NamingRules; + + public partial class SA1314CSharp11UnitTests : SA1314CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1316CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1316CSharp11UnitTests.cs new file mode 100644 index 000000000..d9064720b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SA1316CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp10.NamingRules; + + public partial class SA1316CSharp11UnitTests : SA1316CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SX1309CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SX1309CSharp11UnitTests.cs new file mode 100644 index 000000000..1e5c5849e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SX1309CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp10.NamingRules; + + public partial class SX1309CSharp11UnitTests : SX1309CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SX1309SCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SX1309SCSharp11UnitTests.cs new file mode 100644 index 000000000..f14d8357e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/NamingRules/SX1309SCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp10.NamingRules; + + public partial class SX1309SCSharp11UnitTests : SX1309SCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1200CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1200CSharp11UnitTests.cs new file mode 100644 index 000000000..1300857fc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1200CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class SA1200CSharp11UnitTests : SA1200CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1200OutsideNamespaceCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1200OutsideNamespaceCSharp11UnitTests.cs new file mode 100644 index 000000000..351329a34 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1200OutsideNamespaceCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class SA1200OutsideNamespaceCSharp11UnitTests : SA1200OutsideNamespaceCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1200PreserveCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1200PreserveCSharp11UnitTests.cs new file mode 100644 index 000000000..9be2d4dda --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1200PreserveCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class SA1200PreserveCSharp11UnitTests : SA1200PreserveCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1201CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1201CSharp11UnitTests.cs new file mode 100644 index 000000000..53b12a796 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1201CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class SA1201CSharp11UnitTests : SA1201CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1202CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1202CSharp11UnitTests.cs new file mode 100644 index 000000000..88a9b5a9e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1202CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class SA1202CSharp11UnitTests : SA1202CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1203CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1203CSharp11UnitTests.cs new file mode 100644 index 000000000..13a63f780 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1203CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class SA1203CSharp11UnitTests : SA1203CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1204CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1204CSharp11UnitTests.cs new file mode 100644 index 000000000..a34f23e4d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1204CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class SA1204CSharp11UnitTests : SA1204CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1205CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1205CSharp11UnitTests.cs new file mode 100644 index 000000000..9648ec47c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1205CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class SA1205CSharp11UnitTests : SA1205CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1206CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1206CSharp11UnitTests.cs new file mode 100644 index 000000000..ecfbd47f0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1206CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class SA1206CSharp11UnitTests : SA1206CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1206CodeFixProviderCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1206CodeFixProviderCSharp11UnitTests.cs new file mode 100644 index 000000000..369133453 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1206CodeFixProviderCSharp11UnitTests.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.OrderingRules.SA1206DeclarationKeywordsMustFollowOrder, + StyleCop.Analyzers.OrderingRules.SA1206CodeFixProvider>; + + public partial class SA1206CodeFixProviderCSharp11UnitTests : SA1206CodeFixProviderCSharp10UnitTests + { + [Fact] + [WorkItem(3589, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3589")] + public async Task VerifyFileKeywordReorderingInClassDeclarationAsync() + { + var testCode = $"static unsafe {{|#0:file|}} class TestClass {{}}"; + var fixedTestCode = $"file static unsafe class TestClass {{}}"; + + var expected = Diagnostic().WithLocation(0).WithArguments("file", "unsafe"); + await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3527, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3527")] + public async Task VerifyRequiredKeywordReorderingInPropertiesAndFieldsAsync() + { + var testCode = @" +internal struct SomeStruct +{ + required {|#0:public|} int Prop { get; set; } + required {|#1:public|} int Field; +}"; + + var fixedCode = @" +internal struct SomeStruct +{ + public required int Prop { get; set; } + public required int Field; +}"; + + DiagnosticResult[] expected = + { + Diagnostic().WithLocation(0).WithArguments("public", "required"), + Diagnostic().WithLocation(1).WithArguments("public", "required"), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1207CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1207CSharp11UnitTests.cs new file mode 100644 index 000000000..780718a3b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1207CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class SA1207CSharp11UnitTests : SA1207CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1208CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1208CSharp11UnitTests.cs new file mode 100644 index 000000000..23a6a4519 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1208CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class SA1208CSharp11UnitTests : SA1208CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1209CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1209CSharp11UnitTests.cs new file mode 100644 index 000000000..aec6acb96 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1209CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class SA1209CSharp11UnitTests : SA1209CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1210CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1210CSharp11UnitTests.cs new file mode 100644 index 000000000..26ef17517 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1210CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class SA1210CSharp11UnitTests : SA1210CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1210CombinedSystemDirectivesCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1210CombinedSystemDirectivesCSharp11UnitTests.cs new file mode 100644 index 000000000..ac08406c6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1210CombinedSystemDirectivesCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class SA1210CombinedSystemDirectivesCSharp11UnitTests : SA1210CombinedSystemDirectivesCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1211CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1211CSharp11UnitTests.cs new file mode 100644 index 000000000..72e8c1d30 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1211CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class SA1211CSharp11UnitTests : SA1211CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1212CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1212CSharp11UnitTests.cs new file mode 100644 index 000000000..5469422f7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1212CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class SA1212CSharp11UnitTests : SA1212CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1213CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1213CSharp11UnitTests.cs new file mode 100644 index 000000000..31be82932 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1213CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class SA1213CSharp11UnitTests : SA1213CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1214CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1214CSharp11UnitTests.cs new file mode 100644 index 000000000..c0f26876c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1214CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class SA1214CSharp11UnitTests : SA1214CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1215CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1215CSharp11UnitTests.cs new file mode 100644 index 000000000..1726cb59c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1215CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class SA1215CSharp11UnitTests : SA1215CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1216CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1216CSharp11UnitTests.cs new file mode 100644 index 000000000..81c3edc78 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1216CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class SA1216CSharp11UnitTests : SA1216CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1217CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1217CSharp11UnitTests.cs new file mode 100644 index 000000000..8410c68c1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/SA1217CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class SA1217CSharp11UnitTests : SA1217CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/UsingCodeFixProviderCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/UsingCodeFixProviderCSharp11UnitTests.cs new file mode 100644 index 000000000..bf8d26155 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/UsingCodeFixProviderCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class UsingCodeFixProviderCSharp11UnitTests : UsingCodeFixProviderCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/UsingCodeFixProviderCombinedSystemDirectivesCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/UsingCodeFixProviderCombinedSystemDirectivesCSharp11UnitTests.cs new file mode 100644 index 000000000..bb41770f0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/UsingCodeFixProviderCombinedSystemDirectivesCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class UsingCodeFixProviderCombinedSystemDirectivesCSharp11UnitTests : UsingCodeFixProviderCombinedSystemDirectivesCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/UsingCodeFixProviderGroupSeparationCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/UsingCodeFixProviderGroupSeparationCSharp11UnitTests.cs new file mode 100644 index 000000000..434c862ce --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/UsingCodeFixProviderGroupSeparationCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class UsingCodeFixProviderGroupSeparationCSharp11UnitTests : UsingCodeFixProviderGroupSeparationCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/UsingCodeFixProviderRegressionCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/UsingCodeFixProviderRegressionCSharp11UnitTests.cs new file mode 100644 index 000000000..2fc6bba5a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/OrderingRules/UsingCodeFixProviderRegressionCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp10.OrderingRules; + + public partial class UsingCodeFixProviderRegressionCSharp11UnitTests : UsingCodeFixProviderRegressionCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Properties/AssemblyInfo.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..0b50cd86e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Properties/AssemblyInfo.cs @@ -0,0 +1,14 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +using System; +using System.Runtime.InteropServices; + +[assembly: CLSCompliant(false)] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1100CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1100CSharp11UnitTests.cs new file mode 100644 index 000000000..40b4a822a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1100CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1100CSharp11UnitTests : SA1100CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1101CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1101CSharp11UnitTests.cs new file mode 100644 index 000000000..9e6989ee0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1101CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1101CSharp11UnitTests : SA1101CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1102CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1102CSharp11UnitTests.cs new file mode 100644 index 000000000..9c07c3f58 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1102CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1102CSharp11UnitTests : SA1102CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1103CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1103CSharp11UnitTests.cs new file mode 100644 index 000000000..342089f4a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1103CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1103CSharp11UnitTests : SA1103CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1104CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1104CSharp11UnitTests.cs new file mode 100644 index 000000000..496e9b09e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1104CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1104CSharp11UnitTests : SA1104CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1105CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1105CSharp11UnitTests.cs new file mode 100644 index 000000000..6a367b885 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1105CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1105CSharp11UnitTests : SA1105CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1106CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1106CSharp11UnitTests.cs new file mode 100644 index 000000000..2a39db903 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1106CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1106CSharp11UnitTests : SA1106CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1107CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1107CSharp11UnitTests.cs new file mode 100644 index 000000000..d10b70851 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1107CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1107CSharp11UnitTests : SA1107CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1108CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1108CSharp11UnitTests.cs new file mode 100644 index 000000000..d69f2f5f7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1108CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1108CSharp11UnitTests : SA1108CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1109CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1109CSharp11UnitTests.cs new file mode 100644 index 000000000..d433e920f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1109CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1109CSharp11UnitTests : SA1109CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1110CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1110CSharp11UnitTests.cs new file mode 100644 index 000000000..d2fba6df3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1110CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1110CSharp11UnitTests : SA1110CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1111CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1111CSharp11UnitTests.cs new file mode 100644 index 000000000..7ab5725da --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1111CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1111CSharp11UnitTests : SA1111CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1112CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1112CSharp11UnitTests.cs new file mode 100644 index 000000000..3cba382b0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1112CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1112CSharp11UnitTests : SA1112CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1113CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1113CSharp11UnitTests.cs new file mode 100644 index 000000000..eb60d6571 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1113CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1113CSharp11UnitTests : SA1113CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1114CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1114CSharp11UnitTests.cs new file mode 100644 index 000000000..c54898e9d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1114CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1114CSharp11UnitTests : SA1114CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1115CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1115CSharp11UnitTests.cs new file mode 100644 index 000000000..6fee9b1e7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1115CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1115CSharp11UnitTests : SA1115CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1116CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1116CSharp11UnitTests.cs new file mode 100644 index 000000000..3eced192c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1116CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1116CSharp11UnitTests : SA1116CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1117CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1117CSharp11UnitTests.cs new file mode 100644 index 000000000..5cb3f7875 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1117CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1117CSharp11UnitTests : SA1117CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1118CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1118CSharp11UnitTests.cs new file mode 100644 index 000000000..5c98fab11 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1118CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1118CSharp11UnitTests : SA1118CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1120CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1120CSharp11UnitTests.cs new file mode 100644 index 000000000..64f10ddb0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1120CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1120CSharp11UnitTests : SA1120CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1121CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1121CSharp11UnitTests.cs new file mode 100644 index 000000000..118e24fb8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1121CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1121CSharp11UnitTests : SA1121CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1122CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1122CSharp11UnitTests.cs new file mode 100644 index 000000000..88c0f6bb9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1122CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1122CSharp11UnitTests : SA1122CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1123CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1123CSharp11UnitTests.cs new file mode 100644 index 000000000..d05f52a7c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1123CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1123CSharp11UnitTests : SA1123CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1124CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1124CSharp11UnitTests.cs new file mode 100644 index 000000000..5236c09ba --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1124CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1124CSharp11UnitTests : SA1124CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1125CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1125CSharp11UnitTests.cs new file mode 100644 index 000000000..57b39b93c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1125CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1125CSharp11UnitTests : SA1125CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1126CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1126CSharp11UnitTests.cs new file mode 100644 index 000000000..fd2c5715c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1126CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1126CSharp11UnitTests : SA1126CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1127CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1127CSharp11UnitTests.cs new file mode 100644 index 000000000..eb6b584fe --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1127CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1127CSharp11UnitTests : SA1127CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1128CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1128CSharp11UnitTests.cs new file mode 100644 index 000000000..f34cf8d5c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1128CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1128CSharp11UnitTests : SA1128CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1129CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1129CSharp11UnitTests.cs new file mode 100644 index 000000000..f064d29a8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1129CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1129CSharp11UnitTests : SA1129CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1130CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1130CSharp11UnitTests.cs new file mode 100644 index 000000000..4b0652e42 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1130CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1130CSharp11UnitTests : SA1130CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1131CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1131CSharp11UnitTests.cs new file mode 100644 index 000000000..196b27811 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1131CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1131CSharp11UnitTests : SA1131CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1132CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1132CSharp11UnitTests.cs new file mode 100644 index 000000000..dcb3b3f7e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1132CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1132CSharp11UnitTests : SA1132CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1133CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1133CSharp11UnitTests.cs new file mode 100644 index 000000000..80a78c334 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1133CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1133CSharp11UnitTests : SA1133CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1134CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1134CSharp11UnitTests.cs new file mode 100644 index 000000000..af1aabce9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1134CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1134CSharp11UnitTests : SA1134CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1135CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1135CSharp11UnitTests.cs new file mode 100644 index 000000000..b46ef0d86 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1135CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1135CSharp11UnitTests : SA1135CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1136CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1136CSharp11UnitTests.cs new file mode 100644 index 000000000..8fa455d0b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1136CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1136CSharp11UnitTests : SA1136CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1137CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1137CSharp11UnitTests.cs new file mode 100644 index 000000000..ab7cf511b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1137CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1137CSharp11UnitTests : SA1137CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1139CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1139CSharp11UnitTests.cs new file mode 100644 index 000000000..44ab84d43 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1139CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1139CSharp11UnitTests : SA1139CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1141CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1141CSharp11UnitTests.cs new file mode 100644 index 000000000..f102b7a8e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1141CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1141CSharp11UnitTests : SA1141CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1142CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1142CSharp11UnitTests.cs new file mode 100644 index 000000000..7a3d1ea0b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SA1142CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SA1142CSharp11UnitTests : SA1142CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SX1101CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SX1101CSharp11UnitTests.cs new file mode 100644 index 000000000..a1c3780ab --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/ReadabilityRules/SX1101CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp10.ReadabilityRules; + + public partial class SX1101CSharp11UnitTests : SX1101CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Settings/SettingsCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Settings/SettingsCSharp11UnitTests.cs new file mode 100644 index 000000000..da22660f8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Settings/SettingsCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Settings +{ + using StyleCop.Analyzers.Test.CSharp10.Settings; + + public partial class SettingsCSharp11UnitTests : SettingsCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Settings/SettingsFileCodeFixProviderCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Settings/SettingsFileCodeFixProviderCSharp11UnitTests.cs new file mode 100644 index 000000000..e369839ff --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/Settings/SettingsFileCodeFixProviderCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.Settings +{ + using StyleCop.Analyzers.Test.CSharp10.Settings; + + public partial class SettingsFileCodeFixProviderCSharp11UnitTests : SettingsFileCodeFixProviderCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1000CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1000CSharp11UnitTests.cs new file mode 100644 index 000000000..3e471130d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1000CSharp11UnitTests.cs @@ -0,0 +1,50 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + using Xunit; + + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1000KeywordsMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1000CSharp11UnitTests : SA1000CSharp10UnitTests + { + [Fact] + public async Task TestCheckedOperatorDeclarationAsync() + { + // NOTE: A checked operator requires a non-checked operator as well + // NOTE: Implicit conversion operators can not be checked + var testCode = @" +public class MyClass +{ + public static MyClass operator {|#0:checked|}-(MyClass x) => x; + public static MyClass operator -(MyClass x) => x; + + public static explicit operator {|#1:checked|}@MyClass(int i) => new MyClass(); + public static explicit operator MyClass(int i) => new MyClass(); +}"; + + var fixedCode = @" +public class MyClass +{ + public static MyClass operator checked -(MyClass x) => x; + public static MyClass operator -(MyClass x) => x; + + public static explicit operator checked @MyClass(int i) => new MyClass(); + public static explicit operator MyClass(int i) => new MyClass(); +}"; + + var expected = new[] + { + Diagnostic().WithArguments("checked", string.Empty, "followed").WithLocation(0), + Diagnostic().WithArguments("checked", string.Empty, "followed").WithLocation(1), + }; + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1001CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1001CSharp11UnitTests.cs new file mode 100644 index 000000000..c87017e51 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1001CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1001CSharp11UnitTests : SA1001CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1002CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1002CSharp11UnitTests.cs new file mode 100644 index 000000000..4adbbacc8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1002CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1002CSharp11UnitTests : SA1002CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1003CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1003CSharp11UnitTests.cs new file mode 100644 index 000000000..01deb1d65 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1003CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1003CSharp11UnitTests : SA1003CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1004CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1004CSharp11UnitTests.cs new file mode 100644 index 000000000..d6d3b4a91 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1004CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1004CSharp11UnitTests : SA1004CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1005CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1005CSharp11UnitTests.cs new file mode 100644 index 000000000..824d66ebf --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1005CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1005CSharp11UnitTests : SA1005CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1006CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1006CSharp11UnitTests.cs new file mode 100644 index 000000000..7435f351c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1006CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1006CSharp11UnitTests : SA1006CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1007CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1007CSharp11UnitTests.cs new file mode 100644 index 000000000..02856d0ff --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1007CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1007CSharp11UnitTests : SA1007CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1008CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1008CSharp11UnitTests.cs new file mode 100644 index 000000000..c3a4956f3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1008CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1008CSharp11UnitTests : SA1008CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1009CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1009CSharp11UnitTests.cs new file mode 100644 index 000000000..982d660a7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1009CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1009CSharp11UnitTests : SA1009CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1010CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1010CSharp11UnitTests.cs new file mode 100644 index 000000000..52f154915 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1010CSharp11UnitTests.cs @@ -0,0 +1,46 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + using Xunit; + + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1010OpeningSquareBracketsMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1010CSharp11UnitTests : SA1010CSharp10UnitTests + { + [Theory] + [InlineData("x is [1]")] + [InlineData("x is not [1]")] + [InlineData("x is ([1] or [2])")] + [InlineData("x is ([1] or not [2])")] + [InlineData("x is ([1] and [1])")] + [InlineData("x is ([1] and not [2])")] + [WorkItem(3503, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3503")] + public async Task TestListPatternAsync(string condition) + { + var testCode = $@" +using System.Collections.Generic; + +namespace TestNamespace +{{ + public class TestClass + {{ + public void TestMethod(List x) + {{ + _ = {condition}; + }} + }} +}} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1011CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1011CSharp11UnitTests.cs new file mode 100644 index 000000000..ea820526e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1011CSharp11UnitTests.cs @@ -0,0 +1,57 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1011ClosingSquareBracketsMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1011CSharp11UnitTests : SA1011CSharp10UnitTests + { + [Fact] + [WorkItem(3673, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3673")] + public async Task TestListPatternInSwitchCaseAsync() + { + var testCode = @"public class TestClass +{ + public void TestMethod(object[] arg) + { + switch (arg) + { + case [string s{|#0:]|} : + break; + } + }} +"; + + var fixedCode = @"public class TestClass +{ + public void TestMethod(object[] arg) + { + switch (arg) + { + case [string s]: + break; + } + }} +"; + + await new CSharpTest + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net70, + TestCode = testCode, + ExpectedDiagnostics = + { + Diagnostic().WithLocation(0).WithArguments(" not", "followed"), + }, + FixedCode = fixedCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1012CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1012CSharp11UnitTests.cs new file mode 100644 index 000000000..3e8a33c3b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1012CSharp11UnitTests.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1012OpeningBracesMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1012CSharp11UnitTests : SA1012CSharp10UnitTests + { + [Fact] + [WorkItem(3509, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3509")] + public async Task TestPropertyPatternInsideListPatternAsync() + { + var testCode = @" +class C +{ + void M(string[] a) + { + _ = a is [ {|#0:{|} Length: 1 }]; + _ = a is [{ Length: 0 },{|#1:{|} Length: 1 }]; + } +} +"; + + var fixedCode = @" +class C +{ + void M(string[] a) + { + _ = a is [{ Length: 1 }]; + _ = a is [{ Length: 0 }, { Length: 1 }]; + } +} +"; + + DiagnosticResult[] expected = + { + // Opening brace should not be preceded by a space + Diagnostic().WithLocation(0).WithArguments(" not", "preceded"), + + // Opening brace should be preceded by a space + Diagnostic().WithLocation(1).WithArguments(string.Empty, "preceded"), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1013CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1013CSharp11UnitTests.cs new file mode 100644 index 000000000..5e4657dce --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1013CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1013CSharp11UnitTests : SA1013CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1014CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1014CSharp11UnitTests.cs new file mode 100644 index 000000000..7139d81de --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1014CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1014CSharp11UnitTests : SA1014CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1015CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1015CSharp11UnitTests.cs new file mode 100644 index 000000000..91fab7a48 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1015CSharp11UnitTests.cs @@ -0,0 +1,40 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + using Xunit; + + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1015ClosingGenericBracketsMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1015CSharp11UnitTests : SA1015CSharp10UnitTests + { + [Fact] + [WorkItem(3487, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3487")] + public async Task TestGenericAttributeAsync() + { + var testCode = $@" +using System; + +public class MyAttribute : Attribute +{{ +}} + +public class MyClass +{{ + [MyAttribute] + public double MyDouble {{ get; set; }} +}}"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1016CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1016CSharp11UnitTests.cs new file mode 100644 index 000000000..ede67a3e0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1016CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1016CSharp11UnitTests : SA1016CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1017CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1017CSharp11UnitTests.cs new file mode 100644 index 000000000..f0c11705b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1017CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1017CSharp11UnitTests : SA1017CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1018CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1018CSharp11UnitTests.cs new file mode 100644 index 000000000..b4cf450d4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1018CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1018CSharp11UnitTests : SA1018CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1019CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1019CSharp11UnitTests.cs new file mode 100644 index 000000000..fe00e7db0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1019CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1019CSharp11UnitTests : SA1019CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1020CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1020CSharp11UnitTests.cs new file mode 100644 index 000000000..d3819f3f8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1020CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1020CSharp11UnitTests : SA1020CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1021CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1021CSharp11UnitTests.cs new file mode 100644 index 000000000..27d56cf01 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1021CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1021CSharp11UnitTests : SA1021CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1022CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1022CSharp11UnitTests.cs new file mode 100644 index 000000000..51b69168d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1022CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1022CSharp11UnitTests : SA1022CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1023CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1023CSharp11UnitTests.cs new file mode 100644 index 000000000..0645e210f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1023CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1023CSharp11UnitTests : SA1023CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1024CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1024CSharp11UnitTests.cs new file mode 100644 index 000000000..1c1361543 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1024CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1024CSharp11UnitTests : SA1024CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1025CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1025CSharp11UnitTests.cs new file mode 100644 index 000000000..d2da43875 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1025CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1025CSharp11UnitTests : SA1025CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1026CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1026CSharp11UnitTests.cs new file mode 100644 index 000000000..74c2a55ec --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1026CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1026CSharp11UnitTests : SA1026CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1027AlternateIndentationCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1027AlternateIndentationCSharp11UnitTests.cs new file mode 100644 index 000000000..35e0bce97 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1027AlternateIndentationCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1027AlternateIndentationCSharp11UnitTests : SA1027AlternateIndentationCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1027CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1027CSharp11UnitTests.cs new file mode 100644 index 000000000..7eb4fe4eb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1027CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1027CSharp11UnitTests : SA1027CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1027UseTabsCSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1027UseTabsCSharp11UnitTests.cs new file mode 100644 index 000000000..fcb1b1b38 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1027UseTabsCSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1027UseTabsCSharp11UnitTests : SA1027UseTabsCSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1028CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1028CSharp11UnitTests.cs new file mode 100644 index 000000000..70fb2f8ba --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpacingRules/SA1028CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpacingRules; + + public partial class SA1028CSharp11UnitTests : SA1028CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpecialRules/SA0001CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpecialRules/SA0001CSharp11UnitTests.cs new file mode 100644 index 000000000..4c34633a2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpecialRules/SA0001CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpecialRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpecialRules; + + public partial class SA0001CSharp11UnitTests : SA0001CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpecialRules/SA0002CSharp11UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpecialRules/SA0002CSharp11UnitTests.cs new file mode 100644 index 000000000..2b53080d9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/SpecialRules/SA0002CSharp11UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp11.SpecialRules +{ + using StyleCop.Analyzers.Test.CSharp10.SpecialRules; + + public partial class SA0002CSharp11UnitTests : SA0002CSharp10UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/StyleCop.Analyzers.Test.CSharp11.csproj b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/StyleCop.Analyzers.Test.CSharp11.csproj new file mode 100644 index 000000000..3ce4f0d1c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/StyleCop.Analyzers.Test.CSharp11.csproj @@ -0,0 +1,37 @@ + + + + + net472 + false + true + true + + + + ..\StyleCop.Analyzers.Internal.ruleset + + + + true + ..\..\build\keys\TestingKey.snk + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/AnalyzerConfigurationCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/AnalyzerConfigurationCSharp12UnitTests.cs new file mode 100644 index 000000000..c03a3538a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/AnalyzerConfigurationCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12 +{ + using StyleCop.Analyzers.Test.CSharp11; + + public partial class AnalyzerConfigurationCSharp12UnitTests : AnalyzerConfigurationCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/InheritdocCodeFixProviderCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/InheritdocCodeFixProviderCSharp12UnitTests.cs new file mode 100644 index 000000000..841d6e554 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/InheritdocCodeFixProviderCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class InheritdocCodeFixProviderCSharp12UnitTests : InheritdocCodeFixProviderCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/NoXmlFileHeaderCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/NoXmlFileHeaderCSharp12UnitTests.cs new file mode 100644 index 000000000..062bc667c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/NoXmlFileHeaderCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class NoXmlFileHeaderCSharp12UnitTests : NoXmlFileHeaderCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1600CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1600CSharp12UnitTests.cs new file mode 100644 index 000000000..8d0cbb07f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1600CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1600CSharp12UnitTests : SA1600CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1601CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1601CSharp12UnitTests.cs new file mode 100644 index 000000000..8f6412073 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1601CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1601CSharp12UnitTests : SA1601CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1602CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1602CSharp12UnitTests.cs new file mode 100644 index 000000000..f78fbcd79 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1602CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1602CSharp12UnitTests : SA1602CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1603CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1603CSharp12UnitTests.cs new file mode 100644 index 000000000..cb56f00dd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1603CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1603CSharp12UnitTests : SA1603CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1604CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1604CSharp12UnitTests.cs new file mode 100644 index 000000000..578173ad1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1604CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1604CSharp12UnitTests : SA1604CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1605CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1605CSharp12UnitTests.cs new file mode 100644 index 000000000..25c11d8d1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1605CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1605CSharp12UnitTests : SA1605CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1606CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1606CSharp12UnitTests.cs new file mode 100644 index 000000000..9c622c98a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1606CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1606CSharp12UnitTests : SA1606CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1607CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1607CSharp12UnitTests.cs new file mode 100644 index 000000000..39893d1bd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1607CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1607CSharp12UnitTests : SA1607CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1608CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1608CSharp12UnitTests.cs new file mode 100644 index 000000000..72e54d326 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1608CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1608CSharp12UnitTests : SA1608CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1609CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1609CSharp12UnitTests.cs new file mode 100644 index 000000000..8345fe249 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1609CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1609CSharp12UnitTests : SA1609CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1610CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1610CSharp12UnitTests.cs new file mode 100644 index 000000000..5465ff313 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1610CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1610CSharp12UnitTests : SA1610CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1611CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1611CSharp12UnitTests.cs new file mode 100644 index 000000000..62c49ad12 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1611CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1611CSharp12UnitTests : SA1611CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1612CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1612CSharp12UnitTests.cs new file mode 100644 index 000000000..d588a7346 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1612CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1612CSharp12UnitTests : SA1612CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1613CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1613CSharp12UnitTests.cs new file mode 100644 index 000000000..16e24ff9d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1613CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1613CSharp12UnitTests : SA1613CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1614CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1614CSharp12UnitTests.cs new file mode 100644 index 000000000..5fe48470b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1614CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1614CSharp12UnitTests : SA1614CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1615CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1615CSharp12UnitTests.cs new file mode 100644 index 000000000..994203b2f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1615CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1615CSharp12UnitTests : SA1615CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1616CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1616CSharp12UnitTests.cs new file mode 100644 index 000000000..263b18f9b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1616CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1616CSharp12UnitTests : SA1616CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1617CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1617CSharp12UnitTests.cs new file mode 100644 index 000000000..c96ce8c8e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1617CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1617CSharp12UnitTests : SA1617CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1618CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1618CSharp12UnitTests.cs new file mode 100644 index 000000000..c2dc9df19 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1618CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1618CSharp12UnitTests : SA1618CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1619CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1619CSharp12UnitTests.cs new file mode 100644 index 000000000..82d8e5494 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1619CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1619CSharp12UnitTests : SA1619CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1620CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1620CSharp12UnitTests.cs new file mode 100644 index 000000000..f62590820 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1620CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1620CSharp12UnitTests : SA1620CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1621CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1621CSharp12UnitTests.cs new file mode 100644 index 000000000..2c8d26cdb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1621CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1621CSharp12UnitTests : SA1621CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1622CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1622CSharp12UnitTests.cs new file mode 100644 index 000000000..5c98f63a6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1622CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1622CSharp12UnitTests : SA1622CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1623CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1623CSharp12UnitTests.cs new file mode 100644 index 000000000..998836eb0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1623CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1623CSharp12UnitTests : SA1623CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1624CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1624CSharp12UnitTests.cs new file mode 100644 index 000000000..d36be8b30 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1624CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1624CSharp12UnitTests : SA1624CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1625CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1625CSharp12UnitTests.cs new file mode 100644 index 000000000..4ed6760c8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1625CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1625CSharp12UnitTests : SA1625CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1626CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1626CSharp12UnitTests.cs new file mode 100644 index 000000000..48b24faf5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1626CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1626CSharp12UnitTests : SA1626CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1627CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1627CSharp12UnitTests.cs new file mode 100644 index 000000000..583d4232e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1627CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1627CSharp12UnitTests : SA1627CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1628CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1628CSharp12UnitTests.cs new file mode 100644 index 000000000..ec18bdb3a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1628CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1628CSharp12UnitTests : SA1628CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1629CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1629CSharp12UnitTests.cs new file mode 100644 index 000000000..379596818 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1629CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1629CSharp12UnitTests : SA1629CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1630CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1630CSharp12UnitTests.cs new file mode 100644 index 000000000..6eb50f663 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1630CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1630CSharp12UnitTests : SA1630CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1631CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1631CSharp12UnitTests.cs new file mode 100644 index 000000000..7534f9be3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1631CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1631CSharp12UnitTests : SA1631CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1632CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1632CSharp12UnitTests.cs new file mode 100644 index 000000000..a57660f66 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1632CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1632CSharp12UnitTests : SA1632CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1633CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1633CSharp12UnitTests.cs new file mode 100644 index 000000000..fba7a0231 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1633CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1633CSharp12UnitTests : SA1633CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1634CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1634CSharp12UnitTests.cs new file mode 100644 index 000000000..d180703df --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1634CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1634CSharp12UnitTests : SA1634CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1635CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1635CSharp12UnitTests.cs new file mode 100644 index 000000000..8d22bff7a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1635CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1635CSharp12UnitTests : SA1635CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1636CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1636CSharp12UnitTests.cs new file mode 100644 index 000000000..ede4f64d3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1636CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1636CSharp12UnitTests : SA1636CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1637CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1637CSharp12UnitTests.cs new file mode 100644 index 000000000..3cf10501e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1637CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1637CSharp12UnitTests : SA1637CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1638CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1638CSharp12UnitTests.cs new file mode 100644 index 000000000..c4a93ce02 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1638CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1638CSharp12UnitTests : SA1638CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1639CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1639CSharp12UnitTests.cs new file mode 100644 index 000000000..ed35d825c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1639CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1639CSharp12UnitTests : SA1639CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1640CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1640CSharp12UnitTests.cs new file mode 100644 index 000000000..a21e8e336 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1640CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1640CSharp12UnitTests : SA1640CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1641CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1641CSharp12UnitTests.cs new file mode 100644 index 000000000..00a729c6a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1641CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1641CSharp12UnitTests : SA1641CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1642CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1642CSharp12UnitTests.cs new file mode 100644 index 000000000..51a3ac211 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1642CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1642CSharp12UnitTests : SA1642CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1643CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1643CSharp12UnitTests.cs new file mode 100644 index 000000000..4661a4744 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1643CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1643CSharp12UnitTests : SA1643CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1644CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1644CSharp12UnitTests.cs new file mode 100644 index 000000000..05cc6590e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1644CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1644CSharp12UnitTests : SA1644CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1645CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1645CSharp12UnitTests.cs new file mode 100644 index 000000000..fcbe3a739 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1645CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1645CSharp12UnitTests : SA1645CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1646CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1646CSharp12UnitTests.cs new file mode 100644 index 000000000..3282dcb3f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1646CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1646CSharp12UnitTests : SA1646CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1647CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1647CSharp12UnitTests.cs new file mode 100644 index 000000000..5b8154cda --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1647CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1647CSharp12UnitTests : SA1647CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1648CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1648CSharp12UnitTests.cs new file mode 100644 index 000000000..fcbb4713a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1648CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1648CSharp12UnitTests : SA1648CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1649CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1649CSharp12UnitTests.cs new file mode 100644 index 000000000..7bb593dd2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1649CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1649CSharp12UnitTests : SA1649CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1650CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1650CSharp12UnitTests.cs new file mode 100644 index 000000000..9c175f263 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1650CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1650CSharp12UnitTests : SA1650CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1651CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1651CSharp12UnitTests.cs new file mode 100644 index 000000000..848644a7a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/DocumentationRules/SA1651CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp11.DocumentationRules; + + public partial class SA1651CSharp12UnitTests : SA1651CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/HelperTests/SymbolNameHelpersCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/HelperTests/SymbolNameHelpersCSharp12UnitTests.cs new file mode 100644 index 000000000..d358496b0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/HelperTests/SymbolNameHelpersCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.HelperTests +{ + using StyleCop.Analyzers.Test.CSharp11.HelperTests; + + public partial class SymbolNameHelpersCSharp12UnitTests : SymbolNameHelpersCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1500CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1500CSharp12UnitTests.cs new file mode 100644 index 000000000..1ec187771 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1500CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp11.LayoutRules; + + public partial class SA1500CSharp12UnitTests : SA1500CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1501CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1501CSharp12UnitTests.cs new file mode 100644 index 000000000..ede784dc3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1501CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp11.LayoutRules; + + public partial class SA1501CSharp12UnitTests : SA1501CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1502CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1502CSharp12UnitTests.cs new file mode 100644 index 000000000..37c1cfc65 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1502CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp11.LayoutRules; + + public partial class SA1502CSharp12UnitTests : SA1502CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1503CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1503CSharp12UnitTests.cs new file mode 100644 index 000000000..bb88a854c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1503CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp11.LayoutRules; + + public partial class SA1503CSharp12UnitTests : SA1503CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1504CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1504CSharp12UnitTests.cs new file mode 100644 index 000000000..c54ac19b7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1504CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp11.LayoutRules; + + public partial class SA1504CSharp12UnitTests : SA1504CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1505CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1505CSharp12UnitTests.cs new file mode 100644 index 000000000..a3b59fff0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1505CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp11.LayoutRules; + + public partial class SA1505CSharp12UnitTests : SA1505CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1506CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1506CSharp12UnitTests.cs new file mode 100644 index 000000000..1c9ca8487 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1506CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp11.LayoutRules; + + public partial class SA1506CSharp12UnitTests : SA1506CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1507CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1507CSharp12UnitTests.cs new file mode 100644 index 000000000..4f64be7f0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1507CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp11.LayoutRules; + + public partial class SA1507CSharp12UnitTests : SA1507CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1508CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1508CSharp12UnitTests.cs new file mode 100644 index 000000000..6bc975f7a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1508CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp11.LayoutRules; + + public partial class SA1508CSharp12UnitTests : SA1508CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1509CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1509CSharp12UnitTests.cs new file mode 100644 index 000000000..accaf2ce4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1509CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp11.LayoutRules; + + public partial class SA1509CSharp12UnitTests : SA1509CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1510CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1510CSharp12UnitTests.cs new file mode 100644 index 000000000..4754f566b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1510CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp11.LayoutRules; + + public partial class SA1510CSharp12UnitTests : SA1510CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1511CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1511CSharp12UnitTests.cs new file mode 100644 index 000000000..c8c74b5af --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1511CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp11.LayoutRules; + + public partial class SA1511CSharp12UnitTests : SA1511CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1512CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1512CSharp12UnitTests.cs new file mode 100644 index 000000000..2dc37aae9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1512CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp11.LayoutRules; + + public partial class SA1512CSharp12UnitTests : SA1512CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1513CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1513CSharp12UnitTests.cs new file mode 100644 index 000000000..47cc412e4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1513CSharp12UnitTests.cs @@ -0,0 +1,36 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp11.LayoutRules; + using Xunit; + + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.LayoutRules.SA1513ClosingBraceMustBeFollowedByBlankLine, + StyleCop.Analyzers.LayoutRules.SA1513CodeFixProvider>; + + public partial class SA1513CSharp12UnitTests : SA1513CSharp11UnitTests + { + [Fact] + [WorkItem(3720, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3720")] + public async Task TestObjectInitializerInCollectionExpressionAsync() + { + var testCode = @" +public class Foo +{ + public Foo[] TestMethod() => + [ + new Foo + { + } + ]; +}"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, testCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1514CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1514CSharp12UnitTests.cs new file mode 100644 index 000000000..74acc4e99 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1514CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp11.LayoutRules; + + public partial class SA1514CSharp12UnitTests : SA1514CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1515CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1515CSharp12UnitTests.cs new file mode 100644 index 000000000..e5f42bbf7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1515CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp11.LayoutRules; + + public partial class SA1515CSharp12UnitTests : SA1515CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1516CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1516CSharp12UnitTests.cs new file mode 100644 index 000000000..e3808a076 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1516CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp11.LayoutRules; + + public partial class SA1516CSharp12UnitTests : SA1516CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1516UsingGroupsCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1516UsingGroupsCSharp12UnitTests.cs new file mode 100644 index 000000000..7d623c45f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1516UsingGroupsCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp11.LayoutRules; + + public partial class SA1516UsingGroupsCSharp12UnitTests : SA1516UsingGroupsCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1517CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1517CSharp12UnitTests.cs new file mode 100644 index 000000000..f730fdba0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1517CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp11.LayoutRules; + + public partial class SA1517CSharp12UnitTests : SA1517CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1518CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1518CSharp12UnitTests.cs new file mode 100644 index 000000000..7aac4c5c2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1518CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp11.LayoutRules; + + public partial class SA1518CSharp12UnitTests : SA1518CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1519CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1519CSharp12UnitTests.cs new file mode 100644 index 000000000..4ab533793 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1519CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp11.LayoutRules; + + public partial class SA1519CSharp12UnitTests : SA1519CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1520CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1520CSharp12UnitTests.cs new file mode 100644 index 000000000..42e9e2bab --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/LayoutRules/SA1520CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp11.LayoutRules; + + public partial class SA1520CSharp12UnitTests : SA1520CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/AccessorDeclarationSyntaxExtensionsCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/AccessorDeclarationSyntaxExtensionsCSharp12UnitTests.cs new file mode 100644 index 000000000..6534cd4d8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/AccessorDeclarationSyntaxExtensionsCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class AccessorDeclarationSyntaxExtensionsCSharp12UnitTests : AccessorDeclarationSyntaxExtensionsCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/ArgumentSyntaxExtensionsCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/ArgumentSyntaxExtensionsCSharp12UnitTests.cs new file mode 100644 index 000000000..3c59e8afd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/ArgumentSyntaxExtensionsCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class ArgumentSyntaxExtensionsCSharp12UnitTests : ArgumentSyntaxExtensionsCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/BaseMethodDeclarationSyntaxExtensionsCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/BaseMethodDeclarationSyntaxExtensionsCSharp12UnitTests.cs new file mode 100644 index 000000000..b3132e555 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/BaseMethodDeclarationSyntaxExtensionsCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class BaseMethodDeclarationSyntaxExtensionsCSharp12UnitTests : BaseMethodDeclarationSyntaxExtensionsCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/CasePatternSwitchLabelSyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/CasePatternSwitchLabelSyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..5a0318141 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/CasePatternSwitchLabelSyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class CasePatternSwitchLabelSyntaxWrapperCSharp12UnitTests : CasePatternSwitchLabelSyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/CommonForEachStatementSyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/CommonForEachStatementSyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..b7cccfe53 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/CommonForEachStatementSyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class CommonForEachStatementSyntaxWrapperCSharp12UnitTests : CommonForEachStatementSyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/ConstantPatternSyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/ConstantPatternSyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..8698e02d4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/ConstantPatternSyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class ConstantPatternSyntaxWrapperCSharp12UnitTests : ConstantPatternSyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/ConstructorDeclarationSyntaxExtensionsCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/ConstructorDeclarationSyntaxExtensionsCSharp12UnitTests.cs new file mode 100644 index 000000000..06e11ac3f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/ConstructorDeclarationSyntaxExtensionsCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class ConstructorDeclarationSyntaxExtensionsCSharp12UnitTests : ConstructorDeclarationSyntaxExtensionsCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/CrefParameterSyntaxExtensionsCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/CrefParameterSyntaxExtensionsCSharp12UnitTests.cs new file mode 100644 index 000000000..c09ee00d8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/CrefParameterSyntaxExtensionsCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class CrefParameterSyntaxExtensionsCSharp12UnitTests : CrefParameterSyntaxExtensionsCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/DeclarationExpressionSyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/DeclarationExpressionSyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..5a949b734 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/DeclarationExpressionSyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class DeclarationExpressionSyntaxWrapperCSharp12UnitTests : DeclarationExpressionSyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/DeclarationPatternSyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/DeclarationPatternSyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..3c8e526c3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/DeclarationPatternSyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class DeclarationPatternSyntaxWrapperCSharp12UnitTests : DeclarationPatternSyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/DestructorDeclarationSyntaxExtensionsCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/DestructorDeclarationSyntaxExtensionsCSharp12UnitTests.cs new file mode 100644 index 000000000..8197c2d8d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/DestructorDeclarationSyntaxExtensionsCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class DestructorDeclarationSyntaxExtensionsCSharp12UnitTests : DestructorDeclarationSyntaxExtensionsCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/DiscardDesignationSyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/DiscardDesignationSyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..998bb278b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/DiscardDesignationSyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class DiscardDesignationSyntaxWrapperCSharp12UnitTests : DiscardDesignationSyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..e16e8f8ee --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp12UnitTests : ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/IsPatternExpressionSyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/IsPatternExpressionSyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..fbd658570 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/IsPatternExpressionSyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class IsPatternExpressionSyntaxWrapperCSharp12UnitTests : IsPatternExpressionSyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/LanguageVersionExCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/LanguageVersionExCSharp12UnitTests.cs new file mode 100644 index 000000000..c9e16ad8c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/LanguageVersionExCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class LanguageVersionExCSharp12UnitTests : LanguageVersionExCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/LightupHelpersCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/LightupHelpersCSharp12UnitTests.cs new file mode 100644 index 000000000..896d63d87 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/LightupHelpersCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class LightupHelpersCSharp12UnitTests : LightupHelpersCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/LocalFunctionStatementSyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/LocalFunctionStatementSyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..3d1369b93 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/LocalFunctionStatementSyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class LocalFunctionStatementSyntaxWrapperCSharp12UnitTests : LocalFunctionStatementSyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/MethodKindExCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/MethodKindExCSharp12UnitTests.cs new file mode 100644 index 000000000..6212aeb5b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/MethodKindExCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class MethodKindExCSharp12UnitTests : MethodKindExCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/OperationKindExCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/OperationKindExCSharp12UnitTests.cs new file mode 100644 index 000000000..912fb6f0b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/OperationKindExCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class OperationKindExCSharp12UnitTests : OperationKindExCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/ParenthesizedVariableDesignationSyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/ParenthesizedVariableDesignationSyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..313574ccc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/ParenthesizedVariableDesignationSyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class ParenthesizedVariableDesignationSyntaxWrapperCSharp12UnitTests : ParenthesizedVariableDesignationSyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/PatternSyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/PatternSyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..08d3f8c8b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/PatternSyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class PatternSyntaxWrapperCSharp12UnitTests : PatternSyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/RefExpressionSyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/RefExpressionSyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..9ed8857fc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/RefExpressionSyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class RefExpressionSyntaxWrapperCSharp12UnitTests : RefExpressionSyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/RefTypeSyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/RefTypeSyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..dc6d25e77 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/RefTypeSyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class RefTypeSyntaxWrapperCSharp12UnitTests : RefTypeSyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/SingleVariableDesignationSyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/SingleVariableDesignationSyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..fee719d8c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/SingleVariableDesignationSyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class SingleVariableDesignationSyntaxWrapperCSharp12UnitTests : SingleVariableDesignationSyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/StackAllocArrayCreationExpressionSyntaxExtensionsCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/StackAllocArrayCreationExpressionSyntaxExtensionsCSharp12UnitTests.cs new file mode 100644 index 000000000..6cb44c0d4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/StackAllocArrayCreationExpressionSyntaxExtensionsCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class StackAllocArrayCreationExpressionSyntaxExtensionsCSharp12UnitTests : StackAllocArrayCreationExpressionSyntaxExtensionsCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/SwitchExpressionArmSyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/SwitchExpressionArmSyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..4b185e6b2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/SwitchExpressionArmSyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class SwitchExpressionArmSyntaxWrapperCSharp12UnitTests : SwitchExpressionArmSyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/SwitchExpressionSyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/SwitchExpressionSyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..61f5a769f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/SwitchExpressionSyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class SwitchExpressionSyntaxWrapperCSharp12UnitTests : SwitchExpressionSyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/SyntaxKindExCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/SyntaxKindExCSharp12UnitTests.cs new file mode 100644 index 000000000..70554aa99 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/SyntaxKindExCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class SyntaxKindExCSharp12UnitTests : SyntaxKindExCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/SyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/SyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..c0a88ca91 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/SyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class SyntaxWrapperCSharp12UnitTests : SyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/SyntaxWrapperHelperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/SyntaxWrapperHelperCSharp12UnitTests.cs new file mode 100644 index 000000000..82a38a28f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/SyntaxWrapperHelperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class SyntaxWrapperHelperCSharp12UnitTests : SyntaxWrapperHelperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/ThrowExpressionSyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/ThrowExpressionSyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..721b6f89c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/ThrowExpressionSyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class ThrowExpressionSyntaxWrapperCSharp12UnitTests : ThrowExpressionSyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/TupleElementSyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/TupleElementSyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..cec6b6fd5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/TupleElementSyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class TupleElementSyntaxWrapperCSharp12UnitTests : TupleElementSyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/TupleExpressionSyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/TupleExpressionSyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..6480514d4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/TupleExpressionSyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class TupleExpressionSyntaxWrapperCSharp12UnitTests : TupleExpressionSyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/TupleTypeSyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/TupleTypeSyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..8a7ad4a46 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/TupleTypeSyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class TupleTypeSyntaxWrapperCSharp12UnitTests : TupleTypeSyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/VariableDesignationSyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/VariableDesignationSyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..3b526ab02 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/VariableDesignationSyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class VariableDesignationSyntaxWrapperCSharp12UnitTests : VariableDesignationSyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/WhenClauseSyntaxWrapperCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/WhenClauseSyntaxWrapperCSharp12UnitTests.cs new file mode 100644 index 000000000..790261961 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Lightup/WhenClauseSyntaxWrapperCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Lightup +{ + using StyleCop.Analyzers.Test.CSharp11.Lightup; + + public partial class WhenClauseSyntaxWrapperCSharp12UnitTests : WhenClauseSyntaxWrapperCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1119CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1119CSharp12UnitTests.cs new file mode 100644 index 000000000..d61cdaf6f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1119CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1119CSharp12UnitTests : SA1119CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1400CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1400CSharp12UnitTests.cs new file mode 100644 index 000000000..821898eca --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1400CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1400CSharp12UnitTests : SA1400CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1401CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1401CSharp12UnitTests.cs new file mode 100644 index 000000000..c3c6f3f27 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1401CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1401CSharp12UnitTests : SA1401CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForClassCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForClassCSharp12UnitTests.cs new file mode 100644 index 000000000..76891c499 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForClassCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1402ForClassCSharp12UnitTests : SA1402ForClassCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForDelegateCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForDelegateCSharp12UnitTests.cs new file mode 100644 index 000000000..582c3a6cc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForDelegateCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1402ForDelegateCSharp12UnitTests : SA1402ForDelegateCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForEnumCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForEnumCSharp12UnitTests.cs new file mode 100644 index 000000000..182ae31f4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForEnumCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1402ForEnumCSharp12UnitTests : SA1402ForEnumCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForInterfaceCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForInterfaceCSharp12UnitTests.cs new file mode 100644 index 000000000..a6c94d843 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForInterfaceCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1402ForInterfaceCSharp12UnitTests : SA1402ForInterfaceCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForRecordCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForRecordCSharp12UnitTests.cs new file mode 100644 index 000000000..6664726cc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForRecordCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1402ForRecordCSharp12UnitTests : SA1402ForRecordCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForRecordClassCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForRecordClassCSharp12UnitTests.cs new file mode 100644 index 000000000..6f101a11e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForRecordClassCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1402ForRecordClassCSharp12UnitTests : SA1402ForRecordClassCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForRecordStructCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForRecordStructCSharp12UnitTests.cs new file mode 100644 index 000000000..7c571e758 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForRecordStructCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1402ForRecordStructCSharp12UnitTests : SA1402ForRecordStructCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForStructCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForStructCSharp12UnitTests.cs new file mode 100644 index 000000000..0ec6ef886 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1402ForStructCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1402ForStructCSharp12UnitTests : SA1402ForStructCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1403CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1403CSharp12UnitTests.cs new file mode 100644 index 000000000..65bc7d227 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1403CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1403CSharp12UnitTests : SA1403CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1404CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1404CSharp12UnitTests.cs new file mode 100644 index 000000000..01276ea10 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1404CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1404CSharp12UnitTests : SA1404CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1405CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1405CSharp12UnitTests.cs new file mode 100644 index 000000000..541cf7040 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1405CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1405CSharp12UnitTests : SA1405CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1406CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1406CSharp12UnitTests.cs new file mode 100644 index 000000000..3416b36a9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1406CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1406CSharp12UnitTests : SA1406CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1407CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1407CSharp12UnitTests.cs new file mode 100644 index 000000000..5644a7bda --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1407CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1407CSharp12UnitTests : SA1407CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1408CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1408CSharp12UnitTests.cs new file mode 100644 index 000000000..d6e1015c5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1408CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1408CSharp12UnitTests : SA1408CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1409CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1409CSharp12UnitTests.cs new file mode 100644 index 000000000..fa67db8a5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1409CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1409CSharp12UnitTests : SA1409CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1410CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1410CSharp12UnitTests.cs new file mode 100644 index 000000000..c4becdf09 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1410CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1410CSharp12UnitTests : SA1410CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1411CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1411CSharp12UnitTests.cs new file mode 100644 index 000000000..1eddf8d2d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1411CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1411CSharp12UnitTests : SA1411CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1412CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1412CSharp12UnitTests.cs new file mode 100644 index 000000000..40ff7879b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1412CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1412CSharp12UnitTests : SA1412CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1413CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1413CSharp12UnitTests.cs new file mode 100644 index 000000000..b1fdea503 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1413CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1413CSharp12UnitTests : SA1413CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1414CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1414CSharp12UnitTests.cs new file mode 100644 index 000000000..b1cb00750 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/MaintainabilityRules/SA1414CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.MaintainabilityRules; + + public partial class SA1414CSharp12UnitTests : SA1414CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1300CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1300CSharp12UnitTests.cs new file mode 100644 index 000000000..559ecfce9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1300CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp11.NamingRules; + + public partial class SA1300CSharp12UnitTests : SA1300CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1301CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1301CSharp12UnitTests.cs new file mode 100644 index 000000000..d31fd39a5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1301CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp11.NamingRules; + + public partial class SA1301CSharp12UnitTests : SA1301CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1302CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1302CSharp12UnitTests.cs new file mode 100644 index 000000000..3e5383ae0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1302CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp11.NamingRules; + + public partial class SA1302CSharp12UnitTests : SA1302CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1303CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1303CSharp12UnitTests.cs new file mode 100644 index 000000000..8073c907f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1303CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp11.NamingRules; + + public partial class SA1303CSharp12UnitTests : SA1303CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1304CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1304CSharp12UnitTests.cs new file mode 100644 index 000000000..152a01dad --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1304CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp11.NamingRules; + + public partial class SA1304CSharp12UnitTests : SA1304CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1305CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1305CSharp12UnitTests.cs new file mode 100644 index 000000000..596f19cfe --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1305CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp11.NamingRules; + + public partial class SA1305CSharp12UnitTests : SA1305CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1306CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1306CSharp12UnitTests.cs new file mode 100644 index 000000000..73083bbc7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1306CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp11.NamingRules; + + public partial class SA1306CSharp12UnitTests : SA1306CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1307CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1307CSharp12UnitTests.cs new file mode 100644 index 000000000..84ef32339 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1307CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp11.NamingRules; + + public partial class SA1307CSharp12UnitTests : SA1307CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1308CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1308CSharp12UnitTests.cs new file mode 100644 index 000000000..21757c819 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1308CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp11.NamingRules; + + public partial class SA1308CSharp12UnitTests : SA1308CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1309CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1309CSharp12UnitTests.cs new file mode 100644 index 000000000..f72ba4f15 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1309CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp11.NamingRules; + + public partial class SA1309CSharp12UnitTests : SA1309CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1310CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1310CSharp12UnitTests.cs new file mode 100644 index 000000000..e467133aa --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1310CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp11.NamingRules; + + public partial class SA1310CSharp12UnitTests : SA1310CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1311CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1311CSharp12UnitTests.cs new file mode 100644 index 000000000..ce4325418 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1311CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp11.NamingRules; + + public partial class SA1311CSharp12UnitTests : SA1311CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1312CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1312CSharp12UnitTests.cs new file mode 100644 index 000000000..ede71bded --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1312CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp11.NamingRules; + + public partial class SA1312CSharp12UnitTests : SA1312CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1313CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1313CSharp12UnitTests.cs new file mode 100644 index 000000000..3c6bbd31e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1313CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp11.NamingRules; + + public partial class SA1313CSharp12UnitTests : SA1313CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1314CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1314CSharp12UnitTests.cs new file mode 100644 index 000000000..98278bc71 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1314CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp11.NamingRules; + + public partial class SA1314CSharp12UnitTests : SA1314CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1316CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1316CSharp12UnitTests.cs new file mode 100644 index 000000000..4437f6f0a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SA1316CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp11.NamingRules; + + public partial class SA1316CSharp12UnitTests : SA1316CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SX1309CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SX1309CSharp12UnitTests.cs new file mode 100644 index 000000000..c48d6f672 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SX1309CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp11.NamingRules; + + public partial class SX1309CSharp12UnitTests : SX1309CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SX1309SCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SX1309SCSharp12UnitTests.cs new file mode 100644 index 000000000..eee608d9b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/NamingRules/SX1309SCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp11.NamingRules; + + public partial class SX1309SCSharp12UnitTests : SX1309SCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1200CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1200CSharp12UnitTests.cs new file mode 100644 index 000000000..632757aea --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1200CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class SA1200CSharp12UnitTests : SA1200CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1200OutsideNamespaceCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1200OutsideNamespaceCSharp12UnitTests.cs new file mode 100644 index 000000000..9167f1632 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1200OutsideNamespaceCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class SA1200OutsideNamespaceCSharp12UnitTests : SA1200OutsideNamespaceCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1200PreserveCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1200PreserveCSharp12UnitTests.cs new file mode 100644 index 000000000..2711fcb1e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1200PreserveCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class SA1200PreserveCSharp12UnitTests : SA1200PreserveCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1201CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1201CSharp12UnitTests.cs new file mode 100644 index 000000000..55a37d9fb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1201CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class SA1201CSharp12UnitTests : SA1201CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1202CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1202CSharp12UnitTests.cs new file mode 100644 index 000000000..39a561c0a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1202CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class SA1202CSharp12UnitTests : SA1202CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1203CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1203CSharp12UnitTests.cs new file mode 100644 index 000000000..fbb956c81 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1203CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class SA1203CSharp12UnitTests : SA1203CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1204CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1204CSharp12UnitTests.cs new file mode 100644 index 000000000..70bcd2a7a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1204CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class SA1204CSharp12UnitTests : SA1204CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1205CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1205CSharp12UnitTests.cs new file mode 100644 index 000000000..6e6ac5f6a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1205CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class SA1205CSharp12UnitTests : SA1205CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1206CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1206CSharp12UnitTests.cs new file mode 100644 index 000000000..d7a891bcc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1206CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class SA1206CSharp12UnitTests : SA1206CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1206CodeFixProviderCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1206CodeFixProviderCSharp12UnitTests.cs new file mode 100644 index 000000000..707947617 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1206CodeFixProviderCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class SA1206CodeFixProviderCSharp12UnitTests : SA1206CodeFixProviderCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1207CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1207CSharp12UnitTests.cs new file mode 100644 index 000000000..5df414383 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1207CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class SA1207CSharp12UnitTests : SA1207CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1208CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1208CSharp12UnitTests.cs new file mode 100644 index 000000000..1951de1b8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1208CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class SA1208CSharp12UnitTests : SA1208CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1209CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1209CSharp12UnitTests.cs new file mode 100644 index 000000000..8519c6bc5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1209CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class SA1209CSharp12UnitTests : SA1209CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1210CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1210CSharp12UnitTests.cs new file mode 100644 index 000000000..ca321e5f5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1210CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class SA1210CSharp12UnitTests : SA1210CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1210CombinedSystemDirectivesCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1210CombinedSystemDirectivesCSharp12UnitTests.cs new file mode 100644 index 000000000..d0ffd8b81 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1210CombinedSystemDirectivesCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class SA1210CombinedSystemDirectivesCSharp12UnitTests : SA1210CombinedSystemDirectivesCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1211CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1211CSharp12UnitTests.cs new file mode 100644 index 000000000..6a09f9434 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1211CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class SA1211CSharp12UnitTests : SA1211CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1212CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1212CSharp12UnitTests.cs new file mode 100644 index 000000000..c6308b3bb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1212CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class SA1212CSharp12UnitTests : SA1212CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1213CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1213CSharp12UnitTests.cs new file mode 100644 index 000000000..0a1aa4dfb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1213CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class SA1213CSharp12UnitTests : SA1213CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1214CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1214CSharp12UnitTests.cs new file mode 100644 index 000000000..d7331d6a0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1214CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class SA1214CSharp12UnitTests : SA1214CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1215CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1215CSharp12UnitTests.cs new file mode 100644 index 000000000..67bc76ea5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1215CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class SA1215CSharp12UnitTests : SA1215CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1216CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1216CSharp12UnitTests.cs new file mode 100644 index 000000000..be8f84b66 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1216CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class SA1216CSharp12UnitTests : SA1216CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1217CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1217CSharp12UnitTests.cs new file mode 100644 index 000000000..52d2b7749 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/SA1217CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class SA1217CSharp12UnitTests : SA1217CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/UsingCodeFixProviderCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/UsingCodeFixProviderCSharp12UnitTests.cs new file mode 100644 index 000000000..7f3d5f140 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/UsingCodeFixProviderCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class UsingCodeFixProviderCSharp12UnitTests : UsingCodeFixProviderCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/UsingCodeFixProviderCombinedSystemDirectivesCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/UsingCodeFixProviderCombinedSystemDirectivesCSharp12UnitTests.cs new file mode 100644 index 000000000..260d447df --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/UsingCodeFixProviderCombinedSystemDirectivesCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class UsingCodeFixProviderCombinedSystemDirectivesCSharp12UnitTests : UsingCodeFixProviderCombinedSystemDirectivesCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/UsingCodeFixProviderGroupSeparationCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/UsingCodeFixProviderGroupSeparationCSharp12UnitTests.cs new file mode 100644 index 000000000..0b9542d1c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/UsingCodeFixProviderGroupSeparationCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class UsingCodeFixProviderGroupSeparationCSharp12UnitTests : UsingCodeFixProviderGroupSeparationCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/UsingCodeFixProviderRegressionCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/UsingCodeFixProviderRegressionCSharp12UnitTests.cs new file mode 100644 index 000000000..4f55e0859 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/OrderingRules/UsingCodeFixProviderRegressionCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp11.OrderingRules; + + public partial class UsingCodeFixProviderRegressionCSharp12UnitTests : UsingCodeFixProviderRegressionCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Properties/AssemblyInfo.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..faebdb0d6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Properties/AssemblyInfo.cs @@ -0,0 +1,12 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; +using System.Runtime.InteropServices; + +[assembly: CLSCompliant(false)] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1100CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1100CSharp12UnitTests.cs new file mode 100644 index 000000000..3a066a4d4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1100CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1100CSharp12UnitTests : SA1100CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1101CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1101CSharp12UnitTests.cs new file mode 100644 index 000000000..883984a13 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1101CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1101CSharp12UnitTests : SA1101CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1102CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1102CSharp12UnitTests.cs new file mode 100644 index 000000000..7d2a82b0e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1102CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1102CSharp12UnitTests : SA1102CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1103CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1103CSharp12UnitTests.cs new file mode 100644 index 000000000..930eb7695 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1103CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1103CSharp12UnitTests : SA1103CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1104CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1104CSharp12UnitTests.cs new file mode 100644 index 000000000..2b075d8c1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1104CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1104CSharp12UnitTests : SA1104CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1105CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1105CSharp12UnitTests.cs new file mode 100644 index 000000000..6ada77ff0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1105CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1105CSharp12UnitTests : SA1105CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1106CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1106CSharp12UnitTests.cs new file mode 100644 index 000000000..071222226 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1106CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1106CSharp12UnitTests : SA1106CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1107CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1107CSharp12UnitTests.cs new file mode 100644 index 000000000..c613dc8c2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1107CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1107CSharp12UnitTests : SA1107CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1108CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1108CSharp12UnitTests.cs new file mode 100644 index 000000000..554518a17 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1108CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1108CSharp12UnitTests : SA1108CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1109CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1109CSharp12UnitTests.cs new file mode 100644 index 000000000..8d3cb6f5a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1109CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1109CSharp12UnitTests : SA1109CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1110CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1110CSharp12UnitTests.cs new file mode 100644 index 000000000..1ebc82119 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1110CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1110CSharp12UnitTests : SA1110CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1111CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1111CSharp12UnitTests.cs new file mode 100644 index 000000000..b67e9a3b2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1111CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1111CSharp12UnitTests : SA1111CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1112CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1112CSharp12UnitTests.cs new file mode 100644 index 000000000..2434476e4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1112CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1112CSharp12UnitTests : SA1112CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1113CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1113CSharp12UnitTests.cs new file mode 100644 index 000000000..66dd338ba --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1113CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1113CSharp12UnitTests : SA1113CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1114CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1114CSharp12UnitTests.cs new file mode 100644 index 000000000..88f30e266 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1114CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1114CSharp12UnitTests : SA1114CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1115CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1115CSharp12UnitTests.cs new file mode 100644 index 000000000..f99e7db0a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1115CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1115CSharp12UnitTests : SA1115CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1116CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1116CSharp12UnitTests.cs new file mode 100644 index 000000000..fb5ab1b7f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1116CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1116CSharp12UnitTests : SA1116CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1117CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1117CSharp12UnitTests.cs new file mode 100644 index 000000000..e36a9c1b7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1117CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1117CSharp12UnitTests : SA1117CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1118CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1118CSharp12UnitTests.cs new file mode 100644 index 000000000..f9e1f8c7b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1118CSharp12UnitTests.cs @@ -0,0 +1,43 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + using Xunit; + + using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier< + StyleCop.Analyzers.ReadabilityRules.SA1118ParameterMustNotSpanMultipleLines>; + + public partial class SA1118CSharp12UnitTests : SA1118CSharp11UnitTests + { + [Fact] + [WorkItem(3732, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3732")] + public async Task TestCollectionExpressionAsync() + { + var testCode = @" +class Foo +{ + public void TestMethod() + { + AnotherMethod( + 42, + [ + 1, + 2, + 3 + ]); + } + + public void AnotherMethod(int x, int[] y) + { + } +}"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1120CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1120CSharp12UnitTests.cs new file mode 100644 index 000000000..f0232b445 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1120CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1120CSharp12UnitTests : SA1120CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1121CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1121CSharp12UnitTests.cs new file mode 100644 index 000000000..7514597a8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1121CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1121CSharp12UnitTests : SA1121CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1122CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1122CSharp12UnitTests.cs new file mode 100644 index 000000000..f4fcda365 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1122CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1122CSharp12UnitTests : SA1122CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1123CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1123CSharp12UnitTests.cs new file mode 100644 index 000000000..729fe84a8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1123CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1123CSharp12UnitTests : SA1123CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1124CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1124CSharp12UnitTests.cs new file mode 100644 index 000000000..78211b320 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1124CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1124CSharp12UnitTests : SA1124CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1125CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1125CSharp12UnitTests.cs new file mode 100644 index 000000000..fb8f67ad6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1125CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1125CSharp12UnitTests : SA1125CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1126CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1126CSharp12UnitTests.cs new file mode 100644 index 000000000..d41b8d2ae --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1126CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1126CSharp12UnitTests : SA1126CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1127CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1127CSharp12UnitTests.cs new file mode 100644 index 000000000..694d14c79 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1127CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1127CSharp12UnitTests : SA1127CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1128CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1128CSharp12UnitTests.cs new file mode 100644 index 000000000..94d236f0a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1128CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1128CSharp12UnitTests : SA1128CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1129CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1129CSharp12UnitTests.cs new file mode 100644 index 000000000..bb1bcd2a3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1129CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1129CSharp12UnitTests : SA1129CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1130CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1130CSharp12UnitTests.cs new file mode 100644 index 000000000..a0253a0c5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1130CSharp12UnitTests.cs @@ -0,0 +1,23 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1130CSharp12UnitTests : SA1130CSharp11UnitTests + { + protected override DiagnosticResult[] GetCompilerExpectedResultCodeFixSpecialCases() + { + return new[] + { + DiagnosticResult.CompilerError("CS1065").WithLocation(12, 53), + DiagnosticResult.CompilerError("CS7014").WithLocation(13, 47), + DiagnosticResult.CompilerError("CS1670").WithLocation(14, 47), + DiagnosticResult.CompilerError("CS1669").WithLocation(15, 42), + DiagnosticResult.CompilerError("CS0225").WithLocation(14, 47), + }; + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1131CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1131CSharp12UnitTests.cs new file mode 100644 index 000000000..7d09d8cfd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1131CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1131CSharp12UnitTests : SA1131CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1132CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1132CSharp12UnitTests.cs new file mode 100644 index 000000000..134fda68c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1132CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1132CSharp12UnitTests : SA1132CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1133CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1133CSharp12UnitTests.cs new file mode 100644 index 000000000..2d59c0da2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1133CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1133CSharp12UnitTests : SA1133CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1134CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1134CSharp12UnitTests.cs new file mode 100644 index 000000000..f64d2cdf7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1134CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1134CSharp12UnitTests : SA1134CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1135CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1135CSharp12UnitTests.cs new file mode 100644 index 000000000..5b015b1b7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1135CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1135CSharp12UnitTests : SA1135CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1136CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1136CSharp12UnitTests.cs new file mode 100644 index 000000000..9ecf78616 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1136CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1136CSharp12UnitTests : SA1136CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1137CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1137CSharp12UnitTests.cs new file mode 100644 index 000000000..32aa35907 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1137CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1137CSharp12UnitTests : SA1137CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1139CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1139CSharp12UnitTests.cs new file mode 100644 index 000000000..7959b14c5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1139CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1139CSharp12UnitTests : SA1139CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1141CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1141CSharp12UnitTests.cs new file mode 100644 index 000000000..59a64e721 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1141CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1141CSharp12UnitTests : SA1141CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1142CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1142CSharp12UnitTests.cs new file mode 100644 index 000000000..3990598c3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SA1142CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SA1142CSharp12UnitTests : SA1142CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SX1101CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SX1101CSharp12UnitTests.cs new file mode 100644 index 000000000..bde93ce4c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/ReadabilityRules/SX1101CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp11.ReadabilityRules; + + public partial class SX1101CSharp12UnitTests : SX1101CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Settings/SettingsCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Settings/SettingsCSharp12UnitTests.cs new file mode 100644 index 000000000..4d39b9424 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Settings/SettingsCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Settings +{ + using StyleCop.Analyzers.Test.CSharp11.Settings; + + public partial class SettingsCSharp12UnitTests : SettingsCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Settings/SettingsFileCodeFixProviderCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Settings/SettingsFileCodeFixProviderCSharp12UnitTests.cs new file mode 100644 index 000000000..5c265a3fe --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/Settings/SettingsFileCodeFixProviderCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.Settings +{ + using StyleCop.Analyzers.Test.CSharp11.Settings; + + public partial class SettingsFileCodeFixProviderCSharp12UnitTests : SettingsFileCodeFixProviderCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1000CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1000CSharp12UnitTests.cs new file mode 100644 index 000000000..88f73ce32 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1000CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1000CSharp12UnitTests : SA1000CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1001CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1001CSharp12UnitTests.cs new file mode 100644 index 000000000..d30920309 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1001CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1001CSharp12UnitTests : SA1001CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1002CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1002CSharp12UnitTests.cs new file mode 100644 index 000000000..54a14c9ea --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1002CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1002CSharp12UnitTests : SA1002CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1003CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1003CSharp12UnitTests.cs new file mode 100644 index 000000000..ed17bb71b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1003CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1003CSharp12UnitTests : SA1003CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1004CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1004CSharp12UnitTests.cs new file mode 100644 index 000000000..d832043fb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1004CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1004CSharp12UnitTests : SA1004CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1005CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1005CSharp12UnitTests.cs new file mode 100644 index 000000000..17c8b288c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1005CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1005CSharp12UnitTests : SA1005CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1006CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1006CSharp12UnitTests.cs new file mode 100644 index 000000000..684629414 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1006CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1006CSharp12UnitTests : SA1006CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1007CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1007CSharp12UnitTests.cs new file mode 100644 index 000000000..7aee3f8b6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1007CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1007CSharp12UnitTests : SA1007CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1008CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1008CSharp12UnitTests.cs new file mode 100644 index 000000000..f0544bc37 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1008CSharp12UnitTests.cs @@ -0,0 +1,32 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + using Xunit; + + using static StyleCop.Analyzers.SpacingRules.SA1008OpeningParenthesisMustBeSpacedCorrectly; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1008OpeningParenthesisMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1008CSharp12UnitTests : SA1008CSharp11UnitTests + { + [Fact] + [WorkItem(3743, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3743")] + public async Task TestTupleUsingAliasAsync() + { + const string testCode = @" +using TestAlias ={|#0:(|}string X, bool Y);"; + + const string fixedCode = @" +using TestAlias = (string X, bool Y);"; + + var expected = Diagnostic(DescriptorPreceded).WithLocation(0); + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1009CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1009CSharp12UnitTests.cs new file mode 100644 index 000000000..434f1f720 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1009CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1009CSharp12UnitTests : SA1009CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1010CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1010CSharp12UnitTests.cs new file mode 100644 index 000000000..60bbffff8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1010CSharp12UnitTests.cs @@ -0,0 +1,49 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + using Xunit; + + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1010OpeningSquareBracketsMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1010CSharp12UnitTests : SA1010CSharp11UnitTests + { + [Fact] + [WorkItem(3687, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3687")] + public async Task TestCollectionExpressionAsync() + { + var testCode = $@" +using System.Collections.Generic; + +namespace TestNamespace +{{ + public class TestClass + {{ + protected static readonly int[] DefaultMetadataPaths = [1, 2]; + + public void TestMethod(List x, int y) + {{ + List foo = []; + foo = [42]; + foo = [..x, y]; + Bar([1 ,2, 3]); + }} + + public void Bar(int[] x) + {{ + }} + }} +}} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1011CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1011CSharp12UnitTests.cs new file mode 100644 index 000000000..f546ff7e0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1011CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1011CSharp12UnitTests : SA1011CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1012CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1012CSharp12UnitTests.cs new file mode 100644 index 000000000..ffd23f332 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1012CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1012CSharp12UnitTests : SA1012CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1013CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1013CSharp12UnitTests.cs new file mode 100644 index 000000000..463d491c0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1013CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1013CSharp12UnitTests : SA1013CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1014CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1014CSharp12UnitTests.cs new file mode 100644 index 000000000..8893d944e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1014CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1014CSharp12UnitTests : SA1014CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1015CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1015CSharp12UnitTests.cs new file mode 100644 index 000000000..a01446ce9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1015CSharp12UnitTests.cs @@ -0,0 +1,21 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1015CSharp12UnitTests : SA1015CSharp11UnitTests + { + protected override DiagnosticResult[] GetExpectedResultMissingToken() + { + return new[] + { + DiagnosticResult.CompilerError("CS1003").WithLocation(7, 35).WithArguments(","), + DiagnosticResult.CompilerError("CS1003").WithLocation(7, 36).WithArguments(">"), + DiagnosticResult.CompilerError("CS1026").WithLocation(7, 36), + }; + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1016CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1016CSharp12UnitTests.cs new file mode 100644 index 000000000..92f063a5d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1016CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1016CSharp12UnitTests : SA1016CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1017CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1017CSharp12UnitTests.cs new file mode 100644 index 000000000..2be1eb007 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1017CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1017CSharp12UnitTests : SA1017CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1018CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1018CSharp12UnitTests.cs new file mode 100644 index 000000000..c07aa71e4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1018CSharp12UnitTests.cs @@ -0,0 +1,23 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1018CSharp12UnitTests : SA1018CSharp11UnitTests + { + protected override DiagnosticResult[] GetExpectedResultSyntaxErrorAtEndOfFile() + { + return new[] + { + DiagnosticResult.CompilerError("CS1031").WithLocation(10, 2), + DiagnosticResult.CompilerError("CS8803").WithLocation(11, 1), + DiagnosticResult.CompilerError("CS8805").WithLocation(11, 1), + DiagnosticResult.CompilerError("CS1001").WithLocation(11, 2), + DiagnosticResult.CompilerError("CS1002").WithLocation(11, 2), + }; + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1019CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1019CSharp12UnitTests.cs new file mode 100644 index 000000000..5e4836ea9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1019CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1019CSharp12UnitTests : SA1019CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1020CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1020CSharp12UnitTests.cs new file mode 100644 index 000000000..a633eb73b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1020CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1020CSharp12UnitTests : SA1020CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1021CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1021CSharp12UnitTests.cs new file mode 100644 index 000000000..012715e71 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1021CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1021CSharp12UnitTests : SA1021CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1022CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1022CSharp12UnitTests.cs new file mode 100644 index 000000000..68539d93e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1022CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1022CSharp12UnitTests : SA1022CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1023CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1023CSharp12UnitTests.cs new file mode 100644 index 000000000..de9134b23 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1023CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1023CSharp12UnitTests : SA1023CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1024CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1024CSharp12UnitTests.cs new file mode 100644 index 000000000..9a0cf7b57 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1024CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1024CSharp12UnitTests : SA1024CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1025CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1025CSharp12UnitTests.cs new file mode 100644 index 000000000..e038ec962 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1025CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1025CSharp12UnitTests : SA1025CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1026CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1026CSharp12UnitTests.cs new file mode 100644 index 000000000..62987c401 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1026CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1026CSharp12UnitTests : SA1026CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1027AlternateIndentationCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1027AlternateIndentationCSharp12UnitTests.cs new file mode 100644 index 000000000..e434b41c4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1027AlternateIndentationCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1027AlternateIndentationCSharp12UnitTests : SA1027AlternateIndentationCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1027CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1027CSharp12UnitTests.cs new file mode 100644 index 000000000..9888b07d3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1027CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1027CSharp12UnitTests : SA1027CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1027UseTabsCSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1027UseTabsCSharp12UnitTests.cs new file mode 100644 index 000000000..8f01e1b50 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1027UseTabsCSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1027UseTabsCSharp12UnitTests : SA1027UseTabsCSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1028CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1028CSharp12UnitTests.cs new file mode 100644 index 000000000..8a32d29ad --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpacingRules/SA1028CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpacingRules; + + public partial class SA1028CSharp12UnitTests : SA1028CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpecialRules/SA0001CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpecialRules/SA0001CSharp12UnitTests.cs new file mode 100644 index 000000000..d37ad0179 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpecialRules/SA0001CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpecialRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpecialRules; + + public partial class SA0001CSharp12UnitTests : SA0001CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpecialRules/SA0002CSharp12UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpecialRules/SA0002CSharp12UnitTests.cs new file mode 100644 index 000000000..9d9511ab7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/SpecialRules/SA0002CSharp12UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp12.SpecialRules +{ + using StyleCop.Analyzers.Test.CSharp11.SpecialRules; + + public partial class SA0002CSharp12UnitTests : SA0002CSharp11UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/StyleCop.Analyzers.Test.CSharp12.csproj b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/StyleCop.Analyzers.Test.CSharp12.csproj new file mode 100644 index 000000000..ddb37f4f9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/StyleCop.Analyzers.Test.CSharp12.csproj @@ -0,0 +1,38 @@ + + + + + net472 + false + true + true + + + + ..\StyleCop.Analyzers.Internal.ruleset + + + + true + ..\..\build\keys\TestingKey.snk + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/AnalyzerConfigurationCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/AnalyzerConfigurationCSharp7UnitTests.cs new file mode 100644 index 000000000..d739ae277 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/AnalyzerConfigurationCSharp7UnitTests.cs @@ -0,0 +1,9 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7 +{ + public partial class AnalyzerConfigurationCSharp7UnitTests : AnalyzerConfigurationUnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/AnalyzerConfigurationTestsCSharp7.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/AnalyzerConfigurationTestsCSharp7.cs deleted file mode 100644 index 0eee855c2..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/AnalyzerConfigurationTestsCSharp7.cs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. - -namespace StyleCop.Analyzers.Test.CSharp7 -{ - public class AnalyzerConfigurationTestsCSharp7 : AnalyzerConfigurationTests - { - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/CSharp7InheritdocCodeFixProviderUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/InheritdocCodeFixProviderCSharp7UnitTests.cs similarity index 50% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/CSharp7InheritdocCodeFixProviderUnitTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/InheritdocCodeFixProviderCSharp7UnitTests.cs index 36a6ac710..649c19df9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/CSharp7InheritdocCodeFixProviderUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/InheritdocCodeFixProviderCSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class CSharp7InheritdocCodeFixProviderUnitTests : InheritdocCodeFixProviderUnitTests + public partial class InheritdocCodeFixProviderCSharp7UnitTests : InheritdocCodeFixProviderUnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/CSharp7NoXmlFileHeaderUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/NoXmlFileHeaderCSharp7UnitTests.cs similarity index 52% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/CSharp7NoXmlFileHeaderUnitTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/NoXmlFileHeaderCSharp7UnitTests.cs index f4cb024bf..abd78da9e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/CSharp7NoXmlFileHeaderUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/NoXmlFileHeaderCSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class CSharp7NoXmlFileHeaderUnitTests : NoXmlFileHeaderUnitTests + public partial class NoXmlFileHeaderCSharp7UnitTests : NoXmlFileHeaderUnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1600CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1600CSharp7UnitTests.cs index 62f524452..105ba5506 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1600CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1600CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { @@ -8,7 +10,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules using StyleCop.Analyzers.Test.DocumentationRules; using Xunit; - public class SA1600CSharp7UnitTests : SA1600UnitTests + public partial class SA1600CSharp7UnitTests : SA1600UnitTests { protected override LanguageVersion LanguageVersion => LanguageVersion.CSharp7_2; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1601CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1601CSharp7UnitTests.cs index ed42105e3..d2c033fb0 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1601CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1601CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1601CSharp7UnitTests : SA1601UnitTests + public partial class SA1601CSharp7UnitTests : SA1601UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1602CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1602CSharp7UnitTests.cs index f2ffb9557..44b798e9c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1602CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1602CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1602CSharp7UnitTests : SA1602UnitTests + public partial class SA1602CSharp7UnitTests : SA1602UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1603CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1603CSharp7UnitTests.cs index 8bc824af6..3518ceb14 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1603CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1603CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1603CSharp7UnitTests : SA1603UnitTests + public partial class SA1603CSharp7UnitTests : SA1603UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1604CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1604CSharp7UnitTests.cs index 4a2544780..e5e64861a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1604CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1604CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1604CSharp7UnitTests : SA1604UnitTests + public partial class SA1604CSharp7UnitTests : SA1604UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1605CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1605CSharp7UnitTests.cs index 5c6ba0451..236ab0649 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1605CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1605CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1605CSharp7UnitTests : SA1605UnitTests + public partial class SA1605CSharp7UnitTests : SA1605UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1606CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1606CSharp7UnitTests.cs index 1d1e21db7..dc3dbc779 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1606CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1606CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1606CSharp7UnitTests : SA1606UnitTests + public partial class SA1606CSharp7UnitTests : SA1606UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1607CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1607CSharp7UnitTests.cs index 5ca6e8f16..9913fd0db 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1607CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1607CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1607CSharp7UnitTests : SA1607UnitTests + public partial class SA1607CSharp7UnitTests : SA1607UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1608CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1608CSharp7UnitTests.cs index 8ddff8782..6c1640047 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1608CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1608CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1608CSharp7UnitTests : SA1608UnitTests + public partial class SA1608CSharp7UnitTests : SA1608UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1609CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1609CSharp7UnitTests.cs index e67399a51..da5eabe62 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1609CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1609CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1609CSharp7UnitTests : SA1609UnitTests + public partial class SA1609CSharp7UnitTests : SA1609UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1610CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1610CSharp7UnitTests.cs index 29cc8c66a..7285a9eaf 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1610CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1610CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1610CSharp7UnitTests : SA1610UnitTests + public partial class SA1610CSharp7UnitTests : SA1610UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1611CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1611CSharp7UnitTests.cs index c39359e04..47374b265 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1611CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1611CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1611CSharp7UnitTests : SA1611UnitTests + public partial class SA1611CSharp7UnitTests : SA1611UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1612CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1612CSharp7UnitTests.cs index 925d9f98f..f5ec0ea9d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1612CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1612CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1612CSharp7UnitTests : SA1612UnitTests + public partial class SA1612CSharp7UnitTests : SA1612UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1613CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1613CSharp7UnitTests.cs index 06b9949ce..52e00dfc3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1613CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1613CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1613CSharp7UnitTests : SA1613UnitTests + public partial class SA1613CSharp7UnitTests : SA1613UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1614CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1614CSharp7UnitTests.cs index 735ab82be..ed4222130 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1614CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1614CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1614CSharp7UnitTests : SA1614UnitTests + public partial class SA1614CSharp7UnitTests : SA1614UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1615CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1615CSharp7UnitTests.cs index 52be9ba12..e0dbeb923 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1615CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1615CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1615CSharp7UnitTests : SA1615UnitTests + public partial class SA1615CSharp7UnitTests : SA1615UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1616CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1616CSharp7UnitTests.cs index c7db81885..236b715ab 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1616CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1616CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1616CSharp7UnitTests : SA1616UnitTests + public partial class SA1616CSharp7UnitTests : SA1616UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1617CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1617CSharp7UnitTests.cs index a695cf8e0..ae1defbc3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1617CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1617CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1617CSharp7UnitTests : SA1617UnitTests + public partial class SA1617CSharp7UnitTests : SA1617UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1618CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1618CSharp7UnitTests.cs index 049021217..8cad7a62a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1618CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1618CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1618CSharp7UnitTests : SA1618UnitTests + public partial class SA1618CSharp7UnitTests : SA1618UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1619CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1619CSharp7UnitTests.cs index 98a394df4..8b3e20318 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1619CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1619CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1619CSharp7UnitTests : SA1619UnitTests + public partial class SA1619CSharp7UnitTests : SA1619UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1620CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1620CSharp7UnitTests.cs index 8fc7ec358..de61ca319 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1620CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1620CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1620CSharp7UnitTests : SA1620UnitTests + public partial class SA1620CSharp7UnitTests : SA1620UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1621CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1621CSharp7UnitTests.cs index 77a54228f..6e551a1b4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1621CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1621CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1621CSharp7UnitTests : SA1621UnitTests + public partial class SA1621CSharp7UnitTests : SA1621UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1622CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1622CSharp7UnitTests.cs index 421753722..d58d0ad17 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1622CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1622CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1622CSharp7UnitTests : SA1622UnitTests + public partial class SA1622CSharp7UnitTests : SA1622UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1623CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1623CSharp7UnitTests.cs index d26b82217..93f02805c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1623CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1623CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { @@ -12,7 +14,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules StyleCop.Analyzers.DocumentationRules.PropertySummaryDocumentationAnalyzer, StyleCop.Analyzers.DocumentationRules.PropertySummaryDocumentationCodeFixProvider>; - public class SA1623CSharp7UnitTests : SA1623UnitTests + public partial class SA1623CSharp7UnitTests : SA1623UnitTests { /// /// Verifies that property documentation that does not start with the appropriate text will result in a @@ -48,6 +50,9 @@ public class SA1623CSharp7UnitTests : SA1623UnitTests [InlineData("protected internal", "int", "{ private get => 0; set => this.field = value; }", "Sets")] [InlineData("internal", "int", "{ get => 0; private set => this.field = value; }", "Gets")] [InlineData("internal", "int", "{ private get => 0; set => this.field = value; }", "Sets")] + + [WorkItem(2861, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2861")] + [InlineData("public", "ref int", "{ get => throw null; }", "Gets")] public async Task VerifyDocumentationWithWrongStartingTextWillProduceDiagnosticWithExpressionBodiedAccessorsAsync(string accessibility, string type, string accessors, string expectedArgument) { var testCode = $@" diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1624CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1624CSharp7UnitTests.cs index 49f95456b..75ed164cc 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1624CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1624CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { @@ -12,7 +14,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules StyleCop.Analyzers.DocumentationRules.PropertySummaryDocumentationAnalyzer, StyleCop.Analyzers.DocumentationRules.PropertySummaryDocumentationCodeFixProvider>; - public class SA1624CSharp7UnitTests : SA1624UnitTests + public partial class SA1624CSharp7UnitTests : SA1624UnitTests { /// /// Verifies that documentation that starts with the proper text for multiple expression-bodied accessors will diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1625CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1625CSharp7UnitTests.cs index 49c062ade..337451909 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1625CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1625CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1625CSharp7UnitTests : SA1625UnitTests + public partial class SA1625CSharp7UnitTests : SA1625UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1626CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1626CSharp7UnitTests.cs index fc754d7ff..49b4c7532 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1626CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1626CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1626CSharp7UnitTests : SA1626UnitTests + public partial class SA1626CSharp7UnitTests : SA1626UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1627CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1627CSharp7UnitTests.cs index dcc091ffd..6798c6561 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1627CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1627CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1627CSharp7UnitTests : SA1627UnitTests + public partial class SA1627CSharp7UnitTests : SA1627UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1628CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1628CSharp7UnitTests.cs index 39788eee1..67559a8e4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1628CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1628CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1628CSharp7UnitTests : SA1628UnitTests + public partial class SA1628CSharp7UnitTests : SA1628UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1629CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1629CSharp7UnitTests.cs index cd143fc26..a75f87da3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1629CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1629CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1629CSharp7UnitTests : SA1629UnitTests + public partial class SA1629CSharp7UnitTests : SA1629UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1630CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1630CSharp7UnitTests.cs index 8075a0740..5a053f43f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1630CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1630CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1630CSharp7UnitTests : SA1630UnitTests + public partial class SA1630CSharp7UnitTests : SA1630UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1631CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1631CSharp7UnitTests.cs index 6d26073bf..e18f6108e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1631CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1631CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1631CSharp7UnitTests : SA1631UnitTests + public partial class SA1631CSharp7UnitTests : SA1631UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1632CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1632CSharp7UnitTests.cs index 4569b1e90..1f3e00df6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1632CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1632CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1632CSharp7UnitTests : SA1632UnitTests + public partial class SA1632CSharp7UnitTests : SA1632UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1633CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1633CSharp7UnitTests.cs index f6993ad94..753e047ae 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1633CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1633CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1633CSharp7UnitTests : SA1633UnitTests + public partial class SA1633CSharp7UnitTests : SA1633UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1634CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1634CSharp7UnitTests.cs index 9e1a8d513..968d6bf7c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1634CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1634CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1634CSharp7UnitTests : SA1634UnitTests + public partial class SA1634CSharp7UnitTests : SA1634UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1635CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1635CSharp7UnitTests.cs index 7374f3f71..87022206f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1635CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1635CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1635CSharp7UnitTests : SA1635UnitTests + public partial class SA1635CSharp7UnitTests : SA1635UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1636CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1636CSharp7UnitTests.cs index 67c3a9a95..8767be2e7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1636CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1636CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1636CSharp7UnitTests : SA1636UnitTests + public partial class SA1636CSharp7UnitTests : SA1636UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1637CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1637CSharp7UnitTests.cs index a4026d5f3..ec3c55efa 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1637CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1637CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1637CSharp7UnitTests : SA1637UnitTests + public partial class SA1637CSharp7UnitTests : SA1637UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1638CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1638CSharp7UnitTests.cs index 2bccda920..1a45d81c8 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1638CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1638CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1638CSharp7UnitTests : SA1638UnitTests + public partial class SA1638CSharp7UnitTests : SA1638UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1639CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1639CSharp7UnitTests.cs index d3fbfef61..6f9c69d7d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1639CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1639CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1639CSharp7UnitTests : SA1639UnitTests + public partial class SA1639CSharp7UnitTests : SA1639UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1640CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1640CSharp7UnitTests.cs index e8b12d8c1..278e40584 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1640CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1640CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1640CSharp7UnitTests : SA1640UnitTests + public partial class SA1640CSharp7UnitTests : SA1640UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1641CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1641CSharp7UnitTests.cs index 32c1e179f..1fb908b26 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1641CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1641CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1641CSharp7UnitTests : SA1641UnitTests + public partial class SA1641CSharp7UnitTests : SA1641UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1642CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1642CSharp7UnitTests.cs index b9f4b9085..01fe01d9f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1642CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1642CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1642CSharp7UnitTests : SA1642UnitTests + public partial class SA1642CSharp7UnitTests : SA1642UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1643CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1643CSharp7UnitTests.cs index e48f5b8de..264440bbc 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1643CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1643CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1643CSharp7UnitTests : SA1643UnitTests + public partial class SA1643CSharp7UnitTests : SA1643UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1644CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1644CSharp7UnitTests.cs new file mode 100644 index 000000000..adb8bc6a2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1644CSharp7UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules +{ + using StyleCop.Analyzers.Test.DocumentationRules; + + public partial class SA1644CSharp7UnitTests : SA1644UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1645CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1645CSharp7UnitTests.cs index 87ccdd855..7ea1f2889 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1645CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1645CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1645CSharp7UnitTests : SA1645UnitTests + public partial class SA1645CSharp7UnitTests : SA1645UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1646CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1646CSharp7UnitTests.cs index 4af8ed096..09b9edf3d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1646CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1646CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1646CSharp7UnitTests : SA1646UnitTests + public partial class SA1646CSharp7UnitTests : SA1646UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1647CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1647CSharp7UnitTests.cs index 0662261ed..5512fc0d5 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1647CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1647CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1647CSharp7UnitTests : SA1647UnitTests + public partial class SA1647CSharp7UnitTests : SA1647UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1648CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1648CSharp7UnitTests.cs index f03364ba7..934985890 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1648CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1648CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1648CSharp7UnitTests : SA1648UnitTests + public partial class SA1648CSharp7UnitTests : SA1648UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1649CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1649CSharp7UnitTests.cs index 152d4be1e..1d9d5db6f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1649CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1649CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1649CSharp7UnitTests : SA1649UnitTests + public partial class SA1649CSharp7UnitTests : SA1649UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1650CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1650CSharp7UnitTests.cs index 1728e65af..4c5d2d586 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1650CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1650CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1650CSharp7UnitTests : SA1650UnitTests + public partial class SA1650CSharp7UnitTests : SA1650UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1651CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1651CSharp7UnitTests.cs index afb3ff996..90bfd00ee 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1651CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/DocumentationRules/SA1651CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.DocumentationRules { using StyleCop.Analyzers.Test.DocumentationRules; - public class SA1651CSharp7UnitTests : SA1651UnitTests + public partial class SA1651CSharp7UnitTests : SA1651UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/HelperTests/SymbolNameHelpersCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/HelperTests/SymbolNameHelpersCSharp7UnitTests.cs new file mode 100644 index 000000000..11d2b2dca --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/HelperTests/SymbolNameHelpersCSharp7UnitTests.cs @@ -0,0 +1,39 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp7.HelperTests +{ + using System.Threading.Tasks; + using StyleCop.Analyzers.Test.HelperTests; + using Xunit; + + /// + /// Unit tests for the class in the context of C# 7.x. + /// + public partial class SymbolNameHelpersCSharp7UnitTests : SymbolNameHelpersUnitTests + { + /// + /// Verify the workings of + /// for standard use cases. + /// + /// A string representation of a type or namespace to process. + /// if is a namespace; + /// if is a type to be used as an alias target. + /// A representing the asynchronous unit test. + [Theory] + [InlineData("System.ValueTuple")] + [InlineData("System.ValueTuple")] + [InlineData("System.ValueTuple")] + [InlineData("System.ValueTuple")] + [InlineData("System.Collections.Generic.KeyValuePair")] + [InlineData("System.Collections.Generic.KeyValuePair")] + [InlineData("System.Nullable<(int, object)>")] + [WorkItem(3149, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3149")] + public Task VerifyToQualifiedStringTuplesAsync(string inputString, bool isNamespace = false) + { + return this.PerformTestAsync(inputString, isNamespace); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1500CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1500CSharp7UnitTests.cs index d505ebfaf..5bac4de27 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1500CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1500CSharp7UnitTests.cs @@ -1,19 +1,22 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.LayoutRules; - using TestHelper; using Xunit; + using static StyleCop.Analyzers.Test.Helpers.LanguageVersionTestExtensions; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, StyleCop.Analyzers.LayoutRules.SA1500CodeFixProvider>; - public class SA1500CSharp7UnitTests : SA1500UnitTests + public partial class SA1500CSharp7UnitTests : SA1500UnitTests { /// /// Verifies that no diagnostics are reported for the valid local functions defined in this test. @@ -167,5 +170,173 @@ void LocalFunction6() await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } + + /// + /// Verifies that no diagnostics are reported for the valid stackalloc array initializers defined in this test. + /// + /// + /// These are valid for SA1500 only, some will report other diagnostics. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task TestStackAllocArrayInitializersValidAsync() + { + var testCode = @"using System; + +public class TestClass +{ + public unsafe void TestMethod() + { + var array1 = stackalloc int[0] { }; + var array2 = stackalloc[] { 0, 1 }; + var array3 = stackalloc int[] { 0, 1 }; + var array4 = stackalloc int[] + { + }; + var array5 = stackalloc int[2] + { + 0, + 1, + }; + } +}"; + await VerifyCSharpDiagnosticAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that diagnostics will be reported for all invalid implicit stackalloc array initializer definitions. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task TestImplicitStackAllocArrayInitializersInvalidAsync() + { + var testCode = @" +public class TestClass +{ + public unsafe void TestMethod() + { + var invalidArray1 = stackalloc[] + { 0, 1 + }; + + var invalidArray2 = stackalloc[] + { + 0, 1 }; + + var invalidArray3 = stackalloc[] + { 0, 1 }; + + var invalidArray4 = stackalloc[] + { 0, 1 + }; + + var invalidArray5 = stackalloc[] + { + 0, 1 }; + } +}"; + + var fixedTestCode = @" +public class TestClass +{ + public unsafe void TestMethod() + { + var invalidArray1 = stackalloc[] + { + 0, 1 + }; + + var invalidArray2 = stackalloc[] + { + 0, 1 + }; + + var invalidArray3 = stackalloc[] + { + 0, 1 + }; + + var invalidArray4 = stackalloc[] + { + 0, 1 + }; + + var invalidArray5 = stackalloc[] + { + 0, 1 + }; + } +}"; + + DiagnosticResult[] expectedDiagnostics = + { + Diagnostic().WithLocation(7, 13), + Diagnostic().WithLocation(12, 22), + Diagnostic().WithLocation(15, 13), + Diagnostic().WithLocation(15, 20), + Diagnostic().WithLocation(18, 13), + Diagnostic().WithLocation(23, 22), + }; + + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expectedDiagnostics, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that diagnostics will be reported for all invalid stackalloc array initializer definitions. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task TestStackAllocArrayInitializersInvalidAsync() + { + var testCode = @" +public class TestClass +{ + public unsafe void TestMethod() + { + var invalidArray1 = stackalloc int[] + { 0, 1 }; + + var invalidArray2 = stackalloc int[] + { 0, 1 + }; + + var invalidArray3 = stackalloc int[] + { + 0, 1 }; + } +}"; + + var fixedTestCode = @" +public class TestClass +{ + public unsafe void TestMethod() + { + var invalidArray1 = stackalloc int[] + { + 0, 1 + }; + + var invalidArray2 = stackalloc int[] + { + 0, 1 + }; + + var invalidArray3 = stackalloc int[] + { + 0, 1 + }; + } +}"; + + DiagnosticResult[] expectedDiagnostics = + { + Diagnostic().WithLocation(7, 13), + Diagnostic().WithLocation(7, 20), + Diagnostic().WithLocation(10, 13), + Diagnostic().WithLocation(15, 22), + }; + + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expectedDiagnostics, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1501CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1501CSharp7UnitTests.cs index 845b26927..2f1714efd 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1501CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1501CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules { using StyleCop.Analyzers.Test.LayoutRules; - public class SA1501CSharp7UnitTests : SA1501UnitTests + public partial class SA1501CSharp7UnitTests : SA1501UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1502CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1502CSharp7UnitTests.cs index b556ce1d9..ee437b38b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1502CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1502CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules { @@ -12,7 +14,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules StyleCop.Analyzers.LayoutRules.SA1502ElementMustNotBeOnASingleLine, StyleCop.Analyzers.LayoutRules.SA1502CodeFixProvider>; - public class SA1502CSharp7UnitTests : SA1502UnitTests + public partial class SA1502CSharp7UnitTests : SA1502UnitTests { /// /// Verifies that a valid local function will pass without diagnostic. diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1503CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1503CSharp7UnitTests.cs index dd27f1d44..b61180ca8 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1503CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1503CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules { using StyleCop.Analyzers.Test.LayoutRules; - public class SA1503CSharp7UnitTests : SA1503UnitTests + public partial class SA1503CSharp7UnitTests : SA1503UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1504CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1504CSharp7UnitTests.cs index 7f89e383b..6f6cf5c45 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1504CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1504CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules { using StyleCop.Analyzers.Test.LayoutRules; - public class SA1504CSharp7UnitTests : SA1504UnitTests + public partial class SA1504CSharp7UnitTests : SA1504UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1505CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1505CSharp7UnitTests.cs index a59704b51..cf7cdbb49 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1505CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1505CSharp7UnitTests.cs @@ -1,18 +1,22 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.LayoutRules; using Xunit; + using static StyleCop.Analyzers.Test.Helpers.LanguageVersionTestExtensions; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1505OpeningBracesMustNotBeFollowedByBlankLine, StyleCop.Analyzers.LayoutRules.SA1505CodeFixProvider>; - public class SA1505CSharp7UnitTests : SA1505UnitTests + public partial class SA1505CSharp7UnitTests : SA1505UnitTests { /// /// Verifies that a valid local function will not produce any diagnostics. @@ -38,7 +42,7 @@ void LocalFunction() } "; - await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, testCode, CancellationToken.None).ConfigureAwait(false); } /// @@ -86,5 +90,89 @@ void LocalFunction() var expectedDiagnostic = Diagnostic().WithLocation(10, 13); await VerifyCSharpFixAsync(testCode, expectedDiagnostic, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } + + [Fact] + public async Task TestStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* v1 = stackalloc int[] + { + + 1, + 2, + 3 + }; + } + } +} +"; + + var fixedTestCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* v1 = stackalloc int[] + { + 1, + 2, + 3 + }; + } + } +} +"; + + var expectedDiagnostic = Diagnostic().WithLocation(8, 13); + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expectedDiagnostic, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestImplicitStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* v1 = stackalloc[] + { + + 1, + 2, + 3 + }; + } + } +} +"; + + var fixedTestCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* v1 = stackalloc[] + { + 1, + 2, + 3 + }; + } + } +} +"; + + var expectedDiagnostic = Diagnostic().WithLocation(8, 13); + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expectedDiagnostic, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1506CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1506CSharp7UnitTests.cs index 6a72f54e4..97e1b4e4b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1506CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1506CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules { using StyleCop.Analyzers.Test.LayoutRules; - public class SA1506CSharp7UnitTests : SA1506UnitTests + public partial class SA1506CSharp7UnitTests : SA1506UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1507CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1507CSharp7UnitTests.cs index 9d186bd9c..25029725b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1507CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1507CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules { using StyleCop.Analyzers.Test.LayoutRules; - public class SA1507CSharp7UnitTests : SA1507UnitTests + public partial class SA1507CSharp7UnitTests : SA1507UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1508CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1508CSharp7UnitTests.cs index b3a3aa555..91da7c367 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1508CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1508CSharp7UnitTests.cs @@ -1,18 +1,22 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.LayoutRules; using Xunit; + using static StyleCop.Analyzers.Test.Helpers.LanguageVersionTestExtensions; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1508ClosingBracesMustNotBePrecededByBlankLine, StyleCop.Analyzers.LayoutRules.SA1508CodeFixProvider>; - public class SA1508CSharp7UnitTests : SA1508UnitTests + public partial class SA1508CSharp7UnitTests : SA1508UnitTests { /// /// Verifies that a valid local function will not produce any diagnostics. @@ -38,7 +42,7 @@ void LocalFunction() } "; - await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, testCode, CancellationToken.None).ConfigureAwait(false); } /// @@ -86,5 +90,89 @@ void LocalFunction() var expectedDiagnostic = Diagnostic().WithLocation(13, 13); await VerifyCSharpFixAsync(testCode, expectedDiagnostic, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } + + [Fact] + public async Task TestStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* v1 = stackalloc int[] + { + 1, + 2, + 3 + + }; + } + } +} +"; + + var fixedTestCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* v1 = stackalloc int[] + { + 1, + 2, + 3 + }; + } + } +} +"; + + var expectedDiagnostic = Diagnostic().WithLocation(13, 13); + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expectedDiagnostic, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestImplicitStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* v1 = stackalloc[] + { + 1, + 2, + 3 + + }; + } + } +} +"; + + var fixedTestCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* v1 = stackalloc[] + { + 1, + 2, + 3 + }; + } + } +} +"; + + var expectedDiagnostic = Diagnostic().WithLocation(13, 13); + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expectedDiagnostic, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1509CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1509CSharp7UnitTests.cs index 3e551ecd7..a2e9cf61a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1509CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1509CSharp7UnitTests.cs @@ -1,19 +1,22 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.LayoutRules; - using TestHelper; using Xunit; + using static StyleCop.Analyzers.Test.Helpers.LanguageVersionTestExtensions; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1509OpeningBracesMustNotBePrecededByBlankLine, StyleCop.Analyzers.LayoutRules.SA1509CodeFixProvider>; - public class SA1509CSharp7UnitTests : SA1509UnitTests + public partial class SA1509CSharp7UnitTests : SA1509UnitTests { [Fact] public async Task TestLocalFunctionDeclarationOpeningBraceHasBlankLineAsync() @@ -74,5 +77,89 @@ void Bar() DiagnosticResult expected = Diagnostic().WithLocation(9, 9); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } + + [Fact] + public async Task TestStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* v1 = stackalloc int[] + + { + 1, + 2, + 3 + }; + } + } +} +"; + + var fixedTestCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* v1 = stackalloc int[] + { + 1, + 2, + 3 + }; + } + } +} +"; + + var expectedDiagnostic = Diagnostic().WithLocation(9, 13); + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expectedDiagnostic, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestImplicitStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* v1 = stackalloc[] + + { + 1, + 2, + 3 + }; + } + } +} +"; + + var fixedTestCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* v1 = stackalloc[] + { + 1, + 2, + 3 + }; + } + } +} +"; + + var expectedDiagnostic = Diagnostic().WithLocation(9, 13); + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expectedDiagnostic, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1510CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1510CSharp7UnitTests.cs index 909e265b5..f3dae512d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1510CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1510CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules { using StyleCop.Analyzers.Test.LayoutRules; - public class SA1510CSharp7UnitTests : SA1510UnitTests + public partial class SA1510CSharp7UnitTests : SA1510UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1511CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1511CSharp7UnitTests.cs index 71b96accf..7a6265901 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1511CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1511CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules { using StyleCop.Analyzers.Test.LayoutRules; - public class SA1511CSharp7UnitTests : SA1511UnitTests + public partial class SA1511CSharp7UnitTests : SA1511UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1512CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1512CSharp7UnitTests.cs index dac47a912..1a14fc80c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1512CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1512CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules { using StyleCop.Analyzers.Test.LayoutRules; - public class SA1512CSharp7UnitTests : SA1512UnitTests + public partial class SA1512CSharp7UnitTests : SA1512UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1513CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1513CSharp7UnitTests.cs index acbd5335e..88c4df0df 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1513CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1513CSharp7UnitTests.cs @@ -1,18 +1,22 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.LayoutRules; using Xunit; + using static StyleCop.Analyzers.Test.Helpers.LanguageVersionTestExtensions; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1513ClosingBraceMustBeFollowedByBlankLine, StyleCop.Analyzers.LayoutRules.SA1513CodeFixProvider>; - public class SA1513CSharp7UnitTests : SA1513UnitTests + public partial class SA1513CSharp7UnitTests : SA1513UnitTests { /// /// Verifies that all valid usages of a closing brace in new C# 7 syntax without a following blank line will @@ -52,7 +56,7 @@ int LocalFunction(int value) } "; - await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, testCode, CancellationToken.None).ConfigureAwait(false); } /// @@ -141,5 +145,63 @@ void LocalFunction2() await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } + + [Fact] + public async Task TestStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* v1 = stackalloc int[] + { + 1, + 2, + 3 + }; + int* v2 = stackalloc int[] + { + 1, + 2, + 3 + }; + } + } +} +"; + + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, DiagnosticResult.EmptyDiagnosticResults, testCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestImplicitStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* v1 = stackalloc[] + { + 1, + 2, + 3 + }; + int* v2 = stackalloc[] + { + 1, + 2, + 3 + }; + } + } +} +"; + + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, DiagnosticResult.EmptyDiagnosticResults, testCode, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1514CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1514CSharp7UnitTests.cs index cac251b60..ec8b88303 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1514CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1514CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules { using StyleCop.Analyzers.Test.LayoutRules; - public class SA1514CSharp7UnitTests : SA1514UnitTests + public partial class SA1514CSharp7UnitTests : SA1514UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1515CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1515CSharp7UnitTests.cs index a1b4c05a5..2c57c7072 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1515CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1515CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules { @@ -12,7 +14,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules StyleCop.Analyzers.LayoutRules.SA1515SingleLineCommentMustBePrecededByBlankLine, StyleCop.Analyzers.LayoutRules.SA1515CodeFixProvider>; - public class SA1515CSharp7UnitTests : SA1515UnitTests + public partial class SA1515CSharp7UnitTests : SA1515UnitTests { [Fact] public async Task TestCommentAfterCasePatternSwitchLabelAsync() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1516CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1516CSharp7UnitTests.cs index ea090a7ce..ca718d310 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1516CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1516CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules { using StyleCop.Analyzers.Test.LayoutRules; - public class SA1516CSharp7UnitTests : SA1516UnitTests + public partial class SA1516CSharp7UnitTests : SA1516UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1516CSharp7UsingGroupsUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1516UsingGroupsCSharp7UnitTests.cs similarity index 50% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1516CSharp7UsingGroupsUnitTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1516UsingGroupsCSharp7UnitTests.cs index 7014f8265..66c3ee2a2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1516CSharp7UsingGroupsUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1516UsingGroupsCSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules { using StyleCop.Analyzers.Test.LayoutRules; - public class SA1516CSharp7UsingGroupsUnitTests : SA1516UsingGroupsUnitTests + public partial class SA1516UsingGroupsCSharp7UnitTests : SA1516UsingGroupsUnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1517CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1517CSharp7UnitTests.cs index c09c1a921..413549c5a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1517CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1517CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules { using StyleCop.Analyzers.Test.LayoutRules; - public class SA1517CSharp7UnitTests : SA1517UnitTests + public partial class SA1517CSharp7UnitTests : SA1517UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1518CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1518CSharp7UnitTests.cs index 60fbe17a0..91e1d06bc 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1518CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1518CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules { using StyleCop.Analyzers.Test.LayoutRules; - public class SA1518CSharp7UnitTests : SA1518UnitTests + public partial class SA1518CSharp7UnitTests : SA1518UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1519CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1519CSharp7UnitTests.cs index a25ae0700..17f251418 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1519CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1519CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules { using StyleCop.Analyzers.Test.LayoutRules; - public class SA1519CSharp7UnitTests : SA1519UnitTests + public partial class SA1519CSharp7UnitTests : SA1519UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1520CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1520CSharp7UnitTests.cs index 435e99db8..34e970166 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1520CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/LayoutRules/SA1520CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.LayoutRules { using StyleCop.Analyzers.Test.LayoutRules; - public class SA1520CSharp7UnitTests : SA1520UnitTests + public partial class SA1520CSharp7UnitTests : SA1520UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/AccessorDeclarationSyntaxExtensionsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/AccessorDeclarationSyntaxExtensionsCSharp7UnitTests.cs similarity index 88% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/AccessorDeclarationSyntaxExtensionsTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/AccessorDeclarationSyntaxExtensionsCSharp7UnitTests.cs index 8c1f7537c..545c80ed1 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/AccessorDeclarationSyntaxExtensionsTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/AccessorDeclarationSyntaxExtensionsCSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { @@ -7,7 +9,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.Lightup using StyleCop.Analyzers.Lightup; using Xunit; - public class AccessorDeclarationSyntaxExtensionsTests + public class AccessorDeclarationSyntaxExtensionsCSharp7UnitTests { [Fact] public void TestExpressionBody() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ArgumentSyntaxExtensionsCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ArgumentSyntaxExtensionsCSharp7UnitTests.cs new file mode 100644 index 000000000..204b1d916 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ArgumentSyntaxExtensionsCSharp7UnitTests.cs @@ -0,0 +1,35 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class ArgumentSyntaxExtensionsCSharp7UnitTests + { + [Fact] + public void TestRefKindKeyword() + { + var argumentSyntax = SyntaxFactory.Argument(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)) + .WithRefKindKeyword(SyntaxFactory.Token(SyntaxKind.InKeyword)); + Assert.Equal(argumentSyntax.RefKindKeyword, ArgumentSyntaxExtensions.RefKindKeyword(argumentSyntax)); + Assert.Equal(argumentSyntax.RefOrOutKeyword, ArgumentSyntaxExtensions.RefKindKeyword(argumentSyntax)); + } + + [Fact] + public void TestWithRefKindKeyword() + { + var argumentSyntax = SyntaxFactory.Argument(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)); + + var refKindKeyword = SyntaxFactory.Token(SyntaxKind.InKeyword); + Assert.Equal(default, ArgumentSyntaxExtensions.RefKindKeyword(argumentSyntax)); + var argumentWithInKeyword = ArgumentSyntaxExtensions.WithRefKindKeyword(argumentSyntax, refKindKeyword); + Assert.NotNull(argumentWithInKeyword); + Assert.True(refKindKeyword.IsEquivalentTo(argumentWithInKeyword.RefKindKeyword)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/BaseMethodDeclarationSyntaxExtensionsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/BaseMethodDeclarationSyntaxExtensionsCSharp7UnitTests.cs similarity index 78% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/BaseMethodDeclarationSyntaxExtensionsTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/BaseMethodDeclarationSyntaxExtensionsCSharp7UnitTests.cs index 8d3399299..9cf68c825 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/BaseMethodDeclarationSyntaxExtensionsTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/BaseMethodDeclarationSyntaxExtensionsCSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { @@ -7,7 +9,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.Lightup using StyleCop.Analyzers.Lightup; using Xunit; - public class BaseMethodDeclarationSyntaxExtensionsTests + public class BaseMethodDeclarationSyntaxExtensionsCSharp7UnitTests { [Fact] public void TestExpressionBody() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/CasePatternSwitchLabelSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/CasePatternSwitchLabelSyntaxWrapperCSharp7UnitTests.cs similarity index 97% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/CasePatternSwitchLabelSyntaxWrapperTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/CasePatternSwitchLabelSyntaxWrapperCSharp7UnitTests.cs index dae09d0ba..13c0b5343 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/CasePatternSwitchLabelSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/CasePatternSwitchLabelSyntaxWrapperCSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { @@ -10,7 +12,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.Lightup using StyleCop.Analyzers.Lightup; using Xunit; - public class CasePatternSwitchLabelSyntaxWrapperTests + public class CasePatternSwitchLabelSyntaxWrapperCSharp7UnitTests { [Fact] public void TestNull() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/CommonForEachStatementSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/CommonForEachStatementSyntaxWrapperTests.cs new file mode 100644 index 000000000..2706ae94b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/CommonForEachStatementSyntaxWrapperTests.cs @@ -0,0 +1,166 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class CommonForEachStatementSyntaxWrapperTests + { + [Fact] + public void TestNull() + { + var syntaxNode = default(SyntaxNode); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Null(wrapper.SyntaxNode); + Assert.Throws(() => wrapper.AwaitKeyword); + Assert.Throws(() => wrapper.ForEachKeyword); + Assert.Throws(() => wrapper.OpenParenToken); + Assert.Throws(() => wrapper.InKeyword); + Assert.Throws(() => wrapper.Expression); + Assert.Throws(() => wrapper.CloseParenToken); + Assert.Throws(() => wrapper.Statement); + Assert.Throws(() => wrapper.WithAwaitKeyword(SyntaxFactory.Token(SyntaxKind.AwaitKeyword))); + Assert.Throws(() => wrapper.WithForEachKeyword(SyntaxFactory.Token(SyntaxKind.ForEachKeyword))); + Assert.Throws(() => wrapper.WithOpenParenToken(SyntaxFactory.Token(SyntaxKind.OpenParenToken))); + Assert.Throws(() => wrapper.WithInKeyword(SyntaxFactory.Token(SyntaxKind.InKeyword))); + Assert.Throws(() => wrapper.WithExpression(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + Assert.Throws(() => wrapper.WithCloseParenToken(SyntaxFactory.Token(SyntaxKind.CloseParenToken))); + Assert.Throws(() => wrapper.WithStatement(SyntaxFactory.EmptyStatement())); + } + + [Fact] + public void TestWrapperIdentity() + { + var syntaxNode = this.CreateForEachStatement(); + Assert.True(syntaxNode.IsKind(SyntaxKind.ForEachStatement)); + + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Same(syntaxNode, wrapper.SyntaxNode); + } + + [Fact] + public void TestAwaitKeyword() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Equal(default, wrapper.AwaitKeyword); + + Assert.Throws(() => wrapper.WithAwaitKeyword(SyntaxFactory.Token(SyntaxKind.AwaitKeyword))); + } + + [Fact] + public void TestForEachKeyword() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Equal(syntaxNode.ForEachKeyword, wrapper.ForEachKeyword); + + Assert.Throws(() => wrapper.WithForEachKeyword(SpacingExtensions.WithoutTrivia(SyntaxFactory.Token(SyntaxKind.ForEachKeyword)))); + } + + [Fact] + public void TestOpenParenToken() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Equal(syntaxNode.OpenParenToken, wrapper.OpenParenToken); + + Assert.Throws(() => wrapper.WithOpenParenToken(SpacingExtensions.WithoutTrivia(SyntaxFactory.Token(SyntaxKind.OpenParenToken)))); + } + + [Fact] + public void TestInKeyword() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Equal(syntaxNode.InKeyword, wrapper.InKeyword); + + Assert.Throws(() => wrapper.WithInKeyword(SpacingExtensions.WithoutTrivia(SyntaxFactory.Token(SyntaxKind.InKeyword)))); + } + + [Fact] + public void TestExpression() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Same(syntaxNode.Expression, wrapper.Expression); + + Assert.Throws(() => wrapper.WithExpression(SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal(0)))); + } + + [Fact] + public void TestCloseParenToken() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Equal(syntaxNode.CloseParenToken, wrapper.CloseParenToken); + + Assert.Throws(() => wrapper.WithCloseParenToken(SpacingExtensions.WithoutTrivia(SyntaxFactory.Token(SyntaxKind.CloseParenToken)))); + } + + [Fact] + public void TestStatement() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Same(syntaxNode.Statement, wrapper.Statement); + + Assert.Throws(() => wrapper.WithStatement(SyntaxFactory.Block())); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(CommonForEachStatementSyntaxWrapper.IsInstance(null)); + Assert.False(CommonForEachStatementSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + + var syntaxNode = this.CreateForEachStatement(); + Assert.True(CommonForEachStatementSyntaxWrapper.IsInstance(syntaxNode)); + } + + [Fact] + public void TestConversionsNull() + { + var syntaxNode = default(SyntaxNode); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + + StatementSyntax syntax = wrapper; + Assert.Null(syntax); + } + + [Fact] + public void TestConversions() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + + StatementSyntax syntax = wrapper; + Assert.Same(syntaxNode, syntax); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (CommonForEachStatementSyntaxWrapper)syntaxNode); + } + + private ForEachStatementSyntax CreateForEachStatement() + { + return SyntaxFactory.ForEachStatement( + SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword)), + "x", + SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression), + SyntaxFactory.EmptyStatement()); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ConstantPatternSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ConstantPatternSyntaxWrapperCSharp7UnitTests.cs similarity index 95% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ConstantPatternSyntaxWrapperTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ConstantPatternSyntaxWrapperCSharp7UnitTests.cs index bd73f5aec..88771ce1a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ConstantPatternSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ConstantPatternSyntaxWrapperCSharp7UnitTests.cs @@ -1,16 +1,17 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { using System; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; - using StyleCop.Analyzers.Helpers; using StyleCop.Analyzers.Lightup; using Xunit; - public class ConstantPatternSyntaxWrapperTests + public class ConstantPatternSyntaxWrapperCSharp7UnitTests { [Fact] public void TestNull() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ConstructorDeclarationSyntaxExtensionsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ConstructorDeclarationSyntaxExtensionsCSharp7UnitTests.cs similarity index 82% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ConstructorDeclarationSyntaxExtensionsTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ConstructorDeclarationSyntaxExtensionsCSharp7UnitTests.cs index 0c4ed397c..3833dd262 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ConstructorDeclarationSyntaxExtensionsTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ConstructorDeclarationSyntaxExtensionsCSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { @@ -7,7 +9,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.Lightup using StyleCop.Analyzers.Lightup; using Xunit; - public class ConstructorDeclarationSyntaxExtensionsTests + public class ConstructorDeclarationSyntaxExtensionsCSharp7UnitTests { [Fact] public void TestWithExpressionBody() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/CrefParameterSyntaxExtensionsCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/CrefParameterSyntaxExtensionsCSharp7UnitTests.cs new file mode 100644 index 000000000..1fab8f136 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/CrefParameterSyntaxExtensionsCSharp7UnitTests.cs @@ -0,0 +1,35 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class CrefParameterSyntaxExtensionsCSharp7UnitTests + { + [Fact] + public void TestRefKindKeyword() + { + var crefParameterSyntax = SyntaxFactory.CrefParameter(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword))) + .WithRefKindKeyword(SyntaxFactory.Token(SyntaxKind.InKeyword)); + Assert.Equal(crefParameterSyntax.RefKindKeyword, CrefParameterSyntaxExtensions.RefKindKeyword(crefParameterSyntax)); + Assert.Equal(crefParameterSyntax.RefOrOutKeyword, CrefParameterSyntaxExtensions.RefKindKeyword(crefParameterSyntax)); + } + + [Fact] + public void TestWithRefKindKeyword() + { + var crefParameterSyntax = SyntaxFactory.CrefParameter(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword))); + + var refKindKeyword = SyntaxFactory.Token(SyntaxKind.InKeyword); + Assert.Equal(default, CrefParameterSyntaxExtensions.RefKindKeyword(crefParameterSyntax)); + var crefParameterWithInKeyword = CrefParameterSyntaxExtensions.WithRefKindKeyword(crefParameterSyntax, refKindKeyword); + Assert.NotNull(crefParameterWithInKeyword); + Assert.True(refKindKeyword.IsEquivalentTo(crefParameterWithInKeyword.RefKindKeyword)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DeclarationExpressionSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DeclarationExpressionSyntaxWrapperCSharp7UnitTests.cs similarity index 96% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DeclarationExpressionSyntaxWrapperTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DeclarationExpressionSyntaxWrapperCSharp7UnitTests.cs index 5aaaa8a79..7f87f6ae7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DeclarationExpressionSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DeclarationExpressionSyntaxWrapperCSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { @@ -10,7 +12,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.Lightup using StyleCop.Analyzers.Lightup; using Xunit; - public class DeclarationExpressionSyntaxWrapperTests + public class DeclarationExpressionSyntaxWrapperCSharp7UnitTests { [Fact] public void TestNull() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DeclarationPatternSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DeclarationPatternSyntaxWrapperCSharp7UnitTests.cs similarity index 96% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DeclarationPatternSyntaxWrapperTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DeclarationPatternSyntaxWrapperCSharp7UnitTests.cs index ffb474e89..9f7f804a7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DeclarationPatternSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DeclarationPatternSyntaxWrapperCSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { @@ -7,11 +9,10 @@ namespace StyleCop.Analyzers.Test.CSharp7.Lightup using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; - using StyleCop.Analyzers.Helpers; using StyleCop.Analyzers.Lightup; using Xunit; - public class DeclarationPatternSyntaxWrapperTests + public class DeclarationPatternSyntaxWrapperCSharp7UnitTests { [Fact] public void TestNull() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DestructorDeclarationSyntaxExtensionsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DestructorDeclarationSyntaxExtensionsCSharp7UnitTests.cs similarity index 82% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DestructorDeclarationSyntaxExtensionsTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DestructorDeclarationSyntaxExtensionsCSharp7UnitTests.cs index 744d295a6..6aa3847c9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DestructorDeclarationSyntaxExtensionsTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DestructorDeclarationSyntaxExtensionsCSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { @@ -7,7 +9,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.Lightup using StyleCop.Analyzers.Lightup; using Xunit; - public class DestructorDeclarationSyntaxExtensionsTests + public class DestructorDeclarationSyntaxExtensionsCSharp7UnitTests { [Fact] public void TestWithExpressionBody() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DiscardDesignationSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DiscardDesignationSyntaxWrapperCSharp7UnitTests.cs similarity index 95% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DiscardDesignationSyntaxWrapperTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DiscardDesignationSyntaxWrapperCSharp7UnitTests.cs index a979b294a..a90077aba 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DiscardDesignationSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/DiscardDesignationSyntaxWrapperCSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { @@ -10,7 +12,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.Lightup using StyleCop.Analyzers.Lightup; using Xunit; - public class DiscardDesignationSyntaxWrapperTests + public class DiscardDesignationSyntaxWrapperCSharp7UnitTests { [Fact] public void TestNull() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp7UnitTests.cs new file mode 100644 index 000000000..052aa002a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp7UnitTests.cs @@ -0,0 +1,132 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp7UnitTests + { + [Fact] + public void TestNull() + { + var syntaxNode = default(SyntaxNode); + var wrapper = (ImplicitStackAllocArrayCreationExpressionSyntaxWrapper)syntaxNode; + Assert.Null(wrapper.SyntaxNode); + Assert.Throws(() => wrapper.StackAllocKeyword); + Assert.Throws(() => wrapper.OpenBracketToken); + Assert.Throws(() => wrapper.CloseBracketToken); + Assert.Throws(() => wrapper.Initializer); + Assert.Throws(() => wrapper.WithStackAllocKeyword(SyntaxFactory.Token(SyntaxKind.StackAllocKeyword))); + Assert.Throws(() => wrapper.WithOpenBracketToken(SyntaxFactory.Token(SyntaxKind.OpenBracketToken))); + Assert.Throws(() => wrapper.WithCloseBracketToken(SyntaxFactory.Token(SyntaxKind.CloseBracketToken))); + Assert.Throws(() => wrapper.WithInitializer(SyntaxFactory.InitializerExpression(SyntaxKind.ArrayInitializerExpression))); + Assert.Throws(() => wrapper.AddInitializerExpressions()); + } + + [Fact] + public void TestProperties() + { + var syntaxNode = this.CreateImplicitStackAllocArrayCreationExpression(); + Assert.True(syntaxNode.IsKind(SyntaxKind.ImplicitStackAllocArrayCreationExpression)); + Assert.True(syntaxNode.IsKind(SyntaxKindEx.ImplicitStackAllocArrayCreationExpression)); + + var wrapper = (ImplicitStackAllocArrayCreationExpressionSyntaxWrapper)syntaxNode; + Assert.Same(syntaxNode, wrapper.SyntaxNode); + Assert.Equal(syntaxNode.StackAllocKeyword, wrapper.StackAllocKeyword); // This is a struct, so we can't use Same() + Assert.Equal(syntaxNode.OpenBracketToken, wrapper.OpenBracketToken); // This is a struct, so we can't use Same() + Assert.Equal(syntaxNode.CloseBracketToken, wrapper.CloseBracketToken); // This is a struct, so we can't use Same() + Assert.Same(syntaxNode.Initializer, wrapper.Initializer); + + var newStackAllocKeyword = SyntaxFactory.Token(SyntaxKind.StackAllocKeyword); + var wrapperWithModifiedStackAllocKeyword = wrapper.WithStackAllocKeyword(newStackAllocKeyword); + Assert.NotNull(wrapperWithModifiedStackAllocKeyword.SyntaxNode); + Assert.NotEqual(syntaxNode.StackAllocKeyword, wrapperWithModifiedStackAllocKeyword.StackAllocKeyword); + Assert.Equal(SyntaxKind.StackAllocKeyword, wrapperWithModifiedStackAllocKeyword.StackAllocKeyword.Kind()); + Assert.Equal("stackalloc", wrapperWithModifiedStackAllocKeyword.StackAllocKeyword.Text); + + var newOpenBracketToken = SyntaxFactory.Token(SyntaxKind.OpenBracketToken); + var wrapperWithModifiedOpenBracketToken = wrapper.WithOpenBracketToken(newOpenBracketToken); + Assert.NotNull(wrapperWithModifiedOpenBracketToken.SyntaxNode); + Assert.NotEqual(syntaxNode.OpenBracketToken, wrapperWithModifiedOpenBracketToken.OpenBracketToken); + Assert.Equal(SyntaxKind.OpenBracketToken, wrapperWithModifiedOpenBracketToken.OpenBracketToken.Kind()); + Assert.Equal("[", wrapperWithModifiedOpenBracketToken.OpenBracketToken.Text); + + var newCloseBracketToken = SyntaxFactory.Token(SyntaxKind.CloseBracketToken); + var wrapperWithModifiedCloseBracketToken = wrapper.WithCloseBracketToken(newCloseBracketToken); + Assert.NotNull(wrapperWithModifiedCloseBracketToken.SyntaxNode); + Assert.NotEqual(syntaxNode.CloseBracketToken, wrapperWithModifiedCloseBracketToken.CloseBracketToken); + Assert.Equal(SyntaxKind.CloseBracketToken, wrapperWithModifiedCloseBracketToken.CloseBracketToken.Kind()); + Assert.Equal("]", wrapperWithModifiedCloseBracketToken.CloseBracketToken.Text); + + var newInitializer = SyntaxFactory.InitializerExpression(SyntaxKind.ArrayInitializerExpression); + var wrapperWithModifiedInitializer = wrapper.WithInitializer(newInitializer); + Assert.NotNull(wrapperWithModifiedInitializer.SyntaxNode); + Assert.NotSame(syntaxNode.Initializer, wrapperWithModifiedInitializer.Initializer); + Assert.Empty(wrapperWithModifiedInitializer.Initializer.Expressions); + + var addedInitializerExpressions = new ExpressionSyntax[] { SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal(2)) }; + var wrapperWithAddedInitializerExpressions = wrapper.AddInitializerExpressions(addedInitializerExpressions); + Assert.NotNull(wrapperWithAddedInitializerExpressions.SyntaxNode); + Assert.NotSame(syntaxNode.Initializer, wrapperWithAddedInitializerExpressions.Initializer); + Assert.Equal(2, wrapperWithAddedInitializerExpressions.Initializer.Expressions.Count); + Assert.Equal("1", wrapperWithAddedInitializerExpressions.Initializer.Expressions[0].ToString()); + Assert.Equal("2", wrapperWithAddedInitializerExpressions.Initializer.Expressions[1].ToString()); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(ImplicitStackAllocArrayCreationExpressionSyntaxWrapper.IsInstance(null)); + Assert.False(ImplicitStackAllocArrayCreationExpressionSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + + var syntaxNode = this.CreateImplicitStackAllocArrayCreationExpression(); + Assert.True(ImplicitStackAllocArrayCreationExpressionSyntaxWrapper.IsInstance(syntaxNode)); + } + + [Fact] + public void TestConversionsNull() + { + var syntaxNode = default(SyntaxNode); + var wrapper = (ImplicitStackAllocArrayCreationExpressionSyntaxWrapper)syntaxNode; + + ExpressionSyntax syntax = wrapper; + Assert.Null(syntax); + } + + [Fact] + public void TestConversions() + { + var syntaxNode = this.CreateImplicitStackAllocArrayCreationExpression(); + var wrapper = (ImplicitStackAllocArrayCreationExpressionSyntaxWrapper)syntaxNode; + + ExpressionSyntax syntax = wrapper; + Assert.Same(syntaxNode, syntax); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (ImplicitStackAllocArrayCreationExpressionSyntaxWrapper)syntaxNode); + } + + private ImplicitStackAllocArrayCreationExpressionSyntax CreateImplicitStackAllocArrayCreationExpression() + { + return SyntaxFactory.ImplicitStackAllocArrayCreationExpression( + stackAllocKeyword: SyntaxFactory.Token(SyntaxKind.StackAllocKeyword), + openBracketToken: SyntaxFactory.Token(SyntaxKind.OpenBracketToken), + closeBracketToken: SyntaxFactory.Token(SyntaxKind.CloseBracketToken), + initializer: SyntaxFactory.InitializerExpression( + SyntaxKind.ArrayInitializerExpression, + SyntaxFactory.SingletonSeparatedList(SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal(1))))); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/IsPatternExpressionSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/IsPatternExpressionSyntaxWrapperCSharp7UnitTests.cs similarity index 96% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/IsPatternExpressionSyntaxWrapperTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/IsPatternExpressionSyntaxWrapperCSharp7UnitTests.cs index 356a26f5c..4728d5901 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/IsPatternExpressionSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/IsPatternExpressionSyntaxWrapperCSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { @@ -10,7 +12,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.Lightup using StyleCop.Analyzers.Lightup; using Xunit; - public class IsPatternExpressionSyntaxWrapperTests + public class IsPatternExpressionSyntaxWrapperCSharp7UnitTests { [Fact] public void TestNull() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/LanguageVersionExCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/LanguageVersionExCSharp7UnitTests.cs new file mode 100644 index 000000000..344176dc3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/LanguageVersionExCSharp7UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using StyleCop.Analyzers.Test.Lightup; + + public partial class LanguageVersionExCSharp7UnitTests : LanguageVersionExUnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/LightupHelpersTestsCSharp7.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/LightupHelpersCSharp7UnitTests.cs similarity index 55% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/LightupHelpersTestsCSharp7.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/LightupHelpersCSharp7UnitTests.cs index 235678f5d..65e6a223e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/LightupHelpersTestsCSharp7.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/LightupHelpersCSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { @@ -8,10 +10,10 @@ namespace StyleCop.Analyzers.Test.CSharp7.Lightup /// /// This class tests edge case behavior of in Roslyn 2+. It extends - /// since the tests defined there are valid in both environments without + /// since the tests defined there are valid in both environments without /// alteration. /// - public class LightupHelpersTestsCSharp7 : LightupHelpersTests + public partial class LightupHelpersCSharp7UnitTests : LightupHelpersUnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/LocalFunctionStatementSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/LocalFunctionStatementSyntaxWrapperCSharp7UnitTests.cs similarity index 98% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/LocalFunctionStatementSyntaxWrapperTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/LocalFunctionStatementSyntaxWrapperCSharp7UnitTests.cs index 2273fee35..cbd3b74a1 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/LocalFunctionStatementSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/LocalFunctionStatementSyntaxWrapperCSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { @@ -11,7 +13,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.Lightup using StyleCop.Analyzers.Lightup; using Xunit; - public class LocalFunctionStatementSyntaxWrapperTests + public class LocalFunctionStatementSyntaxWrapperCSharp7UnitTests { [Fact] public void TestNull() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/MethodKindExCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/MethodKindExCSharp7UnitTests.cs new file mode 100644 index 000000000..85670fe52 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/MethodKindExCSharp7UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using StyleCop.Analyzers.Test.Lightup; + + public partial class MethodKindExCSharp7UnitTests : MethodKindExUnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/OperationKindExCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/OperationKindExCSharp7UnitTests.cs new file mode 100644 index 000000000..86dd7b017 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/OperationKindExCSharp7UnitTests.cs @@ -0,0 +1,85 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using System.Collections.Generic; + using System.Reflection; + using Microsoft.CodeAnalysis; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class OperationKindExCSharp7UnitTests + { + private static readonly Dictionary OperationKindToName; + private static readonly Dictionary NameToOperationKind; + + static OperationKindExCSharp7UnitTests() + { + var renamedOperations = + new Dictionary() + { + { "BinaryOperator", "Binary" }, + { "ConstructorBodyOperation", "ConstructorBody" }, + { "MethodBodyOperation", "MethodBody" }, + { "TupleBinaryOperator", "TupleBinary" }, + { "UnaryOperator", "Unary" }, + }; + + OperationKindToName = new Dictionary(); + NameToOperationKind = new Dictionary(); + + foreach (var field in typeof(OperationKind).GetTypeInfo().DeclaredFields) + { + if (!field.IsStatic) + { + continue; + } + + var value = (OperationKind)field.GetRawConstantValue(); + var name = field.Name; + if (renamedOperations.TryGetValue(name, out var newName)) + { + name = newName; + } + + if (!OperationKindToName.ContainsKey(value)) + { + OperationKindToName[value] = name; + } + + if (!NameToOperationKind.ContainsKey(name)) + { + NameToOperationKind.Add(name, value); + } + } + } + + public static IEnumerable OperationKinds + { + get + { + foreach (var field in typeof(OperationKindEx).GetTypeInfo().DeclaredFields) + { + yield return new object[] { field.Name, (OperationKind)field.GetRawConstantValue() }; + } + } + } + + [Theory] + [MemberData(nameof(OperationKinds))] + public void TestOperationKind(string name, OperationKind operationKind) + { + if (OperationKindToName.TryGetValue(operationKind, out var expectedName)) + { + Assert.Equal(expectedName, name); + } + else + { + Assert.False(NameToOperationKind.TryGetValue(name, out _)); + } + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ParenthesizedVariableDesignationSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ParenthesizedVariableDesignationSyntaxWrapperCSharp7UnitTests.cs similarity index 97% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ParenthesizedVariableDesignationSyntaxWrapperTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ParenthesizedVariableDesignationSyntaxWrapperCSharp7UnitTests.cs index f2a633048..d42f8ed42 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ParenthesizedVariableDesignationSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ParenthesizedVariableDesignationSyntaxWrapperCSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { @@ -11,7 +13,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.Lightup using StyleCop.Analyzers.Lightup; using Xunit; - public class ParenthesizedVariableDesignationSyntaxWrapperTests + public class ParenthesizedVariableDesignationSyntaxWrapperCSharp7UnitTests { [Fact] public void TestNull() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/PatternSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/PatternSyntaxWrapperCSharp7UnitTests.cs similarity index 93% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/PatternSyntaxWrapperTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/PatternSyntaxWrapperCSharp7UnitTests.cs index 76c46c77b..71564a994 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/PatternSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/PatternSyntaxWrapperCSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { @@ -9,7 +11,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.Lightup using StyleCop.Analyzers.Lightup; using Xunit; - public class PatternSyntaxWrapperTests + public class PatternSyntaxWrapperCSharp7UnitTests { [Fact] public void TestNull() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/RefExpressionSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/RefExpressionSyntaxWrapperCSharp7UnitTests.cs similarity index 95% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/RefExpressionSyntaxWrapperTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/RefExpressionSyntaxWrapperCSharp7UnitTests.cs index 44386cbb3..82f934e68 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/RefExpressionSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/RefExpressionSyntaxWrapperCSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { @@ -10,7 +12,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.Lightup using StyleCop.Analyzers.Lightup; using Xunit; - public class RefExpressionSyntaxWrapperTests + public class RefExpressionSyntaxWrapperCSharp7UnitTests { [Fact] public void TestNull() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/RefTypeSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/RefTypeSyntaxWrapperCSharp7UnitTests.cs similarity index 78% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/RefTypeSyntaxWrapperTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/RefTypeSyntaxWrapperCSharp7UnitTests.cs index b856d9b65..93e37099c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/RefTypeSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/RefTypeSyntaxWrapperCSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { @@ -10,7 +12,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.Lightup using StyleCop.Analyzers.Lightup; using Xunit; - public class RefTypeSyntaxWrapperTests + public class RefTypeSyntaxWrapperCSharp7UnitTests { [Fact] public void TestNull() @@ -19,9 +21,11 @@ public void TestNull() var wrapper = (RefTypeSyntaxWrapper)syntaxNode; Assert.Null(wrapper.SyntaxNode); Assert.Throws(() => wrapper.RefKeyword); + Assert.Throws(() => wrapper.ReadOnlyKeyword); Assert.Throws(() => wrapper.Type); Assert.Throws(() => wrapper.WithType(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword)))); Assert.Throws(() => wrapper.WithRefKeyword(SyntaxFactory.Token(SyntaxKind.RefKeyword))); + Assert.Throws(() => wrapper.WithReadOnlyKeyword(SyntaxFactory.Token(SyntaxKind.ReadOnlyKeyword))); } [Fact] @@ -35,6 +39,7 @@ public void TestProperties() Assert.Same(syntaxNode, wrapper.SyntaxNode); Assert.Same(syntaxNode.Type, wrapper.Type); Assert.True(syntaxNode.RefKeyword.IsEquivalentTo(wrapper.RefKeyword)); + Assert.Equal(default, syntaxNode.ReadOnlyKeyword); var newType = SyntaxFactory.PointerType(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.BoolKeyword))); var wrapperWithModifiedType = wrapper.WithType(newType); @@ -47,6 +52,13 @@ public void TestProperties() Assert.NotNull(wrapperWithModifiedRefKeyword.SyntaxNode); Assert.Single(wrapperWithModifiedRefKeyword.RefKeyword.LeadingTrivia); Assert.Equal(" ", wrapperWithModifiedRefKeyword.RefKeyword.LeadingTrivia.ToString()); + + var readOnlyKeyword = SyntaxFactory.Token(SyntaxKind.ReadOnlyKeyword).WithLeadingTrivia(SyntaxFactory.Space); + var wrapperWithReadOnlyKeyword = wrapper.WithReadOnlyKeyword(readOnlyKeyword); + Assert.NotNull(wrapperWithReadOnlyKeyword.SyntaxNode); + Assert.Single(wrapperWithReadOnlyKeyword.ReadOnlyKeyword.LeadingTrivia); + Assert.Equal(" ", wrapperWithReadOnlyKeyword.ReadOnlyKeyword.LeadingTrivia.ToString()); + Assert.True(wrapperWithReadOnlyKeyword.ReadOnlyKeyword.IsEquivalentTo(readOnlyKeyword)); } [Fact] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SingleVariableDesignationSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SingleVariableDesignationSyntaxWrapperCSharp7UnitTests.cs similarity index 95% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SingleVariableDesignationSyntaxWrapperTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SingleVariableDesignationSyntaxWrapperCSharp7UnitTests.cs index 2ed431b56..bb4e19833 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SingleVariableDesignationSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SingleVariableDesignationSyntaxWrapperCSharp7UnitTests.cs @@ -1,16 +1,17 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { using System; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; - using StyleCop.Analyzers.Helpers; using StyleCop.Analyzers.Lightup; using Xunit; - public class SingleVariableDesignationSyntaxWrapperTests + public class SingleVariableDesignationSyntaxWrapperCSharp7UnitTests { [Fact] public void TestNull() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/StackAllocArrayCreationExpressionSyntaxExtensionsCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/StackAllocArrayCreationExpressionSyntaxExtensionsCSharp7UnitTests.cs new file mode 100644 index 000000000..e1383388c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/StackAllocArrayCreationExpressionSyntaxExtensionsCSharp7UnitTests.cs @@ -0,0 +1,36 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class StackAllocArrayCreationExpressionSyntaxExtensionsCSharp7UnitTests + { + [Fact] + public void TestInitializer() + { + var stackAllocSyntax = SyntaxFactory.StackAllocArrayCreationExpression(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword))) + .WithInitializer(SyntaxFactory.InitializerExpression(SyntaxKind.ArrayInitializerExpression)); + Assert.NotNull(StackAllocArrayCreationExpressionSyntaxExtensions.Initializer(stackAllocSyntax)); + Assert.Equal(SyntaxKind.ArrayInitializerExpression, StackAllocArrayCreationExpressionSyntaxExtensions.Initializer(stackAllocSyntax).Kind()); + } + + [Fact] + public void TestWithInitializer() + { + var stackAllocSyntax = SyntaxFactory.StackAllocArrayCreationExpression(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword))); + var stackAllocWithDefaultInitializer = StackAllocArrayCreationExpressionSyntaxExtensions.WithInitializer(stackAllocSyntax, null); + Assert.Null(StackAllocArrayCreationExpressionSyntaxExtensions.Initializer(stackAllocWithDefaultInitializer)); + var initializer = SyntaxFactory.InitializerExpression(SyntaxKind.ArrayInitializerExpression); + var stackAllocWithInitializer = StackAllocArrayCreationExpressionSyntaxExtensions.WithInitializer(stackAllocSyntax, initializer); + Assert.NotNull(stackAllocWithInitializer.Initializer); + Assert.Equal(SyntaxKind.ArrayInitializerExpression, stackAllocWithInitializer.Initializer.Kind()); + Assert.True(stackAllocWithInitializer.Initializer.IsEquivalentTo(initializer)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SwitchExpressionArmSyntaxWrapperCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SwitchExpressionArmSyntaxWrapperCSharp7UnitTests.cs new file mode 100644 index 000000000..4d67fc441 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SwitchExpressionArmSyntaxWrapperCSharp7UnitTests.cs @@ -0,0 +1,35 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using StyleCop.Analyzers.Test.Lightup; + using Xunit; + + public partial class SwitchExpressionArmSyntaxWrapperCSharp7UnitTests : SwitchExpressionArmSyntaxWrapperUnitTests + { + [Fact] + public void TestWithPatternOnNullNode() + { + var switchExpressionSyntax = (SwitchExpressionArmSyntaxWrapper)default(SyntaxNode); + + var patternSyntax = SyntaxFactory.ConstantPattern(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)); + Assert.Throws(() => switchExpressionSyntax.WithPattern((PatternSyntaxWrapper)patternSyntax)); + } + + [Fact] + public void TestWithWhenClauseOnNullNode() + { + var switchExpressionSyntax = (SwitchExpressionArmSyntaxWrapper)default(SyntaxNode); + + var whenClause = SyntaxFactory.WhenClause(SyntaxFactory.LiteralExpression(SyntaxKind.TrueLiteralExpression)); + Assert.Throws(() => switchExpressionSyntax.WithWhenClause((WhenClauseSyntaxWrapper)whenClause)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SwitchExpressionSyntaxWrapperCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SwitchExpressionSyntaxWrapperCSharp7UnitTests.cs new file mode 100644 index 000000000..8e6068838 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SwitchExpressionSyntaxWrapperCSharp7UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using StyleCop.Analyzers.Test.Lightup; + + public partial class SwitchExpressionSyntaxWrapperCSharp7UnitTests : SwitchExpressionSyntaxWrapperUnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SyntaxKindExCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SyntaxKindExCSharp7UnitTests.cs new file mode 100644 index 000000000..d5b190ad2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SyntaxKindExCSharp7UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using StyleCop.Analyzers.Test.Lightup; + + public partial class SyntaxKindExCSharp7UnitTests : SyntaxKindExUnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SyntaxWrapperCSharp7UnitTests.cs similarity index 87% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SyntaxWrapperTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SyntaxWrapperCSharp7UnitTests.cs index d4ad25f83..9e13e88cc 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SyntaxWrapperCSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { @@ -9,7 +11,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.Lightup using StyleCop.Analyzers.Lightup; using Xunit; - public class SyntaxWrapperTests + public class SyntaxWrapperCSharp7UnitTests { [Fact] public void TestWrapSyntaxNode() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SyntaxWrapperHelperCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SyntaxWrapperHelperCSharp7UnitTests.cs new file mode 100644 index 000000000..87a277c1a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/SyntaxWrapperHelperCSharp7UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.Lightup +{ + using StyleCop.Analyzers.Test.Lightup; + + public partial class SyntaxWrapperHelperCSharp7UnitTests : SyntaxWrapperHelperUnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ThrowExpressionSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ThrowExpressionSyntaxWrapperCSharp7UnitTests.cs similarity index 96% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ThrowExpressionSyntaxWrapperTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ThrowExpressionSyntaxWrapperCSharp7UnitTests.cs index 40dfa514d..395eb669e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ThrowExpressionSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/ThrowExpressionSyntaxWrapperCSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { @@ -10,7 +12,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.Lightup using StyleCop.Analyzers.Lightup; using Xunit; - public class ThrowExpressionSyntaxWrapperTests + public class ThrowExpressionSyntaxWrapperCSharp7UnitTests { [Fact] public void TestNull() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/TupleElementSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/TupleElementSyntaxWrapperCSharp7UnitTests.cs similarity index 95% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/TupleElementSyntaxWrapperTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/TupleElementSyntaxWrapperCSharp7UnitTests.cs index 49c30fb9c..0a0f4afd3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/TupleElementSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/TupleElementSyntaxWrapperCSharp7UnitTests.cs @@ -1,17 +1,18 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { using System; - using System.Collections.Immutable; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using StyleCop.Analyzers.Lightup; using Xunit; - public class TupleElementSyntaxWrapperTests + public class TupleElementSyntaxWrapperCSharp7UnitTests { [Fact] public void TestNull() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/TupleExpressionSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/TupleExpressionSyntaxWrapperCSharp7UnitTests.cs similarity index 97% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/TupleExpressionSyntaxWrapperTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/TupleExpressionSyntaxWrapperCSharp7UnitTests.cs index d802dd32d..3873414cf 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/TupleExpressionSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/TupleExpressionSyntaxWrapperCSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { @@ -11,7 +13,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.Lightup using StyleCop.Analyzers.Lightup; using Xunit; - public class TupleExpressionSyntaxWrapperTests + public class TupleExpressionSyntaxWrapperCSharp7UnitTests { [Fact] public void TestNull() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/TupleTypeSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/TupleTypeSyntaxWrapperCSharp7UnitTests.cs similarity index 97% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/TupleTypeSyntaxWrapperTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/TupleTypeSyntaxWrapperCSharp7UnitTests.cs index 2fd8d03cf..610d2f5f8 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/TupleTypeSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/TupleTypeSyntaxWrapperCSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { @@ -11,7 +13,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.Lightup using StyleCop.Analyzers.Lightup; using Xunit; - public class TupleTypeSyntaxWrapperTests + public class TupleTypeSyntaxWrapperCSharp7UnitTests { [Fact] public void TestNull() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/VariableDesignationSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/VariableDesignationSyntaxWrapperCSharp7UnitTests.cs similarity index 92% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/VariableDesignationSyntaxWrapperTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/VariableDesignationSyntaxWrapperCSharp7UnitTests.cs index b3ec13804..4b2927982 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/VariableDesignationSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/VariableDesignationSyntaxWrapperCSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { @@ -9,7 +11,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.Lightup using StyleCop.Analyzers.Lightup; using Xunit; - public class VariableDesignationSyntaxWrapperTests + public class VariableDesignationSyntaxWrapperCSharp7UnitTests { [Fact] public void TestNull() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/WhenClauseSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/WhenClauseSyntaxWrapperCSharp7UnitTests.cs similarity index 95% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/WhenClauseSyntaxWrapperTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/WhenClauseSyntaxWrapperCSharp7UnitTests.cs index 32aab8e75..9aaeb6258 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/WhenClauseSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/WhenClauseSyntaxWrapperCSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.Lightup { @@ -10,7 +12,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.Lightup using StyleCop.Analyzers.Lightup; using Xunit; - public class WhenClauseSyntaxWrapperTests + public class WhenClauseSyntaxWrapperCSharp7UnitTests { [Fact] public void TestNull() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/WrapperHelperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/WrapperHelperTests.cs deleted file mode 100644 index f627268d1..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Lightup/WrapperHelperTests.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. - -namespace StyleCop.Analyzers.Test.CSharp7.Lightup -{ - using System.Linq; - using System.Reflection; - using StyleCop.Analyzers.Lightup; - using Xunit; - - public class WrapperHelperTests - { - [Fact] - public void VerifyThatAllWrapperClassesArePresent() - { - var wrapperTypes = typeof(ISyntaxWrapper<>).Assembly.GetTypes() - .Where(t => t.GetTypeInfo().ImplementedInterfaces.Any(i => i.IsGenericType && (i.GetGenericTypeDefinition() == typeof(ISyntaxWrapper<>)))); - - foreach (var wrapperType in wrapperTypes) - { - var wrappedType = WrapperHelper.GetWrappedType(wrapperType); - Assert.NotNull(wrapperType); - } - } - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1119CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1119CSharp7UnitTests.cs index 0d7ed6b0e..e0fb7098b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1119CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1119CSharp7UnitTests.cs @@ -1,20 +1,49 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules { + using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Lightup; + using StyleCop.Analyzers.Test.Helpers; using StyleCop.Analyzers.Test.MaintainabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.MaintainabilityRules.SA1119StatementMustNotUseUnnecessaryParenthesis, StyleCop.Analyzers.MaintainabilityRules.SA1119CodeFixProvider>; - public class SA1119CSharp7UnitTests : SA1119UnitTests + public partial class SA1119CSharp7UnitTests : SA1119UnitTests { + public static IEnumerable Assignments + { + get + { + yield return new object[] { "= 1" }; + yield return new object[] { "+= 1" }; + yield return new object[] { "-= 1" }; + yield return new object[] { "*= 1" }; + yield return new object[] { "/= 1" }; + yield return new object[] { "%= 1" }; + yield return new object[] { "&= 1" }; + yield return new object[] { "|= 1" }; + yield return new object[] { "^= 1" }; + yield return new object[] { "<<= 1" }; + yield return new object[] { ">>= 1" }; + yield return new object[] { "++" }; + yield return new object[] { "--" }; + + if (LightupHelpers.SupportsCSharp11) + { + yield return new object[] { ">>>= 1" }; + } + } + } + /// /// Verifies that extra parentheses in pattern matching is not reported. /// @@ -84,5 +113,21 @@ public void Bar() await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } + + [Theory] + [MemberData(nameof(Assignments))] + [WorkItem(3712, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3712")] + public async Task TestConditionalRefAssignmentAsync(string assignment) + { + var testCode = $@"public class Foo +{{ + public void Bar(bool b, ref int x, ref int y) + {{ + (b ? ref x : ref y) {assignment}; + }} +}}"; + + await VerifyCSharpDiagnosticAsync(LanguageVersionEx.CSharp7_2.OrLaterDefault(), testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1400CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1400CSharp7UnitTests.cs index 07a61e9e4..e9586f580 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1400CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1400CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules { @@ -12,7 +14,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules StyleCop.Analyzers.MaintainabilityRules.SA1400AccessModifierMustBeDeclared, StyleCop.Analyzers.MaintainabilityRules.SA1400CodeFixProvider>; - public class SA1400CSharp7UnitTests : SA1400UnitTests + public partial class SA1400CSharp7UnitTests : SA1400UnitTests { /// /// Verifies that local functions, which do not support access modifiers, do not trigger SA1400. diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1401CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1401CSharp7UnitTests.cs index 186f23645..6cedfd53f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1401CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1401CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules { using StyleCop.Analyzers.Test.MaintainabilityRules; - public class SA1401CSharp7UnitTests : SA1401UnitTests + public partial class SA1401CSharp7UnitTests : SA1401UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402CSharp7ForInterfaceUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402CSharp7ForInterfaceUnitTests.cs deleted file mode 100644 index 25f66f69b..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402CSharp7ForInterfaceUnitTests.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. - -namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules -{ - using StyleCop.Analyzers.Test.MaintainabilityRules; - - public class SA1402CSharp7ForInterfaceUnitTests : SA1402ForInterfaceUnitTests - { - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402CSharp7ForEnumUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402ForClassCSharp7UnitTests.cs similarity index 53% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402CSharp7ForEnumUnitTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402ForClassCSharp7UnitTests.cs index bb7597cd0..8d7ddab6f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402CSharp7ForEnumUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402ForClassCSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules { using StyleCop.Analyzers.Test.MaintainabilityRules; - public class SA1402CSharp7ForEnumUnitTests : SA1402ForEnumUnitTests + public partial class SA1402ForClassCSharp7UnitTests : SA1402ForClassUnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402CSharp7ForClassUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402ForDelegateCSharp7UnitTests.cs similarity index 53% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402CSharp7ForClassUnitTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402ForDelegateCSharp7UnitTests.cs index da5deb788..e703a9c29 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402CSharp7ForClassUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402ForDelegateCSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules { using StyleCop.Analyzers.Test.MaintainabilityRules; - public class SA1402CSharp7ForClassUnitTests : SA1402ForClassUnitTests + public partial class SA1402ForDelegateCSharp7UnitTests : SA1402ForDelegateUnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402CSharp7ForStructUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402ForEnumCSharp7UnitTests.cs similarity index 53% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402CSharp7ForStructUnitTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402ForEnumCSharp7UnitTests.cs index d0cdb3416..89c09c5d8 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402CSharp7ForStructUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402ForEnumCSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules { using StyleCop.Analyzers.Test.MaintainabilityRules; - public class SA1402CSharp7ForStructUnitTests : SA1402ForStructUnitTests + public partial class SA1402ForEnumCSharp7UnitTests : SA1402ForEnumUnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402CSharp7ForDelegateUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402ForInterfaceCSharp7UnitTests.cs similarity index 52% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402CSharp7ForDelegateUnitTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402ForInterfaceCSharp7UnitTests.cs index 5f9ca3b23..e094340d9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402CSharp7ForDelegateUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402ForInterfaceCSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules { using StyleCop.Analyzers.Test.MaintainabilityRules; - public class SA1402CSharp7ForDelegateUnitTests : SA1402ForDelegateUnitTests + public partial class SA1402ForInterfaceCSharp7UnitTests : SA1402ForInterfaceUnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402ForStructCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402ForStructCSharp7UnitTests.cs new file mode 100644 index 000000000..208d1ee1d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1402ForStructCSharp7UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.MaintainabilityRules; + + public partial class SA1402ForStructCSharp7UnitTests : SA1402ForStructUnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1403CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1403CSharp7UnitTests.cs index caaea28e7..d6030252c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1403CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1403CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules { using StyleCop.Analyzers.Test.MaintainabilityRules; - public class SA1403CSharp7UnitTests : SA1403UnitTests + public partial class SA1403CSharp7UnitTests : SA1403UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1404CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1404CSharp7UnitTests.cs index e4ccefc88..e481c41ef 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1404CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1404CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules { using StyleCop.Analyzers.Test.MaintainabilityRules; - public class SA1404CSharp7UnitTests : SA1404UnitTests + public partial class SA1404CSharp7UnitTests : SA1404UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1405CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1405CSharp7UnitTests.cs index 553ba1be2..e4bceaa59 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1405CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1405CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules { using StyleCop.Analyzers.Test.MaintainabilityRules; - public class SA1405CSharp7UnitTests : SA1405UnitTests + public partial class SA1405CSharp7UnitTests : SA1405UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1406CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1406CSharp7UnitTests.cs index d10fe83a2..97431a79b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1406CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1406CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules { using StyleCop.Analyzers.Test.MaintainabilityRules; - public class SA1406CSharp7UnitTests : SA1406UnitTests + public partial class SA1406CSharp7UnitTests : SA1406UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1407CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1407CSharp7UnitTests.cs index dfe783eb6..c09b962cf 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1407CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1407CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules { using StyleCop.Analyzers.Test.MaintainabilityRules; - public class SA1407CSharp7UnitTests : SA1407UnitTests + public partial class SA1407CSharp7UnitTests : SA1407UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1408CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1408CSharp7UnitTests.cs index a38f29800..3b96645ea 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1408CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1408CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules { @@ -12,7 +14,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules StyleCop.Analyzers.MaintainabilityRules.SA1408ConditionalExpressionsMustDeclarePrecedence, StyleCop.Analyzers.MaintainabilityRules.SA1407SA1408CodeFixProvider>; - public class SA1408CSharp7UnitTests : SA1408UnitTests + public partial class SA1408CSharp7UnitTests : SA1408UnitTests { /// /// Verifies that a code fix for SA1119 in a pattern matching expression does not trigger SA1408. diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1409CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1409CSharp7UnitTests.cs index e49f9553e..fbac6385b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1409CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1409CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules { using StyleCop.Analyzers.Test.MaintainabilityRules; - public class SA1409CSharp7UnitTests : SA1409UnitTests + public partial class SA1409CSharp7UnitTests : SA1409UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1410CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1410CSharp7UnitTests.cs index 90aba7ca0..4277a7196 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1410CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1410CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules { using StyleCop.Analyzers.Test.MaintainabilityRules; - public class SA1410CSharp7UnitTests : SA1410UnitTests + public partial class SA1410CSharp7UnitTests : SA1410UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1411CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1411CSharp7UnitTests.cs index 80eab8960..762b82277 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1411CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1411CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules { using StyleCop.Analyzers.Test.MaintainabilityRules; - public class SA1411CSharp7UnitTests : SA1411UnitTests + public partial class SA1411CSharp7UnitTests : SA1411UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1412CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1412CSharp7UnitTests.cs index 04e093dfd..61da03e63 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1412CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1412CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules { using StyleCop.Analyzers.Test.MaintainabilityRules; - public class SA1412CSharp7UnitTests : SA1412UnitTests + public partial class SA1412CSharp7UnitTests : SA1412UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1413CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1413CSharp7UnitTests.cs index ac5c1a505..c6759d47a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1413CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1413CSharp7UnitTests.cs @@ -1,11 +1,115 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules { + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.MaintainabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Helpers.LanguageVersionTestExtensions; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.MaintainabilityRules.SA1413UseTrailingCommasInMultiLineInitializers, + StyleCop.Analyzers.MaintainabilityRules.SA1413CodeFixProvider>; + + public partial class SA1413CSharp7UnitTests : SA1413UnitTests + { + [Fact] + public async Task TestStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc int[] { 1, 1 }; + int* data2 = stackalloc int[] { 1, 1, }; + int* data3 = stackalloc int[] + { + 1, + 1 + }; + } + } +} +"; + + var fixedCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc int[] { 1, 1 }; + int* data2 = stackalloc int[] { 1, 1, }; + int* data3 = stackalloc int[] + { + 1, + 1, + }; + } + } +} +"; - public class SA1413CSharp7UnitTests : SA1413UnitTests + DiagnosticResult[] expected = + { + Diagnostic().WithLocation(12, 17), + }; + + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestImplicitStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc[] { 1, 1 }; + int* data2 = stackalloc[] { 1, 1, }; + int* data3 = stackalloc[] + { + 1, + 1 + }; + } + } +} +"; + + var fixedCode = @"namespace TestNamespace +{ + public class TestClass { + public unsafe void TestMethod() + { + int* data1 = stackalloc[] { 1, 1 }; + int* data2 = stackalloc[] { 1, 1, }; + int* data3 = stackalloc[] + { + 1, + 1, + }; + } + } +} +"; + + DiagnosticResult[] expected = + { + Diagnostic().WithLocation(12, 17), + }; + + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1414CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1414CSharp7UnitTests.cs new file mode 100644 index 000000000..569492f1f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/MaintainabilityRules/SA1414CSharp7UnitTests.cs @@ -0,0 +1,178 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules +{ + using System; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.MaintainabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier< + StyleCop.Analyzers.MaintainabilityRules.SA1414TupleTypesInSignaturesShouldHaveElementNames>; + + /// + /// This class contains the CSharp 7.x unit tests for SA1414. + /// + /// + public class SA1414CSharp7UnitTests + { + [Theory] + [InlineData("(int valueA, int valueB)")] + [InlineData("(int valueA, (long valueB, float valueC, string valueD) valueE)")] + [InlineData("System.Collections.Generic.List<(int valueA, long valueB)>")] + public async Task ValidateTuplesWithElementNamesAsync(string typeExpression) + { + var testCode = $@"using System; + +public delegate {typeExpression} TestDelegate({typeExpression} p1); + +public class TestClass +{{ + public TestClass({typeExpression} p1) + {{ + }} + + public {typeExpression} TestMethod({typeExpression} p1) + {{ + throw new NotImplementedException(); + }} + + public {typeExpression} TestProperty {{ get; set; }} + public {typeExpression} this[int index] + {{ + get + {{ + throw new NotImplementedException(); + }} + }} + + public static explicit operator TestClass({typeExpression} p1) + {{ + throw new NotImplementedException(); + }} + + public static implicit operator {typeExpression}(TestClass p1) + {{ + throw new NotImplementedException(); + }} +}} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Theory] + [InlineData("([|int|], [|int|])")] + [InlineData("(int valueA, [|int|])")] + [InlineData("([|int|], int valueB)")] + [InlineData("([|int|], [|([|long|], [|float|], [|string|])|])")] + [InlineData("([|int|], (long valueB, [|float|], string valueD) valueE)")] + [InlineData("(int valueA, ([|long|], float valueC, [|string|]) valueE)")] + [InlineData("System.Collections.Generic.List<([|int|], [|long|])>")] + public async Task ValidateTuplesWithoutElementNamesAsync(string typeExpression) + { + var testCode = $@"using System; + +public delegate {typeExpression} TestDelegate({typeExpression} p1); + +public class TestClass +{{ + public TestClass({typeExpression} p1) + {{ + }} + + public {typeExpression} TestMethod({typeExpression} p1) + {{ + throw new NotImplementedException(); + }} + + public {typeExpression} TestProperty {{ get; set; }} + public {typeExpression} this[int index] + {{ + get + {{ + throw new NotImplementedException(); + }} + }} + + public static explicit operator TestClass({typeExpression} p1) + {{ + throw new NotImplementedException(); + }} + + public static implicit operator {typeExpression}(TestClass p1) + {{ + throw new NotImplementedException(); + }} +}} +"; + + DiagnosticResult[] expected = + { + // The actual locations have been specified inline. + }; + + await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task ValidateTuplesFromInterfaceAsync() + { + const string testCode = @" +using System.Collections.Generic; + +namespace Test { + class StringTupleComparer : IEqualityComparer<(string, string)> + { + public bool Equals((string, string) x, (string, string) y) => throw null; + + public int GetHashCode((string, string) obj) => throw null; + } +}"; + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task ValidateTuplesFromExplicitInterfaceImplementationAsync() + { + const string testCode = @" +using System.Collections.Generic; + +namespace Test { + class StringTupleComparer : IEqualityComparer<(string, string)> + { + bool IEqualityComparer<(string, string)>.Equals((string, string) x, (string, string) y) => throw null; + + int IEqualityComparer<(string, string)>.GetHashCode((string, string) obj) => throw null; + } +}"; + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task ValidateTuplesFromBaseClassAsync() + { + const string testCode = @" +namespace Test { + class A : B + { + public override (string, string) Run((string, string) x) => throw null; + + public override (int, int) Run((int, int) y) => throw null; + } + + abstract class B + { + public abstract ([|string|], [|string|]) Run(([|string|], [|string|]) x); + + public virtual ([|int|], [|int|]) Run(([|int|], [|int|]) y) => throw null; + } +}"; + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1300CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1300CSharp7UnitTests.cs index c57ad51c0..b8938c6ed 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1300CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1300CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.NamingRules { @@ -7,13 +9,12 @@ namespace StyleCop.Analyzers.Test.CSharp7.NamingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.NamingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.NamingRules.SA1300ElementMustBeginWithUpperCaseLetter, StyleCop.Analyzers.NamingRules.RenameToUpperCaseCodeFixProvider>; - public class SA1300CSharp7UnitTests : SA1300UnitTests + public partial class SA1300CSharp7UnitTests : SA1300UnitTests { [Fact] public async Task TestUpperCaseLocalFunctionAsync() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1301CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1301CSharp7UnitTests.cs index f7074d98c..f72edafa4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1301CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1301CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.NamingRules { using StyleCop.Analyzers.Test.NamingRules; - public class SA1301CSharp7UnitTests : SA1301UnitTests + public partial class SA1301CSharp7UnitTests : SA1301UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1302CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1302CSharp7UnitTests.cs index 5a535d495..2f1f51541 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1302CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1302CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.NamingRules { using StyleCop.Analyzers.Test.NamingRules; - public class SA1302CSharp7UnitTests : SA1302UnitTests + public partial class SA1302CSharp7UnitTests : SA1302UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1303CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1303CSharp7UnitTests.cs index 5cd6ea9f2..0825f5694 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1303CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1303CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.NamingRules { using StyleCop.Analyzers.Test.NamingRules; - public class SA1303CSharp7UnitTests : SA1303UnitTests + public partial class SA1303CSharp7UnitTests : SA1303UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1304CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1304CSharp7UnitTests.cs index af9e36271..a5256cb54 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1304CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1304CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.NamingRules { using StyleCop.Analyzers.Test.NamingRules; - public class SA1304CSharp7UnitTests : SA1304UnitTests + public partial class SA1304CSharp7UnitTests : SA1304UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1305CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1305CSharp7UnitTests.cs index 3c75dc043..fce573e59 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1305CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1305CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.NamingRules { @@ -7,11 +9,10 @@ namespace StyleCop.Analyzers.Test.CSharp7.NamingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.NamingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier; - public class SA1305CSharp7UnitTests : SA1305UnitTests + public partial class SA1305CSharp7UnitTests : SA1305UnitTests { [Fact] public async Task TestInvalidVariableDesignatorNamesAreReportedAsync() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1306CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1306CSharp7UnitTests.cs index c5577a764..ff89b160f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1306CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1306CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.NamingRules { using StyleCop.Analyzers.Test.NamingRules; - public class SA1306CSharp7UnitTests : SA1306UnitTests + public partial class SA1306CSharp7UnitTests : SA1306UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1307CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1307CSharp7UnitTests.cs index e86913e13..4501b5cf5 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1307CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1307CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.NamingRules { using StyleCop.Analyzers.Test.NamingRules; - public class SA1307CSharp7UnitTests : SA1307UnitTests + public partial class SA1307CSharp7UnitTests : SA1307UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1308CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1308CSharp7UnitTests.cs index 789c31e69..5676aff14 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1308CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1308CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.NamingRules { using StyleCop.Analyzers.Test.NamingRules; - public class SA1308CSharp7UnitTests : SA1308UnitTests + public partial class SA1308CSharp7UnitTests : SA1308UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1309CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1309CSharp7UnitTests.cs index 1b2f7386e..edefc99c3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1309CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1309CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.NamingRules { using StyleCop.Analyzers.Test.NamingRules; - public class SA1309CSharp7UnitTests : SA1309UnitTests + public partial class SA1309CSharp7UnitTests : SA1309UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1310CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1310CSharp7UnitTests.cs index 30d765a1a..b65828de6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1310CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1310CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.NamingRules { using StyleCop.Analyzers.Test.NamingRules; - public class SA1310CSharp7UnitTests : SA1310UnitTests + public partial class SA1310CSharp7UnitTests : SA1310UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1311CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1311CSharp7UnitTests.cs index 811d59f11..1dbb386db 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1311CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1311CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.NamingRules { using StyleCop.Analyzers.Test.NamingRules; - public class SA1311CSharp7UnitTests : SA1311UnitTests + public partial class SA1311CSharp7UnitTests : SA1311UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1312CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1312CSharp7UnitTests.cs index 49c0989a8..95ff87099 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1312CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1312CSharp7UnitTests.cs @@ -1,19 +1,21 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.NamingRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Settings.ObjectModel; using StyleCop.Analyzers.Test.NamingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.NamingRules.SA1312VariableNamesMustBeginWithLowerCaseLetter, StyleCop.Analyzers.NamingRules.RenameToLowerCaseCodeFixProvider>; - public class SA1312CSharp7UnitTests : SA1312UnitTests + public partial class SA1312CSharp7UnitTests : SA1312UnitTests { [Fact] public async Task TestThatDiagnosticIsReported_SingleVariableDesignatorAsync() @@ -323,5 +325,55 @@ public void MethodName(int parameter) DiagnosticResult expected = Diagnostic().WithArguments("__").WithLocation(7, 52); await VerifyCSharpFixAsync(testCode, expected, testCode, CancellationToken.None).ConfigureAwait(false); } + + [Fact] + [WorkItem(3031, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3031")] + public async Task TestTupleDesconstructionCamelCaseAsync() + { + var testCode = @" +public class TypeName +{ + public void MethodName((string name, string value) obj) + { + (string name, string value) = obj; + } +} +"; + var settings = $@"{{ + ""settings"": {{ + ""namingRules"": {{ + ""tupleElementNameCasing"": ""{TupleElementNameCase.CamelCase}"" + }} + }} +}} +"; + + await VerifyCSharpDiagnosticAsync(languageVersion: null, testCode, settings, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3031, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3031")] + public async Task TestTupleDesconstructionPascalCaseAsync() + { + var testCode = @" +public class TypeName +{ + public void MethodName((string Name, string Value) obj) + { + (string name, string value) = obj; + } +} +"; + var settings = $@"{{ + ""settings"": {{ + ""namingRules"": {{ + ""tupleElementNameCasing"": ""{TupleElementNameCase.PascalCase}"" + }} + }} +}} +"; + + await VerifyCSharpDiagnosticAsync(languageVersion: null, testCode, settings, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1313CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1313CSharp7UnitTests.cs index 14d97f659..e418deb89 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1313CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1313CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.NamingRules { using StyleCop.Analyzers.Test.NamingRules; - public class SA1313CSharp7UnitTests : SA1313UnitTests + public partial class SA1313CSharp7UnitTests : SA1313UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1314CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1314CSharp7UnitTests.cs index 6c42600f4..2e2e34996 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1314CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1314CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.NamingRules { using StyleCop.Analyzers.Test.NamingRules; - public class SA1314CSharp7UnitTests : SA1314UnitTests + public partial class SA1314CSharp7UnitTests : SA1314UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1316CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1316CSharp7UnitTests.cs new file mode 100644 index 000000000..5e784d66a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SA1316CSharp7UnitTests.cs @@ -0,0 +1,405 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp7.NamingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.NamingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Helpers.LanguageVersionTestExtensions; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.NamingRules.SA1316TupleElementNamesShouldUseCorrectCasing, + StyleCop.Analyzers.NamingRules.SA1316CodeFixProvider>; + + /// + /// This class contains the CSharp 7.x unit tests for SA1316. + /// + /// + /// + public class SA1316CSharp7UnitTests + { + private const string DefaultTestSettings = @" +{ + ""settings"": { + } +} +"; + + private const string CamelCaseTestSettings = @" +{ + ""settings"": { + ""namingRules"": { + ""tupleElementNameCasing"": ""camelCase"" + } + } +} +"; + + private const string PascalCaseTestSettings = @" +{ + ""settings"": { + ""namingRules"": { + ""tupleElementNameCasing"": ""PascalCase"" + } + } +} +"; + + private const string CamelCaseInferredTestSettings = @" +{ + ""settings"": { + ""namingRules"": { + ""includeInferredTupleElementNames"" : true, + ""tupleElementNameCasing"": ""camelCase"" + } + } +} +"; + + private const string PascalCaseInferredTestSettings = @" +{ + ""settings"": { + ""namingRules"": { + ""includeInferredTupleElementNames"" : true, + ""tupleElementNameCasing"": ""PascalCase"" + } + } +} +"; + + private const string CamelCaseExplicitOnlyTestSettings = @" +{ + ""settings"": { + ""namingRules"": { + ""includeInferredTupleElementNames"" : false, + ""tupleElementNameCasing"": ""camelCase"" + } + } +} +"; + + private const string PascalCaseExplicitOnlyTestSettings = @" +{ + ""settings"": { + ""namingRules"": { + ""includeInferredTupleElementNames"" : false, + ""tupleElementNameCasing"": ""PascalCase"" + } + } +} +"; + + /// + /// Validates the properly named tuple element names will not produce diagnostics. + /// + /// The test settings to use. + /// The expected tuple element name for the first field. + /// The expected tuple element name for the second field. + /// A representing the asynchronous unit test. + [Theory] + [InlineData(DefaultTestSettings, "ElementName1", "ElementName2")] + [InlineData(CamelCaseTestSettings, "elementName1", "elementName2")] + [InlineData(PascalCaseTestSettings, "ElementName1", "ElementName2")] + public async Task ValidateProperCasedTupleElementNamesAsync(string settings, string tupleElementName1, string tupleElementName2) + { + var testCode = $@" +public class TestClass +{{ + public (int {tupleElementName1}, int {tupleElementName2}) TestMethod() + {{ + return (1, 1); + }} +}} +"; + + await VerifyCSharpDiagnosticAsync(testCode, settings, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Validates that tuple fields with no name will not produce diagnostics. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task ValidateNoTupleElementNamesAsync() + { + var testCode = @" +public class TestClass +{ + public (int, int) TestMethod() + { + return (1, 1); + } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DefaultTestSettings, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Validates the properly named inferred tuple element names will not produce diagnostics. + /// + /// The test settings to use. + /// The expected tuple element name for the first field. + /// The expected tuple element name for the second field. + /// A representing the asynchronous unit test. + [Theory] + [InlineData(DefaultTestSettings, "elementName1", "elementName2")] + [InlineData(CamelCaseTestSettings, "elementName1", "elementName2")] + [InlineData(PascalCaseTestSettings, "ElementName1", "ElementName2")] + [InlineData(CamelCaseInferredTestSettings, "elementName1", "elementName2")] + [InlineData(PascalCaseInferredTestSettings, "ElementName1", "ElementName2")] + [InlineData(CamelCaseExplicitOnlyTestSettings, "elementName1", "elementName2")] + [InlineData(PascalCaseExplicitOnlyTestSettings, "ElementName1", "ElementName2")] + public async Task ValidateProperCasedInferredTupleElementNamesAsync(string settings, string tupleElementName1, string tupleElementName2) + { + var testCode = $@" +public class TestClass +{{ + public void TestMethod() + {{ + var {tupleElementName1} = 1; + var {tupleElementName2} = ""test""; + var tuple = ({tupleElementName1}, {tupleElementName2}); + }} +}} +"; + + await VerifyCSharpDiagnosticAsync(LanguageVersion.CSharp7_1.OrLaterDefault(), testCode, settings, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Validates the properly explicitly named tuple elements, even when using inferred tuple element names, will not produce diagnostics. + /// + /// The test settings to use. + /// The expected tuple element name for the first field. + /// The expected tuple element name for the second field. + /// The name of the first tuple element that would be inferred if not given explicitly. + /// The name of the second tuple element that would be inferred if not given explicitly. + /// A representing the asynchronous unit test. + [Theory] + [InlineData(CamelCaseInferredTestSettings, "elementName1", "elementName2", "ElementValue1", "ElementValue2")] + [InlineData(PascalCaseInferredTestSettings, "ElementName1", "ElementName2", "elementValue1", "elementValue2")] + public async Task ValidateProperCasedExplicitNamesEvenWithInferredTupleElementNamesAsync(string settings, string tupleElementName1, string tupleElementName2, string tupleInferred1, string tupleInferred2) + { + var testCode = $@" +public class TestClass +{{ + public void TestMethod1() + {{ + var {tupleInferred1} = 1; + var {tupleInferred2} = ""test""; + var tuple = ({tupleElementName1}: {tupleInferred1}, {tupleElementName2}: {tupleInferred2}); + }} + + public void TestMethod2() + {{ + var {tupleInferred1} = 1; + var {tupleElementName2} = ""test""; + var tuple = ({tupleElementName1}: {tupleInferred1}, {tupleElementName2}); + }} +}} +"; + + await VerifyCSharpDiagnosticAsync(LanguageVersion.CSharp7_1.OrLaterDefault(), testCode, settings, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Validates the improperly named tuple element names will produce the expected diagnostics. + /// + /// The test settings to use. + /// The expected tuple element name for the first field. + /// The expected tuple element name for the second field. + /// The expected fixed tuple element name for the first field. + /// The expected fixed tuple element name for the second field. + /// A representing the asynchronous unit test. + [Theory] + [InlineData(DefaultTestSettings, "elementName1", "elementName2", "ElementName1", "ElementName2")] + [InlineData(CamelCaseTestSettings, "ElementName1", "ElementName2", "elementName1", "elementName2")] + [InlineData(PascalCaseTestSettings, "elementName1", "elementName2", "ElementName1", "ElementName2")] + public async Task ValidateImproperCasedTupleElementNamesAsync(string settings, string tupleElementName1, string tupleElementName2, string fixedTupleElementName1, string fixedTupleElementName2) + { + var testCode = $@" +public class TestClass +{{ + public (int [|{tupleElementName1}|], int [|{tupleElementName2}|]) TestMethod1() + {{ + return (1, 1); + }} + + public (int /* 1 */ [|{tupleElementName1}|] /* 2 */ , int /* 3 */ [|{tupleElementName2}|] /* 4 */) TestMethod2() + {{ + return (1, 1); + }} +}} +"; + + var fixedCode = $@" +public class TestClass +{{ + public (int {fixedTupleElementName1}, int {fixedTupleElementName2}) TestMethod1() + {{ + return (1, 1); + }} + + public (int /* 1 */ {fixedTupleElementName1} /* 2 */ , int /* 3 */ {fixedTupleElementName2} /* 4 */) TestMethod2() + {{ + return (1, 1); + }} +}} +"; + + DiagnosticResult[] expectedDiagnostics = + { + // diagnostics are specified inline + }; + + await VerifyCSharpFixAsync(testCode, settings, expectedDiagnostics, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that improperly named inferred tuple element names are ignored when the 'includeInferredTupleElementNames' option is not set to true. + /// + /// The test settings to use. + /// The expected tuple element name for the first field. + /// The expected tuple element name for the second field. + /// A representing the asynchronous unit test. + [Theory] + [InlineData(DefaultTestSettings, "ElementName1", "ElementName2")] + [InlineData(CamelCaseTestSettings, "ElementName1", "ElementName2")] + [InlineData(PascalCaseTestSettings, "elementName1", "elementName2")] + [InlineData(CamelCaseExplicitOnlyTestSettings, "ElementName1", "ElementName2")] + [InlineData(PascalCaseExplicitOnlyTestSettings, "elementName1", "elementName2")] + public async Task ValidateImproperCasedInferredTupleElementNamesAreIgnoredAsync(string settings, string tupleElementName1, string tupleElementName2) + { + var testCode = $@" +public class TestClass +{{ + public void TestMethod() + {{ + var {tupleElementName1} = 1; + var {tupleElementName2} = ""test""; + var tuple = ({tupleElementName1}, {tupleElementName2}); + }} +}} +"; + + await VerifyCSharpDiagnosticAsync(LanguageVersion.CSharp7_1.OrLaterDefault(), testCode, settings, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Validates the improperly named inferred tuple element names will produce the expected diagnostics. + /// + /// The test settings to use. + /// The expected tuple element name for the first field. + /// The expected tuple element name for the second field. + /// A representing the asynchronous unit test. + [Theory] + [InlineData(CamelCaseInferredTestSettings, "ElementName1", "ElementName2")] + [InlineData(PascalCaseInferredTestSettings, "elementName1", "elementName2")] + public async Task ValidateImproperCasedImplicitTupleElementNamesAsync(string settings, string tupleElementName1, string tupleElementName2) + { + //// TODO: C# 7.1 + var testCode = $@" +public class TestClass +{{ + public void TestMethod1() + {{ + var {tupleElementName1} = 1; + var {tupleElementName2} = ""test""; + var tuple = ([|{tupleElementName1}|], [|{tupleElementName2}|]); + }} + + public void TestMethod2() + {{ + var {tupleElementName1} = 1; + var {tupleElementName2} = ""test""; + var tuple = (/* 1 */ [|{tupleElementName1}|] /* 2 */, /* 3 */ [|{tupleElementName2}|] /* 4 */); + }} +}} +"; + + DiagnosticResult[] expectedDiagnostics = + { + // diagnostics are specified inline + }; + + await VerifyCSharpDiagnosticAsync(LanguageVersion.CSharp7_1.OrLaterDefault(), testCode, settings, expectedDiagnostics, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3031, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3031")] + public async Task TestTupleDesconstructionCamelCaseAsync() + { + var testCode = @" +public class TypeName +{ + public void MethodName((string name, string value) obj) + { + (string name, string value) = obj; + } +} +"; + + await VerifyCSharpDiagnosticAsync(languageVersion: null, testCode, CamelCaseTestSettings, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3031, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3031")] + public async Task TestTupleDesconstructionPascalCaseAsync() + { + var testCode = @" +public class TypeName +{ + public void MethodName((string Name, string Value) obj) + { + (string name, string value) = obj; + } +} +"; + + await VerifyCSharpDiagnosticAsync(languageVersion: null, testCode, PascalCaseTestSettings, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3031, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3031")] + public async Task TestTupleDesconstructionPascalCaseListAsync() + { + var testCode = @" +using System.Collections.Generic; +public class TypeName +{ + public void MethodName(List<(string Name, string Value)> list) + { + foreach ((string name, string value) in list) + { + } + } +} +"; + + await VerifyCSharpDiagnosticAsync(languageVersion: null, testCode, PascalCaseTestSettings, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3139, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3139")] + public async Task TestTupleDesconstructionDiscardAsync() + { + var testCode = @" +public class TypeName +{ + public void MethodName((string Name, string Value) obj) + { + (string name, _) = obj; + } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DefaultTestSettings, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SX1309CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SX1309CSharp7UnitTests.cs index ecc67d143..97ede3427 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SX1309CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SX1309CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.NamingRules { using StyleCop.Analyzers.Test.NamingRules; - public class SX1309CSharp7UnitTests : SX1309UnitTests + public partial class SX1309CSharp7UnitTests : SX1309UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SX1309SCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SX1309SCSharp7UnitTests.cs index 44aa326fe..57919e643 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SX1309SCSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/NamingRules/SX1309SCSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.NamingRules { using StyleCop.Analyzers.Test.NamingRules; - public class SX1309SCSharp7UnitTests : SX1309SUnitTests + public partial class SX1309SCSharp7UnitTests : SX1309SUnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/CSharp7UsingCodeFixProviderCombinedSystemDirectivesUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/CSharp7UsingCodeFixProviderCombinedSystemDirectivesUnitTests.cs deleted file mode 100644 index 412cd2305..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/CSharp7UsingCodeFixProviderCombinedSystemDirectivesUnitTests.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. - -namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules -{ - using StyleCop.Analyzers.Test.OrderingRules; - - public class CSharp7UsingCodeFixProviderCombinedSystemDirectivesUnitTests : UsingCodeFixProviderCombinedSystemDirectivesUnitTests - { - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/CSharp7UsingCodeFixProviderGroupSeparationUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/CSharp7UsingCodeFixProviderGroupSeparationUnitTests.cs deleted file mode 100644 index ee36ba4c8..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/CSharp7UsingCodeFixProviderGroupSeparationUnitTests.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. - -namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules -{ - using StyleCop.Analyzers.Test.OrderingRules; - - public class CSharp7UsingCodeFixProviderGroupSeparationUnitTests : UsingCodeFixProviderGroupSeparationUnitTests - { - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/CSharp7UsingCodeFixProviderRegressionUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/CSharp7UsingCodeFixProviderRegressionUnitTests.cs deleted file mode 100644 index 93f34fc30..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/CSharp7UsingCodeFixProviderRegressionUnitTests.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. - -namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules -{ - using StyleCop.Analyzers.Test.OrderingRules; - - public class CSharp7UsingCodeFixProviderRegressionUnitTests : UsingCodeFixProviderRegressionUnitTests - { - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1200CSharp7OutsideNamespaceUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1200CSharp7OutsideNamespaceUnitTests.cs deleted file mode 100644 index f75a2275e..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1200CSharp7OutsideNamespaceUnitTests.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. - -namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules -{ - using StyleCop.Analyzers.Test.OrderingRules; - - public class SA1200CSharp7OutsideNamespaceUnitTests : SA1200OutsideNamespaceUnitTests - { - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1200CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1200CSharp7UnitTests.cs index 890fb9169..c04c66b96 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1200CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1200CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { using StyleCop.Analyzers.Test.OrderingRules; - public class SA1200CSharp7UnitTests : SA1200UnitTests + public partial class SA1200CSharp7UnitTests : SA1200UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/CSharp7UsingCodeFixProviderUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1200OutsideNamespaceCSharp7UnitTests.cs similarity index 50% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/CSharp7UsingCodeFixProviderUnitTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1200OutsideNamespaceCSharp7UnitTests.cs index 8688391dc..3773b883d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/CSharp7UsingCodeFixProviderUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1200OutsideNamespaceCSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { using StyleCop.Analyzers.Test.OrderingRules; - public class CSharp7UsingCodeFixProviderUnitTests : UsingCodeFixProviderUnitTests + public partial class SA1200OutsideNamespaceCSharp7UnitTests : SA1200OutsideNamespaceUnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1200CSharp7PreserveUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1200PreserveCSharp7UnitTests.cs similarity index 51% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1200CSharp7PreserveUnitTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1200PreserveCSharp7UnitTests.cs index 74f4dcd81..621bb206c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1200CSharp7PreserveUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1200PreserveCSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { using StyleCop.Analyzers.Test.OrderingRules; - public class SA1200CSharp7PreserveUnitTests : SA1200PreserveUnitTests + public partial class SA1200PreserveCSharp7UnitTests : SA1200PreserveUnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1201CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1201CSharp7UnitTests.cs index fc87e0c26..e8198e2fb 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1201CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1201CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { using StyleCop.Analyzers.Test.OrderingRules; - public class SA1201CSharp7UnitTests : SA1201UnitTests + public partial class SA1201CSharp7UnitTests : SA1201UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1202CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1202CSharp7UnitTests.cs index db138d670..15eace051 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1202CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1202CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { using StyleCop.Analyzers.Test.OrderingRules; - public class SA1202CSharp7UnitTests : SA1202UnitTests + public partial class SA1202CSharp7UnitTests : SA1202UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1203CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1203CSharp7UnitTests.cs index 7737eb0fb..d488dae4c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1203CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1203CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { using StyleCop.Analyzers.Test.OrderingRules; - public class SA1203CSharp7UnitTests : SA1203UnitTests + public partial class SA1203CSharp7UnitTests : SA1203UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1204CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1204CSharp7UnitTests.cs index 81c2c37e8..0e3aed16d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1204CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1204CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { using StyleCop.Analyzers.Test.OrderingRules; - public class SA1204CSharp7UnitTests : SA1204UnitTests + public partial class SA1204CSharp7UnitTests : SA1204UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1205CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1205CSharp7UnitTests.cs index 71ba8e78a..fda0b3c98 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1205CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1205CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { using StyleCop.Analyzers.Test.OrderingRules; - public class SA1205CSharp7UnitTests : SA1205UnitTests + public partial class SA1205CSharp7UnitTests : SA1205UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1206CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1206CSharp7UnitTests.cs index f458073d8..459a81db7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1206CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1206CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { @@ -7,13 +9,13 @@ namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Testing; - using StyleCop.Analyzers.OrderingRules; using StyleCop.Analyzers.Test.OrderingRules; - using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.OrderingRules.SA1206DeclarationKeywordsMustFollowOrder, + StyleCop.Analyzers.OrderingRules.SA1206CodeFixProvider>; - public class SA1206CSharp7UnitTests : SA1206UnitTests + public partial class SA1206CSharp7UnitTests : SA1206UnitTests { [Theory] [InlineData("readonly")] @@ -32,7 +34,7 @@ public async Task TestReadonlyRefKeywordInStructDeclarationAsync(string keywords }} }} "; - await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpDiagnosticAsync(LanguageVersion.CSharp7_2, testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } [Fact] @@ -51,29 +53,7 @@ readonly private struct BitHelper { Diagnostic().WithLocation(3, 14).WithArguments("private", "readonly"), }; - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); - } - - private static DiagnosticResult Diagnostic() - => StyleCopCodeFixVerifier.Diagnostic(); - - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) - { - var test = new StyleCopCodeFixVerifier.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); + await VerifyCSharpDiagnosticAsync(LanguageVersion.CSharp7_2, testCode, expected, CancellationToken.None).ConfigureAwait(false); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1206CSharp7CodeFixProviderUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1206CodeFixProviderCSharp7UnitTests.cs similarity index 50% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1206CSharp7CodeFixProviderUnitTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1206CodeFixProviderCSharp7UnitTests.cs index 3f7768f8a..16b535432 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1206CSharp7CodeFixProviderUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1206CodeFixProviderCSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { using StyleCop.Analyzers.Test.OrderingRules; - public class SA1206CSharp7CodeFixProviderUnitTests : SA1206CodeFixProviderUnitTests + public partial class SA1206CodeFixProviderCSharp7UnitTests : SA1206CodeFixProviderUnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1207CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1207CSharp7UnitTests.cs index 6e898d485..4d6dfc0fc 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1207CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1207CSharp7UnitTests.cs @@ -1,11 +1,44 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.CSharp; using StyleCop.Analyzers.Test.OrderingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.OrderingRules.SA1207ProtectedMustComeBeforeInternal, + StyleCop.Analyzers.OrderingRules.SA1207CodeFixProvider>; - public class SA1207CSharp7UnitTests : SA1207UnitTests + public partial class SA1207CSharp7UnitTests : SA1207UnitTests + { + [Fact] + public async Task TestPrivateProtectedAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass { + protected private int testField; + } +} +"; + + var fixedTestCode = @"namespace TestNamespace +{ + public class TestClass + { + private protected int testField; + } +} +"; + + var expectedDiagnostic = Diagnostic().WithArguments("private", "protected").WithLocation(5, 19); + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_2, testCode, expectedDiagnostic, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1208CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1208CSharp7UnitTests.cs index b7b30cb39..dcf0b8a7f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1208CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1208CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { using StyleCop.Analyzers.Test.OrderingRules; - public class SA1208CSharp7UnitTests : SA1208UnitTests + public partial class SA1208CSharp7UnitTests : SA1208UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1209CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1209CSharp7UnitTests.cs index c50aa3997..0e062194d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1209CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1209CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { using StyleCop.Analyzers.Test.OrderingRules; - public class SA1209CSharp7UnitTests : SA1209UnitTests + public partial class SA1209CSharp7UnitTests : SA1209UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1210CSharp7CombinedSystemDirectivesUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1210CSharp7CombinedSystemDirectivesUnitTests.cs deleted file mode 100644 index 379bf3a07..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1210CSharp7CombinedSystemDirectivesUnitTests.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. - -namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules -{ - using StyleCop.Analyzers.Test.OrderingRules; - - public class SA1210CSharp7CombinedSystemDirectivesUnitTests : SA1210CombinedSystemDirectivesUnitTests - { - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1210CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1210CSharp7UnitTests.cs index 4fb86922d..d69a57518 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1210CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1210CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { using StyleCop.Analyzers.Test.OrderingRules; - public class SA1210CSharp7UnitTests : SA1210UnitTests + public partial class SA1210CSharp7UnitTests : SA1210UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1210CombinedSystemDirectivesCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1210CombinedSystemDirectivesCSharp7UnitTests.cs new file mode 100644 index 000000000..04d5fb878 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1210CombinedSystemDirectivesCSharp7UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules +{ + using StyleCop.Analyzers.Test.OrderingRules; + + public partial class SA1210CombinedSystemDirectivesCSharp7UnitTests : SA1210CombinedSystemDirectivesUnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1211CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1211CSharp7UnitTests.cs index 87b2e61c1..923a4d7f6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1211CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1211CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { using StyleCop.Analyzers.Test.OrderingRules; - public class SA1211CSharp7UnitTests : SA1211UnitTests + public partial class SA1211CSharp7UnitTests : SA1211UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1212CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1212CSharp7UnitTests.cs index 814c28a5e..675ec596c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1212CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1212CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { using StyleCop.Analyzers.Test.OrderingRules; - public class SA1212CSharp7UnitTests : SA1212UnitTests + public partial class SA1212CSharp7UnitTests : SA1212UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1213CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1213CSharp7UnitTests.cs index 93b851029..8c1c1b6be 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1213CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1213CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { using StyleCop.Analyzers.Test.OrderingRules; - public class SA1213CSharp7UnitTests : SA1213UnitTests + public partial class SA1213CSharp7UnitTests : SA1213UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1214CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1214CSharp7UnitTests.cs index c4f5d3af7..c04edd78c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1214CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1214CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { using StyleCop.Analyzers.Test.OrderingRules; - public class SA1214CSharp7UnitTests : SA1214UnitTests + public partial class SA1214CSharp7UnitTests : SA1214UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1215CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1215CSharp7UnitTests.cs index 0798d61ee..7a323e80c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1215CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1215CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { using StyleCop.Analyzers.Test.OrderingRules; - public class SA1215CSharp7UnitTests : SA1215UnitTests + public partial class SA1215CSharp7UnitTests : SA1215UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1216CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1216CSharp7UnitTests.cs index 41b7deadd..7098ccdcd 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1216CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1216CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { using StyleCop.Analyzers.Test.OrderingRules; - public class SA1216CSharp7UnitTests : SA1216UnitTests + public partial class SA1216CSharp7UnitTests : SA1216UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1217CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1217CSharp7UnitTests.cs index 5464909ef..6b75bf263 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1217CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/SA1217CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules { using StyleCop.Analyzers.Test.OrderingRules; - public class SA1217CSharp7UnitTests : SA1217UnitTests + public partial class SA1217CSharp7UnitTests : SA1217UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/UsingCodeFixProviderCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/UsingCodeFixProviderCSharp7UnitTests.cs new file mode 100644 index 000000000..6f1abb228 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/UsingCodeFixProviderCSharp7UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules +{ + using StyleCop.Analyzers.Test.OrderingRules; + + public partial class UsingCodeFixProviderCSharp7UnitTests : UsingCodeFixProviderUnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/UsingCodeFixProviderCombinedSystemDirectivesCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/UsingCodeFixProviderCombinedSystemDirectivesCSharp7UnitTests.cs new file mode 100644 index 000000000..4cd086690 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/UsingCodeFixProviderCombinedSystemDirectivesCSharp7UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules +{ + using StyleCop.Analyzers.Test.OrderingRules; + + public partial class UsingCodeFixProviderCombinedSystemDirectivesCSharp7UnitTests : UsingCodeFixProviderCombinedSystemDirectivesUnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/UsingCodeFixProviderGroupSeparationCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/UsingCodeFixProviderGroupSeparationCSharp7UnitTests.cs new file mode 100644 index 000000000..3c8ed4479 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/UsingCodeFixProviderGroupSeparationCSharp7UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules +{ + using StyleCop.Analyzers.Test.OrderingRules; + + public partial class UsingCodeFixProviderGroupSeparationCSharp7UnitTests : UsingCodeFixProviderGroupSeparationUnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/UsingCodeFixProviderRegressionCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/UsingCodeFixProviderRegressionCSharp7UnitTests.cs new file mode 100644 index 000000000..e409d7410 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/OrderingRules/UsingCodeFixProviderRegressionCSharp7UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.OrderingRules +{ + using StyleCop.Analyzers.Test.OrderingRules; + + public partial class UsingCodeFixProviderRegressionCSharp7UnitTests : UsingCodeFixProviderRegressionUnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Properties/AssemblyInfo.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Properties/AssemblyInfo.cs index bf6dd27a8..6b3c320f6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Properties/AssemblyInfo.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Properties/AssemblyInfo.cs @@ -1,7 +1,10 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; [assembly: CLSCompliant(false)] @@ -10,3 +13,7 @@ // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] + +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp8, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp9, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp10, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1100CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1100CSharp7UnitTests.cs index 4f51863a4..38e877faf 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1100CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1100CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using StyleCop.Analyzers.Test.ReadabilityRules; - public class SA1100CSharp7UnitTests : SA1100UnitTests + public partial class SA1100CSharp7UnitTests : SA1100UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1101CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1101CSharp7UnitTests.cs index 502b5af99..fca751c15 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1101CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1101CSharp7UnitTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { @@ -12,7 +12,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules StyleCop.Analyzers.ReadabilityRules.SA1101PrefixLocalCallsWithThis, StyleCop.Analyzers.ReadabilityRules.SA1101CodeFixProvider>; - public class SA1101CSharp7UnitTests : SA1101UnitTests + public partial class SA1101CSharp7UnitTests : SA1101UnitTests { /// /// Verifies that a value tuple is handled properly. @@ -29,6 +29,104 @@ public async Task TestValueTupleAsync() return (a: true, b: false); } } +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2845, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2845")] + public async Task TestPropertyWithExpressionBodiedAccessorAsync() + { + var testCode = @" +public class Foo +{ + private int bar; + + public int Bar + { + get => bar; + set => bar = value; + } +} +"; + + var fixedCode = @" +public class Foo +{ + private int bar; + + public int Bar + { + get => this.bar; + set => this.bar = value; + } +} +"; + + var expected = new[] + { + Diagnostic().WithLocation(8, 16), + Diagnostic().WithLocation(9, 16), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2845, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2845")] + public async Task TestIndexerWithExpressionBodiedAccessorAsync() + { + var testCode = @" +public class Foo +{ + private T[] arr = new T[100]; + + public T this[int i] + { + get => arr[i]; + set => arr[i] = value; + } +} +"; + + var fixedCode = @" +public class Foo +{ + private T[] arr = new T[100]; + + public T this[int i] + { + get => this.arr[i]; + set => this.arr[i] = value; + } +} +"; + + var expected = new[] + { + Diagnostic().WithLocation(8, 14), + Diagnostic().WithLocation(9, 14), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3018, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3018")] + public async Task TestGenericLocalFunctionAsync() + { + var testCode = @" +public class TestClass +{ + private int foobar = 1; + + public int Foo() + { + int Quux() => this.foobar; + return Quux(); + } +} "; await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1102CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1102CSharp7UnitTests.cs index b089765a1..8504339dc 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1102CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1102CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using StyleCop.Analyzers.Test.ReadabilityRules; - public class SA1102CSharp7UnitTests : SA1102UnitTests + public partial class SA1102CSharp7UnitTests : SA1102UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1103CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1103CSharp7UnitTests.cs index ee404f569..4e5d9edaa 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1103CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1103CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using StyleCop.Analyzers.Test.ReadabilityRules; - public class SA1103CSharp7UnitTests : SA1103UnitTests + public partial class SA1103CSharp7UnitTests : SA1103UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1104CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1104CSharp7UnitTests.cs index af95bf11e..9beb811cd 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1104CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1104CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using StyleCop.Analyzers.Test.ReadabilityRules; - public class SA1104CSharp7UnitTests : SA1104UnitTests + public partial class SA1104CSharp7UnitTests : SA1104UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1105CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1105CSharp7UnitTests.cs index f8a3d2c07..3a99198d2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1105CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1105CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using StyleCop.Analyzers.Test.ReadabilityRules; - public class SA1105CSharp7UnitTests : SA1105UnitTests + public partial class SA1105CSharp7UnitTests : SA1105UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1106CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1106CSharp7UnitTests.cs index 4729e74ae..9ff55c0fa 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1106CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1106CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using StyleCop.Analyzers.Test.ReadabilityRules; - public class SA1106CSharp7UnitTests : SA1106UnitTests + public partial class SA1106CSharp7UnitTests : SA1106UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1107CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1107CSharp7UnitTests.cs index 86c7f8c04..1eded99d2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1107CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1107CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using StyleCop.Analyzers.Test.ReadabilityRules; - public class SA1107CSharp7UnitTests : SA1107UnitTests + public partial class SA1107CSharp7UnitTests : SA1107UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1108CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1108CSharp7UnitTests.cs index de7251610..bd47f6d5f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1108CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1108CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using StyleCop.Analyzers.Test.ReadabilityRules; - public class SA1108CSharp7UnitTests : SA1108UnitTests + public partial class SA1108CSharp7UnitTests : SA1108UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1109CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1109CSharp7UnitTests.cs index bd4990b84..441185036 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1109CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1109CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using StyleCop.Analyzers.Test.ReadabilityRules; - public class SA1109CSharp7UnitTests : SA1109UnitTests + public partial class SA1109CSharp7UnitTests : SA1109UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1110CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1110CSharp7UnitTests.cs index 90c9f6494..2dce4fcdf 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1110CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1110CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { @@ -7,13 +9,12 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1110OpeningParenthesisMustBeOnDeclarationLine, StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; - public class SA1110CSharp7UnitTests : SA1110UnitTests + public partial class SA1110CSharp7UnitTests : SA1110UnitTests { [Fact] public async Task TestLocalFunctionDeclarationOpeningParenthesisInTheNextLineAsync() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1111CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1111CSharp7UnitTests.cs index 21f795251..7a427a056 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1111CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1111CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { @@ -7,13 +9,12 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1111ClosingParenthesisMustBeOnLineOfLastParameter, StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; - public class SA1111CSharp7UnitTests : SA1111UnitTests + public partial class SA1111CSharp7UnitTests : SA1111UnitTests { [Fact] public async Task TestLocalFunctionDeclarationWithOneParameterClosingParenthesisOnTheNextLineAsTheLastParameterAsync() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1112CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1112CSharp7UnitTests.cs index 6c92e5c38..57162e542 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1112CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1112CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { @@ -7,13 +9,12 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1112ClosingParenthesisMustBeOnLineOfOpeningParenthesis, StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; - public class SA1112CSharp7UnitTests : SA1112UnitTests + public partial class SA1112CSharp7UnitTests : SA1112UnitTests { [Fact] public async Task TestLocalFunctionWithNoParametersClosingParenthesisOnTheNextLineAsync() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1113CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1113CSharp7UnitTests.cs index 1fd27d9ec..e583fc8a1 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1113CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1113CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { @@ -7,13 +9,12 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1113CommaMustBeOnSameLineAsPreviousParameter, StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; - public class SA1113CSharp7UnitTests : SA1113UnitTests + public partial class SA1113CSharp7UnitTests : SA1113UnitTests { [Fact] public async Task TestLocalFunctionDeclarationWithTwoParametersCommaPlacedAtTheSameLineAsTheSecondParameterAsync() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1114CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1114CSharp7UnitTests.cs index 17ac28b42..f11bb438b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1114CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1114CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { @@ -7,11 +9,10 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier; - public class SA1114CSharp7UnitTests : SA1114UnitTests + public partial class SA1114CSharp7UnitTests : SA1114UnitTests { [Fact] public async Task TestLocalFunctionDeclarationParametersList2LinesAfterOpeningParenthesisAsync() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1115CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1115CSharp7UnitTests.cs index 1551f462c..d5177f6ec 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1115CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1115CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { @@ -7,11 +9,10 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier; - public class SA1115CSharp7UnitTests : SA1115UnitTests + public partial class SA1115CSharp7UnitTests : SA1115UnitTests { [Fact] public async Task TestLocalFunctionDeclarationEmptyLinesBetweenParametersAsync() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1116CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1116CSharp7UnitTests.cs index 47751b23a..99ba474de 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1116CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1116CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { @@ -7,13 +9,12 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1116SplitParametersMustStartOnLineAfterDeclaration, StyleCop.Analyzers.ReadabilityRules.SA1116CodeFixProvider>; - public class SA1116CSharp7UnitTests : SA1116UnitTests + public partial class SA1116CSharp7UnitTests : SA1116UnitTests { [Fact] public async Task TestValidLocalFunctionAsync() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1117CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1117CSharp7UnitTests.cs index 889cc8d18..583aaa48e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1117CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1117CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { @@ -7,11 +9,10 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier; - public class SA1117CSharp7UnitTests : SA1117UnitTests + public partial class SA1117CSharp7UnitTests : SA1117UnitTests { [Fact] public async Task TestValidLocalFunctionsAsync() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1118CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1118CSharp7UnitTests.cs index a2d31ef2a..36fa24b59 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1118CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1118CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using StyleCop.Analyzers.Test.ReadabilityRules; - public class SA1118CSharp7UnitTests : SA1118UnitTests + public partial class SA1118CSharp7UnitTests : SA1118UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1120CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1120CSharp7UnitTests.cs index ee728c431..94356425c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1120CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1120CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using StyleCop.Analyzers.Test.ReadabilityRules; - public class SA1120CSharp7UnitTests : SA1120UnitTests + public partial class SA1120CSharp7UnitTests : SA1120UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1121CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1121CSharp7UnitTests.cs index 985744281..500558ad2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1121CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1121CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using StyleCop.Analyzers.Test.ReadabilityRules; - public class SA1121CSharp7UnitTests : SA1121UnitTests + public partial class SA1121CSharp7UnitTests : SA1121UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1122CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1122CSharp7UnitTests.cs index 1b03b9266..e084afbab 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1122CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1122CSharp7UnitTests.cs @@ -1,11 +1,78 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.ReadabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.ReadabilityRules.SA1122UseStringEmptyForEmptyStrings, + StyleCop.Analyzers.ReadabilityRules.SA1122CodeFixProvider>; + + public partial class SA1122CSharp7UnitTests : SA1122UnitTests + { + /// + /// Verifies the analyzer will properly handle an empty string in a case label. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3028, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3028")] + public async Task TestEmptyStringInCaseLabelWithConditionAsync() + { + string testCode = @" +public class TestClass +{ + public void TestMethod(string condition) + { + switch (""Test string"") + { + case """" when condition == [|""""|]: + break; + case ("""" + ""a"") when condition == [|""""|]: + break; + } + } +} +"; + string fixedCode = @" +public class TestClass +{ + public void TestMethod(string condition) + { + switch (""Test string"") + { + case """" when condition == string.Empty: + break; + case ("""" + ""a"") when condition == string.Empty: + break; + } + } +} +"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false); + } - public class SA1122CSharp7UnitTests : SA1122UnitTests + [Fact] + [WorkItem(3028, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3028")] + public async Task TestEmptyStringInSimplePatternAsync() + { + string testCode = @" +public class TestClass +{ + public bool TestMethod(string condition) { + return condition is """"; + } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1123CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1123CSharp7UnitTests.cs index 06e8e12cb..2c7b57263 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1123CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1123CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using StyleCop.Analyzers.Test.ReadabilityRules; - public class SA1123CSharp7UnitTests : SA1123UnitTests + public partial class SA1123CSharp7UnitTests : SA1123UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1124CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1124CSharp7UnitTests.cs index edf8c3448..a8f45c8ef 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1124CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1124CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using StyleCop.Analyzers.Test.ReadabilityRules; - public class SA1124CSharp7UnitTests : SA1124UnitTests + public partial class SA1124CSharp7UnitTests : SA1124UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1125CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1125CSharp7UnitTests.cs index 8fae64516..4ab90b3d9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1125CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1125CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { @@ -8,11 +10,10 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier; - public class SA1125CSharp7UnitTests : SA1125UnitTests + public partial class SA1125CSharp7UnitTests : SA1125UnitTests { /// /// This is a regression test for DotNetAnalyzers/StyleCopAnalyzers#386. diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1126CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1126CSharp7UnitTests.cs index 0438e2ea2..4b94c90c6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1126CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1126CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using StyleCop.Analyzers.Test.ReadabilityRules; - public class SA1126CSharp7UnitTests : SA1126UnitTests + public partial class SA1126CSharp7UnitTests : SA1126UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1127CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1127CSharp7UnitTests.cs index db8a6ca64..597f3d4f2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1127CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1127CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { @@ -11,7 +13,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules StyleCop.Analyzers.ReadabilityRules.SA1127GenericTypeConstraintsMustBeOnOwnLine, StyleCop.Analyzers.ReadabilityRules.SA1127CodeFixProvider>; - public class SA1127CSharp7UnitTests : SA1127UnitTests + public partial class SA1127CSharp7UnitTests : SA1127UnitTests { [Fact] public async Task TestViolationWithLocalFunctionDeclarationAsync() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1128CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1128CSharp7UnitTests.cs index 24138aaff..8220b7942 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1128CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1128CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using StyleCop.Analyzers.Test.ReadabilityRules; - public class SA1128CSharp7UnitTests : SA1128UnitTests + public partial class SA1128CSharp7UnitTests : SA1128UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1129CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1129CSharp7UnitTests.cs index a90fceef6..3f300502b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1129CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1129CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using StyleCop.Analyzers.Test.ReadabilityRules; - public class SA1129CSharp7UnitTests : SA1129UnitTests + public partial class SA1129CSharp7UnitTests : SA1129UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1130CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1130CSharp7UnitTests.cs index 880861ffd..838d53f9f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1130CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1130CSharp7UnitTests.cs @@ -1,11 +1,51 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.ReadabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.ReadabilityRules.SA1130UseLambdaSyntax, + StyleCop.Analyzers.ReadabilityRules.SA1130CodeFixProvider>; + + public partial class SA1130CSharp7UnitTests : SA1130UnitTests + { + [Fact] + [WorkItem(2902, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2902")] + public async Task VerifyLocalFunctionAsync() + { + var testCode = @"using System; +public class TestClass +{ + public void TestMethod() + { + EventHandler LocalTestFunction() => delegate { }; + } +} +"; - public class SA1130CSharp7UnitTests : SA1130UnitTests + var fixedCode = @"using System; +public class TestClass +{ + public void TestMethod() { + EventHandler LocalTestFunction() => (sender, e) => { }; + } +} +"; + + DiagnosticResult[] expected = + { + Diagnostic().WithLocation(6, 45), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1131CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1131CSharp7UnitTests.cs index cea691371..09260b565 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1131CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1131CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { @@ -8,13 +10,12 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1131UseReadableConditions, StyleCop.Analyzers.ReadabilityRules.SA1131CodeFixProvider>; - public class SA1131CSharp7UnitTests : SA1131UnitTests + public partial class SA1131CSharp7UnitTests : SA1131UnitTests { [Theory] [InlineData("==", "==")] @@ -57,20 +58,7 @@ struct TestStruct }} "; DiagnosticResult expected = Diagnostic().WithLocation(8, 18); - await new CSharpTest - { - TestCode = testCode, - ExpectedDiagnostics = { expected }, - FixedCode = fixedCode, - SolutionTransforms = - { - (solution, projectId) => - { - var parseOptions = (CSharpParseOptions)solution.GetProject(projectId).ParseOptions; - return solution.WithProjectParseOptions(projectId, parseOptions.WithLanguageVersion(LanguageVersion.Latest)); - }, - }, - }.RunAsync(CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_1, testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1132CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1132CSharp7UnitTests.cs index 423d83a00..1abeb123a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1132CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1132CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using StyleCop.Analyzers.Test.ReadabilityRules; - public class SA1132CSharp7UnitTests : SA1132UnitTests + public partial class SA1132CSharp7UnitTests : SA1132UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1133CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1133CSharp7UnitTests.cs index e32296d90..fa1e56d21 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1133CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1133CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using StyleCop.Analyzers.Test.ReadabilityRules; - public class SA1133CSharp7UnitTests : SA1133UnitTests + public partial class SA1133CSharp7UnitTests : SA1133UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1134CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1134CSharp7UnitTests.cs index 0e3225c98..ef25bac51 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1134CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1134CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using StyleCop.Analyzers.Test.ReadabilityRules; - public class SA1134CSharp7UnitTests : SA1134UnitTests + public partial class SA1134CSharp7UnitTests : SA1134UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1135CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1135CSharp7UnitTests.cs index 82beb5e4d..02fbfafee 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1135CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1135CSharp7UnitTests.cs @@ -1,11 +1,45 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.ReadabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.ReadabilityRules.SA1135UsingDirectivesMustBeQualified, + StyleCop.Analyzers.ReadabilityRules.SA1135CodeFixProvider>; - public class SA1135CSharp7UnitTests : SA1135UnitTests + public partial class SA1135CSharp7UnitTests : SA1135UnitTests { + [Fact] + [WorkItem(2879, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2879")] + public async Task TestTupleTypeInUsingAliasAsync() + { + var testCode = @" +namespace TestNamespace +{ + using Example = System.Collections.Generic.List<(int, int)>; +} +"; + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2879, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2879")] + public async Task TestTupleTypeWithNamedElementsInUsingAliasAsync() + { + var testCode = @" +namespace TestNamespace +{ + using Example = System.Collections.Generic.List<(int x, int y)>; +} +"; + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1136CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1136CSharp7UnitTests.cs index 2b49343c6..0e7cd2a1a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1136CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1136CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using StyleCop.Analyzers.Test.ReadabilityRules; - public class SA1136CSharp7UnitTests : SA1136UnitTests + public partial class SA1136CSharp7UnitTests : SA1136UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1137CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1137CSharp7UnitTests.cs index 2ba594222..56f0fc7af 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1137CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1137CSharp7UnitTests.cs @@ -1,11 +1,227 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.ReadabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Helpers.LanguageVersionTestExtensions; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.ReadabilityRules.SA1137ElementsShouldHaveTheSameIndentation, + StyleCop.Analyzers.ReadabilityRules.IndentationCodeFixProvider>; + + public partial class SA1137CSharp7UnitTests : SA1137UnitTests + { + [Fact] + public async Task TestTupleTypeAsync() + { + string testCode = @" +class Container +{ + ( + int x, + int y, +int z) NonZeroAlignment; + + ( +int x, + int y, + int z) ZeroAlignment; +} +"; + string fixedCode = @" +class Container +{ + ( + int x, + int y, + int z) NonZeroAlignment; + + ( +int x, +int y, +int z) ZeroAlignment; +} +"; + + DiagnosticResult[] expected = + { + Diagnostic().WithLocation(6, 1), + Diagnostic().WithLocation(7, 1), + Diagnostic().WithLocation(11, 1), + Diagnostic().WithLocation(12, 1), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestTupleExpressionAsync() + { + string testCode = @" +class Container +{ + (int x, int y, int z) NonZeroAlignment = ( + 0, + 0, +0); + + (int x, int y, int z) ZeroAlignment = ( +0, + 0, + 0); +} +"; + string fixedCode = @" +class Container +{ + (int x, int y, int z) NonZeroAlignment = ( + 0, + 0, + 0); + + (int x, int y, int z) ZeroAlignment = ( +0, +0, +0); +} +"; + + DiagnosticResult[] expected = + { + Diagnostic().WithLocation(6, 1), + Diagnostic().WithLocation(7, 1), + Diagnostic().WithLocation(11, 1), + Diagnostic().WithLocation(12, 1), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc int[] + { + 0, + 0, +0, + }; + int* data2 = stackalloc int[] + { +0, + 0, + 0, + }; + } + } +} +"; - public class SA1137CSharp7UnitTests : SA1137UnitTests + var fixedCode = @"namespace TestNamespace +{ + public class TestClass { + public unsafe void TestMethod() + { + int* data1 = stackalloc int[] + { + 0, + 0, + 0, + }; + int* data2 = stackalloc int[] + { +0, +0, +0, + }; + } + } +} +"; + + DiagnosticResult[] expected = + { + Diagnostic().WithLocation(10, 1), + Diagnostic().WithLocation(11, 1), + Diagnostic().WithLocation(16, 1), + Diagnostic().WithLocation(17, 1), + }; + + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestImplicitStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc[] + { + 0, + 0, +0, + }; + int* data2 = stackalloc[] + { +0, + 0, + 0, + }; + } + } +} +"; + + var fixedCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc[] + { + 0, + 0, + 0, + }; + int* data2 = stackalloc[] + { +0, +0, +0, + }; + } + } +} +"; + + DiagnosticResult[] expected = + { + Diagnostic().WithLocation(10, 1), + Diagnostic().WithLocation(11, 1), + Diagnostic().WithLocation(16, 1), + Diagnostic().WithLocation(17, 1), + }; + + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1139CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1139CSharp7UnitTests.cs index 4e001e0d6..c8711a7e9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1139CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1139CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { @@ -7,13 +9,12 @@ namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1139UseLiteralSuffixNotationInsteadOfCasting, StyleCop.Analyzers.ReadabilityRules.SA1139CodeFixProvider>; - public class SA1139CSharp7UnitTests : SA1139UnitTests + public partial class SA1139CSharp7UnitTests : SA1139UnitTests { /// /// Verifies that using literals with digit separators does not produce diagnostic. diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1141CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1141CSharp7UnitTests.cs new file mode 100644 index 000000000..5da606afa --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1141CSharp7UnitTests.cs @@ -0,0 +1,433 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.ReadabilityRules; + using StyleCop.Analyzers.Test.ReadabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.ReadabilityRules.SA1141UseTupleSyntax, + StyleCop.Analyzers.ReadabilityRules.SA1141CodeFixProvider>; + + /// + /// This class contains the CSharp 7.x unit tests for SA1141. + /// + /// + /// + public partial class SA1141CSharp7UnitTests : SA1141UnitTests + { + /// + /// Verifies that member declarations containing ValueTuple will result in the proper diagnostics and fixes. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task ValidateMemberDeclarationsWithValueTuplesAsync() + { + var testCode = @"using System; + +public class TestClass +{ + public ValueTuple TestMethod(ValueTuple value) + { + throw new NotImplementedException(); + } + + public System.ValueTuple<(int, int), int> TestMethod2(int p1, ValueTuple, long> p2, (ValueTuple, string) p3) + { + throw new NotImplementedException(); + } + + public System.ValueTuple TestProperty1 { get; set; } + + public System.Collections.Generic.List> TestProperty2 { get; set; } + + public System.ValueTuple this[int i] { get { return (1, 1l); } set { } } + + public static explicit operator TestClass(System.ValueTuple p1) + { + throw new NotImplementedException(); + } + + public static implicit operator System.ValueTuple(TestClass p1) + { + throw new NotImplementedException(); + } +} +"; + + var fixedCode = @"using System; + +public class TestClass +{ + public (int, int) TestMethod((double, double) value) + { + throw new NotImplementedException(); + } + + public ((int, int), int) TestMethod2(int p1, ((long, long), long) p2, ((string, string), string) p3) + { + throw new NotImplementedException(); + } + + public (int, int) TestProperty1 { get; set; } + + public System.Collections.Generic.List<(int, int)> TestProperty2 { get; set; } + + public (int, long) this[int i] { get { return (1, 1l); } set { } } + + public static explicit operator TestClass((int, int) p1) + { + throw new NotImplementedException(); + } + + public static implicit operator (int, int)(TestClass p1) + { + throw new NotImplementedException(); + } +} +"; + + DiagnosticResult[] expectedDiagnostics = + { + Diagnostic().WithLocation(5, 12), + Diagnostic().WithLocation(5, 44), + Diagnostic().WithLocation(10, 12), + Diagnostic().WithLocation(10, 67), + Diagnostic().WithLocation(10, 120), + Diagnostic().WithLocation(15, 12), + Diagnostic().WithLocation(17, 44), + Diagnostic().WithLocation(19, 12), + Diagnostic().WithLocation(21, 47), + Diagnostic().WithLocation(26, 37), + }; + + await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verify that ValueTuple object creation expressions will produce the expected diagnostics and fixes. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task ValidateValueTupleObjectCreationAsync() + { + var testCode = @"using System; + +public class TestClass +{ + public void TestMethod() + { + var test1 = new ValueTuple(1, 2); + var test2 = new System.ValueTuple(1, 2); + var test3 = new ValueTuple, int>(new ValueTuple(3, 4), 2); + var test4 = new System.ValueTuple>(1, new System.ValueTuple(2, 3)); + var test5 = (new ValueTuple(3, 4), 2); + var test6 = new System.ValueTuple>(1, (2, 3)); + var test7 = ValueTuple.Create(1, 2); + var test8 = ValueTuple.Create(1, 2); + var test9 = System.ValueTuple.Create(1, new ValueTuple(2, 3)); + var test10 = ValueTuple.Create(ValueTuple.Create(1, 2, 3), 4); + var test11 = new ValueTuple>(1, ValueTuple.Create(2, 3)); + var test12 = new System.ValueTuple(1, 2); + } +} +"; + + var fixedCode = @"using System; + +public class TestClass +{ + public void TestMethod() + { + var test1 = (1, 2); + var test2 = (1, 2); + var test3 = ((3, 4), 2); + var test4 = (1, (2, 3)); + var test5 = ((3, 4), 2); + var test6 = (1, (2, 3)); + var test7 = (1, 2); + var test8 = (1, (double)2); + var test9 = (1, (2, (double)3)); + var test10 = ((1, 2, 3), 4); + var test11 = (1, (2, 3)); + var test12 = ((byte)1, 2); + } +} +"; + + DiagnosticResult[] expectedDiagnostics = + { + Diagnostic().WithLocation(7, 21), + Diagnostic().WithLocation(8, 21), + Diagnostic().WithLocation(9, 21), + Diagnostic().WithLocation(9, 63), + Diagnostic().WithLocation(10, 21), + Diagnostic().WithLocation(10, 80), + Diagnostic().WithLocation(11, 22), + Diagnostic().WithLocation(12, 21), + Diagnostic().WithLocation(13, 21), + Diagnostic().WithLocation(14, 21), + Diagnostic().WithLocation(15, 21), + Diagnostic().WithLocation(15, 49), + Diagnostic().WithLocation(16, 22), + Diagnostic().WithLocation(16, 40), + Diagnostic().WithLocation(17, 22), + Diagnostic().WithLocation(17, 67), + Diagnostic().WithLocation(18, 22), + }; + + await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Validates that the usage of within LINQ expression trees will produce no + /// diagnostics. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3305, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3305")] + public async Task ValidateValueTupleUsageInExpressionTreeAsync() + { + var testCode = @"using System; +using System.Linq.Expressions; + +public class TestClass +{ + Expression> expression1 = () => ValueTuple.Create(10, 20); + Expression> expression2 = () => new ValueTuple(10, 20); + Expression> expression3 = () => new ValueTuple, int>(ValueTuple.Create(10, 10), 20); + Expression> expression4 = () => new System.ValueTuple(10, 20); + Expression> expression5 = arg => new System.ValueTuple(arg.Item1, arg.Item2); + Expression> expression6 = (arg) => new System.ValueTuple(arg.Item1, arg.Item2); + + Expression|], [|ValueTuple|]>> expression7 = ([|ValueTuple|] arg) => ValueTuple.Create(arg.Item1, arg.Item2); +} +"; + var fixedCode = @"using System; +using System.Linq.Expressions; + +public class TestClass +{ + Expression> expression1 = () => ValueTuple.Create(10, 20); + Expression> expression2 = () => new ValueTuple(10, 20); + Expression> expression3 = () => new ValueTuple, int>(ValueTuple.Create(10, 10), 20); + Expression> expression4 = () => new System.ValueTuple(10, 20); + Expression> expression5 = arg => new System.ValueTuple(arg.Item1, arg.Item2); + Expression> expression6 = (arg) => new System.ValueTuple(arg.Item1, arg.Item2); + + Expression> expression7 = ((int, int) arg) => ValueTuple.Create(arg.Item1, arg.Item2); +} +"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Validates that the usage of within pattern matching will produce no diagnostics. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task ValidateValueTupleUsageInPatternMatchingAsync() + { + var testCode = @"using System; + +public class TestClass +{ + public void TestMethod(object x) + { + switch (x) + { + case System.ValueTuple a: + break; + + case ValueTuple> b: + break; + } + + if (x is ValueTuple c) + { + } + + if (x is System.ValueTuple, long> d) + { + } + } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3055, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3055")] + public async Task ValidateSingleElementValueTupleUsageAsync() + { + var testCode = @"using System; + +public class TestClass +{ + public void TestMethod() + { + var test1 = default(ValueTuple); + var test2 = default(ValueTuple>); + ValueTuple test3 = ValueTuple.Create(3); + } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Validates that the usage of within exception filtering will produce no diagnostics. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task ValidateValueTupleUsageInExceptionFiltersAsync() + { + var testCode = @"using System; + +public class TestClass +{ + public string TestMethod(object x) + { + try + { + return x.ToString(); + } + catch (TestException e) when (e.AdditionalInfo is ValueTuple) + { + return null; + } + } +} + +public class TestException : Exception +{ + public object AdditionalInfo { get; set; } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Validates that the usage of within type casts will produce the expected diagnostics and code fixes. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task ValidateValueTupleUsageInTypeCastsAsync() + { + var testCode = @"using System; + +public class TestClass +{ + public void TestMethod(object input) + { + var test1 = (ValueTuple)input; + var test2 = (System.ValueTuple, byte>)input; + } +} +"; + + var fixedCode = @"using System; + +public class TestClass +{ + public void TestMethod(object input) + { + var test1 = ((int, int))input; + var test2 = (((int, long), byte))input; + } +} +"; + + DiagnosticResult[] expectedDiagnostics = + { + Diagnostic().WithLocation(7, 22), + Diagnostic().WithLocation(8, 22), + }; + + await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Validates that the usage of within a default expression will produce the expected diagnostics and code fixes. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task ValidateValueTupleUsageInDefaultExpressionAsync() + { + var testCode = @"using System; + +public class TestClass +{ + public void TestMethod() + { + var test1 = default(ValueTuple); + var test2 = default(System.ValueTuple, byte>); + } +} +"; + + var fixedCode = @"using System; + +public class TestClass +{ + public void TestMethod() + { + var test1 = default((int, int)); + var test2 = default(((int, long), byte)); + } +} +"; + + DiagnosticResult[] expectedDiagnostics = + { + Diagnostic().WithLocation(7, 29), + Diagnostic().WithLocation(8, 29), + }; + + await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Validates that the usage of within a delegate will produce the expected diagnostics and code fixes. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task ValidateValueTupleUsageInDelegateAsync() + { + var testCode = @"using System; + +public class TestClass +{ + public delegate System.ValueTuple TestDelegate(ValueTuple> arg1, (long, double) arg2, (long, System.ValueTuple) arg3); +} +"; + + var fixedCode = @"using System; + +public class TestClass +{ + public delegate (int, bool) TestDelegate((int, (int, long)) arg1, (long, double) arg2, (long, (bool, bool)) arg3); +} +"; + + DiagnosticResult[] expectedDiagnostics = + { + Diagnostic().WithLocation(5, 21), + Diagnostic().WithLocation(5, 63), + Diagnostic().WithLocation(5, 136), + }; + + await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1142CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1142CSharp7UnitTests.cs new file mode 100644 index 000000000..55a6c9416 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SA1142CSharp7UnitTests.cs @@ -0,0 +1,89 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.ReadabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.ReadabilityRules.SA1142ReferToTupleElementsByName, + StyleCop.Analyzers.ReadabilityRules.SA1142CodeFixProvider>; + + /// + /// This class contains the CSharp 7.x unit tests for SA1142. + /// + /// + /// + public partial class SA1142CSharp7UnitTests + { + /// + /// Validate that tuple fields that are referenced by their name will not produce any diagnostics. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task ValidateFieldNameReferencesAsync() + { + var testCode = @" +public class TestClass +{ + public int TestMethod((int nameA, int nameB) p1, (int, int) p2, (int, int nameC) p3) + { + return p1.nameA + p1.nameB + p2.Item1 + p2.Item2 + p3.Item1 + p3.nameC; + } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verify that tuple names referenced by their metadata name will produce the expected diagnostics. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task ValidateMetadataNameReferencesAsync() + { + var testCode = @" +public class TestClass +{ + public int TestMethod1((int nameA, int nameB) p1) + { + return p1.[|Item1|] + p1.[|Item2|] /* test */ + p1.ToString().Length; + } + + public int TestMethod2((int nameA, (int subNameA, int subNameB) nameB) p1) + { + return p1.[|Item1|] + p1.nameB.[|Item1|] + p1.[|Item2|].[|Item2|]; + } +} +"; + + var fixedCode = @" +public class TestClass +{ + public int TestMethod1((int nameA, int nameB) p1) + { + return p1.nameA + p1.nameB /* test */ + p1.ToString().Length; + } + + public int TestMethod2((int nameA, (int subNameA, int subNameB) nameB) p1) + { + return p1.nameA + p1.nameB.subNameA + p1.nameB.subNameB; + } +} +"; + + DiagnosticResult[] expectedDiagnostics = + { + // diagnostics are specified inline + }; + + await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SX1101CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SX1101CSharp7UnitTests.cs index 63ef6aed1..ae7eba7e7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SX1101CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/ReadabilityRules/SX1101CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.ReadabilityRules { using StyleCop.Analyzers.Test.ReadabilityRules; - public class SX1101CSharp7UnitTests : SX1101UnitTests + public partial class SX1101CSharp7UnitTests : SX1101UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Settings/SettingsCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Settings/SettingsCSharp7UnitTests.cs new file mode 100644 index 000000000..c0b4d6016 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Settings/SettingsCSharp7UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.Settings +{ + using StyleCop.Analyzers.Test.Settings; + + public partial class SettingsCSharp7UnitTests : SettingsUnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Settings/SettingsFileCodeFixProviderCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Settings/SettingsFileCodeFixProviderCSharp7UnitTests.cs new file mode 100644 index 000000000..5b93e733a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/Settings/SettingsFileCodeFixProviderCSharp7UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp7.Settings +{ + using StyleCop.Analyzers.Test.Settings; + + public partial class SettingsFileCodeFixProviderCSharp7UnitTests : SettingsFileCodeFixProviderUnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1000CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1000CSharp7UnitTests.cs index da83a32d0..96f4b8455 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1000CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1000CSharp7UnitTests.cs @@ -1,19 +1,22 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.SpacingRules; - using TestHelper; using Xunit; + using static StyleCop.Analyzers.Test.Helpers.LanguageVersionTestExtensions; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1000KeywordsMustBeSpacedCorrectly, StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; - public class SA1000CSharp7UnitTests : SA1000UnitTests + public partial class SA1000CSharp7UnitTests : SA1000UnitTests { [Fact] public async Task TestOutVariableDeclarationAsync() @@ -236,5 +239,18 @@ public void TestMethod() await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } + + [Fact] + public async Task TestStackAllocImplicitArrayStatementAsync() + { + string statementWithoutSpace = @"int* x = stackalloc[] { 3 };"; + + string statementWithSpace = @"int* x = stackalloc [] { 3 };"; + + await this.TestKeywordStatementAsync(statementWithoutSpace, DiagnosticResult.EmptyDiagnosticResults, statementWithoutSpace, languageVersion: LanguageVersion.CSharp7_3.OrLaterDefault()).ConfigureAwait(false); + + // this case is handled by SA1026, so it shouldn't be reported here + await this.TestKeywordStatementAsync(statementWithSpace, DiagnosticResult.EmptyDiagnosticResults, statementWithSpace, languageVersion: LanguageVersion.CSharp7_3.OrLaterDefault()).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1001CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1001CSharp7UnitTests.cs index 2f4f7f15d..023f50839 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1001CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1001CSharp7UnitTests.cs @@ -1,19 +1,22 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.SpacingRules; - using TestHelper; using Xunit; + using static StyleCop.Analyzers.Test.Helpers.LanguageVersionTestExtensions; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1001CommasMustBeSpacedCorrectly, StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; - public class SA1001CSharp7UnitTests : SA1001UnitTests + public partial class SA1001CSharp7UnitTests : SA1001UnitTests { /// /// Verifies spacing around a ] character in tuple types and expressions. @@ -119,5 +122,83 @@ public void TestMethod() DiagnosticResult expected = Diagnostic().WithLocation(7, 21).WithArguments(" not", "preceded"); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } + + [Fact] + public async Task TestStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc int[] { 1 , 1 }; + int* data2 = stackalloc int[] { 1 ,1 }; + } + } +} +"; + + var fixedCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc int[] { 1, 1 }; + int* data2 = stackalloc int[] { 1, 1 }; + } + } +} +"; + + DiagnosticResult[] expected = + { + Diagnostic().WithLocation(7, 47).WithArguments(" not", "preceded"), + Diagnostic().WithLocation(8, 47).WithArguments(" not", "preceded"), + Diagnostic().WithLocation(8, 47).WithArguments(string.Empty, "followed"), + }; + + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestImplicitStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc[] { 1 , 1 }; + int* data2 = stackalloc[] { 1 ,1 }; + } + } +} +"; + + var fixedCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc[] { 1, 1 }; + int* data2 = stackalloc[] { 1, 1 }; + } + } +} +"; + + DiagnosticResult[] expected = + { + Diagnostic().WithLocation(7, 43).WithArguments(" not", "preceded"), + Diagnostic().WithLocation(8, 43).WithArguments(" not", "preceded"), + Diagnostic().WithLocation(8, 43).WithArguments(string.Empty, "followed"), + }; + + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1002CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1002CSharp7UnitTests.cs index 7d5e4b5b9..a82a62795 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1002CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1002CSharp7UnitTests.cs @@ -1,11 +1,91 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.SpacingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Helpers.LanguageVersionTestExtensions; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1002SemicolonsMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1002CSharp7UnitTests : SA1002UnitTests + { + [Fact] + public async Task TestStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data = stackalloc int[] { 1, 1 } ; + } + } +} +"; + + var fixedCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data = stackalloc int[] { 1, 1 }; + } + } +} +"; - public class SA1002CSharp7UnitTests : SA1002UnitTests + DiagnosticResult[] expected = + { + Diagnostic().WithArguments(" not", "preceded").WithLocation(7, 51), + }; + + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestImplicitStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data = stackalloc[] { 1, 1 } ; + } + } +} +"; + + var fixedCode = @"namespace TestNamespace +{ + public class TestClass { + public unsafe void TestMethod() + { + int* data = stackalloc[] { 1, 1 }; + } + } +} +"; + + DiagnosticResult[] expected = + { + Diagnostic().WithArguments(" not", "preceded").WithLocation(7, 47), + }; + + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1003CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1003CSharp7UnitTests.cs index d3c13f5de..94e4c9802 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1003CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1003CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.SpacingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.SpacingRules.SA1003SymbolsMustBeSpacedCorrectly; @@ -15,7 +16,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules StyleCop.Analyzers.SpacingRules.SA1003SymbolsMustBeSpacedCorrectly, StyleCop.Analyzers.SpacingRules.SA1003CodeFixProvider>; - public class SA1003CSharp7UnitTests : SA1003UnitTests + public partial class SA1003CSharp7UnitTests : SA1003UnitTests { /// /// Verifies that the additional expression-bodied members supported in C# 7 trigger diagnostics as expected. diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1004CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1004CSharp7UnitTests.cs index f5a1a9e19..1473a7e7f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1004CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1004CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { using StyleCop.Analyzers.Test.SpacingRules; - public class SA1004CSharp7UnitTests : SA1004UnitTests + public partial class SA1004CSharp7UnitTests : SA1004UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1005CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1005CSharp7UnitTests.cs index 5b2007d75..70c5c5fda 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1005CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1005CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { using StyleCop.Analyzers.Test.SpacingRules; - public class SA1005CSharp7UnitTests : SA1005UnitTests + public partial class SA1005CSharp7UnitTests : SA1005UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1006CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1006CSharp7UnitTests.cs index c8c3660e6..d456af3ac 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1006CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1006CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { using StyleCop.Analyzers.Test.SpacingRules; - public class SA1006CSharp7UnitTests : SA1006UnitTests + public partial class SA1006CSharp7UnitTests : SA1006UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1007CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1007CSharp7UnitTests.cs index 35cd97bc1..fd5de3c78 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1007CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1007CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { using StyleCop.Analyzers.Test.SpacingRules; - public class SA1007CSharp7UnitTests : SA1007UnitTests + public partial class SA1007CSharp7UnitTests : SA1007UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1008CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1008CSharp7UnitTests.cs index 4c9e13ced..ef99c691d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1008CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1008CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.SpacingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.SpacingRules.SA1008OpeningParenthesisMustBeSpacedCorrectly; @@ -15,7 +16,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules StyleCop.Analyzers.SpacingRules.SA1008OpeningParenthesisMustBeSpacedCorrectly, StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; - public class SA1008CSharp7UnitTests : SA1008UnitTests + public partial class SA1008CSharp7UnitTests : SA1008UnitTests { /// /// Verifies that spacing around tuple type casts is handled properly. @@ -977,5 +978,65 @@ public void TestMethod(params (string name, string value)[] options) await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } + + [Fact] + [WorkItem(3117, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3117")] + public async Task TestTupleParameterAttributesAsync() + { + var testCode = @" +namespace TestNamespace +{ + class NotNullAttribute : System.Attribute { } + class CustomAttribute : System.Attribute { } + + class TestClass + { + void TestMethod1([NotNull] (string, string) tuple) { } + + void TestMethod2([NotNull, Custom] (string, string) tuple) { } + + void TestMethod3([NotNull][Custom] (string, string) tuple) { } + + void TestMethod4([NotNull]{|#0:(|}string, string) tuple) { } + + void TestMethod5([NotNull, Custom]{|#1:(|}string, string) tuple) { } + + void TestMethod6([NotNull][Custom]{|#2:(|}string, string) tuple) { } + } +} +"; + + var fixedCode = @" +namespace TestNamespace +{ + class NotNullAttribute : System.Attribute { } + class CustomAttribute : System.Attribute { } + + class TestClass + { + void TestMethod1([NotNull] (string, string) tuple) { } + + void TestMethod2([NotNull, Custom] (string, string) tuple) { } + + void TestMethod3([NotNull][Custom] (string, string) tuple) { } + + void TestMethod4([NotNull] (string, string) tuple) { } + + void TestMethod5([NotNull, Custom] (string, string) tuple) { } + + void TestMethod6([NotNull][Custom] (string, string) tuple) { } + } +} +"; + + DiagnosticResult[] expectedDiagnostics = + { + Diagnostic(DescriptorPreceded).WithLocation(0), + Diagnostic(DescriptorPreceded).WithLocation(1), + Diagnostic(DescriptorPreceded).WithLocation(2), + }; + + await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedCode, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1009CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1009CSharp7UnitTests.cs index c971ed5fb..538972648 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1009CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1009CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { @@ -7,13 +9,13 @@ namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.SpacingRules; - using TestHelper; using Xunit; + using static StyleCop.Analyzers.SpacingRules.SA1009ClosingParenthesisMustBeSpacedCorrectly; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1009ClosingParenthesisMustBeSpacedCorrectly, StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; - public class SA1009CSharp7UnitTests : SA1009UnitTests + public partial class SA1009CSharp7UnitTests : SA1009UnitTests { /// /// Verifies spacing around a ] character in tuple types and expressions. @@ -47,10 +49,10 @@ public class Foo DiagnosticResult[] expected = { - Diagnostic().WithLocation(5, 27).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(5, 55).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(7, 24).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(7, 98).WithArguments(" not", "preceded"), + Diagnostic(DescriptorNotPreceded).WithLocation(5, 27), + Diagnostic(DescriptorNotPreceded).WithLocation(5, 55), + Diagnostic(DescriptorNotPreceded).WithLocation(7, 24), + Diagnostic(DescriptorNotPreceded).WithLocation(7, 98), }; await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -84,7 +86,7 @@ public void TestMethod() } }"; - DiagnosticResult expected = Diagnostic().WithLocation(7, 47).WithArguments(" not", "preceded"); + DiagnosticResult expected = Diagnostic(DescriptorNotPreceded).WithLocation(7, 47); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } @@ -117,7 +119,7 @@ public void TestMethod() } }"; - DiagnosticResult expected = Diagnostic().WithLocation(7, 34).WithArguments(" not", "preceded"); + DiagnosticResult expected = Diagnostic(DescriptorNotPreceded).WithLocation(7, 34); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } @@ -164,16 +166,16 @@ public void TestMethod() DiagnosticResult[] expectedDiagnostic = { // test1 - Diagnostic().WithArguments(" not", "preceded").WithLocation(7, 36), - Diagnostic().WithArguments(" not", "followed").WithLocation(7, 36), - Diagnostic().WithArguments(" not", "preceded").WithLocation(7, 38), + Diagnostic(DescriptorNotPreceded).WithLocation(7, 36), + Diagnostic(DescriptorNotFollowed).WithLocation(7, 36), + Diagnostic(DescriptorNotPreceded).WithLocation(7, 38), // test2 - Diagnostic().WithArguments(" not", "preceded").WithLocation(8, 36), + Diagnostic(DescriptorNotPreceded).WithLocation(8, 36), // test3 - Diagnostic().WithArguments(" not", "followed").WithLocation(9, 35), - Diagnostic().WithArguments(" not", "preceded").WithLocation(9, 37), + Diagnostic(DescriptorNotFollowed).WithLocation(9, 35), + Diagnostic(DescriptorNotPreceded).WithLocation(9, 37), }; await VerifyCSharpFixAsync(testCode, expectedDiagnostic, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -235,28 +237,28 @@ public class TestClass DiagnosticResult[] expectedDiagnostic = { // TestMethod1, TestMethod2, TestMethod3 - Diagnostic().WithArguments(" not", "preceded").WithLocation(5, 42), - Diagnostic().WithArguments(string.Empty, "followed").WithLocation(5, 42), - Diagnostic().WithArguments(" not", "preceded").WithLocation(6, 42), - Diagnostic().WithArguments(string.Empty, "followed").WithLocation(7, 41), + Diagnostic(DescriptorNotPreceded).WithLocation(5, 42), + Diagnostic(DescriptorFollowed).WithLocation(5, 42), + Diagnostic(DescriptorNotPreceded).WithLocation(6, 42), + Diagnostic(DescriptorFollowed).WithLocation(7, 41), // TestMethod4, TestMethod5, TestMethod6 - Diagnostic().WithArguments(" not", "preceded").WithLocation(9, 59), - Diagnostic().WithArguments(string.Empty, "followed").WithLocation(9, 59), - Diagnostic().WithArguments(" not", "preceded").WithLocation(10, 59), - Diagnostic().WithArguments(string.Empty, "followed").WithLocation(11, 58), + Diagnostic(DescriptorNotPreceded).WithLocation(9, 59), + Diagnostic(DescriptorFollowed).WithLocation(9, 59), + Diagnostic(DescriptorNotPreceded).WithLocation(10, 59), + Diagnostic(DescriptorFollowed).WithLocation(11, 58), // TestMethod7, TestMethod8, TestMethod9 - Diagnostic().WithArguments(" not", "preceded").WithLocation(13, 44), - Diagnostic().WithArguments(string.Empty, "followed").WithLocation(13, 44), - Diagnostic().WithArguments(" not", "preceded").WithLocation(14, 44), - Diagnostic().WithArguments(string.Empty, "followed").WithLocation(15, 43), + Diagnostic(DescriptorNotPreceded).WithLocation(13, 44), + Diagnostic(DescriptorFollowed).WithLocation(13, 44), + Diagnostic(DescriptorNotPreceded).WithLocation(14, 44), + Diagnostic(DescriptorFollowed).WithLocation(15, 43), // TestMethod10, TestMethod11, TestMethod12 - Diagnostic().WithArguments(" not", "preceded").WithLocation(17, 43), - Diagnostic().WithArguments(" not", "followed").WithLocation(17, 43), - Diagnostic().WithArguments(" not", "preceded").WithLocation(18, 43), - Diagnostic().WithArguments(" not", "followed").WithLocation(19, 42), + Diagnostic(DescriptorNotPreceded).WithLocation(17, 43), + Diagnostic(DescriptorNotFollowed).WithLocation(17, 43), + Diagnostic(DescriptorNotPreceded).WithLocation(18, 43), + Diagnostic(DescriptorNotFollowed).WithLocation(19, 42), }; await VerifyCSharpFixAsync(testCode, expectedDiagnostic, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -350,96 +352,96 @@ public class TestClass DiagnosticResult[] expectedDiagnostic = { // TestMethod1, TestMethod2, TestMethod3 - Diagnostic().WithArguments(" not", "preceded").WithLocation(5, 26), - Diagnostic().WithArguments(string.Empty, "followed").WithLocation(5, 26), - Diagnostic().WithArguments(" not", "preceded").WithLocation(5, 62), - Diagnostic().WithArguments(" not", "followed").WithLocation(5, 62), - Diagnostic().WithArguments(" not", "preceded").WithLocation(5, 64), - Diagnostic().WithArguments(" not", "preceded").WithLocation(6, 26), - Diagnostic().WithArguments(" not", "preceded").WithLocation(6, 63), - Diagnostic().WithArguments(string.Empty, "followed").WithLocation(7, 25), - Diagnostic().WithArguments(" not", "followed").WithLocation(7, 60), - Diagnostic().WithArguments(" not", "preceded").WithLocation(7, 62), + Diagnostic(DescriptorNotPreceded).WithLocation(5, 26), + Diagnostic(DescriptorFollowed).WithLocation(5, 26), + Diagnostic(DescriptorNotPreceded).WithLocation(5, 62), + Diagnostic(DescriptorNotFollowed).WithLocation(5, 62), + Diagnostic(DescriptorNotPreceded).WithLocation(5, 64), + Diagnostic(DescriptorNotPreceded).WithLocation(6, 26), + Diagnostic(DescriptorNotPreceded).WithLocation(6, 63), + Diagnostic(DescriptorFollowed).WithLocation(7, 25), + Diagnostic(DescriptorNotFollowed).WithLocation(7, 60), + Diagnostic(DescriptorNotPreceded).WithLocation(7, 62), // TestMethod4, TestMethod5, TestMethod6 - Diagnostic().WithArguments(" not", "preceded").WithLocation(9, 27), - Diagnostic().WithArguments(" not", "followed").WithLocation(9, 27), - Diagnostic().WithArguments(" not", "preceded").WithLocation(9, 72), - Diagnostic().WithArguments(" not", "followed").WithLocation(9, 72), - Diagnostic().WithArguments(" not", "preceded").WithLocation(10, 27), - Diagnostic().WithArguments(" not", "preceded").WithLocation(10, 71), - Diagnostic().WithArguments(" not", "followed").WithLocation(11, 26), - Diagnostic().WithArguments(" not", "followed").WithLocation(11, 70), + Diagnostic(DescriptorNotPreceded).WithLocation(9, 27), + Diagnostic(DescriptorNotFollowed).WithLocation(9, 27), + Diagnostic(DescriptorNotPreceded).WithLocation(9, 72), + Diagnostic(DescriptorNotFollowed).WithLocation(9, 72), + Diagnostic(DescriptorNotPreceded).WithLocation(10, 27), + Diagnostic(DescriptorNotPreceded).WithLocation(10, 71), + Diagnostic(DescriptorNotFollowed).WithLocation(11, 26), + Diagnostic(DescriptorNotFollowed).WithLocation(11, 70), // TestMethod7, TestMethod8, TestMethod9 - Diagnostic().WithArguments(" not", "preceded").WithLocation(13, 32), - Diagnostic().WithArguments(" not", "followed").WithLocation(13, 32), - Diagnostic().WithArguments(" not", "preceded").WithLocation(13, 34), - Diagnostic().WithArguments(" not", "preceded").WithLocation(13, 77), - Diagnostic().WithArguments(" not", "followed").WithLocation(13, 77), - Diagnostic().WithArguments(" not", "preceded").WithLocation(13, 79), - Diagnostic().WithArguments(" not", "preceded").WithLocation(14, 32), - Diagnostic().WithArguments(" not", "preceded").WithLocation(14, 76), - Diagnostic().WithArguments(" not", "followed").WithLocation(15, 31), - Diagnostic().WithArguments(" not", "preceded").WithLocation(15, 33), - Diagnostic().WithArguments(" not", "followed").WithLocation(15, 75), - Diagnostic().WithArguments(" not", "preceded").WithLocation(15, 77), + Diagnostic(DescriptorNotPreceded).WithLocation(13, 32), + Diagnostic(DescriptorNotFollowed).WithLocation(13, 32), + Diagnostic(DescriptorNotPreceded).WithLocation(13, 34), + Diagnostic(DescriptorNotPreceded).WithLocation(13, 77), + Diagnostic(DescriptorNotFollowed).WithLocation(13, 77), + Diagnostic(DescriptorNotPreceded).WithLocation(13, 79), + Diagnostic(DescriptorNotPreceded).WithLocation(14, 32), + Diagnostic(DescriptorNotPreceded).WithLocation(14, 76), + Diagnostic(DescriptorNotFollowed).WithLocation(15, 31), + Diagnostic(DescriptorNotPreceded).WithLocation(15, 33), + Diagnostic(DescriptorNotFollowed).WithLocation(15, 75), + Diagnostic(DescriptorNotPreceded).WithLocation(15, 77), // TestMethod10, TestMethod11, TestMethod12 - Diagnostic().WithArguments(" not", "preceded").WithLocation(17, 30), - Diagnostic().WithArguments(string.Empty, "followed").WithLocation(17, 30), - Diagnostic().WithArguments(" not", "preceded").WithLocation(17, 71), - Diagnostic().WithArguments(" not", "followed").WithLocation(17, 71), - Diagnostic().WithArguments(" not", "preceded").WithLocation(17, 73), - Diagnostic().WithArguments(" not", "preceded").WithLocation(18, 30), - Diagnostic().WithArguments(" not", "preceded").WithLocation(18, 72), - Diagnostic().WithArguments(string.Empty, "followed").WithLocation(19, 29), - Diagnostic().WithArguments(" not", "followed").WithLocation(19, 69), - Diagnostic().WithArguments(" not", "preceded").WithLocation(19, 71), + Diagnostic(DescriptorNotPreceded).WithLocation(17, 30), + Diagnostic(DescriptorFollowed).WithLocation(17, 30), + Diagnostic(DescriptorNotPreceded).WithLocation(17, 71), + Diagnostic(DescriptorNotFollowed).WithLocation(17, 71), + Diagnostic(DescriptorNotPreceded).WithLocation(17, 73), + Diagnostic(DescriptorNotPreceded).WithLocation(18, 30), + Diagnostic(DescriptorNotPreceded).WithLocation(18, 72), + Diagnostic(DescriptorFollowed).WithLocation(19, 29), + Diagnostic(DescriptorNotFollowed).WithLocation(19, 69), + Diagnostic(DescriptorNotPreceded).WithLocation(19, 71), // TestMethod13, TestMethod14, TestMethod15 - Diagnostic().WithArguments(" not", "preceded").WithLocation(21, 31), - Diagnostic().WithArguments(" not", "followed").WithLocation(21, 31), - Diagnostic().WithArguments(" not", "preceded").WithLocation(21, 83), - Diagnostic().WithArguments(" not", "followed").WithLocation(21, 83), - Diagnostic().WithArguments(" not", "preceded").WithLocation(22, 31), - Diagnostic().WithArguments(" not", "preceded").WithLocation(22, 82), - Diagnostic().WithArguments(" not", "followed").WithLocation(23, 30), - Diagnostic().WithArguments(" not", "followed").WithLocation(23, 81), + Diagnostic(DescriptorNotPreceded).WithLocation(21, 31), + Diagnostic(DescriptorNotFollowed).WithLocation(21, 31), + Diagnostic(DescriptorNotPreceded).WithLocation(21, 83), + Diagnostic(DescriptorNotFollowed).WithLocation(21, 83), + Diagnostic(DescriptorNotPreceded).WithLocation(22, 31), + Diagnostic(DescriptorNotPreceded).WithLocation(22, 82), + Diagnostic(DescriptorNotFollowed).WithLocation(23, 30), + Diagnostic(DescriptorNotFollowed).WithLocation(23, 81), // TestMethod16, TestMethod17, TestMethod18 - Diagnostic().WithArguments(" not", "preceded").WithLocation(25, 38), - Diagnostic().WithArguments(" not", "followed").WithLocation(25, 38), - Diagnostic().WithArguments(" not", "preceded").WithLocation(25, 40), - Diagnostic().WithArguments(" not", "preceded").WithLocation(25, 90), - Diagnostic().WithArguments(" not", "followed").WithLocation(25, 90), - Diagnostic().WithArguments(" not", "preceded").WithLocation(25, 92), - Diagnostic().WithArguments(" not", "preceded").WithLocation(26, 38), - Diagnostic().WithArguments(" not", "preceded").WithLocation(26, 89), - Diagnostic().WithArguments(" not", "followed").WithLocation(27, 37), - Diagnostic().WithArguments(" not", "preceded").WithLocation(27, 39), - Diagnostic().WithArguments(" not", "followed").WithLocation(27, 88), - Diagnostic().WithArguments(" not", "preceded").WithLocation(27, 90), + Diagnostic(DescriptorNotPreceded).WithLocation(25, 38), + Diagnostic(DescriptorNotFollowed).WithLocation(25, 38), + Diagnostic(DescriptorNotPreceded).WithLocation(25, 40), + Diagnostic(DescriptorNotPreceded).WithLocation(25, 90), + Diagnostic(DescriptorNotFollowed).WithLocation(25, 90), + Diagnostic(DescriptorNotPreceded).WithLocation(25, 92), + Diagnostic(DescriptorNotPreceded).WithLocation(26, 38), + Diagnostic(DescriptorNotPreceded).WithLocation(26, 89), + Diagnostic(DescriptorNotFollowed).WithLocation(27, 37), + Diagnostic(DescriptorNotPreceded).WithLocation(27, 39), + Diagnostic(DescriptorNotFollowed).WithLocation(27, 88), + Diagnostic(DescriptorNotPreceded).WithLocation(27, 90), // TestMethod19, TestMethod20, TestMethod21 - Diagnostic().WithArguments(" not", "preceded").WithLocation(29, 27), - Diagnostic().WithArguments(string.Empty, "followed").WithLocation(29, 27), - Diagnostic().WithArguments(" not", "preceded").WithLocation(29, 75), - Diagnostic().WithArguments(string.Empty, "followed").WithLocation(29, 75), - Diagnostic().WithArguments(" not", "preceded").WithLocation(30, 27), - Diagnostic().WithArguments(" not", "preceded").WithLocation(30, 76), - Diagnostic().WithArguments(string.Empty, "followed").WithLocation(31, 26), - Diagnostic().WithArguments(string.Empty, "followed").WithLocation(31, 73), + Diagnostic(DescriptorNotPreceded).WithLocation(29, 27), + Diagnostic(DescriptorFollowed).WithLocation(29, 27), + Diagnostic(DescriptorNotPreceded).WithLocation(29, 75), + Diagnostic(DescriptorFollowed).WithLocation(29, 75), + Diagnostic(DescriptorNotPreceded).WithLocation(30, 27), + Diagnostic(DescriptorNotPreceded).WithLocation(30, 76), + Diagnostic(DescriptorFollowed).WithLocation(31, 26), + Diagnostic(DescriptorFollowed).WithLocation(31, 73), // TestMethod22, TestMethod23, TestMethod24 - Diagnostic().WithArguments(" not", "preceded").WithLocation(33, 34), - Diagnostic().WithArguments(string.Empty, "followed").WithLocation(33, 34), - Diagnostic().WithArguments(" not", "preceded").WithLocation(33, 82), - Diagnostic().WithArguments(string.Empty, "followed").WithLocation(33, 82), - Diagnostic().WithArguments(" not", "preceded").WithLocation(34, 34), - Diagnostic().WithArguments(" not", "preceded").WithLocation(34, 83), - Diagnostic().WithArguments(string.Empty, "followed").WithLocation(35, 33), - Diagnostic().WithArguments(string.Empty, "followed").WithLocation(35, 80), + Diagnostic(DescriptorNotPreceded).WithLocation(33, 34), + Diagnostic(DescriptorFollowed).WithLocation(33, 34), + Diagnostic(DescriptorNotPreceded).WithLocation(33, 82), + Diagnostic(DescriptorFollowed).WithLocation(33, 82), + Diagnostic(DescriptorNotPreceded).WithLocation(34, 34), + Diagnostic(DescriptorNotPreceded).WithLocation(34, 83), + Diagnostic(DescriptorFollowed).WithLocation(35, 33), + Diagnostic(DescriptorFollowed).WithLocation(35, 80), }; await VerifyCSharpFixAsync(testCode, expectedDiagnostic, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -482,24 +484,24 @@ public class TestClass DiagnosticResult[] expectedDiagnostic = { // TestMethod1, TestMethod2, TestMethod3 - Diagnostic().WithArguments(" not", "preceded").WithLocation(5, 26), - Diagnostic().WithArguments(" not", "followed").WithLocation(5, 26), - Diagnostic().WithArguments(" not", "preceded").WithLocation(5, 65), - Diagnostic().WithArguments(" not", "followed").WithLocation(5, 65), - Diagnostic().WithArguments(" not", "preceded").WithLocation(6, 26), - Diagnostic().WithArguments(" not", "preceded").WithLocation(6, 64), - Diagnostic().WithArguments(" not", "followed").WithLocation(7, 25), - Diagnostic().WithArguments(" not", "followed").WithLocation(7, 63), + Diagnostic(DescriptorNotPreceded).WithLocation(5, 26), + Diagnostic(DescriptorNotFollowed).WithLocation(5, 26), + Diagnostic(DescriptorNotPreceded).WithLocation(5, 65), + Diagnostic(DescriptorNotFollowed).WithLocation(5, 65), + Diagnostic(DescriptorNotPreceded).WithLocation(6, 26), + Diagnostic(DescriptorNotPreceded).WithLocation(6, 64), + Diagnostic(DescriptorNotFollowed).WithLocation(7, 25), + Diagnostic(DescriptorNotFollowed).WithLocation(7, 63), // TestMethod4, TestMethod5, TestMethod6 - Diagnostic().WithArguments(" not", "preceded").WithLocation(9, 26), - Diagnostic().WithArguments(" not", "followed").WithLocation(9, 26), - Diagnostic().WithArguments(" not", "preceded").WithLocation(9, 66), - Diagnostic().WithArguments(" not", "followed").WithLocation(9, 66), - Diagnostic().WithArguments(" not", "preceded").WithLocation(10, 26), - Diagnostic().WithArguments(" not", "preceded").WithLocation(10, 65), - Diagnostic().WithArguments(" not", "followed").WithLocation(11, 25), - Diagnostic().WithArguments(" not", "followed").WithLocation(11, 64), + Diagnostic(DescriptorNotPreceded).WithLocation(9, 26), + Diagnostic(DescriptorNotFollowed).WithLocation(9, 26), + Diagnostic(DescriptorNotPreceded).WithLocation(9, 66), + Diagnostic(DescriptorNotFollowed).WithLocation(9, 66), + Diagnostic(DescriptorNotPreceded).WithLocation(10, 26), + Diagnostic(DescriptorNotPreceded).WithLocation(10, 65), + Diagnostic(DescriptorNotFollowed).WithLocation(11, 25), + Diagnostic(DescriptorNotFollowed).WithLocation(11, 64), }; await VerifyCSharpFixAsync(testCode, expectedDiagnostic, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -687,102 +689,102 @@ public void TestMethod() DiagnosticResult[] expectedDiagnostics = { // v1, v2, v3 - Diagnostic().WithArguments(" not", "preceded").WithLocation(12, 28), - Diagnostic().WithArguments(" not", "followed").WithLocation(12, 28), - Diagnostic().WithArguments(" not", "preceded").WithLocation(13, 28), - Diagnostic().WithArguments(" not", "followed").WithLocation(14, 27), + Diagnostic(DescriptorNotPreceded).WithLocation(12, 28), + Diagnostic(DescriptorNotFollowed).WithLocation(12, 28), + Diagnostic(DescriptorNotPreceded).WithLocation(13, 28), + Diagnostic(DescriptorNotFollowed).WithLocation(14, 27), // v4, v5, v6 - Diagnostic().WithArguments(" not", "preceded").WithLocation(17, 29), - Diagnostic().WithArguments(" not", "followed").WithLocation(17, 29), - Diagnostic().WithArguments(" not", "preceded").WithLocation(18, 29), - Diagnostic().WithArguments(" not", "followed").WithLocation(19, 28), + Diagnostic(DescriptorNotPreceded).WithLocation(17, 29), + Diagnostic(DescriptorNotFollowed).WithLocation(17, 29), + Diagnostic(DescriptorNotPreceded).WithLocation(18, 29), + Diagnostic(DescriptorNotFollowed).WithLocation(19, 28), // v7, v8, v9 - Diagnostic().WithArguments(" not", "preceded").WithLocation(22, 32), - Diagnostic().WithArguments(" not", "followed").WithLocation(22, 32), - Diagnostic().WithArguments(" not", "preceded").WithLocation(22, 34), - Diagnostic().WithArguments(" not", "preceded").WithLocation(23, 32), - Diagnostic().WithArguments(" not", "followed").WithLocation(24, 31), - Diagnostic().WithArguments(" not", "preceded").WithLocation(24, 33), + Diagnostic(DescriptorNotPreceded).WithLocation(22, 32), + Diagnostic(DescriptorNotFollowed).WithLocation(22, 32), + Diagnostic(DescriptorNotPreceded).WithLocation(22, 34), + Diagnostic(DescriptorNotPreceded).WithLocation(23, 32), + Diagnostic(DescriptorNotFollowed).WithLocation(24, 31), + Diagnostic(DescriptorNotPreceded).WithLocation(24, 33), // v10, v11, v12 - Diagnostic().WithArguments(" not", "preceded").WithLocation(27, 32), - Diagnostic().WithArguments(" not", "followed").WithLocation(27, 32), - Diagnostic().WithArguments(" not", "preceded").WithLocation(28, 32), - Diagnostic().WithArguments(" not", "followed").WithLocation(29, 31), + Diagnostic(DescriptorNotPreceded).WithLocation(27, 32), + Diagnostic(DescriptorNotFollowed).WithLocation(27, 32), + Diagnostic(DescriptorNotPreceded).WithLocation(28, 32), + Diagnostic(DescriptorNotFollowed).WithLocation(29, 31), // v13, v14, v15 - Diagnostic().WithArguments(" not", "preceded").WithLocation(32, 33), - Diagnostic().WithArguments(" not", "followed").WithLocation(32, 33), - Diagnostic().WithArguments(" not", "preceded").WithLocation(33, 33), - Diagnostic().WithArguments(" not", "followed").WithLocation(34, 32), + Diagnostic(DescriptorNotPreceded).WithLocation(32, 33), + Diagnostic(DescriptorNotFollowed).WithLocation(32, 33), + Diagnostic(DescriptorNotPreceded).WithLocation(33, 33), + Diagnostic(DescriptorNotFollowed).WithLocation(34, 32), // v16, v17, v18 - Diagnostic().WithArguments(" not", "preceded").WithLocation(37, 36), - Diagnostic().WithArguments(" not", "followed").WithLocation(37, 36), - Diagnostic().WithArguments(" not", "preceded").WithLocation(37, 38), - Diagnostic().WithArguments(" not", "preceded").WithLocation(38, 36), - Diagnostic().WithArguments(" not", "followed").WithLocation(39, 35), - Diagnostic().WithArguments(" not", "preceded").WithLocation(39, 37), + Diagnostic(DescriptorNotPreceded).WithLocation(37, 36), + Diagnostic(DescriptorNotFollowed).WithLocation(37, 36), + Diagnostic(DescriptorNotPreceded).WithLocation(37, 38), + Diagnostic(DescriptorNotPreceded).WithLocation(38, 36), + Diagnostic(DescriptorNotFollowed).WithLocation(39, 35), + Diagnostic(DescriptorNotPreceded).WithLocation(39, 37), // v19, v20, v21 - Diagnostic().WithArguments(" not", "preceded").WithLocation(42, 33), - Diagnostic().WithArguments(" not", "followed").WithLocation(42, 33), - Diagnostic().WithArguments(" not", "preceded").WithLocation(43, 33), - Diagnostic().WithArguments(" not", "followed").WithLocation(44, 32), + Diagnostic(DescriptorNotPreceded).WithLocation(42, 33), + Diagnostic(DescriptorNotFollowed).WithLocation(42, 33), + Diagnostic(DescriptorNotPreceded).WithLocation(43, 33), + Diagnostic(DescriptorNotFollowed).WithLocation(44, 32), // v22, v23, v24 - Diagnostic().WithArguments(" not", "preceded").WithLocation(47, 36), - Diagnostic().WithArguments(" not", "followed").WithLocation(47, 36), - Diagnostic().WithArguments(" not", "preceded").WithLocation(47, 38), - Diagnostic().WithArguments(" not", "preceded").WithLocation(48, 36), - Diagnostic().WithArguments(" not", "followed").WithLocation(49, 35), - Diagnostic().WithArguments(" not", "preceded").WithLocation(49, 37), + Diagnostic(DescriptorNotPreceded).WithLocation(47, 36), + Diagnostic(DescriptorNotFollowed).WithLocation(47, 36), + Diagnostic(DescriptorNotPreceded).WithLocation(47, 38), + Diagnostic(DescriptorNotPreceded).WithLocation(48, 36), + Diagnostic(DescriptorNotFollowed).WithLocation(49, 35), + Diagnostic(DescriptorNotPreceded).WithLocation(49, 37), // v25, v26, v27 - Diagnostic().WithArguments(" not", "preceded").WithLocation(52, 40), - Diagnostic().WithArguments(" not", "followed").WithLocation(52, 40), - Diagnostic().WithArguments(" not", "preceded").WithLocation(53, 40), - Diagnostic().WithArguments(" not", "followed").WithLocation(54, 39), - Diagnostic().WithArguments(" not", "preceded").WithLocation(55, 45), - Diagnostic().WithArguments(" not", "followed").WithLocation(55, 45), - Diagnostic().WithArguments(" not", "preceded").WithLocation(56, 45), - Diagnostic().WithArguments(" not", "followed").WithLocation(57, 44), + Diagnostic(DescriptorNotPreceded).WithLocation(52, 40), + Diagnostic(DescriptorNotFollowed).WithLocation(52, 40), + Diagnostic(DescriptorNotPreceded).WithLocation(53, 40), + Diagnostic(DescriptorNotFollowed).WithLocation(54, 39), + Diagnostic(DescriptorNotPreceded).WithLocation(55, 45), + Diagnostic(DescriptorNotFollowed).WithLocation(55, 45), + Diagnostic(DescriptorNotPreceded).WithLocation(56, 45), + Diagnostic(DescriptorNotFollowed).WithLocation(57, 44), // First argument - Diagnostic().WithArguments(" not", "preceded").WithLocation(60, 34), - Diagnostic().WithArguments(" not", "followed").WithLocation(60, 34), - Diagnostic().WithArguments(" not", "preceded").WithLocation(61, 34), - Diagnostic().WithArguments(" not", "followed").WithLocation(62, 33), - Diagnostic().WithArguments(" not", "preceded").WithLocation(63, 39), - Diagnostic().WithArguments(" not", "followed").WithLocation(63, 39), - Diagnostic().WithArguments(" not", "preceded").WithLocation(64, 39), - Diagnostic().WithArguments(" not", "followed").WithLocation(65, 38), + Diagnostic(DescriptorNotPreceded).WithLocation(60, 34), + Diagnostic(DescriptorNotFollowed).WithLocation(60, 34), + Diagnostic(DescriptorNotPreceded).WithLocation(61, 34), + Diagnostic(DescriptorNotFollowed).WithLocation(62, 33), + Diagnostic(DescriptorNotPreceded).WithLocation(63, 39), + Diagnostic(DescriptorNotFollowed).WithLocation(63, 39), + Diagnostic(DescriptorNotPreceded).WithLocation(64, 39), + Diagnostic(DescriptorNotFollowed).WithLocation(65, 38), // Second argument - Diagnostic().WithArguments(" not", "preceded").WithLocation(68, 42), - Diagnostic().WithArguments(" not", "followed").WithLocation(68, 42), - Diagnostic().WithArguments(" not", "preceded").WithLocation(68, 44), - Diagnostic().WithArguments(" not", "preceded").WithLocation(69, 42), - Diagnostic().WithArguments(" not", "followed").WithLocation(70, 41), - Diagnostic().WithArguments(" not", "preceded").WithLocation(70, 43), - Diagnostic().WithArguments(" not", "preceded").WithLocation(71, 54), - Diagnostic().WithArguments(" not", "followed").WithLocation(71, 54), - Diagnostic().WithArguments(" not", "preceded").WithLocation(71, 56), - Diagnostic().WithArguments(" not", "preceded").WithLocation(72, 54), - Diagnostic().WithArguments(" not", "followed").WithLocation(73, 53), - Diagnostic().WithArguments(" not", "preceded").WithLocation(73, 55), + Diagnostic(DescriptorNotPreceded).WithLocation(68, 42), + Diagnostic(DescriptorNotFollowed).WithLocation(68, 42), + Diagnostic(DescriptorNotPreceded).WithLocation(68, 44), + Diagnostic(DescriptorNotPreceded).WithLocation(69, 42), + Diagnostic(DescriptorNotFollowed).WithLocation(70, 41), + Diagnostic(DescriptorNotPreceded).WithLocation(70, 43), + Diagnostic(DescriptorNotPreceded).WithLocation(71, 54), + Diagnostic(DescriptorNotFollowed).WithLocation(71, 54), + Diagnostic(DescriptorNotPreceded).WithLocation(71, 56), + Diagnostic(DescriptorNotPreceded).WithLocation(72, 54), + Diagnostic(DescriptorNotFollowed).WithLocation(73, 53), + Diagnostic(DescriptorNotPreceded).WithLocation(73, 55), // Returns - Diagnostic().WithArguments(" not", "preceded").WithLocation(76, 56), - Diagnostic().WithArguments(" not", "followed").WithLocation(76, 56), - Diagnostic().WithArguments(" not", "preceded").WithLocation(77, 56), - Diagnostic().WithArguments(" not", "followed").WithLocation(78, 55), - Diagnostic().WithArguments(" not", "preceded").WithLocation(79, 50), - Diagnostic().WithArguments(" not", "followed").WithLocation(79, 50), - Diagnostic().WithArguments(" not", "preceded").WithLocation(80, 50), - Diagnostic().WithArguments(" not", "followed").WithLocation(81, 49), + Diagnostic(DescriptorNotPreceded).WithLocation(76, 56), + Diagnostic(DescriptorNotFollowed).WithLocation(76, 56), + Diagnostic(DescriptorNotPreceded).WithLocation(77, 56), + Diagnostic(DescriptorNotFollowed).WithLocation(78, 55), + Diagnostic(DescriptorNotPreceded).WithLocation(79, 50), + Diagnostic(DescriptorNotFollowed).WithLocation(79, 50), + Diagnostic(DescriptorNotPreceded).WithLocation(80, 50), + Diagnostic(DescriptorNotFollowed).WithLocation(81, 49), }; await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -831,14 +833,14 @@ public class TestClass DiagnosticResult[] expectedDiagnostics = { - Diagnostic().WithArguments(" not", "preceded").WithLocation(7, 31), - Diagnostic().WithArguments(" not", "followed").WithLocation(7, 31), - Diagnostic().WithArguments(" not", "preceded").WithLocation(8, 31), - Diagnostic().WithArguments(" not", "followed").WithLocation(9, 30), - Diagnostic().WithArguments(" not", "preceded").WithLocation(11, 43), - Diagnostic().WithArguments(" not", "followed").WithLocation(11, 43), - Diagnostic().WithArguments(" not", "preceded").WithLocation(12, 43), - Diagnostic().WithArguments(" not", "followed").WithLocation(13, 42), + Diagnostic(DescriptorNotPreceded).WithLocation(7, 31), + Diagnostic(DescriptorNotFollowed).WithLocation(7, 31), + Diagnostic(DescriptorNotPreceded).WithLocation(8, 31), + Diagnostic(DescriptorNotFollowed).WithLocation(9, 30), + Diagnostic(DescriptorNotPreceded).WithLocation(11, 43), + Diagnostic(DescriptorNotFollowed).WithLocation(11, 43), + Diagnostic(DescriptorNotPreceded).WithLocation(12, 43), + Diagnostic(DescriptorNotFollowed).WithLocation(13, 42), }; await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -885,24 +887,24 @@ public class TestClass DiagnosticResult[] expectedDiagnostics = { // Function1, Function2, Function3 - Diagnostic().WithArguments(" not", "preceded").WithLocation(7, 31), - Diagnostic().WithArguments(" not", "followed").WithLocation(7, 31), - Diagnostic().WithArguments(" not", "preceded").WithLocation(7, 46), - Diagnostic().WithArguments(" not", "followed").WithLocation(7, 46), - Diagnostic().WithArguments(" not", "preceded").WithLocation(8, 31), - Diagnostic().WithArguments(" not", "preceded").WithLocation(8, 45), - Diagnostic().WithArguments(" not", "followed").WithLocation(9, 30), - Diagnostic().WithArguments(" not", "followed").WithLocation(9, 44), + Diagnostic(DescriptorNotPreceded).WithLocation(7, 31), + Diagnostic(DescriptorNotFollowed).WithLocation(7, 31), + Diagnostic(DescriptorNotPreceded).WithLocation(7, 46), + Diagnostic(DescriptorNotFollowed).WithLocation(7, 46), + Diagnostic(DescriptorNotPreceded).WithLocation(8, 31), + Diagnostic(DescriptorNotPreceded).WithLocation(8, 45), + Diagnostic(DescriptorNotFollowed).WithLocation(9, 30), + Diagnostic(DescriptorNotFollowed).WithLocation(9, 44), // Function4, Function5, Function6 - Diagnostic().WithArguments(" not", "preceded").WithLocation(11, 31), - Diagnostic().WithArguments(" not", "followed").WithLocation(11, 31), - Diagnostic().WithArguments(" not", "preceded").WithLocation(11, 47), - Diagnostic().WithArguments(" not", "followed").WithLocation(11, 47), - Diagnostic().WithArguments(" not", "preceded").WithLocation(12, 31), - Diagnostic().WithArguments(" not", "preceded").WithLocation(12, 46), - Diagnostic().WithArguments(" not", "followed").WithLocation(13, 30), - Diagnostic().WithArguments(" not", "followed").WithLocation(13, 45), + Diagnostic(DescriptorNotPreceded).WithLocation(11, 31), + Diagnostic(DescriptorNotFollowed).WithLocation(11, 31), + Diagnostic(DescriptorNotPreceded).WithLocation(11, 47), + Diagnostic(DescriptorNotFollowed).WithLocation(11, 47), + Diagnostic(DescriptorNotPreceded).WithLocation(12, 31), + Diagnostic(DescriptorNotPreceded).WithLocation(12, 46), + Diagnostic(DescriptorNotFollowed).WithLocation(13, 30), + Diagnostic(DescriptorNotFollowed).WithLocation(13, 45), }; await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -945,10 +947,10 @@ public void TestMethod() DiagnosticResult[] expectedDiagnostics = { - Diagnostic().WithArguments(" not", "preceded").WithLocation(7, 25), - Diagnostic().WithArguments(string.Empty, "followed").WithLocation(7, 25), - Diagnostic().WithArguments(" not", "preceded").WithLocation(8, 25), - Diagnostic().WithArguments(string.Empty, "followed").WithLocation(9, 24), + Diagnostic(DescriptorNotPreceded).WithLocation(7, 25), + Diagnostic(DescriptorFollowed).WithLocation(7, 25), + Diagnostic(DescriptorNotPreceded).WithLocation(8, 25), + Diagnostic(DescriptorFollowed).WithLocation(9, 24), }; await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -997,10 +999,10 @@ public void TestMethod() DiagnosticResult[] expectedDiagnostics = { - Diagnostic().WithArguments(" not", "preceded").WithLocation(10, 36), - Diagnostic().WithArguments(" not", "followed").WithLocation(10, 36), - Diagnostic().WithArguments(" not", "preceded").WithLocation(11, 36), - Diagnostic().WithArguments(" not", "followed").WithLocation(12, 35), + Diagnostic(DescriptorNotPreceded).WithLocation(10, 36), + Diagnostic(DescriptorNotFollowed).WithLocation(10, 36), + Diagnostic(DescriptorNotPreceded).WithLocation(11, 36), + Diagnostic(DescriptorNotFollowed).WithLocation(12, 35), }; await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -1048,7 +1050,7 @@ public void TestMethod() DiagnosticResult[] expectedDiagnostics = { - Diagnostic().WithArguments(" not", "followed").WithLocation(6, 25), + Diagnostic(DescriptorNotFollowed).WithLocation(6, 25), }; await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedCode, CancellationToken.None).ConfigureAwait(false); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1010CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1010CSharp7UnitTests.cs index b74e94bfe..baf779e46 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1010CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1010CSharp7UnitTests.cs @@ -1,11 +1,110 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.SpacingRules; + using Xunit; + using static StyleCop.Analyzers.SpacingRules.SA1010OpeningSquareBracketsMustBeSpacedCorrectly; + using static StyleCop.Analyzers.Test.Helpers.LanguageVersionTestExtensions; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1010OpeningSquareBracketsMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1010CSharp7UnitTests : SA1010UnitTests + { + [Fact] + public async Task TestStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc int [ ] { 1 , 1 }; + int* data2 = stackalloc int [] { 1 , 1 }; + int* data3 = stackalloc int[] { 1 , 1 }; + int* data4 = stackalloc int[ +] { 1 , 1 }; + } + } +} +"; + + var fixedCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc int[] { 1 , 1 }; + int* data2 = stackalloc int[] { 1 , 1 }; + int* data3 = stackalloc int[] { 1 , 1 }; + int* data4 = stackalloc int[ +] { 1 , 1 }; + } + } +} +"; - public class SA1010CSharp7UnitTests : SA1010UnitTests + DiagnosticResult[] expected = + { + Diagnostic(DescriptorNotPreceded).WithLocation(7, 41), + Diagnostic(DescriptorNotFollowed).WithLocation(7, 41), + Diagnostic(DescriptorNotPreceded).WithLocation(8, 41), + }; + + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestImplicitStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc [ ] { 1 , 1 }; + int* data2 = stackalloc [] { 1 , 1 }; + int* data3 = stackalloc[] { 1 , 1 }; + int* data4 = stackalloc[ +] { 1 , 1 }; + } + } +} +"; + + var fixedCode = @"namespace TestNamespace +{ + public class TestClass { + public unsafe void TestMethod() + { + int* data1 = stackalloc [] { 1 , 1 }; + int* data2 = stackalloc [] { 1 , 1 }; + int* data3 = stackalloc[] { 1 , 1 }; + int* data4 = stackalloc[ +] { 1 , 1 }; + } + } +} +"; + + DiagnosticResult[] expected = + { + Diagnostic(DescriptorNotFollowed).WithLocation(7, 37), + }; + + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1011CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1011CSharp7UnitTests.cs index 1e80f99fc..1a9737ee4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1011CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1011CSharp7UnitTests.cs @@ -1,18 +1,22 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.SpacingRules; using Xunit; + using static StyleCop.Analyzers.Test.Helpers.LanguageVersionTestExtensions; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1011ClosingSquareBracketsMustBeSpacedCorrectly, StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; - public class SA1011CSharp7UnitTests : SA1011UnitTests + public partial class SA1011CSharp7UnitTests : SA1011UnitTests { /// /// Verifies spacing around a ] character in tuple types and expressions. @@ -36,7 +40,103 @@ public class Foo } }"; - await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, testCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc int[ ] { 1 , 1 }; + int* data2 = stackalloc int[ ]{ 1 , 1 }; + int* data3 = stackalloc int[] { 1 , 1 }; + int* data4 = stackalloc int[]{ 1 , 1 }; + int* data5 = stackalloc int[] +{ 1 , 1 }; + } + } +} +"; + + var fixedCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc int[] { 1 , 1 }; + int* data2 = stackalloc int[] { 1 , 1 }; + int* data3 = stackalloc int[] { 1 , 1 }; + int* data4 = stackalloc int[] { 1 , 1 }; + int* data5 = stackalloc int[] +{ 1 , 1 }; + } + } +} +"; + + DiagnosticResult[] expected = + { + Diagnostic().WithArguments(" not", "preceded").WithLocation(7, 42), + Diagnostic().WithArguments(" not", "preceded").WithLocation(8, 42), + Diagnostic().WithArguments(string.Empty, "followed").WithLocation(8, 42), + Diagnostic().WithArguments(string.Empty, "followed").WithLocation(10, 41), + }; + + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestImplicitStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc[ ] { 1 , 1 }; + int* data2 = stackalloc[ ]{ 1 , 1 }; + int* data3 = stackalloc[] { 1 , 1 }; + int* data4 = stackalloc[]{ 1 , 1 }; + int* data5 = stackalloc[] +{ 1 , 1 }; + } + } +} +"; + + var fixedCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc[] { 1 , 1 }; + int* data2 = stackalloc[] { 1 , 1 }; + int* data3 = stackalloc[] { 1 , 1 }; + int* data4 = stackalloc[] { 1 , 1 }; + int* data5 = stackalloc[] +{ 1 , 1 }; + } + } +} +"; + + DiagnosticResult[] expected = + { + Diagnostic().WithArguments(" not", "preceded").WithLocation(7, 38), + Diagnostic().WithArguments(" not", "preceded").WithLocation(8, 38), + Diagnostic().WithArguments(string.Empty, "followed").WithLocation(8, 38), + Diagnostic().WithArguments(string.Empty, "followed").WithLocation(10, 37), + }; + + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1012CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1012CSharp7UnitTests.cs index 36c45ccb6..ebead0c25 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1012CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1012CSharp7UnitTests.cs @@ -1,11 +1,139 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.SpacingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Helpers.LanguageVersionTestExtensions; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1012OpeningBracesMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1012CSharp7UnitTests : SA1012UnitTests + { + [Fact] + public async Task TestStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc int[] { 1 , 1 }; + int* data2 = stackalloc int[] {1 , 1 }; + int* data3 = stackalloc int[]{ 1 , 1 }; + int* data4 = stackalloc int[]{1 , 1 }; + int* data5 = stackalloc int[] { +1 , 1 }; + int* data6 = stackalloc int[] + {1 , 1 }; + int* data7 = stackalloc int[] + { + 1 , 1 }; + } + } +} +"; + + var fixedCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc int[] { 1 , 1 }; + int* data2 = stackalloc int[] { 1 , 1 }; + int* data3 = stackalloc int[] { 1 , 1 }; + int* data4 = stackalloc int[] { 1 , 1 }; + int* data5 = stackalloc int[] { +1 , 1 }; + int* data6 = stackalloc int[] + { 1 , 1 }; + int* data7 = stackalloc int[] + { + 1 , 1 }; + } + } +} +"; - public class SA1012CSharp7UnitTests : SA1012UnitTests + DiagnosticResult[] expected = + { + Diagnostic().WithArguments(string.Empty, "followed").WithLocation(8, 43), + Diagnostic().WithArguments(string.Empty, "preceded").WithLocation(9, 42), + Diagnostic().WithArguments(string.Empty, "preceded").WithLocation(10, 42), + Diagnostic().WithArguments(string.Empty, "followed").WithLocation(10, 42), + Diagnostic().WithArguments(string.Empty, "followed").WithLocation(14, 13), + }; + + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestImplicitStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc[] { 1 , 1 }; + int* data2 = stackalloc[] {1 , 1 }; + int* data3 = stackalloc[]{ 1 , 1 }; + int* data4 = stackalloc[]{1 , 1 }; + int* data5 = stackalloc[] { +1 , 1 }; + int* data6 = stackalloc[] + {1 , 1 }; + int* data7 = stackalloc[] + { + 1 , 1 }; + } + } +} +"; + + var fixedCode = @"namespace TestNamespace +{ + public class TestClass { + public unsafe void TestMethod() + { + int* data1 = stackalloc[] { 1 , 1 }; + int* data2 = stackalloc[] { 1 , 1 }; + int* data3 = stackalloc[] { 1 , 1 }; + int* data4 = stackalloc[] { 1 , 1 }; + int* data5 = stackalloc[] { +1 , 1 }; + int* data6 = stackalloc[] + { 1 , 1 }; + int* data7 = stackalloc[] + { + 1 , 1 }; + } + } +} +"; + + DiagnosticResult[] expected = + { + Diagnostic().WithArguments(string.Empty, "followed").WithLocation(8, 39), + Diagnostic().WithArguments(string.Empty, "preceded").WithLocation(9, 38), + Diagnostic().WithArguments(string.Empty, "preceded").WithLocation(10, 38), + Diagnostic().WithArguments(string.Empty, "followed").WithLocation(10, 38), + Diagnostic().WithArguments(string.Empty, "followed").WithLocation(14, 13), + }; + + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1013CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1013CSharp7UnitTests.cs index e9a62dbbb..7472baa02 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1013CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1013CSharp7UnitTests.cs @@ -1,19 +1,20 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.SpacingRules; - using TestHelper; using Xunit; + using static StyleCop.Analyzers.Test.Helpers.LanguageVersionTestExtensions; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1013ClosingBracesMustBeSpacedCorrectly, StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; - public class SA1013CSharp7UnitTests : SA1013UnitTests + public partial class SA1013CSharp7UnitTests : SA1013UnitTests { /// /// Verifies spacing around a } character in tuple expressions. @@ -30,7 +31,7 @@ public class Foo { public void TestMethod() { - var values = (new[] { 3} , new[] { 3} ); + var values = (new[] { 3{|#0:}|} , new[] { 3{|#1:}|} ); } }"; const string fixedCode = @"using System; @@ -45,11 +46,125 @@ public void TestMethod() DiagnosticResult[] expected = { - Diagnostic().WithLocation(7, 32).WithArguments(string.Empty, "preceded"), - Diagnostic().WithLocation(7, 45).WithArguments(string.Empty, "preceded"), + Diagnostic().WithLocation(0).WithArguments(string.Empty, "preceded"), + Diagnostic().WithLocation(1).WithArguments(string.Empty, "preceded"), }; await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } + + [Fact] + public async Task TestStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc int[] { 1 , 1 } ; + int* data2 = stackalloc int[] { 1 , 1 }; + int* data3 = stackalloc int[] { 1 , 1{|#0:}|} ; + int* data4 = stackalloc int[] { 1 , 1{|#1:}|}; + int* data5 = stackalloc int[] { 1 , 1 +}; + int* data6 = stackalloc int[] + { 1 , 1{|#2:}|}; + int* data7 = stackalloc int[] + { + 1 , 1 } ; + } + } +} +"; + + var fixedCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc int[] { 1 , 1 } ; + int* data2 = stackalloc int[] { 1 , 1 }; + int* data3 = stackalloc int[] { 1 , 1 } ; + int* data4 = stackalloc int[] { 1 , 1 }; + int* data5 = stackalloc int[] { 1 , 1 +}; + int* data6 = stackalloc int[] + { 1 , 1 }; + int* data7 = stackalloc int[] + { + 1 , 1 } ; + } + } +} +"; + + DiagnosticResult[] expected = + { + Diagnostic().WithLocation(0).WithArguments(string.Empty, "preceded"), + Diagnostic().WithLocation(1).WithArguments(string.Empty, "preceded"), + Diagnostic().WithLocation(2).WithArguments(string.Empty, "preceded"), + }; + + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestImplicitStackAllocArrayCreationExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc[] { 1 , 1 } ; + int* data2 = stackalloc[] { 1 , 1 }; + int* data3 = stackalloc[] { 1 , 1{|#0:}|} ; + int* data4 = stackalloc[] { 1 , 1{|#1:}|}; + int* data5 = stackalloc[] { 1 , 1 +}; + int* data6 = stackalloc[] + { 1 , 1{|#2:}|}; + int* data7 = stackalloc[] + { + 1 , 1 } ; + } + } +} +"; + + var fixedCode = @"namespace TestNamespace +{ + public class TestClass + { + public unsafe void TestMethod() + { + int* data1 = stackalloc[] { 1 , 1 } ; + int* data2 = stackalloc[] { 1 , 1 }; + int* data3 = stackalloc[] { 1 , 1 } ; + int* data4 = stackalloc[] { 1 , 1 }; + int* data5 = stackalloc[] { 1 , 1 +}; + int* data6 = stackalloc[] + { 1 , 1 }; + int* data7 = stackalloc[] + { + 1 , 1 } ; + } + } +} +"; + + DiagnosticResult[] expected = + { + Diagnostic().WithLocation(0).WithArguments(string.Empty, "preceded"), + Diagnostic().WithLocation(1).WithArguments(string.Empty, "preceded"), + Diagnostic().WithLocation(2).WithArguments(string.Empty, "preceded"), + }; + + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1014CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1014CSharp7UnitTests.cs index 48e1e83cf..6b777bf3a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1014CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1014CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { using StyleCop.Analyzers.Test.SpacingRules; - public class SA1014CSharp7UnitTests : SA1014UnitTests + public partial class SA1014CSharp7UnitTests : SA1014UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1015CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1015CSharp7UnitTests.cs index 5ac08ae7b..3f12cd92e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1015CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1015CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { @@ -7,13 +9,13 @@ namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.SpacingRules; - using TestHelper; using Xunit; + using static StyleCop.Analyzers.SpacingRules.SA1015ClosingGenericBracketsMustBeSpacedCorrectly; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1015ClosingGenericBracketsMustBeSpacedCorrectly, StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; - public class SA1015CSharp7UnitTests : SA1015UnitTests + public partial class SA1015CSharp7UnitTests : SA1015UnitTests { /// /// Verifies spacing around a > character in tuple types. @@ -45,9 +47,9 @@ public void TestMethod() DiagnosticResult[] expected = { - Diagnostic().WithLocation(7, 19).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(7, 19).WithArguments(" not", "followed"), - Diagnostic().WithLocation(7, 32).WithArguments(" not", "preceded"), + Diagnostic(DescriptorNotPreceded).WithLocation(7, 19), + Diagnostic(DescriptorNotFollowed).WithLocation(7, 19), + Diagnostic(DescriptorNotPreceded).WithLocation(7, 32), }; await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1016CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1016CSharp7UnitTests.cs index 540d795dd..89545bc10 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1016CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1016CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { using StyleCop.Analyzers.Test.SpacingRules; - public class SA1016CSharp7UnitTests : SA1016UnitTests + public partial class SA1016CSharp7UnitTests : SA1016UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1017CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1017CSharp7UnitTests.cs index 94755aa8e..ffc64ad80 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1017CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1017CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { using StyleCop.Analyzers.Test.SpacingRules; - public class SA1017CSharp7UnitTests : SA1017UnitTests + public partial class SA1017CSharp7UnitTests : SA1017UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1018CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1018CSharp7UnitTests.cs index 42468be5a..ab27a9c85 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1018CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1018CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { @@ -11,7 +13,7 @@ namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules StyleCop.Analyzers.SpacingRules.SA1018NullableTypeSymbolsMustNotBePrecededBySpace, StyleCop.Analyzers.SpacingRules.SA1018CodeFixProvider>; - public class SA1018CSharp7UnitTests : SA1018UnitTests + public partial class SA1018CSharp7UnitTests : SA1018UnitTests { /// /// Verifies that nullable tuple types with different kinds of spacing will report. diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1019CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1019CSharp7UnitTests.cs index 50cff6948..694b6f7f2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1019CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1019CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { using StyleCop.Analyzers.Test.SpacingRules; - public class SA1019CSharp7UnitTests : SA1019UnitTests + public partial class SA1019CSharp7UnitTests : SA1019UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1020CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1020CSharp7UnitTests.cs index 9e3c43316..b83c058a2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1020CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1020CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { using StyleCop.Analyzers.Test.SpacingRules; - public class SA1020CSharp7UnitTests : SA1020UnitTests + public partial class SA1020CSharp7UnitTests : SA1020UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1021CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1021CSharp7UnitTests.cs index c1ec5c12c..0f5d77c5f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1021CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1021CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { using StyleCop.Analyzers.Test.SpacingRules; - public class SA1021CSharp7UnitTests : SA1021UnitTests + public partial class SA1021CSharp7UnitTests : SA1021UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1022CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1022CSharp7UnitTests.cs index 0add6a02d..ce6240b79 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1022CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1022CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { using StyleCop.Analyzers.Test.SpacingRules; - public class SA1022CSharp7UnitTests : SA1022UnitTests + public partial class SA1022CSharp7UnitTests : SA1022UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1023CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1023CSharp7UnitTests.cs index 32df5eb21..debcb346d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1023CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1023CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { using StyleCop.Analyzers.Test.SpacingRules; - public class SA1023CSharp7UnitTests : SA1023UnitTests + public partial class SA1023CSharp7UnitTests : SA1023UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1024CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1024CSharp7UnitTests.cs index 9c5bc6384..36e1a5e3e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1024CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1024CSharp7UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { @@ -7,13 +9,13 @@ namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.SpacingRules; - using TestHelper; using Xunit; + using static StyleCop.Analyzers.SpacingRules.SA1024ColonsMustBeSpacedCorrectly; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1024ColonsMustBeSpacedCorrectly, StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; - public class SA1024CSharp7UnitTests : SA1024UnitTests + public partial class SA1024CSharp7UnitTests : SA1024UnitTests { /// /// Verifies spacing around a : character in tuple expressions. @@ -43,10 +45,10 @@ public void TestMethod() DiagnosticResult[] expected = { - Diagnostic().WithLocation(7, 25).WithArguments(" not", "preceded", string.Empty), - Diagnostic().WithLocation(7, 25).WithArguments(string.Empty, "followed", string.Empty), - Diagnostic().WithLocation(7, 31).WithArguments(" not", "preceded", string.Empty), - Diagnostic().WithLocation(7, 31).WithArguments(string.Empty, "followed", string.Empty), + Diagnostic(DescriptorNotPreceded).WithLocation(7, 25), + Diagnostic(DescriptorFollowed).WithLocation(7, 25), + Diagnostic(DescriptorNotPreceded).WithLocation(7, 31), + Diagnostic(DescriptorFollowed).WithLocation(7, 31), }; await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -90,8 +92,8 @@ public void TestMethod() DiagnosticResult[] expected = { - Diagnostic().WithLocation(9, 35).WithArguments(" not", "preceded", string.Empty), - Diagnostic().WithLocation(11, 22).WithArguments(" not", "preceded", string.Empty), + Diagnostic(DescriptorNotPreceded).WithLocation(9, 35), + Diagnostic(DescriptorNotPreceded).WithLocation(11, 22), }; await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1025CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1025CSharp7UnitTests.cs index b5d707ddd..68404c70e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1025CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1025CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { using StyleCop.Analyzers.Test.SpacingRules; - public class SA1025CSharp7UnitTests : SA1025UnitTests + public partial class SA1025CSharp7UnitTests : SA1025UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1026CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1026CSharp7UnitTests.cs index 3df16135a..3c866385e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1026CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1026CSharp7UnitTests.cs @@ -1,11 +1,39 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.SpacingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Helpers.LanguageVersionTestExtensions; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1026CodeMustNotContainSpaceAfterNewKeywordInImplicitlyTypedArrayAllocation, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; - public class SA1026CSharp7UnitTests : SA1026UnitTests + public partial class SA1026CSharp7UnitTests : SA1026UnitTests { + [Theory] + [InlineData(" ")] + [InlineData(" ")] + [InlineData("\t")] + [InlineData("\r")] + [InlineData("\n")] + [InlineData("\r\n")] + [InlineData(" \t \r\n")] + [InlineData(" \t \r\n\t ")] + public async Task TestImplicitStackAllocArrayCreationExpressionAsync(string space) + { + string testCode = $"public class Foo {{ public unsafe Foo() {{ int* ints = stackalloc{space}[] {{ 1, 2, 3 }}; }} }}"; + const string expectedCode = "public class Foo { public unsafe Foo() { int* ints = stackalloc[] { 1, 2, 3 }; } }"; + DiagnosticResult[] expected = { Diagnostic().WithArguments("stackalloc").WithLocation(1, 54) }; + + await VerifyCSharpFixAsync(LanguageVersion.CSharp7_3.OrLaterDefault(), testCode, expected, expectedCode, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1027AlternateIndentationCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1027AlternateIndentationCSharp7UnitTests.cs index ce1b31e8b..1e4a26336 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1027AlternateIndentationCSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1027AlternateIndentationCSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { using StyleCop.Analyzers.Test.SpacingRules; - public class SA1027AlternateIndentationCSharp7UnitTests : SA1027AlternateIndentationUnitTests + public partial class SA1027AlternateIndentationCSharp7UnitTests : SA1027AlternateIndentationUnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1027CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1027CSharp7UnitTests.cs index fc2b0a8d3..4a2afc535 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1027CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1027CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { using StyleCop.Analyzers.Test.SpacingRules; - public class SA1027CSharp7UnitTests : SA1027UnitTests + public partial class SA1027CSharp7UnitTests : SA1027UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1027UseTabsCSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1027UseTabsCSharp7UnitTests.cs index 692749694..040e91a55 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1027UseTabsCSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1027UseTabsCSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { using StyleCop.Analyzers.Test.SpacingRules; - public class SA1027UseTabsCSharp7UnitTests : SA1027UseTabsUnitTests + public partial class SA1027UseTabsCSharp7UnitTests : SA1027UseTabsUnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1028CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1028CSharp7UnitTests.cs index cc9d5a7c5..f70738336 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1028CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpacingRules/SA1028CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.SpacingRules { using StyleCop.Analyzers.Test.SpacingRules; - public class SA1028CSharp7UnitTests : SA1028UnitTests + public partial class SA1028CSharp7UnitTests : SA1028UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpecialRules/SA0001CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpecialRules/SA0001CSharp7UnitTests.cs index dfca27249..71523176f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpecialRules/SA0001CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpecialRules/SA0001CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.SpecialRules { using StyleCop.Analyzers.Test.SpecialRules; - public class SA0001CSharp7UnitTests : SA0001UnitTests + public partial class SA0001CSharp7UnitTests : SA0001UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpecialRules/SA0002CSharp7UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpecialRules/SA0002CSharp7UnitTests.cs index 8a983f746..d72d3a892 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpecialRules/SA0002CSharp7UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/SpecialRules/SA0002CSharp7UnitTests.cs @@ -1,11 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.CSharp7.SpecialRules { using StyleCop.Analyzers.Test.SpecialRules; - public class SA0002CSharp7UnitTests : SA0002UnitTests + public partial class SA0002CSharp7UnitTests : SA0002UnitTests { } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/StyleCop.Analyzers.Test.CSharp7.csproj b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/StyleCop.Analyzers.Test.CSharp7.csproj index 8e5184399..dc7c46be7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/StyleCop.Analyzers.Test.CSharp7.csproj +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/StyleCop.Analyzers.Test.CSharp7.csproj @@ -3,6 +3,7 @@ net46 + false true true @@ -17,15 +18,22 @@ - - - + + + + + + + + + PreserveNewest + \ No newline at end of file diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/xunit.runner.json b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/xunit.runner.json new file mode 100644 index 000000000..aa59e4469 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/xunit.runner.json @@ -0,0 +1,3 @@ +{ + "shadowCopy": false +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/AnalyzerConfigurationCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/AnalyzerConfigurationCSharp8UnitTests.cs new file mode 100644 index 000000000..dd71a0f1c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/AnalyzerConfigurationCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8 +{ + using StyleCop.Analyzers.Test.CSharp7; + + public partial class AnalyzerConfigurationCSharp8UnitTests : AnalyzerConfigurationCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/InheritdocCodeFixProviderCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/InheritdocCodeFixProviderCSharp8UnitTests.cs new file mode 100644 index 000000000..2bf510f7a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/InheritdocCodeFixProviderCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class InheritdocCodeFixProviderCSharp8UnitTests : InheritdocCodeFixProviderCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/NoXmlFileHeaderCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/NoXmlFileHeaderCSharp8UnitTests.cs new file mode 100644 index 000000000..b6acb0c61 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/NoXmlFileHeaderCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class NoXmlFileHeaderCSharp8UnitTests : NoXmlFileHeaderCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1600CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1600CSharp8UnitTests.cs new file mode 100644 index 000000000..8f06ca41f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1600CSharp8UnitTests.cs @@ -0,0 +1,14 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1600CSharp8UnitTests : SA1600CSharp7UnitTests + { + // Using 'Default' here makes sure that later test projects also run these tests with their own language version, without having to override this property + protected override LanguageVersion LanguageVersion => LanguageVersion.Default; + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1601CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1601CSharp8UnitTests.cs new file mode 100644 index 000000000..5915f4a1b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1601CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1601CSharp8UnitTests : SA1601CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1602CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1602CSharp8UnitTests.cs new file mode 100644 index 000000000..c42f3e64d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1602CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1602CSharp8UnitTests : SA1602CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1603CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1603CSharp8UnitTests.cs new file mode 100644 index 000000000..e9418aecd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1603CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1603CSharp8UnitTests : SA1603CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1604CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1604CSharp8UnitTests.cs new file mode 100644 index 000000000..ab2122627 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1604CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1604CSharp8UnitTests : SA1604CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1605CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1605CSharp8UnitTests.cs new file mode 100644 index 000000000..f415423d0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1605CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1605CSharp8UnitTests : SA1605CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1606CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1606CSharp8UnitTests.cs new file mode 100644 index 000000000..8fe19d10b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1606CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1606CSharp8UnitTests : SA1606CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1607CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1607CSharp8UnitTests.cs new file mode 100644 index 000000000..da228dd10 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1607CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1607CSharp8UnitTests : SA1607CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1608CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1608CSharp8UnitTests.cs new file mode 100644 index 000000000..a215d7318 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1608CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1608CSharp8UnitTests : SA1608CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1609CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1609CSharp8UnitTests.cs new file mode 100644 index 000000000..3d2cbaa71 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1609CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1609CSharp8UnitTests : SA1609CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1610CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1610CSharp8UnitTests.cs new file mode 100644 index 000000000..ca9f99e05 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1610CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1610CSharp8UnitTests : SA1610CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1611CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1611CSharp8UnitTests.cs new file mode 100644 index 000000000..d3ee9199e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1611CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1611CSharp8UnitTests : SA1611CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1612CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1612CSharp8UnitTests.cs new file mode 100644 index 000000000..f6fc45ccd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1612CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1612CSharp8UnitTests : SA1612CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1613CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1613CSharp8UnitTests.cs new file mode 100644 index 000000000..d492a5058 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1613CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1613CSharp8UnitTests : SA1613CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1614CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1614CSharp8UnitTests.cs new file mode 100644 index 000000000..010e63daa --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1614CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1614CSharp8UnitTests : SA1614CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1615CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1615CSharp8UnitTests.cs new file mode 100644 index 000000000..a43316bdd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1615CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1615CSharp8UnitTests : SA1615CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1616CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1616CSharp8UnitTests.cs new file mode 100644 index 000000000..c7c1c7a93 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1616CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1616CSharp8UnitTests : SA1616CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1617CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1617CSharp8UnitTests.cs new file mode 100644 index 000000000..6c649265c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1617CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1617CSharp8UnitTests : SA1617CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1618CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1618CSharp8UnitTests.cs new file mode 100644 index 000000000..a997a5edb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1618CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1618CSharp8UnitTests : SA1618CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1619CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1619CSharp8UnitTests.cs new file mode 100644 index 000000000..638572a76 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1619CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1619CSharp8UnitTests : SA1619CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1620CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1620CSharp8UnitTests.cs new file mode 100644 index 000000000..63090a0a1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1620CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1620CSharp8UnitTests : SA1620CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1621CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1621CSharp8UnitTests.cs new file mode 100644 index 000000000..6ec251ca7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1621CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1621CSharp8UnitTests : SA1621CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1622CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1622CSharp8UnitTests.cs new file mode 100644 index 000000000..13ab7b84e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1622CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1622CSharp8UnitTests : SA1622CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1623CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1623CSharp8UnitTests.cs new file mode 100644 index 000000000..58a612de4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1623CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1623CSharp8UnitTests : SA1623CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1624CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1624CSharp8UnitTests.cs new file mode 100644 index 000000000..f486efe85 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1624CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1624CSharp8UnitTests : SA1624CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1625CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1625CSharp8UnitTests.cs new file mode 100644 index 000000000..4fbc7a7ab --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1625CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1625CSharp8UnitTests : SA1625CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1626CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1626CSharp8UnitTests.cs new file mode 100644 index 000000000..b306c1e4c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1626CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1626CSharp8UnitTests : SA1626CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1627CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1627CSharp8UnitTests.cs new file mode 100644 index 000000000..3a65bafb5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1627CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1627CSharp8UnitTests : SA1627CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1628CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1628CSharp8UnitTests.cs new file mode 100644 index 000000000..9d6a7e127 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1628CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1628CSharp8UnitTests : SA1628CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1629CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1629CSharp8UnitTests.cs new file mode 100644 index 000000000..bb6287f45 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1629CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1629CSharp8UnitTests : SA1629CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1630CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1630CSharp8UnitTests.cs new file mode 100644 index 000000000..2a5136cf6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1630CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1630CSharp8UnitTests : SA1630CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1631CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1631CSharp8UnitTests.cs new file mode 100644 index 000000000..e9dd1702d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1631CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1631CSharp8UnitTests : SA1631CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1632CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1632CSharp8UnitTests.cs new file mode 100644 index 000000000..def9954e3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1632CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1632CSharp8UnitTests : SA1632CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1633CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1633CSharp8UnitTests.cs new file mode 100644 index 000000000..a26bd000d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1633CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1633CSharp8UnitTests : SA1633CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1634CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1634CSharp8UnitTests.cs new file mode 100644 index 000000000..8cea9ccee --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1634CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1634CSharp8UnitTests : SA1634CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1635CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1635CSharp8UnitTests.cs new file mode 100644 index 000000000..1177e40bd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1635CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1635CSharp8UnitTests : SA1635CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1636CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1636CSharp8UnitTests.cs new file mode 100644 index 000000000..d119bcc5f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1636CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1636CSharp8UnitTests : SA1636CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1637CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1637CSharp8UnitTests.cs new file mode 100644 index 000000000..3573e1ad7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1637CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1637CSharp8UnitTests : SA1637CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1638CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1638CSharp8UnitTests.cs new file mode 100644 index 000000000..d533ed4e1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1638CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1638CSharp8UnitTests : SA1638CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1639CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1639CSharp8UnitTests.cs new file mode 100644 index 000000000..e418eec30 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1639CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1639CSharp8UnitTests : SA1639CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1640CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1640CSharp8UnitTests.cs new file mode 100644 index 000000000..c4458554b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1640CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1640CSharp8UnitTests : SA1640CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1641CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1641CSharp8UnitTests.cs new file mode 100644 index 000000000..975162264 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1641CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1641CSharp8UnitTests : SA1641CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1642CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1642CSharp8UnitTests.cs new file mode 100644 index 000000000..3e5deab1f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1642CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1642CSharp8UnitTests : SA1642CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1643CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1643CSharp8UnitTests.cs new file mode 100644 index 000000000..9de19d904 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1643CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1643CSharp8UnitTests : SA1643CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1644CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1644CSharp8UnitTests.cs new file mode 100644 index 000000000..3c0d333e8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1644CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1644CSharp8UnitTests : SA1644CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1645CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1645CSharp8UnitTests.cs new file mode 100644 index 000000000..71d0ad9b5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1645CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1645CSharp8UnitTests : SA1645CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1646CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1646CSharp8UnitTests.cs new file mode 100644 index 000000000..a10e28279 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1646CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1646CSharp8UnitTests : SA1646CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1647CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1647CSharp8UnitTests.cs new file mode 100644 index 000000000..08f89126f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1647CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1647CSharp8UnitTests : SA1647CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1648CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1648CSharp8UnitTests.cs new file mode 100644 index 000000000..82f21335f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1648CSharp8UnitTests.cs @@ -0,0 +1,39 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + using Xunit; + + public partial class SA1648CSharp8UnitTests : SA1648CSharp7UnitTests + { + [WorkItem(3595, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3595")] + [Theory] + [InlineData("void TestMethod() {}")] + [InlineData("int TestProperty { get; set; }")] + [InlineData("event System.Action TestEvent;")] + public async Task TestIncorrectMemberInheritDocFromStaticMemberInInterfaceAsync(string member) + { + var testCode = $@" +public interface TestInterface +{{ + /// + /// A summary text. + /// + static {member} +}} + +public class TestClass : TestInterface +{{ + /// [||] + public static {member} +}}"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1649CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1649CSharp8UnitTests.cs new file mode 100644 index 000000000..5bcbd9791 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1649CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1649CSharp8UnitTests : SA1649CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1650CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1650CSharp8UnitTests.cs new file mode 100644 index 000000000..1fb954762 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1650CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1650CSharp8UnitTests : SA1650CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1651CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1651CSharp8UnitTests.cs new file mode 100644 index 000000000..b3c2acee1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/DocumentationRules/SA1651CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp7.DocumentationRules; + + public partial class SA1651CSharp8UnitTests : SA1651CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/HelperTests/SymbolNameHelpersCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/HelperTests/SymbolNameHelpersCSharp8UnitTests.cs new file mode 100644 index 000000000..e7fc159fd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/HelperTests/SymbolNameHelpersCSharp8UnitTests.cs @@ -0,0 +1,66 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.HelperTests +{ + using System.Threading.Tasks; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using StyleCop.Analyzers.Test.CSharp7.HelperTests; + using Xunit; + + /// + /// Unit tests for the class in the context of C# 8.0. + /// + public partial class SymbolNameHelpersCSharp8UnitTests : SymbolNameHelpersCSharp7UnitTests + { + /// + /// Verify the workings of + /// for nullable reference types. + /// + /// A string representation of a type or namespace to process. + /// if is a namespace; + /// if is a type to be used as an alias target. + /// A representing the asynchronous unit test. + [Theory] + [InlineData("System.ValueTuple")] + [InlineData("System.ValueTuple")] + [InlineData("System.ValueTuple")] + [InlineData("System.ValueTuple")] + [InlineData("System.ValueTuple")] + [InlineData("System.ValueTuple")] + [InlineData("System.ValueTuple")] + [InlineData("System.ValueTuple")] + [InlineData("System.ValueTuple")] + [InlineData("System.ValueTuple")] + [InlineData("System.ValueTuple")] + [InlineData("System.Collections.Generic.KeyValuePair")] + [InlineData("System.Collections.Generic.KeyValuePair")] + [InlineData("System.Collections.Generic.KeyValuePair")] + [InlineData("System.Collections.Generic.KeyValuePair")] + [InlineData("System.Collections.Generic.KeyValuePair")] + [InlineData("System.Collections.Generic.KeyValuePair")] + [InlineData("System.Collections.Generic.KeyValuePair")] + [InlineData("System.Collections.Generic.KeyValuePair")] + [InlineData("System.Nullable<(int, object?)>")] + [WorkItem(3149, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3149")] + public Task VerifyToQualifiedStringNullableReferenceTypesAsync(string inputString, bool isNamespace = false) + { + return this.PerformTestAsync(inputString, isNamespace); + } + + /// + /// Provides a instance with enabled nullable reference types + /// to be used for the test project in the workspace. + /// + /// An instance of describing the project compilation options. + protected override CSharpCompilationOptions GetCompilationOptions() + { + return new CSharpCompilationOptions( + OutputKind.DynamicallyLinkedLibrary, nullableContextOptions: NullableContextOptions.Enable); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1500CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1500CSharp8UnitTests.cs new file mode 100644 index 000000000..6e9dca68c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1500CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp7.LayoutRules; + + public partial class SA1500CSharp8UnitTests : SA1500CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1501CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1501CSharp8UnitTests.cs new file mode 100644 index 000000000..9b2ad5faa --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1501CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp7.LayoutRules; + + public partial class SA1501CSharp8UnitTests : SA1501CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1502CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1502CSharp8UnitTests.cs new file mode 100644 index 000000000..40ce2dc62 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1502CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp7.LayoutRules; + + public partial class SA1502CSharp8UnitTests : SA1502CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1503CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1503CSharp8UnitTests.cs new file mode 100644 index 000000000..b24c99a48 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1503CSharp8UnitTests.cs @@ -0,0 +1,36 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.LayoutRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp7.LayoutRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.LayoutRules.SA1503BracesMustNotBeOmitted, + StyleCop.Analyzers.LayoutRules.SA1503CodeFixProvider>; + + public partial class SA1503CSharp8UnitTests : SA1503CSharp7UnitTests + { + [Fact] + [WorkItem(3074, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3074")] + public async Task TestNoDiagnosticForUsingDeclarationStatementAsync() + { + var testCode = @" +using System.IO; +public class Foo +{ + public void Method() + { + using var v = new MemoryStream(); + } +}"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1504CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1504CSharp8UnitTests.cs new file mode 100644 index 000000000..822485a7c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1504CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp7.LayoutRules; + + public partial class SA1504CSharp8UnitTests : SA1504CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1505CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1505CSharp8UnitTests.cs new file mode 100644 index 000000000..4cb22056f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1505CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp7.LayoutRules; + + public partial class SA1505CSharp8UnitTests : SA1505CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1506CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1506CSharp8UnitTests.cs new file mode 100644 index 000000000..ec7574ed9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1506CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp7.LayoutRules; + + public partial class SA1506CSharp8UnitTests : SA1506CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1507CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1507CSharp8UnitTests.cs new file mode 100644 index 000000000..412ffed6d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1507CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp7.LayoutRules; + + public partial class SA1507CSharp8UnitTests : SA1507CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1508CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1508CSharp8UnitTests.cs new file mode 100644 index 000000000..4c9cb6290 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1508CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp7.LayoutRules; + + public partial class SA1508CSharp8UnitTests : SA1508CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1509CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1509CSharp8UnitTests.cs new file mode 100644 index 000000000..2de494f11 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1509CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp7.LayoutRules; + + public partial class SA1509CSharp8UnitTests : SA1509CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1510CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1510CSharp8UnitTests.cs new file mode 100644 index 000000000..8193647b2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1510CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp7.LayoutRules; + + public partial class SA1510CSharp8UnitTests : SA1510CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1511CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1511CSharp8UnitTests.cs new file mode 100644 index 000000000..94f2421a7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1511CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp7.LayoutRules; + + public partial class SA1511CSharp8UnitTests : SA1511CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1512CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1512CSharp8UnitTests.cs new file mode 100644 index 000000000..6044e6f79 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1512CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp7.LayoutRules; + + public partial class SA1512CSharp8UnitTests : SA1512CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1513CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1513CSharp8UnitTests.cs new file mode 100644 index 000000000..f9ab08448 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1513CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp7.LayoutRules; + + public partial class SA1513CSharp8UnitTests : SA1513CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1514CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1514CSharp8UnitTests.cs new file mode 100644 index 000000000..b9d6cb1ba --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1514CSharp8UnitTests.cs @@ -0,0 +1,43 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.LayoutRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp7.LayoutRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.LayoutRules.SA1514ElementDocumentationHeaderMustBePrecededByBlankLine, + StyleCop.Analyzers.LayoutRules.SA1514CodeFixProvider>; + + public partial class SA1514CSharp8UnitTests : SA1514CSharp7UnitTests + { + [Fact] + [WorkItem(3067, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3067")] + public async Task TestValidPropertyDeclarationAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + /// + /// Gets or sets the value. + /// + public string SomeString { get; set; } = null!; + + /// + /// Gets or sets the value. + /// + public string AnotherString { get; set; } = null!; + } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1515CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1515CSharp8UnitTests.cs new file mode 100644 index 000000000..be1a4e640 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1515CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp7.LayoutRules; + + public partial class SA1515CSharp8UnitTests : SA1515CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1516CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1516CSharp8UnitTests.cs new file mode 100644 index 000000000..2e4e29b60 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1516CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp7.LayoutRules; + + public partial class SA1516CSharp8UnitTests : SA1516CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1516UsingGroupsCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1516UsingGroupsCSharp8UnitTests.cs new file mode 100644 index 000000000..690957c49 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1516UsingGroupsCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp7.LayoutRules; + + public partial class SA1516UsingGroupsCSharp8UnitTests : SA1516UsingGroupsCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1517CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1517CSharp8UnitTests.cs new file mode 100644 index 000000000..834606cab --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1517CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp7.LayoutRules; + + public partial class SA1517CSharp8UnitTests : SA1517CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1518CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1518CSharp8UnitTests.cs new file mode 100644 index 000000000..385782732 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1518CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp7.LayoutRules; + + public partial class SA1518CSharp8UnitTests : SA1518CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1519CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1519CSharp8UnitTests.cs new file mode 100644 index 000000000..acb03b3e7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1519CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp7.LayoutRules; + + public partial class SA1519CSharp8UnitTests : SA1519CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1520CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1520CSharp8UnitTests.cs new file mode 100644 index 000000000..99e1cc487 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/LayoutRules/SA1520CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp7.LayoutRules; + + public partial class SA1520CSharp8UnitTests : SA1520CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/AccessorDeclarationSyntaxExtensionsCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/AccessorDeclarationSyntaxExtensionsCSharp8UnitTests.cs new file mode 100644 index 000000000..5b3b5fb89 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/AccessorDeclarationSyntaxExtensionsCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class AccessorDeclarationSyntaxExtensionsCSharp8UnitTests : AccessorDeclarationSyntaxExtensionsCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/ArgumentSyntaxExtensionsCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/ArgumentSyntaxExtensionsCSharp8UnitTests.cs new file mode 100644 index 000000000..166f69bcb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/ArgumentSyntaxExtensionsCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class ArgumentSyntaxExtensionsCSharp8UnitTests : ArgumentSyntaxExtensionsCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/BaseMethodDeclarationSyntaxExtensionsCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/BaseMethodDeclarationSyntaxExtensionsCSharp8UnitTests.cs new file mode 100644 index 000000000..fb089484e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/BaseMethodDeclarationSyntaxExtensionsCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class BaseMethodDeclarationSyntaxExtensionsCSharp8UnitTests : BaseMethodDeclarationSyntaxExtensionsCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/CasePatternSwitchLabelSyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/CasePatternSwitchLabelSyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..8055e962b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/CasePatternSwitchLabelSyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class CasePatternSwitchLabelSyntaxWrapperCSharp8UnitTests : CasePatternSwitchLabelSyntaxWrapperCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/CommonForEachStatementSyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/CommonForEachStatementSyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..93d29e6ce --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/CommonForEachStatementSyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,189 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class CommonForEachStatementSyntaxWrapperCSharp8UnitTests + { + [Fact] + public void TestNull() + { + var syntaxNode = default(SyntaxNode); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Null(wrapper.SyntaxNode); + Assert.Throws(() => wrapper.AwaitKeyword); + Assert.Throws(() => wrapper.ForEachKeyword); + Assert.Throws(() => wrapper.OpenParenToken); + Assert.Throws(() => wrapper.InKeyword); + Assert.Throws(() => wrapper.Expression); + Assert.Throws(() => wrapper.CloseParenToken); + Assert.Throws(() => wrapper.Statement); + Assert.Throws(() => wrapper.WithAwaitKeyword(SyntaxFactory.Token(SyntaxKind.AwaitKeyword))); + Assert.Throws(() => wrapper.WithForEachKeyword(SyntaxFactory.Token(SyntaxKind.ForEachKeyword))); + Assert.Throws(() => wrapper.WithOpenParenToken(SyntaxFactory.Token(SyntaxKind.OpenParenToken))); + Assert.Throws(() => wrapper.WithInKeyword(SyntaxFactory.Token(SyntaxKind.InKeyword))); + Assert.Throws(() => wrapper.WithExpression(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + Assert.Throws(() => wrapper.WithCloseParenToken(SyntaxFactory.Token(SyntaxKind.CloseParenToken))); + Assert.Throws(() => wrapper.WithStatement(SyntaxFactory.EmptyStatement())); + } + + [Fact] + public void TestWrapperIdentity() + { + var syntaxNode = this.CreateForEachStatement(); + Assert.True(syntaxNode.IsKind(SyntaxKind.ForEachStatement)); + + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Same(syntaxNode, wrapper.SyntaxNode); + } + + [Fact] + public void TestAwaitKeyword() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Equal(default, wrapper.AwaitKeyword); + + wrapper = wrapper.WithAwaitKeyword(SpacingExtensions.WithoutTrivia(SyntaxFactory.Token(SyntaxKind.AwaitKeyword))); + Assert.NotNull(wrapper.SyntaxNode); + Assert.NotSame(syntaxNode, wrapper.SyntaxNode); + Assert.False(syntaxNode.AwaitKeyword.IsEquivalentTo(wrapper.AwaitKeyword)); + } + + [Fact] + public void TestForEachKeyword() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Equal(syntaxNode.ForEachKeyword, wrapper.ForEachKeyword); + + wrapper = wrapper.WithForEachKeyword(SpacingExtensions.WithoutTrivia(SyntaxFactory.Token(SyntaxKind.ForEachKeyword))); + Assert.NotNull(wrapper.SyntaxNode); + Assert.NotSame(syntaxNode, wrapper.SyntaxNode); + Assert.False(syntaxNode.ForEachKeyword.IsEquivalentTo(wrapper.ForEachKeyword)); + } + + [Fact] + public void TestOpenParenToken() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Equal(syntaxNode.OpenParenToken, wrapper.OpenParenToken); + + wrapper = wrapper.WithOpenParenToken(SpacingExtensions.WithoutTrivia(SyntaxFactory.Token(SyntaxKind.OpenParenToken))); + Assert.NotNull(wrapper.SyntaxNode); + Assert.NotSame(syntaxNode, wrapper.SyntaxNode); + Assert.False(syntaxNode.OpenParenToken.IsEquivalentTo(wrapper.OpenParenToken)); + } + + [Fact] + public void TestInKeyword() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Equal(syntaxNode.InKeyword, wrapper.InKeyword); + + wrapper = wrapper.WithInKeyword(SpacingExtensions.WithoutTrivia(SyntaxFactory.Token(SyntaxKind.InKeyword))); + Assert.NotNull(wrapper.SyntaxNode); + Assert.NotSame(syntaxNode, wrapper.SyntaxNode); + Assert.False(syntaxNode.InKeyword.IsEquivalentTo(wrapper.InKeyword)); + } + + [Fact] + public void TestExpression() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Same(syntaxNode.Expression, wrapper.Expression); + + wrapper = wrapper.WithExpression(SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal(0))); + Assert.NotNull(wrapper.SyntaxNode); + Assert.NotSame(syntaxNode, wrapper.SyntaxNode); + Assert.NotSame(syntaxNode.Expression, wrapper.Expression); + Assert.False(syntaxNode.Expression.IsEquivalentTo(wrapper.Expression)); + } + + [Fact] + public void TestCloseParenToken() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Equal(syntaxNode.CloseParenToken, wrapper.CloseParenToken); + + wrapper = wrapper.WithCloseParenToken(SpacingExtensions.WithoutTrivia(SyntaxFactory.Token(SyntaxKind.CloseParenToken))); + Assert.NotNull(wrapper.SyntaxNode); + Assert.NotSame(syntaxNode, wrapper.SyntaxNode); + Assert.False(syntaxNode.CloseParenToken.IsEquivalentTo(wrapper.CloseParenToken)); + } + + [Fact] + public void TestStatement() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Same(syntaxNode.Statement, wrapper.Statement); + + wrapper = wrapper.WithStatement(SyntaxFactory.Block()); + Assert.NotNull(wrapper.SyntaxNode); + Assert.NotSame(syntaxNode, wrapper.SyntaxNode); + Assert.NotSame(syntaxNode.Statement, wrapper.Statement); + Assert.False(syntaxNode.Statement.IsEquivalentTo(wrapper.Statement)); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(CommonForEachStatementSyntaxWrapper.IsInstance(null)); + Assert.False(CommonForEachStatementSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + + var syntaxNode = this.CreateForEachStatement(); + Assert.True(CommonForEachStatementSyntaxWrapper.IsInstance(syntaxNode)); + } + + [Fact] + public void TestConversionsNull() + { + var syntaxNode = default(SyntaxNode); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + + StatementSyntax syntax = wrapper; + Assert.Null(syntax); + } + + [Fact] + public void TestConversions() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + + StatementSyntax syntax = wrapper; + Assert.Same(syntaxNode, syntax); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (CommonForEachStatementSyntaxWrapper)syntaxNode); + } + + private ForEachStatementSyntax CreateForEachStatement() + { + return SyntaxFactory.ForEachStatement( + SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword)), + "x", + SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression), + SyntaxFactory.EmptyStatement()); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/ConstantPatternSyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/ConstantPatternSyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..538d4b40d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/ConstantPatternSyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class ConstantPatternSyntaxWrapperCSharp8UnitTests : ConstantPatternSyntaxWrapperCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/ConstructorDeclarationSyntaxExtensionsCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/ConstructorDeclarationSyntaxExtensionsCSharp8UnitTests.cs new file mode 100644 index 000000000..263e1b600 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/ConstructorDeclarationSyntaxExtensionsCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class ConstructorDeclarationSyntaxExtensionsCSharp8UnitTests : ConstructorDeclarationSyntaxExtensionsCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/CrefParameterSyntaxExtensionsCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/CrefParameterSyntaxExtensionsCSharp8UnitTests.cs new file mode 100644 index 000000000..76fada855 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/CrefParameterSyntaxExtensionsCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class CrefParameterSyntaxExtensionsCSharp8UnitTests : CrefParameterSyntaxExtensionsCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/DeclarationExpressionSyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/DeclarationExpressionSyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..9dd442081 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/DeclarationExpressionSyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class DeclarationExpressionSyntaxWrapperCSharp8UnitTests : DeclarationExpressionSyntaxWrapperCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/DeclarationPatternSyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/DeclarationPatternSyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..85fee6b3e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/DeclarationPatternSyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class DeclarationPatternSyntaxWrapperCSharp8UnitTests : DeclarationPatternSyntaxWrapperCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/DestructorDeclarationSyntaxExtensionsCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/DestructorDeclarationSyntaxExtensionsCSharp8UnitTests.cs new file mode 100644 index 000000000..fe31338f5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/DestructorDeclarationSyntaxExtensionsCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class DestructorDeclarationSyntaxExtensionsCSharp8UnitTests : DestructorDeclarationSyntaxExtensionsCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/DiscardDesignationSyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/DiscardDesignationSyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..bd58f7b2a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/DiscardDesignationSyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class DiscardDesignationSyntaxWrapperCSharp8UnitTests : DiscardDesignationSyntaxWrapperCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..0862bce43 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp8UnitTests : ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/IsPatternExpressionSyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/IsPatternExpressionSyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..c62d04d21 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/IsPatternExpressionSyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class IsPatternExpressionSyntaxWrapperCSharp8UnitTests : IsPatternExpressionSyntaxWrapperCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/LanguageVersionExCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/LanguageVersionExCSharp8UnitTests.cs new file mode 100644 index 000000000..02f3b1328 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/LanguageVersionExCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class LanguageVersionExCSharp8UnitTests : LanguageVersionExCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/LightupHelpersCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/LightupHelpersCSharp8UnitTests.cs new file mode 100644 index 000000000..f555cec2a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/LightupHelpersCSharp8UnitTests.cs @@ -0,0 +1,20 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Lightup; + using StyleCop.Analyzers.Test.CSharp7.Lightup; + using StyleCop.Analyzers.Test.Lightup; + + /// + /// This class tests edge case behavior of in Roslyn 2+. It extends + /// since the tests defined there are valid in both environments without + /// alteration. + /// + public partial class LightupHelpersCSharp8UnitTests : LightupHelpersCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/LocalFunctionStatementSyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/LocalFunctionStatementSyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..517438789 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/LocalFunctionStatementSyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class LocalFunctionStatementSyntaxWrapperCSharp8UnitTests : LocalFunctionStatementSyntaxWrapperCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/MethodKindExCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/MethodKindExCSharp8UnitTests.cs new file mode 100644 index 000000000..a24e962a5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/MethodKindExCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class MethodKindExCSharp8UnitTests : MethodKindExCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/OperationKindExCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/OperationKindExCSharp8UnitTests.cs new file mode 100644 index 000000000..8d4c7305a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/OperationKindExCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class OperationKindExCSharp8UnitTests : OperationKindExCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/ParenthesizedVariableDesignationSyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/ParenthesizedVariableDesignationSyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..6cb134f09 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/ParenthesizedVariableDesignationSyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class ParenthesizedVariableDesignationSyntaxWrapperCSharp8UnitTests : ParenthesizedVariableDesignationSyntaxWrapperCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/PatternSyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/PatternSyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..03755cf02 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/PatternSyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class PatternSyntaxWrapperCSharp8UnitTests : PatternSyntaxWrapperCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/RefExpressionSyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/RefExpressionSyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..4c1dc65a2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/RefExpressionSyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class RefExpressionSyntaxWrapperCSharp8UnitTests : RefExpressionSyntaxWrapperCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/RefTypeSyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/RefTypeSyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..cae76f955 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/RefTypeSyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class RefTypeSyntaxWrapperCSharp8UnitTests : RefTypeSyntaxWrapperCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/SingleVariableDesignationSyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/SingleVariableDesignationSyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..e01276511 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/SingleVariableDesignationSyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class SingleVariableDesignationSyntaxWrapperCSharp8UnitTests : SingleVariableDesignationSyntaxWrapperCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/StackAllocArrayCreationExpressionSyntaxExtensionsCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/StackAllocArrayCreationExpressionSyntaxExtensionsCSharp8UnitTests.cs new file mode 100644 index 000000000..dcfa5e472 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/StackAllocArrayCreationExpressionSyntaxExtensionsCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class StackAllocArrayCreationExpressionSyntaxExtensionsCSharp8UnitTests : StackAllocArrayCreationExpressionSyntaxExtensionsCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/SwitchExpressionArmSyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/SwitchExpressionArmSyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..471ad4a42 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/SwitchExpressionArmSyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,115 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using StyleCop.Analyzers.Lightup; + using StyleCop.Analyzers.Test.CSharp7.Lightup; + using Xunit; + + public partial class SwitchExpressionArmSyntaxWrapperCSharp8UnitTests : SwitchExpressionArmSyntaxWrapperCSharp7UnitTests + { + [Fact] + public void TestSyntaxNodeProperty() + { + var syntaxNode = this.CreateSwitchExpressionArm(); + + Assert.True(syntaxNode.IsKind(SyntaxKind.SwitchExpressionArm)); + Assert.True(syntaxNode.IsKind(SyntaxKindEx.SwitchExpressionArm)); + + var wrapper = (SwitchExpressionArmSyntaxWrapper)syntaxNode; + Assert.Same(syntaxNode, wrapper.SyntaxNode); + } + + [Fact] + public void TestPatternProperty() + { + var syntaxNode = this.CreateSwitchExpressionArm(); + + var wrapper = (SwitchExpressionArmSyntaxWrapper)syntaxNode; + Assert.Same(syntaxNode.Pattern, wrapper.Pattern.SyntaxNode); + + var newPattern = SyntaxFactory.ConstantPattern(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)); + var wrapperWithModifiedPattern = wrapper.WithPattern((PatternSyntaxWrapper)newPattern); + Assert.NotNull(wrapperWithModifiedPattern.SyntaxNode); + Assert.NotSame(syntaxNode.Pattern, wrapperWithModifiedPattern.Pattern.SyntaxNode); + Assert.True(newPattern.IsEquivalentTo(wrapperWithModifiedPattern.Pattern)); + } + + [Fact] + public void TestWhenClauseProperty() + { + var syntaxNode = this.CreateSwitchExpressionArm(); + + var wrapper = (SwitchExpressionArmSyntaxWrapper)syntaxNode; + Assert.Same(syntaxNode.WhenClause, wrapper.WhenClause.SyntaxNode); + + var newWhenClause = SyntaxFactory.WhenClause(SyntaxFactory.LiteralExpression(SyntaxKind.TrueLiteralExpression)); + var wrapperWithModifiedWhenClause = wrapper.WithWhenClause((WhenClauseSyntaxWrapper)newWhenClause); + Assert.NotNull(wrapperWithModifiedWhenClause.SyntaxNode); + Assert.NotSame(syntaxNode.WhenClause, wrapperWithModifiedWhenClause.WhenClause.SyntaxNode); + Assert.True(newWhenClause.IsEquivalentTo(wrapperWithModifiedWhenClause.WhenClause)); + } + + [Fact] + public void TestExpressionProperty() + { + var syntaxNode = this.CreateSwitchExpressionArm(); + + var wrapper = (SwitchExpressionArmSyntaxWrapper)syntaxNode; + Assert.Same(syntaxNode.Expression, wrapper.Expression); + + var newExpression = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + var wrapperWithModifiedExpression = wrapper.WithExpression(newExpression); + Assert.NotNull(wrapperWithModifiedExpression.SyntaxNode); + Assert.NotSame(syntaxNode.Expression, wrapperWithModifiedExpression.Expression); + Assert.True(newExpression.IsEquivalentTo(wrapperWithModifiedExpression.Expression)); + } + + [Fact] + public void TestEqualsGreaterThanTokenProperty() + { + var syntaxNode = this.CreateSwitchExpressionArm(); + + var wrapper = (SwitchExpressionArmSyntaxWrapper)syntaxNode; + + Assert.Equal(syntaxNode.EqualsGreaterThanToken, wrapper.EqualsGreaterThanToken); + + Assert.Throws(() => wrapper.WithEqualsGreaterThanToken(SyntaxFactory.Token(SyntaxKind.EqualsEqualsToken))); + + var newToken = SyntaxFactory.Token(SyntaxTriviaList.Create(SyntaxFactory.SyntaxTrivia(SyntaxKind.SingleLineCommentTrivia, "/* 1 */")), SyntaxKind.EqualsGreaterThanToken, SyntaxTriviaList.Empty); + var wrapperWithModifiedToken = wrapper.WithEqualsGreaterThanToken(newToken); + Assert.True(newToken.IsEquivalentTo(wrapperWithModifiedToken.EqualsGreaterThanToken)); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(SwitchExpressionArmSyntaxWrapper.IsInstance(null)); + Assert.False(SwitchExpressionArmSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + + Assert.True(SwitchExpressionArmSyntaxWrapper.IsInstance(this.CreateSwitchExpressionArm())); + } + + [Fact] + public void TestConversions() + { + var syntaxNode = this.CreateSwitchExpressionArm(); + var wrapper = (SwitchExpressionArmSyntaxWrapper)syntaxNode; + + CSharpSyntaxNode syntax = wrapper; + Assert.Same(syntaxNode, syntax); + } + + private SwitchExpressionArmSyntax CreateSwitchExpressionArm() + => SyntaxFactory.SwitchExpressionArm( + SyntaxFactory.DiscardPattern(), + SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression)); + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/SwitchExpressionSyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/SwitchExpressionSyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..374208711 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/SwitchExpressionSyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,139 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using System.Linq; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using StyleCop.Analyzers.Lightup; + using StyleCop.Analyzers.Test.CSharp7.Lightup; + using Xunit; + + public partial class SwitchExpressionSyntaxWrapperCSharp8UnitTests : SwitchExpressionSyntaxWrapperCSharp7UnitTests + { + [Fact] + public void TestSyntaxNodeProperty() + { + var switchExpression = this.CreateSwitchExpression(); + + Assert.True(switchExpression.IsKind(SyntaxKind.SwitchExpression)); + Assert.True(switchExpression.IsKind(SyntaxKindEx.SwitchExpression)); + + var wrapper = (SwitchExpressionSyntaxWrapper)switchExpression; + Assert.Same(switchExpression, wrapper.SyntaxNode); + } + + [Fact] + public void TestArmsProperty() + { + var switchExpression = this.CreateSwitchExpression(); + + var wrapper = (SwitchExpressionSyntaxWrapper)switchExpression; + Assert.Single(switchExpression.Arms); + Assert.Single(wrapper.Arms); + Assert.Same(switchExpression.Arms[0], wrapper.Arms[0].SyntaxNode); + + var arm = SyntaxFactory.SwitchExpressionArm( + SyntaxFactory.ConstantPattern(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)), + SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression)); + var arms = SyntaxFactory.SingletonSeparatedList(arm); + + var wrapperWithArms = wrapper.WithArms(new SeparatedSyntaxListWrapper.AutoWrapSeparatedSyntaxList(arms)); + Assert.Single(wrapperWithArms.Arms); + Assert.True(arm.IsEquivalentTo(wrapperWithArms.Arms.Single())); + } + + [Fact] + public void TestGoverningExpressionProperty() + { + var switchExpression = this.CreateSwitchExpression(); + + var wrapper = (SwitchExpressionSyntaxWrapper)switchExpression; + Assert.Same(switchExpression.GoverningExpression, wrapper.GoverningExpression); + + var newGoverningExpression = SyntaxFactory.IdentifierName("x"); + var wrapperWithGoverningExpression = wrapper.WithGoverningExpression(newGoverningExpression); + + Assert.True(newGoverningExpression.IsEquivalentTo(wrapperWithGoverningExpression.GoverningExpression)); + } + + [Fact] + public void TestOpenBraceTokenProperty() + { + var switchExpression = this.CreateSwitchExpression(); + + var wrapper = (SwitchExpressionSyntaxWrapper)switchExpression; + Assert.Equal(switchExpression.OpenBraceToken, wrapper.OpenBraceToken); + + var newOpenBraceToken = SyntaxFactory.Token( + SyntaxTriviaList.Create(SyntaxFactory.SyntaxTrivia(SyntaxKind.SingleLineCommentTrivia, "/* 1 */")), + SyntaxKind.OpenBraceToken, + SyntaxTriviaList.Empty); + var wrapperWithOpenBrace = wrapper.WithOpenBraceToken(newOpenBraceToken); + Assert.True(newOpenBraceToken.IsEquivalentTo(wrapperWithOpenBrace.OpenBraceToken)); + } + + [Fact] + public void TestSwitchKeywordProperty() + { + var switchExpression = this.CreateSwitchExpression(); + + var wrapper = (SwitchExpressionSyntaxWrapper)switchExpression; + Assert.Equal(switchExpression.SwitchKeyword, wrapper.SwitchKeyword); + + var newSwitchKeyword = SyntaxFactory.Token( + SyntaxTriviaList.Create(SyntaxFactory.SyntaxTrivia(SyntaxKind.SingleLineCommentTrivia, "/* 1 */")), + SyntaxKind.SwitchKeyword, + SyntaxTriviaList.Empty); + var wrapperWithSwitchKeyword = wrapper.WithSwitchKeyword(newSwitchKeyword); + Assert.True(newSwitchKeyword.IsEquivalentTo(wrapperWithSwitchKeyword.SwitchKeyword)); + } + + [Fact] + public void TestCloseBraceTokenProperty() + { + var switchExpression = this.CreateSwitchExpression(); + + var wrapper = (SwitchExpressionSyntaxWrapper)switchExpression; + Assert.Equal(switchExpression.CloseBraceToken, wrapper.CloseBraceToken); + + var newCloseBraceToken = SyntaxFactory.Token( + SyntaxTriviaList.Create(SyntaxFactory.SyntaxTrivia(SyntaxKind.SingleLineCommentTrivia, "/* 1 */")), + SyntaxKind.CloseBraceToken, + SyntaxTriviaList.Empty); + var wrapperWithCloseBrace = wrapper.WithCloseBraceToken(newCloseBraceToken); + Assert.True(newCloseBraceToken.IsEquivalentTo(wrapperWithCloseBrace.CloseBraceToken)); + } + + [Fact] + public void TestIsInstanceTrue() + { + var switchExpression = this.CreateSwitchExpression(); + Assert.True(SwitchExpressionSyntaxWrapper.IsInstance(switchExpression)); + } + + [Fact] + public void TestConversions() + { + var switchExpressionSyntax = this.CreateSwitchExpression(); + var wrapper = (SwitchExpressionSyntaxWrapper)switchExpressionSyntax; + + CSharpSyntaxNode syntax = wrapper; + Assert.Same(switchExpressionSyntax, syntax); + } + + private SwitchExpressionSyntax CreateSwitchExpression() + => SyntaxFactory.SwitchExpression( + SyntaxFactory.IdentifierName(SyntaxFactory.Identifier("type")), + SyntaxFactory.SeparatedList(new[] { this.CreateSwitchExpressionArm() })); + + private SwitchExpressionArmSyntax CreateSwitchExpressionArm() + => SyntaxFactory.SwitchExpressionArm( + SyntaxFactory.DiscardPattern(), + SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression)); + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/SyntaxKindExCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/SyntaxKindExCSharp8UnitTests.cs new file mode 100644 index 000000000..bbb48a835 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/SyntaxKindExCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class SyntaxKindExCSharp8UnitTests : SyntaxKindExCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/SyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/SyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..0a9a23853 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/SyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class SyntaxWrapperCSharp8UnitTests : SyntaxWrapperCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/SyntaxWrapperHelperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/SyntaxWrapperHelperCSharp8UnitTests.cs new file mode 100644 index 000000000..b7c1b3aad --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/SyntaxWrapperHelperCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class SyntaxWrapperHelperCSharp8UnitTests : SyntaxWrapperHelperCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/ThrowExpressionSyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/ThrowExpressionSyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..378fc9984 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/ThrowExpressionSyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class ThrowExpressionSyntaxWrapperCSharp8UnitTests : ThrowExpressionSyntaxWrapperCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/TupleElementSyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/TupleElementSyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..66ead12ea --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/TupleElementSyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class TupleElementSyntaxWrapperCSharp8UnitTests : TupleElementSyntaxWrapperCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/TupleExpressionSyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/TupleExpressionSyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..7f28fbb4b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/TupleExpressionSyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class TupleExpressionSyntaxWrapperCSharp8UnitTests : TupleExpressionSyntaxWrapperCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/TupleTypeSyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/TupleTypeSyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..7cbd2f5aa --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/TupleTypeSyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class TupleTypeSyntaxWrapperCSharp8UnitTests : TupleTypeSyntaxWrapperCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/VariableDesignationSyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/VariableDesignationSyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..5c5fa6929 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/VariableDesignationSyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class VariableDesignationSyntaxWrapperCSharp8UnitTests : VariableDesignationSyntaxWrapperCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/WhenClauseSyntaxWrapperCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/WhenClauseSyntaxWrapperCSharp8UnitTests.cs new file mode 100644 index 000000000..d8bd59755 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Lightup/WhenClauseSyntaxWrapperCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Lightup +{ + using StyleCop.Analyzers.Test.CSharp7.Lightup; + + public partial class WhenClauseSyntaxWrapperCSharp8UnitTests : WhenClauseSyntaxWrapperCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1119CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1119CSharp8UnitTests.cs new file mode 100644 index 000000000..176071c3c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1119CSharp8UnitTests.cs @@ -0,0 +1,332 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules; + + using Xunit; + + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.MaintainabilityRules.SA1119StatementMustNotUseUnnecessaryParenthesis, + StyleCop.Analyzers.MaintainabilityRules.SA1119CodeFixProvider>; + + public partial class SA1119CSharp8UnitTests : SA1119CSharp7UnitTests + { + /// + /// Verifies that a type cast followed by a switch expression is handled correctly. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3171, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3171")] + public async Task TestTypeCastFollowedBySwitchExpressionIsHandledCorrectlyAsync() + { + const string testCode = @" +public class Foo +{ + public string TestMethod(int n, object a, object b) + { + return (string)(n switch { 1 => a, 2 => b }); + } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that a type cast followed by a switch expression with unnecessary parenthesis is handled correctly. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3171, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3171")] + public async Task TestTypeCastFollowedBySwitchExpressionWithUnnecessaryParenthesisIsHandledCorrectlyAsync() + { + const string testCode = @" +public class Foo +{ + public string TestMethod(int n, object a, object b) + { + return (string)((n switch { 1 => a, 2 => b })); + } +} +"; + + const string fixedCode = @" +public class Foo +{ + public string TestMethod(int n, object a, object b) + { + return (string)(n switch { 1 => a, 2 => b }); + } +} +"; + + DiagnosticResult[] expected = + { + Diagnostic(DiagnosticId).WithSpan(6, 24, 6, 55), + Diagnostic(ParenthesesDiagnosticId).WithLocation(6, 24), + Diagnostic(ParenthesesDiagnosticId).WithLocation(6, 54), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that followed by a switch expression is handled correctly. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3460, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3460")] + public async Task TestAwaitFollowedBySwitchExpressionIsHandledCorrectlyAsync() + { + const string testCode = @" +using System.Threading.Tasks; + +public class Foo +{ + public async Task TestMethod(int n, Task a, Task b) + { + return await (n switch { 1 => a, 2 => b }); + } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that followed by a switch expression with unnecessary parenthesis is handled correctly. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3460, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3460")] + public async Task TestAwaitFollowedBySwitchExpressionWithUnnecessaryParenthesisIsHandledCorrectlyAsync() + { + const string testCode = @" +using System.Threading.Tasks; + +public class Foo +{ + public async Task TestMethod(int n, Task a, Task b) + { + return await {|#0:{|#1:(|}(n switch { 1 => a, 2 => b }){|#2:)|}|}; + } +} +"; + + const string fixedCode = @" +using System.Threading.Tasks; + +public class Foo +{ + public async Task TestMethod(int n, Task a, Task b) + { + return await (n switch { 1 => a, 2 => b }); + } +} +"; + + DiagnosticResult[] expected = + { + Diagnostic(DiagnosticId).WithLocation(0), + Diagnostic(ParenthesesDiagnosticId).WithLocation(1), + Diagnostic(ParenthesesDiagnosticId).WithLocation(2), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that a switch expression with unnecessary parenthesis is handled correcly. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3171, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3171")] + public async Task TestSwitchExpressionWithUnnecessaryParenthesisAsync() + { + const string testCode = @" +public class Foo +{ + public void TestMethod(int n, object a, object b) + { + var test = (n switch { 1 => a, 2 => b }); + } +} +"; + + const string fixedCode = @" +public class Foo +{ + public void TestMethod(int n, object a, object b) + { + var test = n switch { 1 => a, 2 => b }; + } +} +"; + + DiagnosticResult[] expected = + { + Diagnostic(DiagnosticId).WithSpan(6, 20, 6, 49), + Diagnostic(ParenthesesDiagnosticId).WithLocation(6, 20), + Diagnostic(ParenthesesDiagnosticId).WithLocation(6, 48), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Theory] + [InlineData(".ToString()")] + [InlineData("?.ToString()")] + [InlineData("[0]")] + [InlineData("?[0]")] + [WorkItem(3171, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3171")] + public async Task TestSwitchExpressionFollowedByDereferenceAsync(string operation) + { + string testCode = $@" +public class Foo +{{ + public object TestMethod(int n, string a, string b) + {{ + return (n switch {{ 1 => a, 2 => b }}){operation}; + }} +}} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3171, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3171")] + public async Task TestSwitchExpressionFollowedByPointerDereferenceAsync() + { + string testCode = @" +public class Foo +{ + public unsafe string TestMethod(int n, byte* a, byte* b) + { + return (n switch { 1 => a, 2 => b })->ToString(); + } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3730, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3730")] + public async Task TestSwitchExpressionFollowedByInvocationAsync() + { + string testCode = @" +using System; + +public class Foo +{ + public string TestMethod(int n, Func a, Func b) + { + return (n switch { 1 => a, 2 => b })(); + } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestStackAllocExpressionInExpressionAsync() + { + const string testCode = @"public class TestClass +{ + public unsafe void TestMethod() + { + var ptr1 = stackalloc byte[1]; + var span1 = (stackalloc byte[1]); + var ptr2 = stackalloc[] { 0 }; + var span2 = (stackalloc[] { 0 }); + } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3370, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3370")] + public async Task TestRangeFollowedByMemberCallAsync() + { + const string testCode = @"using System; + +public class TestClass +{ + public void TestMethod() + { + var array = (1..10).ToString(); + } +} +"; + + await new CSharpTest() + { + ReferenceAssemblies = ReferenceAssemblies.NetCore.NetCoreApp31, + TestCode = testCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3370, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3370")] + public async Task TestRangeAsync() + { + const string testCode = @"using System; + +public class TestClass +{ + public void TestMethod() + { + var a = new int[0]; + var b = a[(..)]; + var range = (1..10); + } +} +"; + + const string fixedCode = @"using System; + +public class TestClass +{ + public void TestMethod() + { + var a = new int[0]; + var b = a[..]; + var range = 1..10; + } +} +"; + + DiagnosticResult[] expected = + { + Diagnostic(DiagnosticId).WithSpan(8, 19, 8, 23), + Diagnostic(ParenthesesDiagnosticId).WithLocation(8, 19), + Diagnostic(ParenthesesDiagnosticId).WithLocation(8, 22), + Diagnostic(DiagnosticId).WithSpan(9, 21, 9, 28), + Diagnostic(ParenthesesDiagnosticId).WithLocation(9, 21), + Diagnostic(ParenthesesDiagnosticId).WithLocation(9, 27), + }; + + var test = new CSharpTest() + { + ReferenceAssemblies = ReferenceAssemblies.NetCore.NetCoreApp31, + TestCode = testCode, + FixedCode = fixedCode, + }; + test.ExpectedDiagnostics.AddRange(expected); + + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1400CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1400CSharp8UnitTests.cs new file mode 100644 index 000000000..f9c174b8b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1400CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules; + + public partial class SA1400CSharp8UnitTests : SA1400CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1401CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1401CSharp8UnitTests.cs new file mode 100644 index 000000000..bcffe2ee6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1401CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules; + + public partial class SA1401CSharp8UnitTests : SA1401CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1402ForClassCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1402ForClassCSharp8UnitTests.cs new file mode 100644 index 000000000..9087471f5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1402ForClassCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules; + + public partial class SA1402ForClassCSharp8UnitTests : SA1402ForClassCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1402ForDelegateCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1402ForDelegateCSharp8UnitTests.cs new file mode 100644 index 000000000..603cb2007 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1402ForDelegateCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules; + + public partial class SA1402ForDelegateCSharp8UnitTests : SA1402ForDelegateCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1402ForEnumCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1402ForEnumCSharp8UnitTests.cs new file mode 100644 index 000000000..b8f99f638 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1402ForEnumCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules; + + public partial class SA1402ForEnumCSharp8UnitTests : SA1402ForEnumCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1402ForInterfaceCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1402ForInterfaceCSharp8UnitTests.cs new file mode 100644 index 000000000..df025251b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1402ForInterfaceCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules; + + public partial class SA1402ForInterfaceCSharp8UnitTests : SA1402ForInterfaceCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1402ForStructCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1402ForStructCSharp8UnitTests.cs new file mode 100644 index 000000000..b8b12c589 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1402ForStructCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules; + + public partial class SA1402ForStructCSharp8UnitTests : SA1402ForStructCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1403CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1403CSharp8UnitTests.cs new file mode 100644 index 000000000..bc3f151a4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1403CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules; + + public partial class SA1403CSharp8UnitTests : SA1403CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1404CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1404CSharp8UnitTests.cs new file mode 100644 index 000000000..7c87ae9d2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1404CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules; + + public partial class SA1404CSharp8UnitTests : SA1404CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1405CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1405CSharp8UnitTests.cs new file mode 100644 index 000000000..fd641b943 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1405CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules; + + public partial class SA1405CSharp8UnitTests : SA1405CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1406CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1406CSharp8UnitTests.cs new file mode 100644 index 000000000..db8e4cd17 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1406CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules; + + public partial class SA1406CSharp8UnitTests : SA1406CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1407CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1407CSharp8UnitTests.cs new file mode 100644 index 000000000..ca2bc0ad5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1407CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules; + + public partial class SA1407CSharp8UnitTests : SA1407CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1408CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1408CSharp8UnitTests.cs new file mode 100644 index 000000000..2ae88f114 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1408CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules; + + public partial class SA1408CSharp8UnitTests : SA1408CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1409CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1409CSharp8UnitTests.cs new file mode 100644 index 000000000..f5dcf03dc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1409CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules; + + public partial class SA1409CSharp8UnitTests : SA1409CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1410CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1410CSharp8UnitTests.cs new file mode 100644 index 000000000..f3b9b6018 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1410CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules; + + public partial class SA1410CSharp8UnitTests : SA1410CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1411CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1411CSharp8UnitTests.cs new file mode 100644 index 000000000..31e86d8d3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1411CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules; + + public partial class SA1411CSharp8UnitTests : SA1411CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1412CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1412CSharp8UnitTests.cs new file mode 100644 index 000000000..5723401f1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1412CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules; + + public partial class SA1412CSharp8UnitTests : SA1412CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1413CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1413CSharp8UnitTests.cs new file mode 100644 index 000000000..08a63d281 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1413CSharp8UnitTests.cs @@ -0,0 +1,62 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.MaintainabilityRules.SA1413UseTrailingCommasInMultiLineInitializers, + StyleCop.Analyzers.MaintainabilityRules.SA1413CodeFixProvider>; + + public partial class SA1413CSharp8UnitTests : SA1413CSharp7UnitTests + { + [Fact] + [WorkItem(3056, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3056")] + public async Task TestSwitchExpressionAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public void TestMethod(int input) + { + int data1 = input switch { 0 => 1, 1 => 2 }; + int data2 = input switch { 0 => 1, 1 => 2, }; + int data3 = input switch + { + 0 => 1, + [|1 => 2|] + }; + } + } +} +"; + + var fixedCode = @"namespace TestNamespace +{ + public class TestClass + { + public void TestMethod(int input) + { + int data1 = input switch { 0 => 1, 1 => 2 }; + int data2 = input switch { 0 => 1, 1 => 2, }; + int data3 = input switch + { + 0 => 1, + 1 => 2, + }; + } + } +} +"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1414CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1414CSharp8UnitTests.cs new file mode 100644 index 000000000..db729916b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/MaintainabilityRules/SA1414CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.MaintainabilityRules; + + public partial class SA1414CSharp8UnitTests : SA1414CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1300CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1300CSharp8UnitTests.cs new file mode 100644 index 000000000..0a683cfda --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1300CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp7.NamingRules; + + public partial class SA1300CSharp8UnitTests : SA1300CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1301CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1301CSharp8UnitTests.cs new file mode 100644 index 000000000..c694d08c4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1301CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp7.NamingRules; + + public partial class SA1301CSharp8UnitTests : SA1301CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1302CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1302CSharp8UnitTests.cs new file mode 100644 index 000000000..381ff45e6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1302CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp7.NamingRules; + + public partial class SA1302CSharp8UnitTests : SA1302CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1303CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1303CSharp8UnitTests.cs new file mode 100644 index 000000000..975be7b89 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1303CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp7.NamingRules; + + public partial class SA1303CSharp8UnitTests : SA1303CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1304CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1304CSharp8UnitTests.cs new file mode 100644 index 000000000..e9a6a8a09 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1304CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp7.NamingRules; + + public partial class SA1304CSharp8UnitTests : SA1304CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1305CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1305CSharp8UnitTests.cs new file mode 100644 index 000000000..1de87ab2f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1305CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp7.NamingRules; + + public partial class SA1305CSharp8UnitTests : SA1305CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1306CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1306CSharp8UnitTests.cs new file mode 100644 index 000000000..1d59e1371 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1306CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp7.NamingRules; + + public partial class SA1306CSharp8UnitTests : SA1306CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1307CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1307CSharp8UnitTests.cs new file mode 100644 index 000000000..43a4c36bf --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1307CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp7.NamingRules; + + public partial class SA1307CSharp8UnitTests : SA1307CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1308CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1308CSharp8UnitTests.cs new file mode 100644 index 000000000..901ba7cd6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1308CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp7.NamingRules; + + public partial class SA1308CSharp8UnitTests : SA1308CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1309CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1309CSharp8UnitTests.cs new file mode 100644 index 000000000..c3147322e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1309CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp7.NamingRules; + + public partial class SA1309CSharp8UnitTests : SA1309CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1310CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1310CSharp8UnitTests.cs new file mode 100644 index 000000000..07d273ff4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1310CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp7.NamingRules; + + public partial class SA1310CSharp8UnitTests : SA1310CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1311CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1311CSharp8UnitTests.cs new file mode 100644 index 000000000..014cdf13a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1311CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp7.NamingRules; + + public partial class SA1311CSharp8UnitTests : SA1311CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1312CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1312CSharp8UnitTests.cs new file mode 100644 index 000000000..0655df382 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1312CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp7.NamingRules; + + public partial class SA1312CSharp8UnitTests : SA1312CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1313CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1313CSharp8UnitTests.cs new file mode 100644 index 000000000..37032ad83 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1313CSharp8UnitTests.cs @@ -0,0 +1,24 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.NamingRules +{ + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp7.NamingRules; + + public partial class SA1313CSharp8UnitTests : SA1313CSharp7UnitTests + { + protected override DiagnosticResult[] GetInvalidMethodOverrideShouldNotProduceDiagnosticAsyncDiagnostics() + { + return new DiagnosticResult[] + { + DiagnosticResult.CompilerError("CS0534").WithLocation(9, 18).WithMessage("'TestClass' does not implement inherited abstract member 'BaseClass.TestMethod(int, int)'"), + DiagnosticResult.CompilerError("CS0246").WithLocation(11, 49).WithMessage("The type or namespace name 'X' could not be found (are you missing a using directive or an assembly reference?)"), + DiagnosticResult.CompilerError("CS1001").WithLocation(11, 51).WithMessage("Identifier expected"), + DiagnosticResult.CompilerError("CS1003").WithLocation(11, 51).WithMessage("Syntax error, ',' expected"), + }; + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1314CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1314CSharp8UnitTests.cs new file mode 100644 index 000000000..ecbe1541a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1314CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp7.NamingRules; + + public partial class SA1314CSharp8UnitTests : SA1314CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1316CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1316CSharp8UnitTests.cs new file mode 100644 index 000000000..be18301c8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SA1316CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp7.NamingRules; + + public partial class SA1316CSharp8UnitTests : SA1316CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SX1309CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SX1309CSharp8UnitTests.cs new file mode 100644 index 000000000..fb1517e84 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SX1309CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp7.NamingRules; + + public partial class SX1309CSharp8UnitTests : SX1309CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SX1309SCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SX1309SCSharp8UnitTests.cs new file mode 100644 index 000000000..e73c3d6e9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/NamingRules/SX1309SCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp7.NamingRules; + + public partial class SX1309SCSharp8UnitTests : SX1309SCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1200CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1200CSharp8UnitTests.cs new file mode 100644 index 000000000..0ffb4941e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1200CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class SA1200CSharp8UnitTests : SA1200CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1200OutsideNamespaceCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1200OutsideNamespaceCSharp8UnitTests.cs new file mode 100644 index 000000000..bb093832f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1200OutsideNamespaceCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class SA1200OutsideNamespaceCSharp8UnitTests : SA1200OutsideNamespaceCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1200PreserveCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1200PreserveCSharp8UnitTests.cs new file mode 100644 index 000000000..3e8a11d6c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1200PreserveCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class SA1200PreserveCSharp8UnitTests : SA1200PreserveCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1201CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1201CSharp8UnitTests.cs new file mode 100644 index 000000000..78960c377 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1201CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class SA1201CSharp8UnitTests : SA1201CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1202CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1202CSharp8UnitTests.cs new file mode 100644 index 000000000..64e4db6ff --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1202CSharp8UnitTests.cs @@ -0,0 +1,61 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using System.Threading; + using System.Threading.Tasks; + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.OrderingRules.SA1202ElementsMustBeOrderedByAccess, + StyleCop.Analyzers.OrderingRules.ElementOrderCodeFixProvider>; + + public partial class SA1202CSharp8UnitTests : SA1202CSharp7UnitTests + { + /// + /// Verifies that the analyzer will properly handle property access levels. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task TestPropertiesOfInterfaceAsync() + { + var testCode = @"public interface TestClass +{ + private string TestProperty1 { get { return """"; } set { } } + protected string {|#0:TestProperty2|} { get; set; } + protected internal string {|#1:TestProperty3|} { get; set; } + internal string {|#2:TestProperty4|} { get; set; } + public string {|#3:TestProperty5|} { get; set; } + string TestProperty0 { get; set; } +} +"; + + var fixedCode = @"public interface TestClass +{ + public string TestProperty5 { get; set; } + string TestProperty0 { get; set; } + internal string TestProperty4 { get; set; } + protected internal string TestProperty3 { get; set; } + protected string TestProperty2 { get; set; } + private string TestProperty1 { get { return """"; } set { } } +} +"; + + await new CSharpTest + { + TestCode = testCode, + ExpectedDiagnostics = + { + Diagnostic().WithLocation(0).WithArguments("protected", "private"), + Diagnostic().WithLocation(1).WithArguments("protected internal", "protected"), + Diagnostic().WithLocation(2).WithArguments("internal", "protected internal"), + Diagnostic().WithLocation(3).WithArguments("public", "internal"), + }, + FixedCode = fixedCode, + NumberOfIncrementalIterations = 5, + NumberOfFixAllIterations = 2, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1203CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1203CSharp8UnitTests.cs new file mode 100644 index 000000000..37886c713 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1203CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class SA1203CSharp8UnitTests : SA1203CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1204CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1204CSharp8UnitTests.cs new file mode 100644 index 000000000..a2f8caefa --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1204CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class SA1204CSharp8UnitTests : SA1204CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1205CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1205CSharp8UnitTests.cs new file mode 100644 index 000000000..15d2055e0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1205CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class SA1205CSharp8UnitTests : SA1205CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1206CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1206CSharp8UnitTests.cs new file mode 100644 index 000000000..63f88cd27 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1206CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class SA1206CSharp8UnitTests : SA1206CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1206CodeFixProviderCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1206CodeFixProviderCSharp8UnitTests.cs new file mode 100644 index 000000000..18f5b599f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1206CodeFixProviderCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class SA1206CodeFixProviderCSharp8UnitTests : SA1206CodeFixProviderCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1207CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1207CSharp8UnitTests.cs new file mode 100644 index 000000000..c847cd98b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1207CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class SA1207CSharp8UnitTests : SA1207CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1208CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1208CSharp8UnitTests.cs new file mode 100644 index 000000000..67b62cf99 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1208CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class SA1208CSharp8UnitTests : SA1208CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1209CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1209CSharp8UnitTests.cs new file mode 100644 index 000000000..758862fc5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1209CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class SA1209CSharp8UnitTests : SA1209CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1210CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1210CSharp8UnitTests.cs new file mode 100644 index 000000000..cefca6134 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1210CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class SA1210CSharp8UnitTests : SA1210CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1210CombinedSystemDirectivesCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1210CombinedSystemDirectivesCSharp8UnitTests.cs new file mode 100644 index 000000000..d51d0c167 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1210CombinedSystemDirectivesCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class SA1210CombinedSystemDirectivesCSharp8UnitTests : SA1210CombinedSystemDirectivesCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1211CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1211CSharp8UnitTests.cs new file mode 100644 index 000000000..6bc92d9a2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1211CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class SA1211CSharp8UnitTests : SA1211CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1212CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1212CSharp8UnitTests.cs new file mode 100644 index 000000000..4e1a7fc9d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1212CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class SA1212CSharp8UnitTests : SA1212CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1213CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1213CSharp8UnitTests.cs new file mode 100644 index 000000000..9750b834b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1213CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class SA1213CSharp8UnitTests : SA1213CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1214CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1214CSharp8UnitTests.cs new file mode 100644 index 000000000..9ebf41395 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1214CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class SA1214CSharp8UnitTests : SA1214CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1215CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1215CSharp8UnitTests.cs new file mode 100644 index 000000000..c95e5696e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1215CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class SA1215CSharp8UnitTests : SA1215CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1216CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1216CSharp8UnitTests.cs new file mode 100644 index 000000000..8f5ca1be4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1216CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class SA1216CSharp8UnitTests : SA1216CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1217CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1217CSharp8UnitTests.cs new file mode 100644 index 000000000..d73b0696d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/SA1217CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class SA1217CSharp8UnitTests : SA1217CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/UsingCodeFixProviderCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/UsingCodeFixProviderCSharp8UnitTests.cs new file mode 100644 index 000000000..4ff8773b0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/UsingCodeFixProviderCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class UsingCodeFixProviderCSharp8UnitTests : UsingCodeFixProviderCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/UsingCodeFixProviderCombinedSystemDirectivesCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/UsingCodeFixProviderCombinedSystemDirectivesCSharp8UnitTests.cs new file mode 100644 index 000000000..f3c897b76 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/UsingCodeFixProviderCombinedSystemDirectivesCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class UsingCodeFixProviderCombinedSystemDirectivesCSharp8UnitTests : UsingCodeFixProviderCombinedSystemDirectivesCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/UsingCodeFixProviderGroupSeparationCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/UsingCodeFixProviderGroupSeparationCSharp8UnitTests.cs new file mode 100644 index 000000000..6f6d99d98 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/UsingCodeFixProviderGroupSeparationCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class UsingCodeFixProviderGroupSeparationCSharp8UnitTests : UsingCodeFixProviderGroupSeparationCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/UsingCodeFixProviderRegressionCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/UsingCodeFixProviderRegressionCSharp8UnitTests.cs new file mode 100644 index 000000000..03ec8e1bb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/OrderingRules/UsingCodeFixProviderRegressionCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp7.OrderingRules; + + public partial class UsingCodeFixProviderRegressionCSharp8UnitTests : UsingCodeFixProviderRegressionCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Properties/AssemblyInfo.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..7aa23cdbb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Properties/AssemblyInfo.cs @@ -0,0 +1,18 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: CLSCompliant(false)] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp9, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp10, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1100CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1100CSharp8UnitTests.cs new file mode 100644 index 000000000..d8187c1b4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1100CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1100CSharp8UnitTests : SA1100CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1101CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1101CSharp8UnitTests.cs new file mode 100644 index 000000000..574609702 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1101CSharp8UnitTests.cs @@ -0,0 +1,35 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.ReadabilityRules.SA1101PrefixLocalCallsWithThis, + StyleCop.Analyzers.ReadabilityRules.SA1101CodeFixProvider>; + + public partial class SA1101CSharp8UnitTests : SA1101CSharp7UnitTests + { + [Fact] + [WorkItem(3472, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3472")] + public async Task TestPropertyPatternAsync() + { + var testCode = @"public class Test +{ + public Test Inner; + public string Value; + + public bool Method(Test arg) + { + return arg is { Value: """" }; + } +}"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1102CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1102CSharp8UnitTests.cs new file mode 100644 index 000000000..7c0efbbc2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1102CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1102CSharp8UnitTests : SA1102CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1103CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1103CSharp8UnitTests.cs new file mode 100644 index 000000000..ead25a88f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1103CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1103CSharp8UnitTests : SA1103CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1104CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1104CSharp8UnitTests.cs new file mode 100644 index 000000000..3afafa153 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1104CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1104CSharp8UnitTests : SA1104CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1105CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1105CSharp8UnitTests.cs new file mode 100644 index 000000000..63197f1b3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1105CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1105CSharp8UnitTests : SA1105CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1106CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1106CSharp8UnitTests.cs new file mode 100644 index 000000000..75053c29b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1106CSharp8UnitTests.cs @@ -0,0 +1,36 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.ReadabilityRules.SA1106CodeMustNotContainEmptyStatements, + StyleCop.Analyzers.ReadabilityRules.SA1106CodeFixProvider>; + + public partial class SA1106CSharp8UnitTests : SA1106CSharp7UnitTests + { + [Fact] + [WorkItem(3075, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3075")] + public async Task TestNoDiagnosticForUsingDeclarationStatementAsync() + { + var testCode = @" +using System.IO; +public class Foo +{ + public void Method() + { + using var v = new MemoryStream(); + } +}"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1107CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1107CSharp8UnitTests.cs new file mode 100644 index 000000000..d05b3b8b7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1107CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1107CSharp8UnitTests : SA1107CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1108CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1108CSharp8UnitTests.cs new file mode 100644 index 000000000..315b8fb62 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1108CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1108CSharp8UnitTests : SA1108CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1109CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1109CSharp8UnitTests.cs new file mode 100644 index 000000000..2335f87a0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1109CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1109CSharp8UnitTests : SA1109CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1110CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1110CSharp8UnitTests.cs new file mode 100644 index 000000000..e0e4469f4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1110CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1110CSharp8UnitTests : SA1110CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1111CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1111CSharp8UnitTests.cs new file mode 100644 index 000000000..edb327d34 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1111CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1111CSharp8UnitTests : SA1111CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1112CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1112CSharp8UnitTests.cs new file mode 100644 index 000000000..6f37898ab --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1112CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1112CSharp8UnitTests : SA1112CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1113CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1113CSharp8UnitTests.cs new file mode 100644 index 000000000..2cca0735a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1113CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1113CSharp8UnitTests : SA1113CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1114CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1114CSharp8UnitTests.cs new file mode 100644 index 000000000..f1a4ab46d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1114CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1114CSharp8UnitTests : SA1114CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1115CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1115CSharp8UnitTests.cs new file mode 100644 index 000000000..df2a27f2c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1115CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1115CSharp8UnitTests : SA1115CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1116CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1116CSharp8UnitTests.cs new file mode 100644 index 000000000..babc7d804 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1116CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1116CSharp8UnitTests : SA1116CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1117CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1117CSharp8UnitTests.cs new file mode 100644 index 000000000..daaf27422 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1117CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1117CSharp8UnitTests : SA1117CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1118CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1118CSharp8UnitTests.cs new file mode 100644 index 000000000..90f0bd84f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1118CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1118CSharp8UnitTests : SA1118CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1120CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1120CSharp8UnitTests.cs new file mode 100644 index 000000000..26430be2f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1120CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1120CSharp8UnitTests : SA1120CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1121CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1121CSharp8UnitTests.cs new file mode 100644 index 000000000..6c2c3898d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1121CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1121CSharp8UnitTests : SA1121CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1122CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1122CSharp8UnitTests.cs new file mode 100644 index 000000000..e37a99688 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1122CSharp8UnitTests.cs @@ -0,0 +1,96 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.ReadabilityRules.SA1122UseStringEmptyForEmptyStrings, + StyleCop.Analyzers.ReadabilityRules.SA1122CodeFixProvider>; + + public partial class SA1122CSharp8UnitTests : SA1122CSharp7UnitTests + { + /// + /// Verifies the analyzer will properly handle an empty string in a switch expression. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3028, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3028")] + public async Task TestEmptyStringInSwitchExpressionAsync() + { + string testCode = @" +public class TestClass +{ + public void TestMethod(string condition) + { + _ = [|""""|] switch + { + """" when condition == [|""""|] => + 0, + ("""" + ""a"") when condition == [|""""|] => + 0, + }; + } +} +"; + string fixedCode = @" +public class TestClass +{ + public void TestMethod(string condition) + { + _ = string.Empty switch + { + """" when condition == string.Empty => + 0, + ("""" + ""a"") when condition == string.Empty => + 0, + }; + } +} +"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3028, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3028")] + public async Task TestEmptyStringInTuplePatternAsync() + { + string testCode = @" +public class TestClass +{ + public bool TestMethod((string, string) condition) + { + return condition is ("""", null); + } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3028, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3028")] + public async Task TestEmptyStringInRecursivePatternAsync() + { + string testCode = @" +using System.Collections.Generic; +public class TestClass +{ + public bool TestMethod(KeyValuePair condition) + { + return condition is { Key: """" }; + } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1123CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1123CSharp8UnitTests.cs new file mode 100644 index 000000000..d85a4807d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1123CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1123CSharp8UnitTests : SA1123CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1124CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1124CSharp8UnitTests.cs new file mode 100644 index 000000000..612732720 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1124CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1124CSharp8UnitTests : SA1124CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1125CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1125CSharp8UnitTests.cs new file mode 100644 index 000000000..7c8b79e4f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1125CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1125CSharp8UnitTests : SA1125CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1126CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1126CSharp8UnitTests.cs new file mode 100644 index 000000000..933092e64 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1126CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1126CSharp8UnitTests : SA1126CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1127CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1127CSharp8UnitTests.cs new file mode 100644 index 000000000..68f3f0626 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1127CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1127CSharp8UnitTests : SA1127CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1128CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1128CSharp8UnitTests.cs new file mode 100644 index 000000000..6b0f1575c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1128CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1128CSharp8UnitTests : SA1128CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1129CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1129CSharp8UnitTests.cs new file mode 100644 index 000000000..c1b22a4a4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1129CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1129CSharp8UnitTests : SA1129CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1130CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1130CSharp8UnitTests.cs new file mode 100644 index 000000000..ef4838880 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1130CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1130CSharp8UnitTests : SA1130CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1131CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1131CSharp8UnitTests.cs new file mode 100644 index 000000000..d81d67a7f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1131CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1131CSharp8UnitTests : SA1131CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1132CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1132CSharp8UnitTests.cs new file mode 100644 index 000000000..7ed020612 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1132CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1132CSharp8UnitTests : SA1132CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1133CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1133CSharp8UnitTests.cs new file mode 100644 index 000000000..e9bf82c01 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1133CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1133CSharp8UnitTests : SA1133CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1134CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1134CSharp8UnitTests.cs new file mode 100644 index 000000000..a03cf71b1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1134CSharp8UnitTests.cs @@ -0,0 +1,23 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using System.Threading.Tasks; + + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1134CSharp8UnitTests : SA1134CSharp7UnitTests + { + /// + public override Task VerifyInvalidMemberSyntaxInCodeFixAsync() + { + // Making this test a dummy, as the 3.6.0 compiler actually parses the invalid syntax + // into a valid AttributeSyntaxList, with an attribute named ';' (which is an invalid name). + // Because of this, the code fix no longer fails, but it ofcourse produces garbage. + return Task.CompletedTask; + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1135CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1135CSharp8UnitTests.cs new file mode 100644 index 000000000..a5f1a229e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1135CSharp8UnitTests.cs @@ -0,0 +1,32 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.ReadabilityRules.SA1135UsingDirectivesMustBeQualified, + StyleCop.Analyzers.ReadabilityRules.SA1135CodeFixProvider>; + + public partial class SA1135CSharp8UnitTests : SA1135CSharp7UnitTests + { + [Fact] + [WorkItem(3149, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3149")] + public async Task TestAliasTypeGenericNullableReferenceTypeAsync() + { + var testCode = @" +namespace TestNamespace +{ + using KeyValue = System.Collections.Generic.KeyValuePair; +} +"; + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1136CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1136CSharp8UnitTests.cs new file mode 100644 index 000000000..7f3441a5c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1136CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1136CSharp8UnitTests : SA1136CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1137CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1137CSharp8UnitTests.cs new file mode 100644 index 000000000..228da84b1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1137CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1137CSharp8UnitTests : SA1137CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1139CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1139CSharp8UnitTests.cs new file mode 100644 index 000000000..75c2b6a54 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1139CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1139CSharp8UnitTests : SA1139CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1141CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1141CSharp8UnitTests.cs new file mode 100644 index 000000000..ea6bd3028 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1141CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1141CSharp8UnitTests : SA1141CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1142CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1142CSharp8UnitTests.cs new file mode 100644 index 000000000..300ada9d2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SA1142CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SA1142CSharp8UnitTests : SA1142CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SX1101CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SX1101CSharp8UnitTests.cs new file mode 100644 index 000000000..d8daa6dd6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/ReadabilityRules/SX1101CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp7.ReadabilityRules; + + public partial class SX1101CSharp8UnitTests : SX1101CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Settings/SettingsCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Settings/SettingsCSharp8UnitTests.cs new file mode 100644 index 000000000..0e880897c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Settings/SettingsCSharp8UnitTests.cs @@ -0,0 +1,236 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.Settings +{ + using System.Collections.Immutable; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.Diagnostics; + using Microsoft.CodeAnalysis.Text; + using StyleCop.Analyzers.Settings.ObjectModel; + using StyleCop.Analyzers.Test.CSharp7.Settings; + using StyleCop.Analyzers.Test.Verifiers; + using Xunit; + + public partial class SettingsCSharp8UnitTests : SettingsCSharp7UnitTests + { + private const string TestProjectName = "TestProject"; + + [Fact] + public async Task VerifyEditorConfigSettingsAreReadCorrectlyAsync() + { + var settings = @"root = true + +[*] +file_header_template = Custom copyright text. +insert_final_newline = true +csharp_using_directive_placement = outside_namespace:none +dotnet_separate_import_directive_groups = false + +stylecop.documentation.companyName = TestCompany +stylecop.documentation.documentationCulture = ru-RU +stylecop.documentation.unrecognizedValue = 3 + +stylecop.naming.allowCommonHungarianPrefixes = false +stylecop.naming.allowedHungarianPrefixes = a, ab, ignoredTooLong +stylecop.naming.allowedNamespaceComponents = eBay, iMac +stylecop.naming.unrecognizedValue = 3 + +stylecop.layout.unrecognizedValue = 3 + +stylecop.ordering.unrecognizedValue = 3 + +stylecop.maintainability.unrecognizedValue = 3 + +stylecop.indentation.unrecognizedValue = 3 + +stylecop.unrecognizedValue = 3 +"; + var context = await this.CreateAnalysisContextFromEditorConfigAsync(settings).ConfigureAwait(false); + + var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None); + + Assert.Equal("TestCompany", styleCopSettings.DocumentationRules.CompanyName); + Assert.Equal("Custom copyright text.", styleCopSettings.DocumentationRules.GetCopyrightText("unused")); + Assert.Equal("ru-RU", styleCopSettings.DocumentationRules.DocumentationCulture); + Assert.False(styleCopSettings.NamingRules.AllowCommonHungarianPrefixes); + Assert.Equal(new[] { "a", "ab" }, styleCopSettings.NamingRules.AllowedHungarianPrefixes); + Assert.Equal(new[] { "eBay", "iMac" }, styleCopSettings.NamingRules.AllowedNamespaceComponents); + + Assert.NotNull(styleCopSettings.LayoutRules); + Assert.Equal(OptionSetting.Require, styleCopSettings.LayoutRules.NewlineAtEndOfFile); + + Assert.NotNull(styleCopSettings.OrderingRules); + Assert.Equal(UsingDirectivesPlacement.OutsideNamespace, styleCopSettings.OrderingRules.UsingDirectivesPlacement); + Assert.Equal(OptionSetting.Allow, styleCopSettings.OrderingRules.BlankLinesBetweenUsingGroups); + } + + [Fact] + public async Task VerifyFileHeaderTemplateFromEditorConfigAsync() + { + var settings = @"root = true + +[*] +file_header_template = Line 1\nLine 2. +"; + var context = await this.CreateAnalysisContextFromEditorConfigAsync(settings).ConfigureAwait(false); + + var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None); + + Assert.Equal("Line 1\nLine 2.", styleCopSettings.DocumentationRules.GetCopyrightText("unused")); + } + + [Fact] + public async Task VerifyStyleCopDocumentationCopyrightTextFromEditorConfigAsync() + { + var settings = @"root = true + +[*] +stylecop.documentation.copyrightText = Line 1\nLine 2. +"; + var context = await this.CreateAnalysisContextFromEditorConfigAsync(settings).ConfigureAwait(false); + + var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None); + + Assert.Equal("Line 1\nLine 2.", styleCopSettings.DocumentationRules.GetCopyrightText("unused")); + } + + [Theory] + [CombinatorialData] + public async Task VerifyBooleanDocumentationSettingsFromEditorConfigAsync(bool value) + { + string valueText = value.ToString().ToLowerInvariant(); + var settings = $@"root = true + +[*] +stylecop.documentation.documentExposedElements = {valueText} +stylecop.documentation.documentInternalElements = {valueText} +stylecop.documentation.documentPrivateElements = {valueText} +stylecop.documentation.documentInterfaces = {valueText} +stylecop.documentation.documentPrivateFields = {valueText} +"; + var context = await this.CreateAnalysisContextFromEditorConfigAsync(settings).ConfigureAwait(false); + + var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None); + + Assert.Equal(value, styleCopSettings.DocumentationRules.DocumentExposedElements); + Assert.Equal(value, styleCopSettings.DocumentationRules.DocumentInternalElements); + Assert.Equal(value, styleCopSettings.DocumentationRules.DocumentPrivateElements); + Assert.Equal(value, styleCopSettings.DocumentationRules.DocumentInterfaces); + Assert.Equal(value, styleCopSettings.DocumentationRules.DocumentPrivateFields); + } + + [Theory] + [InlineData("TestCompany")] + [InlineData("TestCompany2")] + public async Task VerifySettingsWillUseCompanyNameInDefaultCopyrightTextFromEditorConfigAsync(string companyName) + { + var settings = $@"root = true + +[*] +stylecop.documentation.companyName = {companyName} +"; + var context = await this.CreateAnalysisContextFromEditorConfigAsync(settings).ConfigureAwait(false); + + var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None); + + Assert.Equal(companyName, styleCopSettings.DocumentationRules.CompanyName); + Assert.Equal($"Copyright (c) {companyName}. All rights reserved.", styleCopSettings.DocumentationRules.GetCopyrightText("unused")); + } + + [Fact] + public async Task VerifyCircularReferenceBehaviorFromEditorConfigAsync() + { + var settings = @"root = true + +[*] +file_header_template = {copyrightText} +"; + var context = await this.CreateAnalysisContextFromEditorConfigAsync(settings).ConfigureAwait(false); + + var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None); + + Assert.Equal("[CircularReference]", styleCopSettings.DocumentationRules.GetCopyrightText("unused")); + } + + [Fact] + public async Task VerifyInvalidReferenceBehaviorFromEditorConfigAsync() + { + var settings = @"root = true + +[*] +file_header_template = {variable} +"; + var context = await this.CreateAnalysisContextFromEditorConfigAsync(settings).ConfigureAwait(false); + + var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None); + + Assert.Equal("[InvalidReference]", styleCopSettings.DocumentationRules.GetCopyrightText("unused")); + } + + protected virtual AnalyzerConfigOptionsProvider CreateAnalyzerConfigOptionsProvider(AnalyzerConfigSet analyzerConfigSet) + => new TestAnalyzerConfigOptionsProvider(analyzerConfigSet); + + private async Task CreateAnalysisContextFromEditorConfigAsync(string editorConfig) + { + var projectId = ProjectId.CreateNewId(); + var documentId = DocumentId.CreateNewId(projectId); + var analyzerConfigDocumentId = DocumentId.CreateNewId(projectId); + + var solution = GenericAnalyzerTest.CreateWorkspace() + .CurrentSolution + .AddProject(projectId, TestProjectName, TestProjectName, LanguageNames.CSharp) + .AddDocument(documentId, "/0/Test0.cs", SourceText.From(string.Empty)) + .AddAnalyzerConfigDocument(analyzerConfigDocumentId, "/.editorconfig", SourceText.From(editorConfig), filePath: "/.editorconfig"); + + var document = solution.GetDocument(documentId); + var syntaxTree = await document.GetSyntaxTreeAsync(CancellationToken.None).ConfigureAwait(false); + + var analyzerConfigSet = AnalyzerConfigSet.Create(new[] { AnalyzerConfig.Parse(SourceText.From(editorConfig), "/.editorconfig") }); + var additionalFiles = ImmutableArray.Empty; + var optionsProvider = this.CreateAnalyzerConfigOptionsProvider(analyzerConfigSet); + var analyzerOptions = new AnalyzerOptions(additionalFiles, optionsProvider); + + return new SyntaxTreeAnalysisContext(syntaxTree, analyzerOptions, reportDiagnostic: _ => { }, isSupportedDiagnostic: _ => true, CancellationToken.None); + } + + protected class TestAnalyzerConfigOptions : AnalyzerConfigOptions + { + private readonly AnalyzerConfigOptionsResult analyzerConfigOptionsResult; + + public TestAnalyzerConfigOptions(AnalyzerConfigOptionsResult analyzerConfigOptionsResult) + { + this.analyzerConfigOptionsResult = analyzerConfigOptionsResult; + } + + public override bool TryGetValue(string key, out string value) + { + return this.analyzerConfigOptionsResult.AnalyzerOptions.TryGetValue(key, out value); + } + } + + private sealed class TestAnalyzerConfigOptionsProvider : AnalyzerConfigOptionsProvider + { + private readonly AnalyzerConfigSet analyzerConfigSet; + + public TestAnalyzerConfigOptionsProvider(AnalyzerConfigSet analyzerConfigSet) + { + this.analyzerConfigSet = analyzerConfigSet; + } + + public override AnalyzerConfigOptions GetOptions(SyntaxTree tree) + { + return new TestAnalyzerConfigOptions(this.analyzerConfigSet.GetOptionsForSourcePath(tree.FilePath)); + } + + public override AnalyzerConfigOptions GetOptions(AdditionalText textFile) + { + return new TestAnalyzerConfigOptions(this.analyzerConfigSet.GetOptionsForSourcePath(textFile.Path)); + } + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Settings/SettingsFileCodeFixProviderCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Settings/SettingsFileCodeFixProviderCSharp8UnitTests.cs new file mode 100644 index 000000000..38fdbe2ce --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/Settings/SettingsFileCodeFixProviderCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.Settings +{ + using StyleCop.Analyzers.Test.CSharp7.Settings; + + public partial class SettingsFileCodeFixProviderCSharp8UnitTests : SettingsFileCodeFixProviderCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1000CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1000CSharp8UnitTests.cs new file mode 100644 index 000000000..99687250f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1000CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + + public partial class SA1000CSharp8UnitTests : SA1000CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1001CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1001CSharp8UnitTests.cs new file mode 100644 index 000000000..1cd773294 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1001CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + + public partial class SA1001CSharp8UnitTests : SA1001CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1002CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1002CSharp8UnitTests.cs new file mode 100644 index 000000000..0f0c85f9e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1002CSharp8UnitTests.cs @@ -0,0 +1,60 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1002SemicolonsMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1002CSharp8UnitTests : SA1002CSharp7UnitTests + { + [Fact] + [WorkItem(3052, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3052")] + public async Task TestClosingSquareBracketFollowedByExclamationAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public void TestMethod(object?[] arguments) + { + object o1 = arguments[0] !; + object o2 = arguments[0]! ; + object o3 = arguments[0] ! ; + } + } +} +"; + + var fixedCode = @"namespace TestNamespace +{ + public class TestClass + { + public void TestMethod(object?[] arguments) + { + object o1 = arguments[0] !; + object o2 = arguments[0]!; + object o3 = arguments[0] !; + } + } +} +"; + + DiagnosticResult[] expected = + { + Diagnostic().WithArguments(" not", "preceded").WithLocation(8, 39), + Diagnostic().WithArguments(" not", "preceded").WithLocation(9, 40), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1003CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1003CSharp8UnitTests.cs new file mode 100644 index 000000000..39133b371 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1003CSharp8UnitTests.cs @@ -0,0 +1,70 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + using Xunit; + + using static StyleCop.Analyzers.SpacingRules.SA1003SymbolsMustBeSpacedCorrectly; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1003SymbolsMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.SA1003CodeFixProvider>; + + public partial class SA1003CSharp8UnitTests : SA1003CSharp7UnitTests + { + /// + /// Verifies that spacing around a range expression double dots isn't required. + /// + /// + /// Double dots of range expressions already provide enough spacing for readability so there is no + /// need to surround the range expression with spaces. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3386, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3386")] + public async Task TestRangeExpressionAsync() + { + var testCode = @" +namespace TestNamespace +{ + using System; + public class TestClass + { + public void TestMethod() + { + var test1 = .. {|#0:(|}int)1; + } + } +} +"; + + var fixedCode = @" +namespace TestNamespace +{ + using System; + public class TestClass + { + public void TestMethod() + { + var test1 = ..(int)1; + } + } +} +"; + + await new CSharpTest() + { + ReferenceAssemblies = ReferenceAssemblies.NetCore.NetCoreApp31, + TestCode = testCode, + ExpectedDiagnostics = { Diagnostic(DescriptorNotPrecededByWhitespace).WithLocation(0).WithArguments("(int)") }, + FixedCode = fixedCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1004CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1004CSharp8UnitTests.cs new file mode 100644 index 000000000..f3203b240 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1004CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + + public partial class SA1004CSharp8UnitTests : SA1004CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1005CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1005CSharp8UnitTests.cs new file mode 100644 index 000000000..1aeb432c5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1005CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + + public partial class SA1005CSharp8UnitTests : SA1005CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1006CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1006CSharp8UnitTests.cs new file mode 100644 index 000000000..fb50891c8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1006CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + + public partial class SA1006CSharp8UnitTests : SA1006CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1007CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1007CSharp8UnitTests.cs new file mode 100644 index 000000000..78c1974d1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1007CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + + public partial class SA1007CSharp8UnitTests : SA1007CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1008CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1008CSharp8UnitTests.cs new file mode 100644 index 000000000..cbdc8fc61 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1008CSharp8UnitTests.cs @@ -0,0 +1,198 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + using Xunit; + + using static StyleCop.Analyzers.SpacingRules.SA1008OpeningParenthesisMustBeSpacedCorrectly; + + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1008OpeningParenthesisMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1008CSharp8UnitTests : SA1008CSharp7UnitTests + { + /// + /// Verifies that spacing after a range expression double dots isn't required. + /// + /// + /// Double dots of range expressions already provide enough spacing for readability so there is no + /// need to prefix the opening parenthesis with a space. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3386, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3386")] + public async Task TestAfterRangeExpressionAsync() + { + var testCode = @" +namespace TestNamespace +{ + using System; + public class TestClass + { + public void TestMethod() + { + string str = ""test""; + int finalLen = 4; + var test1 = str[.. {|#0:(|}finalLen - 1)]; + var test2 = .. {|#1:(|}int)finalLen; + } + } +} +"; + + var fixedCode = @" +namespace TestNamespace +{ + using System; + public class TestClass + { + public void TestMethod() + { + string str = ""test""; + int finalLen = 4; + var test1 = str[..(finalLen - 1)]; + var test2 = ..(int)finalLen; + } + } +} +"; + + await new CSharpTest() + { + ReferenceAssemblies = ReferenceAssemblies.NetCore.NetCoreApp31, + TestCode = testCode, + ExpectedDiagnostics = + { + Diagnostic(DescriptorNotPreceded).WithLocation(0), + Diagnostic(DescriptorNotPreceded).WithLocation(1), + }, + FixedCode = fixedCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3141, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3141")] + public async Task TestInPropertyPatternsAsync() + { + var testCode = @" +class C +{ + void M((string A, string B) tuple) + { + _ = tuple is{|#0:(|} { Length: 1 }, { Length: 2 }); + } +} +"; + var fixedCode = @" +class C +{ + void M((string A, string B) tuple) + { + _ = tuple is ({ Length: 1 }, { Length: 2 }); + } +} +"; + DiagnosticResult[] expectedResults = + { + Diagnostic(DescriptorPreceded).WithLocation(0), + Diagnostic(DescriptorNotFollowed).WithLocation(0), + }; + + await VerifyCSharpFixAsync( + testCode, + expectedResults, + fixedCode, + CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3198, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3198")] + public async Task TestInPositionalPatternAsync() + { + var testCode = @" +class C +{ + void M((bool A, bool B) tuple) + { + _ = (tuple, tuple) is{|#0:(|} (true, true),{|#1:(|} true, true)); + } +} +"; + var fixedCode = @" +class C +{ + void M((bool A, bool B) tuple) + { + _ = (tuple, tuple) is ((true, true), (true, true)); + } +} +"; + DiagnosticResult[] expectedResults = + { + Diagnostic(DescriptorPreceded).WithLocation(0), + Diagnostic(DescriptorNotFollowed).WithLocation(0), + Diagnostic(DescriptorPreceded).WithLocation(1), + Diagnostic(DescriptorNotFollowed).WithLocation(1), + }; + + await VerifyCSharpFixAsync( + testCode, + expectedResults, + fixedCode, + CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3556, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3556")] + public async Task TestInPositionalPatternAfterTagAsync() + { + var testCode = @" +internal class TestClass + { + private void TestMethod(object obj) + { + _ = obj is ClassWithTuple { Tag:{|#0:(|} true, false) }; + } + + public class ClassWithTuple + { + public (bool Item1, bool Item2) Tag { get; set; } + } + } +"; + var fixedCode = @" +internal class TestClass + { + private void TestMethod(object obj) + { + _ = obj is ClassWithTuple { Tag: (true, false) }; + } + + public class ClassWithTuple + { + public (bool Item1, bool Item2) Tag { get; set; } + } + } +"; + DiagnosticResult[] expectedResults = + { + Diagnostic(DescriptorPreceded).WithLocation(0), + Diagnostic(DescriptorNotFollowed).WithLocation(0), + }; + + await VerifyCSharpFixAsync( + testCode, + expectedResults, + fixedCode, + CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1009CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1009CSharp8UnitTests.cs new file mode 100644 index 000000000..da46713b8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1009CSharp8UnitTests.cs @@ -0,0 +1,211 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + using Xunit; + using static StyleCop.Analyzers.SpacingRules.SA1009ClosingParenthesisMustBeSpacedCorrectly; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1009ClosingParenthesisMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1009CSharp8UnitTests : SA1009CSharp7UnitTests + { + [Fact] + [WorkItem(2991, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2991")] + public async Task TestFollowedBySuppressionOperatorAsync() + { + const string testCode = @" +public class Foo +{ + public void TestMethod() + { + if (default(T[|)|] ! is null) + { + } + } +}"; + const string fixedCode = @" +public class Foo +{ + public void TestMethod() + { + if (default(T)! is null) + { + } + } +}"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3143, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3143")] + public async Task TestFollowedBySuppressionOperator2Async() + { + const string testCode = @" +using System; + +public class Base +{ + protected Base(Func to, Func from) => throw null; +} + +public class Derived : Base +{ + public Derived() + : base( + (v) => int.Parse(v{|#0:)|} !, + (v) => v.ToString({|#1:)|} ! {|#2:)|} + { + } +} +"; + const string fixedCode = @" +using System; + +public class Base +{ + protected Base(Func to, Func from) => throw null; +} + +public class Derived : Base +{ + public Derived() + : base( + (v) => int.Parse(v)!, + (v) => v.ToString()!) + { + } +} +"; + + DiagnosticResult[] expected = + { + // /0/Test0.cs(13,31): warning SA1009: Closing parenthesis should not be followed by a space + Diagnostic(DescriptorNotFollowed).WithLocation(0), + + // /0/Test0.cs(14,31): warning SA1009: Closing parenthesis should not be followed by a space + Diagnostic(DescriptorNotFollowed).WithLocation(1), + + // /0/Test0.cs(14,35): warning SA1009: Closing parenthesis should not be preceded by a space + Diagnostic(DescriptorNotPreceded).WithLocation(2), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2968, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2968")] + public async Task TestExpressionBodyEndsWithSuppressionAsync() + { + const string testCode = @"using System; +#nullable enable +public class Foo +{ + public T? TestMethod() where T : class => throw null; + + public IDisposable Service => this.TestMethod([|)|] !; +}"; + const string fixedCode = @"using System; +#nullable enable +public class Foo +{ + public T? TestMethod() where T : class => throw null; + + public IDisposable Service => this.TestMethod()!; +}"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2968, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2968")] + public async Task TestBlockBodyEndsWithSuppressionAsync() + { + const string testCode = @"using System; +#nullable enable +public class Foo +{ + public T? TestMethod() where T : class => throw null; + + public IDisposable Service() + { + return this.TestMethod([|)|] !; + } +}"; + const string fixedCode = @"using System; +#nullable enable +public class Foo +{ + public T? TestMethod() where T : class => throw null; + + public IDisposable Service() + { + return this.TestMethod()!; + } +}"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that spacing before a range expression double dots isn't required. + /// + /// + /// Double dots of range expressions already provide enough spacing for readability so there is no + /// need to suffix the closing parenthesis with a space. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3064, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3064")] + public async Task TestBeforeRangeExpressionAsync() + { + var testCode = @" +namespace TestNamespace +{ + using System; + public class TestClass + { + public string TestMethod() + { + string str = ""test""; + int startLen = 4; + return str[(startLen - 1{|#0:)|} ..]; + } + } +} +"; + + var fixedCode = @" +namespace TestNamespace +{ + using System; + public class TestClass + { + public string TestMethod() + { + string str = ""test""; + int startLen = 4; + return str[(startLen - 1)..]; + } + } +} +"; + + await new CSharpTest() + { + ReferenceAssemblies = ReferenceAssemblies.NetCore.NetCoreApp31, + TestCode = testCode, + ExpectedDiagnostics = { Diagnostic(DescriptorNotFollowed).WithLocation(0) }, + FixedCode = fixedCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1010CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1010CSharp8UnitTests.cs new file mode 100644 index 000000000..71ba2da89 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1010CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + + public partial class SA1010CSharp8UnitTests : SA1010CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1011CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1011CSharp8UnitTests.cs new file mode 100644 index 000000000..47bbc6312 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1011CSharp8UnitTests.cs @@ -0,0 +1,130 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1011ClosingSquareBracketsMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1011CSharp8UnitTests : SA1011CSharp7UnitTests + { + /// + /// Verify that declaring a null reference type works for arrays. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(2927, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2927")] + public async Task VerifyNullableContextWithArraysAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public void TestMethod() + { + byte[]? data = null; + } + } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2900, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2900")] + public async Task VerifyNullableContextWithArrayReturnsAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public byte[]? TestMethod() + { + return null; + } + } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3052, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3052")] + public async Task TestClosingSquareBracketFollowedByExclamationAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public void TestMethod(object?[] arguments) + { + object o1 = arguments[0] !; + object o2 = arguments[0]! ; + object o3 = arguments[0] ! ; + string s1 = arguments[0] !.ToString(); + string s2 = arguments[0]! .ToString(); + string s3 = arguments[0] ! .ToString(); + } + } +} +"; + + var fixedCode = @"namespace TestNamespace +{ + public class TestClass + { + public void TestMethod(object?[] arguments) + { + object o1 = arguments[0]!; + object o2 = arguments[0]! ; + object o3 = arguments[0]! ; + string s1 = arguments[0]!.ToString(); + string s2 = arguments[0]! .ToString(); + string s3 = arguments[0]! .ToString(); + } + } +} +"; + + DiagnosticResult[] expected = + { + Diagnostic().WithArguments(" not", "followed").WithLocation(7, 36), + Diagnostic().WithArguments(" not", "followed").WithLocation(9, 36), + Diagnostic().WithArguments(" not", "followed").WithLocation(10, 36), + Diagnostic().WithArguments(" not", "followed").WithLocation(12, 36), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3708, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3708")] + public async Task TestClosingSquareBracketFollowedByRangeAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public void TestMethod(int[] arg) + { + _ = arg[0]..; + _ = arg[0] ..; + } + } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1012CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1012CSharp8UnitTests.cs new file mode 100644 index 000000000..065ab860b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1012CSharp8UnitTests.cs @@ -0,0 +1,64 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1012OpeningBracesMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1012CSharp8UnitTests : SA1012CSharp7UnitTests + { + [Fact] + [WorkItem(3141, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3141")] + public async Task TestInPropertyPatternsAsync() + { + var testCode = @" +class C +{ + void M((string A, string B) tuple) + { + _ = tuple is ( {|#0:{|}Length: 1 },{|#1:{|}Length: 2 }); + } +} +"; + var fixedCode = @" +class C +{ + void M((string A, string B) tuple) + { + _ = tuple is ({ Length: 1 }, { Length: 2 }); + } +} +"; + + DiagnosticResult[] expectedResults = + { + // /0/Test0.cs(6,24): warning SA1012: Opening brace should be followed by a space + Diagnostic().WithLocation(0).WithArguments(string.Empty, "followed"), + + // /0/Test0.cs(6,24): warning SA1012: Opening brace should not be preceded by a space + Diagnostic().WithLocation(0).WithArguments(" not", "preceded"), + + // /0/Test0.cs(6,37): warning SA1012: Opening brace should be followed by a space + Diagnostic().WithLocation(1).WithArguments(string.Empty, "followed"), + + // /0/Test0.cs(6,37): warning SA1012: Opening brace should be preceded by a space + Diagnostic().WithLocation(1).WithArguments(string.Empty, "preceded"), + }; + + await VerifyCSharpFixAsync( + testCode, + expectedResults, + fixedCode, + CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1013CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1013CSharp8UnitTests.cs new file mode 100644 index 000000000..7839335bf --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1013CSharp8UnitTests.cs @@ -0,0 +1,96 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + + using Microsoft.CodeAnalysis.Testing; + + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + + using Xunit; + + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1013ClosingBracesMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1013CSharp8UnitTests : SA1013CSharp7UnitTests + { + /// + /// Verifies the behavior of closing braces in case patterns. + /// + /// A representing the asynchronous unit test. + /// + [Fact] + [WorkItem(3053, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3053")] + public async Task TestSpacingAroundClosingBraceInPatternAsync() + { + const string testCode = @"using System; + +public class Foo +{ + public void TestMethod(object value) + { + switch (value) + { + // The space before ':' is not checked + case ArgumentException { Message: { } message } : + break; + + // The space before 'message' is checked + case Exception { Message: { {|#0:}|}message }: + break; + } + } +}"; + const string fixedCode = @"using System; + +public class Foo +{ + public void TestMethod(object value) + { + switch (value) + { + // The space before ':' is not checked + case ArgumentException { Message: { } message } : + break; + + // The space before 'message' is checked + case Exception { Message: { } message }: + break; + } + } +}"; + + var expected = Diagnostic().WithLocation(0).WithArguments(string.Empty, "followed"); + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Validates that a closing brace followed by a null-forgiving operator does not require a space. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3172, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3172")] + public async Task TestCloseBraceWithNullForgivingOperatorAsync() + { + const string testCode = @"#nullable enable +public class Foo +{ + public void TestMethod() + { + var test = new[] + { + new { Value = ""a"" }!, + new { Value = ""b"" } !, + }; + } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1014CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1014CSharp8UnitTests.cs new file mode 100644 index 000000000..693b08d5f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1014CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + + public partial class SA1014CSharp8UnitTests : SA1014CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1015CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1015CSharp8UnitTests.cs new file mode 100644 index 000000000..fe04df86b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1015CSharp8UnitTests.cs @@ -0,0 +1,41 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1015ClosingGenericBracketsMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1015CSharp8UnitTests : SA1015CSharp7UnitTests + { + [Fact] + [WorkItem(3302, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3302")] + public async Task TestGenericTypePointerAsync() + { + const string testCode = @"using System; + +public struct Foo +{ + internal unsafe Foo|] * Next1; + internal unsafe Foo|]* Next2; +}"; + const string fixedCode = @"using System; + +public struct Foo +{ + internal unsafe Foo * Next1; + internal unsafe Foo* Next2; +}"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1016CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1016CSharp8UnitTests.cs new file mode 100644 index 000000000..7d08778b9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1016CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + + public partial class SA1016CSharp8UnitTests : SA1016CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1017CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1017CSharp8UnitTests.cs new file mode 100644 index 000000000..132fda1d9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1017CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + + public partial class SA1017CSharp8UnitTests : SA1017CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1018CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1018CSharp8UnitTests.cs new file mode 100644 index 000000000..3a2c55676 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1018CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + + public partial class SA1018CSharp8UnitTests : SA1018CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1019CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1019CSharp8UnitTests.cs new file mode 100644 index 000000000..6ff5fc1e6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1019CSharp8UnitTests.cs @@ -0,0 +1,69 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + using Xunit; + using static StyleCop.Analyzers.SpacingRules.SA1019MemberAccessSymbolsMustBeSpacedCorrectly; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1019MemberAccessSymbolsMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1019CSharp8UnitTests : SA1019CSharp7UnitTests + { + [Fact] + [WorkItem(3052, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3052")] + public async Task TestClosingSquareBracketFollowedByExclamationAsync() + { + var testCode = @"namespace TestNamespace +{ + public class TestClass + { + public void TestMethod(object?[] arguments) + { + string s1 = arguments[0] !.ToString(); + string s2 = arguments[0]! .ToString(); + string s3 = arguments[0] ! .ToString(); + string s4 = arguments[0] !?.ToString(); + string s5 = arguments[0]! ?.ToString(); + string s6 = arguments[0] ! ?.ToString(); + } + } +} +"; + + var fixedCode = @"namespace TestNamespace +{ + public class TestClass + { + public void TestMethod(object?[] arguments) + { + string s1 = arguments[0] !.ToString(); + string s2 = arguments[0]!.ToString(); + string s3 = arguments[0] !.ToString(); + string s4 = arguments[0] !?.ToString(); + string s5 = arguments[0]!?.ToString(); + string s6 = arguments[0] !?.ToString(); + } + } +} +"; + + DiagnosticResult[] expected = + { + Diagnostic(DescriptorNotPreceded).WithArguments(".").WithLocation(8, 39), + Diagnostic(DescriptorNotPreceded).WithArguments(".").WithLocation(9, 40), + Diagnostic(DescriptorNotPreceded).WithArguments("?").WithLocation(11, 39), + Diagnostic(DescriptorNotPreceded).WithArguments("?").WithLocation(12, 40), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1020CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1020CSharp8UnitTests.cs new file mode 100644 index 000000000..69895f2ed --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1020CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + + public partial class SA1020CSharp8UnitTests : SA1020CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1021CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1021CSharp8UnitTests.cs new file mode 100644 index 000000000..38f0cd920 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1021CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + + public partial class SA1021CSharp8UnitTests : SA1021CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1022CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1022CSharp8UnitTests.cs new file mode 100644 index 000000000..46b7df58c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1022CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + + public partial class SA1022CSharp8UnitTests : SA1022CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1023CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1023CSharp8UnitTests.cs new file mode 100644 index 000000000..2a50ae516 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1023CSharp8UnitTests.cs @@ -0,0 +1,43 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1023DereferenceAndAccessOfSymbolsMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1023CSharp8UnitTests : SA1023CSharp7UnitTests + { + [Fact] + [WorkItem(3302, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3302")] + public async Task TestGenericTypePointerAsync() + { + const string testCode = @"using System; + +public struct Foo +{ + internal unsafe Foo [|*|] Next1; + internal unsafe Foo[|*|]Next2; + internal unsafe Foo [|[|*|]|]Next3; +}"; + const string fixedCode = @"using System; + +public struct Foo +{ + internal unsafe Foo* Next1; + internal unsafe Foo* Next2; + internal unsafe Foo* Next3; +}"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1024CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1024CSharp8UnitTests.cs new file mode 100644 index 000000000..2b255321d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1024CSharp8UnitTests.cs @@ -0,0 +1,59 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + using Xunit; + using static StyleCop.Analyzers.SpacingRules.SA1024ColonsMustBeSpacedCorrectly; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1024ColonsMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1024CSharp8UnitTests : SA1024CSharp7UnitTests + { + /// + /// Verifies the behavior of colons in case patterns. + /// + /// A representing the asynchronous unit test. + /// + [Fact] + [WorkItem(3053, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3053")] + public async Task TestColonAfterClosingBraceInPatternAsync() + { + const string testCode = @"using System; + +public class Foo +{ + public void TestMethod(object value) + { + switch (value) + { + case Exception { Message: { } message } : + break; + } + } +}"; + const string fixedCode = @"using System; + +public class Foo +{ + public void TestMethod(object value) + { + switch (value) + { + case Exception { Message: { } message }: + break; + } + } +}"; + + var expected = Diagnostic(DescriptorNotPreceded).WithSpan(9, 49, 9, 50); + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1025CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1025CSharp8UnitTests.cs new file mode 100644 index 000000000..1ed086a78 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1025CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + + public partial class SA1025CSharp8UnitTests : SA1025CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1026CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1026CSharp8UnitTests.cs new file mode 100644 index 000000000..69671961d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1026CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + + public partial class SA1026CSharp8UnitTests : SA1026CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1027AlternateIndentationCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1027AlternateIndentationCSharp8UnitTests.cs new file mode 100644 index 000000000..e38c955a0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1027AlternateIndentationCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + + public partial class SA1027AlternateIndentationCSharp8UnitTests : SA1027AlternateIndentationCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1027CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1027CSharp8UnitTests.cs new file mode 100644 index 000000000..94140e600 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1027CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + + public partial class SA1027CSharp8UnitTests : SA1027CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1027UseTabsCSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1027UseTabsCSharp8UnitTests.cs new file mode 100644 index 000000000..68efb3436 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1027UseTabsCSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + + public partial class SA1027UseTabsCSharp8UnitTests : SA1027UseTabsCSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1028CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1028CSharp8UnitTests.cs new file mode 100644 index 000000000..50b7cd0f5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpacingRules/SA1028CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp7.SpacingRules; + + public partial class SA1028CSharp8UnitTests : SA1028CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpecialRules/SA0001CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpecialRules/SA0001CSharp8UnitTests.cs new file mode 100644 index 000000000..25e29f3f1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpecialRules/SA0001CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpecialRules +{ + using StyleCop.Analyzers.Test.CSharp7.SpecialRules; + + public partial class SA0001CSharp8UnitTests : SA0001CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpecialRules/SA0002CSharp8UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpecialRules/SA0002CSharp8UnitTests.cs new file mode 100644 index 000000000..393c4c3ca --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/SpecialRules/SA0002CSharp8UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp8.SpecialRules +{ + using StyleCop.Analyzers.Test.CSharp7.SpecialRules; + + public partial class SA0002CSharp8UnitTests : SA0002CSharp7UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/StyleCop.Analyzers.Test.CSharp8.csproj b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/StyleCop.Analyzers.Test.CSharp8.csproj new file mode 100644 index 000000000..109a19593 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/StyleCop.Analyzers.Test.CSharp8.csproj @@ -0,0 +1,37 @@ + + + + + net472 + false + true + true + + + + ..\StyleCop.Analyzers.Internal.ruleset + + + + true + ..\..\build\keys\TestingKey.snk + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/AnalyzerConfigurationCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/AnalyzerConfigurationCSharp9UnitTests.cs new file mode 100644 index 000000000..d36b8e12e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/AnalyzerConfigurationCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9 +{ + using StyleCop.Analyzers.Test.CSharp8; + + public partial class AnalyzerConfigurationCSharp9UnitTests : AnalyzerConfigurationCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/InheritdocCodeFixProviderCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/InheritdocCodeFixProviderCSharp9UnitTests.cs new file mode 100644 index 000000000..e34902be0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/InheritdocCodeFixProviderCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class InheritdocCodeFixProviderCSharp9UnitTests : InheritdocCodeFixProviderCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/NoXmlFileHeaderCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/NoXmlFileHeaderCSharp9UnitTests.cs new file mode 100644 index 000000000..145111f79 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/NoXmlFileHeaderCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class NoXmlFileHeaderCSharp9UnitTests : NoXmlFileHeaderCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1600CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1600CSharp9UnitTests.cs new file mode 100644 index 000000000..42ae8fef9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1600CSharp9UnitTests.cs @@ -0,0 +1,30 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1600CSharp9UnitTests : SA1600CSharp8UnitTests + { + protected override DiagnosticResult[] GetExpectedResultTestRegressionMethodGlobalNamespace(string code) + { + if (code == "public void {|#0:TestMember|}() { }") + { + return new[] + { + // error CS8805: Program using top-level statements must be an executable. + DiagnosticResult.CompilerError("CS8805"), + + // /0/Test0.cs(4,1): error CS0106: The modifier 'public' is not valid for this item + DiagnosticResult.CompilerError("CS0106").WithSpan(4, 1, 4, 7).WithArguments("public"), + }; + } + + return base.GetExpectedResultTestRegressionMethodGlobalNamespace(code); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1601CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1601CSharp9UnitTests.cs new file mode 100644 index 000000000..56b69fffd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1601CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1601CSharp9UnitTests : SA1601CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1602CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1602CSharp9UnitTests.cs new file mode 100644 index 000000000..0e01eea68 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1602CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1602CSharp9UnitTests : SA1602CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1603CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1603CSharp9UnitTests.cs new file mode 100644 index 000000000..ea9e194f0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1603CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1603CSharp9UnitTests : SA1603CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1604CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1604CSharp9UnitTests.cs new file mode 100644 index 000000000..5996b6db6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1604CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1604CSharp9UnitTests : SA1604CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1605CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1605CSharp9UnitTests.cs new file mode 100644 index 000000000..9dc8a456c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1605CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1605CSharp9UnitTests : SA1605CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1606CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1606CSharp9UnitTests.cs new file mode 100644 index 000000000..45ccf3a7c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1606CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1606CSharp9UnitTests : SA1606CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1607CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1607CSharp9UnitTests.cs new file mode 100644 index 000000000..033818a29 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1607CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1607CSharp9UnitTests : SA1607CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1608CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1608CSharp9UnitTests.cs new file mode 100644 index 000000000..bb525faff --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1608CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1608CSharp9UnitTests : SA1608CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1609CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1609CSharp9UnitTests.cs new file mode 100644 index 000000000..be6d4ac79 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1609CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1609CSharp9UnitTests : SA1609CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1610CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1610CSharp9UnitTests.cs new file mode 100644 index 000000000..85460f07b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1610CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1610CSharp9UnitTests : SA1610CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1611CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1611CSharp9UnitTests.cs new file mode 100644 index 000000000..27bb08e0c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1611CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1611CSharp9UnitTests : SA1611CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1612CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1612CSharp9UnitTests.cs new file mode 100644 index 000000000..19d9c78db --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1612CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1612CSharp9UnitTests : SA1612CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1613CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1613CSharp9UnitTests.cs new file mode 100644 index 000000000..9f8525638 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1613CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1613CSharp9UnitTests : SA1613CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1614CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1614CSharp9UnitTests.cs new file mode 100644 index 000000000..821130db1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1614CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1614CSharp9UnitTests : SA1614CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1615CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1615CSharp9UnitTests.cs new file mode 100644 index 000000000..0ff5568f0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1615CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1615CSharp9UnitTests : SA1615CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1616CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1616CSharp9UnitTests.cs new file mode 100644 index 000000000..2eab728ef --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1616CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1616CSharp9UnitTests : SA1616CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1617CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1617CSharp9UnitTests.cs new file mode 100644 index 000000000..f29a79905 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1617CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1617CSharp9UnitTests : SA1617CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1618CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1618CSharp9UnitTests.cs new file mode 100644 index 000000000..ed06fe525 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1618CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1618CSharp9UnitTests : SA1618CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1619CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1619CSharp9UnitTests.cs new file mode 100644 index 000000000..83461655f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1619CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1619CSharp9UnitTests : SA1619CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1620CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1620CSharp9UnitTests.cs new file mode 100644 index 000000000..2b713f5ea --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1620CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1620CSharp9UnitTests : SA1620CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1621CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1621CSharp9UnitTests.cs new file mode 100644 index 000000000..975848527 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1621CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1621CSharp9UnitTests : SA1621CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1622CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1622CSharp9UnitTests.cs new file mode 100644 index 000000000..97e142ca3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1622CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1622CSharp9UnitTests : SA1622CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1623CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1623CSharp9UnitTests.cs new file mode 100644 index 000000000..654afe47f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1623CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1623CSharp9UnitTests : SA1623CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1624CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1624CSharp9UnitTests.cs new file mode 100644 index 000000000..98d1ad100 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1624CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1624CSharp9UnitTests : SA1624CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1625CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1625CSharp9UnitTests.cs new file mode 100644 index 000000000..d8b0bd51c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1625CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1625CSharp9UnitTests : SA1625CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1626CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1626CSharp9UnitTests.cs new file mode 100644 index 000000000..3e6defa81 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1626CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1626CSharp9UnitTests : SA1626CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1627CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1627CSharp9UnitTests.cs new file mode 100644 index 000000000..d1006a84f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1627CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1627CSharp9UnitTests : SA1627CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1628CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1628CSharp9UnitTests.cs new file mode 100644 index 000000000..37823715c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1628CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1628CSharp9UnitTests : SA1628CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1629CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1629CSharp9UnitTests.cs new file mode 100644 index 000000000..30d25219a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1629CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1629CSharp9UnitTests : SA1629CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1630CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1630CSharp9UnitTests.cs new file mode 100644 index 000000000..b1198d9fd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1630CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1630CSharp9UnitTests : SA1630CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1631CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1631CSharp9UnitTests.cs new file mode 100644 index 000000000..4bd33a0c9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1631CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1631CSharp9UnitTests : SA1631CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1632CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1632CSharp9UnitTests.cs new file mode 100644 index 000000000..4f8c31db1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1632CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1632CSharp9UnitTests : SA1632CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1633CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1633CSharp9UnitTests.cs new file mode 100644 index 000000000..57486d0fb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1633CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1633CSharp9UnitTests : SA1633CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1634CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1634CSharp9UnitTests.cs new file mode 100644 index 000000000..0a71166b7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1634CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1634CSharp9UnitTests : SA1634CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1635CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1635CSharp9UnitTests.cs new file mode 100644 index 000000000..e5a6f1d57 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1635CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1635CSharp9UnitTests : SA1635CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1636CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1636CSharp9UnitTests.cs new file mode 100644 index 000000000..831fe42d4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1636CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1636CSharp9UnitTests : SA1636CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1637CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1637CSharp9UnitTests.cs new file mode 100644 index 000000000..9bff99754 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1637CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1637CSharp9UnitTests : SA1637CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1638CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1638CSharp9UnitTests.cs new file mode 100644 index 000000000..2e6dff393 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1638CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1638CSharp9UnitTests : SA1638CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1639CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1639CSharp9UnitTests.cs new file mode 100644 index 000000000..d7841b698 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1639CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1639CSharp9UnitTests : SA1639CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1640CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1640CSharp9UnitTests.cs new file mode 100644 index 000000000..43245d4e0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1640CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1640CSharp9UnitTests : SA1640CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1641CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1641CSharp9UnitTests.cs new file mode 100644 index 000000000..cdb25bed8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1641CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1641CSharp9UnitTests : SA1641CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1642CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1642CSharp9UnitTests.cs new file mode 100644 index 000000000..55a38204b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1642CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1642CSharp9UnitTests : SA1642CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1643CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1643CSharp9UnitTests.cs new file mode 100644 index 000000000..ed69f6711 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1643CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1643CSharp9UnitTests : SA1643CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1644CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1644CSharp9UnitTests.cs new file mode 100644 index 000000000..18a030866 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1644CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1644CSharp9UnitTests : SA1644CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1645CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1645CSharp9UnitTests.cs new file mode 100644 index 000000000..85bda5d57 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1645CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1645CSharp9UnitTests : SA1645CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1646CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1646CSharp9UnitTests.cs new file mode 100644 index 000000000..b20964b47 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1646CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1646CSharp9UnitTests : SA1646CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1647CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1647CSharp9UnitTests.cs new file mode 100644 index 000000000..13c81bf7c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1647CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1647CSharp9UnitTests : SA1647CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1648CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1648CSharp9UnitTests.cs new file mode 100644 index 000000000..6434f2134 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1648CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1648CSharp9UnitTests : SA1648CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1649CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1649CSharp9UnitTests.cs new file mode 100644 index 000000000..f2f23447a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1649CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1649CSharp9UnitTests : SA1649CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1650CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1650CSharp9UnitTests.cs new file mode 100644 index 000000000..ef1941d90 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1650CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1650CSharp9UnitTests : SA1650CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1651CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1651CSharp9UnitTests.cs new file mode 100644 index 000000000..ccfdc89a8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/DocumentationRules/SA1651CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.DocumentationRules +{ + using StyleCop.Analyzers.Test.CSharp8.DocumentationRules; + + public partial class SA1651CSharp9UnitTests : SA1651CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/HelperTests/SymbolNameHelpersCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/HelperTests/SymbolNameHelpersCSharp9UnitTests.cs new file mode 100644 index 000000000..f628ba5fc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/HelperTests/SymbolNameHelpersCSharp9UnitTests.cs @@ -0,0 +1,16 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.HelperTests +{ + using StyleCop.Analyzers.Test.CSharp8.HelperTests; + + /// + /// Unit tests for the class in the context of C# 9.0. + /// + public partial class SymbolNameHelpersCSharp9UnitTests : SymbolNameHelpersCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1500CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1500CSharp9UnitTests.cs new file mode 100644 index 000000000..9a32b20c4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1500CSharp9UnitTests.cs @@ -0,0 +1,141 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.LayoutRules; + using StyleCop.Analyzers.Test.Helpers; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, + StyleCop.Analyzers.LayoutRules.SA1500CodeFixProvider>; + + public partial class SA1500CSharp9UnitTests : SA1500CSharp8UnitTests + { + [Theory] + [MemberData(nameof(CommonMemberData.RecordTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + [WorkItem(3272, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3272")] + public async Task TestSingleLineRecordAsync(string keyword) + { + var testCode = $@"namespace TestNamespace +{{ + public {keyword} TestRecord; +}} +"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, testCode, CancellationToken.None).ConfigureAwait(false); + } + + [Theory] + [MemberData(nameof(CommonMemberData.RecordTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + [WorkItem(3272, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3272")] + public async Task TestSingleLineRecordWithParameterAsync(string keyword) + { + var testCode = $@"namespace TestNamespace +{{ + public {keyword} TestRecord(int Count); +}} +"; + + await new CSharpTest + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestCode = testCode, + FixedCode = testCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + [Theory] + [MemberData(nameof(CommonMemberData.RecordTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + [WorkItem(3272, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3272")] + public async Task TestMultiLineRecordAsync(string keyword) + { + var testCode = $@"namespace TestNamespace +{{ + public {keyword} TestRecord + {{ + public int Count {{ get; init; }} + }} +}} +"; + + await new CSharpTest + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestCode = testCode, + FixedCode = testCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + [Theory] + [MemberData(nameof(CommonMemberData.RecordTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + [WorkItem(3272, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3272")] + public async Task TestMultiLineRecordWithParameterAsync(string keyword) + { + var testCode = $@"namespace TestNamespace +{{ + public {keyword} TestRecord(int Count) + {{ + public int Count2 {{ get; init; }} = 0; + }} +}} +"; + + await new CSharpTest + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestCode = testCode, + FixedCode = testCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3667, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3667")] + public async Task TestInitAccessorAsync() + { + var testCode = @" +class TestClass +{ + int Property1 + { + init + [|{|] } + } + + int Property2 + { + init [|{|] + } + } +}"; + + var fixedCode = @" +class TestClass +{ + int Property1 + { + init { } + } + + int Property2 + { + init + { + } + } +}"; + + await new CSharpTest + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestCode = testCode, + FixedCode = fixedCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1501CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1501CSharp9UnitTests.cs new file mode 100644 index 000000000..e4360d126 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1501CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp8.LayoutRules; + + public partial class SA1501CSharp9UnitTests : SA1501CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1502CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1502CSharp9UnitTests.cs new file mode 100644 index 000000000..c5901f4fd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1502CSharp9UnitTests.cs @@ -0,0 +1,97 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.LayoutRules; + using StyleCop.Analyzers.Test.Helpers; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.LayoutRules.SA1502ElementMustNotBeOnASingleLine, + StyleCop.Analyzers.LayoutRules.SA1502CodeFixProvider>; + + public partial class SA1502CSharp9UnitTests : SA1502CSharp8UnitTests + { + [Theory] + [MemberData(nameof(CommonMemberData.RecordTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + [WorkItem(3272, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3272")] + public async Task TestSingleLineRecordAsync(string keyword) + { + var testCode = $@"namespace TestNamespace +{{ + public {keyword} TestRecord; +}} +"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, testCode, CancellationToken.None).ConfigureAwait(false); + } + + [Theory] + [MemberData(nameof(CommonMemberData.RecordTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + [WorkItem(3272, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3272")] + public async Task TestSingleLineRecordWithParameterAsync(string keyword) + { + var testCode = $@"namespace TestNamespace +{{ + public {keyword} TestRecord(int Count); +}} +"; + + await new CSharpTest + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestCode = testCode, + FixedCode = testCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + [Theory] + [MemberData(nameof(CommonMemberData.RecordTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + [WorkItem(3272, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3272")] + public async Task TestMultiLineRecordAsync(string keyword) + { + var testCode = $@"namespace TestNamespace +{{ + public {keyword} TestRecord + {{ + public int Count {{ get; init; }} + }} +}} +"; + + await new CSharpTest + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestCode = testCode, + FixedCode = testCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + [Theory] + [MemberData(nameof(CommonMemberData.RecordTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + [WorkItem(3272, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3272")] + public async Task TestMultiLineRecordWithParameterAsync(string keyword) + { + var testCode = $@"namespace TestNamespace +{{ + public {keyword} TestRecord(int Count) + {{ + public int Count2 {{ get; init; }} = 0; + }} +}} +"; + + await new CSharpTest + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestCode = testCode, + FixedCode = testCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1503CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1503CSharp9UnitTests.cs new file mode 100644 index 000000000..687f1eb86 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1503CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp8.LayoutRules; + + public partial class SA1503CSharp9UnitTests : SA1503CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1504CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1504CSharp9UnitTests.cs new file mode 100644 index 000000000..f7f866255 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1504CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp8.LayoutRules; + + public partial class SA1504CSharp9UnitTests : SA1504CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1505CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1505CSharp9UnitTests.cs new file mode 100644 index 000000000..4c9a49a9b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1505CSharp9UnitTests.cs @@ -0,0 +1,32 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.LayoutRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.LayoutRules.SA1505OpeningBracesMustNotBeFollowedByBlankLine, + StyleCop.Analyzers.LayoutRules.SA1505CodeFixProvider>; + + public partial class SA1505CSharp9UnitTests : SA1505CSharp8UnitTests + { + [Fact] + [WorkItem(3272, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3272")] + public async Task TestSingleLineRecordAsync() + { + var testCode = @"namespace TestNamespace +{ + public record TestRecord; +} +"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, testCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1506CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1506CSharp9UnitTests.cs new file mode 100644 index 000000000..8906a0a9f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1506CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp8.LayoutRules; + + public partial class SA1506CSharp9UnitTests : SA1506CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1507CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1507CSharp9UnitTests.cs new file mode 100644 index 000000000..acf24c784 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1507CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp8.LayoutRules; + + public partial class SA1507CSharp9UnitTests : SA1507CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1508CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1508CSharp9UnitTests.cs new file mode 100644 index 000000000..507fcff7a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1508CSharp9UnitTests.cs @@ -0,0 +1,97 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.LayoutRules; + using StyleCop.Analyzers.Test.Helpers; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.LayoutRules.SA1508ClosingBracesMustNotBePrecededByBlankLine, + StyleCop.Analyzers.LayoutRules.SA1508CodeFixProvider>; + + public partial class SA1508CSharp9UnitTests : SA1508CSharp8UnitTests + { + [Theory] + [MemberData(nameof(CommonMemberData.RecordTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + [WorkItem(3272, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3272")] + public async Task TestSingleLineRecordAsync(string keyword) + { + var testCode = $@"namespace TestNamespace +{{ + public {keyword} TestRecord; +}} +"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, testCode, CancellationToken.None).ConfigureAwait(false); + } + + [Theory] + [MemberData(nameof(CommonMemberData.RecordTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + [WorkItem(3272, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3272")] + public async Task TestSingleLineRecordWithParameterAsync(string keyword) + { + var testCode = $@"namespace TestNamespace +{{ + public {keyword} TestRecord(int Count); +}} +"; + + await new CSharpTest + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestCode = testCode, + FixedCode = testCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + [Theory] + [MemberData(nameof(CommonMemberData.RecordTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + [WorkItem(3272, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3272")] + public async Task TestMultiLineRecordAsync(string keyword) + { + var testCode = $@"namespace TestNamespace +{{ + public {keyword} TestRecord + {{ + public int Count {{ get; init; }} + }} +}} +"; + + await new CSharpTest + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestCode = testCode, + FixedCode = testCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + [Theory] + [MemberData(nameof(CommonMemberData.RecordTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + [WorkItem(3272, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3272")] + public async Task TestMultiLineRecordWithParameterAsync(string keyword) + { + var testCode = $@"namespace TestNamespace +{{ + public {keyword} TestRecord(int Count) + {{ + public int Count2 {{ get; init; }} = 0; + }} +}} +"; + + await new CSharpTest + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestCode = testCode, + FixedCode = testCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1509CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1509CSharp9UnitTests.cs new file mode 100644 index 000000000..3137ab9bc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1509CSharp9UnitTests.cs @@ -0,0 +1,32 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.LayoutRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.LayoutRules.SA1509OpeningBracesMustNotBePrecededByBlankLine, + StyleCop.Analyzers.LayoutRules.SA1509CodeFixProvider>; + + public partial class SA1509CSharp9UnitTests : SA1509CSharp8UnitTests + { + [Fact] + [WorkItem(3272, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3272")] + public async Task TestSingleLineRecordAsync() + { + var testCode = @"namespace TestNamespace +{ + public record TestRecord; +} +"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, testCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1510CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1510CSharp9UnitTests.cs new file mode 100644 index 000000000..2ffdaeeb4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1510CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp8.LayoutRules; + + public partial class SA1510CSharp9UnitTests : SA1510CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1511CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1511CSharp9UnitTests.cs new file mode 100644 index 000000000..745cb6f89 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1511CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp8.LayoutRules; + + public partial class SA1511CSharp9UnitTests : SA1511CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1512CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1512CSharp9UnitTests.cs new file mode 100644 index 000000000..8afa0f109 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1512CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp8.LayoutRules; + + public partial class SA1512CSharp9UnitTests : SA1512CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1513CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1513CSharp9UnitTests.cs new file mode 100644 index 000000000..0dbe6f05d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1513CSharp9UnitTests.cs @@ -0,0 +1,69 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.LayoutRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.LayoutRules.SA1513ClosingBraceMustBeFollowedByBlankLine, + StyleCop.Analyzers.LayoutRules.SA1513CodeFixProvider>; + + public partial class SA1513CSharp9UnitTests : SA1513CSharp8UnitTests + { + [Fact] + [WorkItem(3410, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3410")] + public async Task TestThrowSwitchExpressionValueAsync() + { + var testCode = @"using System; + +public class Foo +{ + public void Baz(string arg) + { + throw arg switch + { + """" => new ArgumentException(), + _ => new Exception() + }; + } +} +"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, testCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3658, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3658")] + public async Task TestInitAccessorAsync() + { + var testCode = @"using System; + +public class Foo +{ + public int X + { + get + { + return 0; + } + init + { + } + } +} +"; + + await new CSharpTest + { + TestCode = testCode, + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1514CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1514CSharp9UnitTests.cs new file mode 100644 index 000000000..908ae5be6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1514CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp8.LayoutRules; + + public partial class SA1514CSharp9UnitTests : SA1514CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1515CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1515CSharp9UnitTests.cs new file mode 100644 index 000000000..c2f36a211 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1515CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp8.LayoutRules; + + public partial class SA1515CSharp9UnitTests : SA1515CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1516CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1516CSharp9UnitTests.cs new file mode 100644 index 000000000..1781cfd48 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1516CSharp9UnitTests.cs @@ -0,0 +1,180 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.LayoutRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.LayoutRules.SA1516ElementsMustBeSeparatedByBlankLine, + StyleCop.Analyzers.LayoutRules.SA1516CodeFixProvider>; + + public partial class SA1516CSharp9UnitTests : SA1516CSharp8UnitTests + { + /// + /// Verifies that SA1516 is reported at the correct location in top-level programs. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3242, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3242")] + public async Task TestUsingAndGlobalStatementSpacingInTopLevelProgramAsync() + { + var testCode = @"using System; +using System.Threading; +{|#0:return|} 0; +"; + var fixedCode = @"using System; +using System.Threading; + +return 0; +"; + + var test = new CSharpTest() + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestState = + { + OutputKind = OutputKind.ConsoleApplication, + Sources = { testCode }, + }, + FixedCode = fixedCode, + }; + var expectedDiagnostics = this.GetExpectedResultTestUsingAndGlobalStatementSpacingInTopLevelProgram(); + test.TestState.ExpectedDiagnostics.AddRange(expectedDiagnostics); + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that SA1516 is not reported between global statement in top-level programs. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3351, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3351")] + public async Task TestGlobalStatementSpacingInTopLevelProgramAsync() + { + var testCode = @"int i = 0; +return i; +"; + + await new CSharpTest() + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestState = + { + OutputKind = OutputKind.ConsoleApplication, + Sources = { testCode }, + }, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that SA1516 is reported between global statement and record declaration in top-level programs. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task TestGlobalStatementAndRecordSpacingInTopLevelProgramAsync() + { + var testCode = @"return 0; +{|#0:record|} A(); +"; + + var fixedCode = @"return 0; + +record A(); +"; + + var test = new CSharpTest() + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestState = + { + OutputKind = OutputKind.ConsoleApplication, + Sources = { testCode }, + }, + FixedCode = fixedCode, + }; + var expectedDiagnostics = this.GetExpectedResultTestGlobalStatementAndRecordSpacingInTopLevelProgram(); + test.TestState.ExpectedDiagnostics.AddRange(expectedDiagnostics); + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3658, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3658")] + public async Task TestInitAccessorAsync() + { + var testCode = @"using System; + +public class Foo +{ + public int X + { + get + { + return 0; + } +[| |]init + { + } + } +} +"; + + var fixedCode = @"using System; + +public class Foo +{ + public int X + { + get + { + return 0; + } + + init + { + } + } +} +"; + + await new CSharpTest + { + TestCode = testCode, + FixedCode = fixedCode, + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + protected virtual DiagnosticResult[] GetExpectedResultTestUsingAndGlobalStatementSpacingInTopLevelProgram() + { + // NOTE: Seems like a Roslyn bug made diagnostics be reported twice. Fixed in a later version. + return new[] + { + // /0/Test0.cs(3,1): warning SA1516: Elements should be separated by blank line + Diagnostic().WithLocation(0), + + // /0/Test0.cs(3,1): warning SA1516: Elements should be separated by blank line + Diagnostic().WithLocation(0), + }; + } + + protected virtual DiagnosticResult[] GetExpectedResultTestGlobalStatementAndRecordSpacingInTopLevelProgram() + { + // NOTE: Seems like a Roslyn bug made diagnostics be reported twice. Fixed in a later version. + return new[] + { + // /0/Test0.cs(2,1): warning SA1516: Elements should be separated by blank line + Diagnostic().WithLocation(0), + + // /0/Test0.cs(2,1): warning SA1516: Elements should be separated by blank line + Diagnostic().WithLocation(0), + }; + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1516UsingGroupsCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1516UsingGroupsCSharp9UnitTests.cs new file mode 100644 index 000000000..9f702755b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1516UsingGroupsCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp8.LayoutRules; + + public partial class SA1516UsingGroupsCSharp9UnitTests : SA1516UsingGroupsCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1517CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1517CSharp9UnitTests.cs new file mode 100644 index 000000000..6086f8a8f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1517CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp8.LayoutRules; + + public partial class SA1517CSharp9UnitTests : SA1517CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1518CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1518CSharp9UnitTests.cs new file mode 100644 index 000000000..fa58c537a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1518CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp8.LayoutRules; + + public partial class SA1518CSharp9UnitTests : SA1518CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1519CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1519CSharp9UnitTests.cs new file mode 100644 index 000000000..18d30da08 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1519CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp8.LayoutRules; + + public partial class SA1519CSharp9UnitTests : SA1519CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1520CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1520CSharp9UnitTests.cs new file mode 100644 index 000000000..5bdca5ff9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/LayoutRules/SA1520CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.LayoutRules +{ + using StyleCop.Analyzers.Test.CSharp8.LayoutRules; + + public partial class SA1520CSharp9UnitTests : SA1520CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/AccessorDeclarationSyntaxExtensionsCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/AccessorDeclarationSyntaxExtensionsCSharp9UnitTests.cs new file mode 100644 index 000000000..bb4369626 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/AccessorDeclarationSyntaxExtensionsCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class AccessorDeclarationSyntaxExtensionsCSharp9UnitTests : AccessorDeclarationSyntaxExtensionsCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/ArgumentSyntaxExtensionsCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/ArgumentSyntaxExtensionsCSharp9UnitTests.cs new file mode 100644 index 000000000..d855355f5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/ArgumentSyntaxExtensionsCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class ArgumentSyntaxExtensionsCSharp9UnitTests : ArgumentSyntaxExtensionsCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/BaseMethodDeclarationSyntaxExtensionsCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/BaseMethodDeclarationSyntaxExtensionsCSharp9UnitTests.cs new file mode 100644 index 000000000..08cd87ebe --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/BaseMethodDeclarationSyntaxExtensionsCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class BaseMethodDeclarationSyntaxExtensionsCSharp9UnitTests : BaseMethodDeclarationSyntaxExtensionsCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/CasePatternSwitchLabelSyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/CasePatternSwitchLabelSyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..58c2edbbb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/CasePatternSwitchLabelSyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class CasePatternSwitchLabelSyntaxWrapperCSharp9UnitTests : CasePatternSwitchLabelSyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/CommonForEachStatementSyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/CommonForEachStatementSyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..92e7f8112 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/CommonForEachStatementSyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class CommonForEachStatementSyntaxWrapperCSharp9UnitTests : CommonForEachStatementSyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/ConstantPatternSyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/ConstantPatternSyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..4b740c2d0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/ConstantPatternSyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class ConstantPatternSyntaxWrapperCSharp9UnitTests : ConstantPatternSyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/ConstructorDeclarationSyntaxExtensionsCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/ConstructorDeclarationSyntaxExtensionsCSharp9UnitTests.cs new file mode 100644 index 000000000..e05c1c99b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/ConstructorDeclarationSyntaxExtensionsCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class ConstructorDeclarationSyntaxExtensionsCSharp9UnitTests : ConstructorDeclarationSyntaxExtensionsCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/CrefParameterSyntaxExtensionsCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/CrefParameterSyntaxExtensionsCSharp9UnitTests.cs new file mode 100644 index 000000000..ec2c99103 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/CrefParameterSyntaxExtensionsCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class CrefParameterSyntaxExtensionsCSharp9UnitTests : CrefParameterSyntaxExtensionsCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/DeclarationExpressionSyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/DeclarationExpressionSyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..ed0b861fc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/DeclarationExpressionSyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class DeclarationExpressionSyntaxWrapperCSharp9UnitTests : DeclarationExpressionSyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/DeclarationPatternSyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/DeclarationPatternSyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..1d422c1e1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/DeclarationPatternSyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class DeclarationPatternSyntaxWrapperCSharp9UnitTests : DeclarationPatternSyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/DestructorDeclarationSyntaxExtensionsCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/DestructorDeclarationSyntaxExtensionsCSharp9UnitTests.cs new file mode 100644 index 000000000..8dcb23b95 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/DestructorDeclarationSyntaxExtensionsCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class DestructorDeclarationSyntaxExtensionsCSharp9UnitTests : DestructorDeclarationSyntaxExtensionsCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/DiscardDesignationSyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/DiscardDesignationSyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..f0db61549 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/DiscardDesignationSyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class DiscardDesignationSyntaxWrapperCSharp9UnitTests : DiscardDesignationSyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..f82974d81 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp9UnitTests : ImplicitStackAllocArrayCreationExpressionSyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/IsPatternExpressionSyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/IsPatternExpressionSyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..535dd4cc8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/IsPatternExpressionSyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class IsPatternExpressionSyntaxWrapperCSharp9UnitTests : IsPatternExpressionSyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/LanguageVersionExCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/LanguageVersionExCSharp9UnitTests.cs new file mode 100644 index 000000000..872c92c08 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/LanguageVersionExCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class LanguageVersionExCSharp9UnitTests : LanguageVersionExCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/LightupHelpersCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/LightupHelpersCSharp9UnitTests.cs new file mode 100644 index 000000000..c7ccefc9c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/LightupHelpersCSharp9UnitTests.cs @@ -0,0 +1,20 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Lightup; + using StyleCop.Analyzers.Test.CSharp8.Lightup; + using StyleCop.Analyzers.Test.Lightup; + + /// + /// This class tests edge case behavior of in Roslyn 3.8+. It extends + /// since the tests defined there are valid in both environments without + /// alteration. + /// + public partial class LightupHelpersCSharp9UnitTests : LightupHelpersCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/LocalFunctionStatementSyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/LocalFunctionStatementSyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..3a255c96f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/LocalFunctionStatementSyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class LocalFunctionStatementSyntaxWrapperCSharp9UnitTests : LocalFunctionStatementSyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/MethodKindExCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/MethodKindExCSharp9UnitTests.cs new file mode 100644 index 000000000..bd7bdd7d3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/MethodKindExCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class MethodKindExCSharp9UnitTests : MethodKindExCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/OperationKindExCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/OperationKindExCSharp9UnitTests.cs new file mode 100644 index 000000000..428de1dcb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/OperationKindExCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class OperationKindExCSharp9UnitTests : OperationKindExCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/ParenthesizedVariableDesignationSyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/ParenthesizedVariableDesignationSyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..d714a7f93 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/ParenthesizedVariableDesignationSyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class ParenthesizedVariableDesignationSyntaxWrapperCSharp9UnitTests : ParenthesizedVariableDesignationSyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/PatternSyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/PatternSyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..908e125fb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/PatternSyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class PatternSyntaxWrapperCSharp9UnitTests : PatternSyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/RefExpressionSyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/RefExpressionSyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..82b48681a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/RefExpressionSyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class RefExpressionSyntaxWrapperCSharp9UnitTests : RefExpressionSyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/RefTypeSyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/RefTypeSyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..d32584654 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/RefTypeSyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class RefTypeSyntaxWrapperCSharp9UnitTests : RefTypeSyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/SingleVariableDesignationSyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/SingleVariableDesignationSyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..8c8681ecc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/SingleVariableDesignationSyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class SingleVariableDesignationSyntaxWrapperCSharp9UnitTests : SingleVariableDesignationSyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/StackAllocArrayCreationExpressionSyntaxExtensionsCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/StackAllocArrayCreationExpressionSyntaxExtensionsCSharp9UnitTests.cs new file mode 100644 index 000000000..2e4ec19c9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/StackAllocArrayCreationExpressionSyntaxExtensionsCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class StackAllocArrayCreationExpressionSyntaxExtensionsCSharp9UnitTests : StackAllocArrayCreationExpressionSyntaxExtensionsCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/SwitchExpressionArmSyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/SwitchExpressionArmSyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..e278b1d4d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/SwitchExpressionArmSyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class SwitchExpressionArmSyntaxWrapperCSharp9UnitTests : SwitchExpressionArmSyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/SwitchExpressionSyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/SwitchExpressionSyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..15f7cb580 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/SwitchExpressionSyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class SwitchExpressionSyntaxWrapperCSharp9UnitTests : SwitchExpressionSyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/SyntaxKindExCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/SyntaxKindExCSharp9UnitTests.cs new file mode 100644 index 000000000..1f7596791 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/SyntaxKindExCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class SyntaxKindExCSharp9UnitTests : SyntaxKindExCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/SyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/SyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..4cc37b8f9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/SyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class SyntaxWrapperCSharp9UnitTests : SyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/SyntaxWrapperHelperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/SyntaxWrapperHelperCSharp9UnitTests.cs new file mode 100644 index 000000000..dd957d625 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/SyntaxWrapperHelperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class SyntaxWrapperHelperCSharp9UnitTests : SyntaxWrapperHelperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/ThrowExpressionSyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/ThrowExpressionSyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..77689227b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/ThrowExpressionSyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class ThrowExpressionSyntaxWrapperCSharp9UnitTests : ThrowExpressionSyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/TupleElementSyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/TupleElementSyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..f4dbb293a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/TupleElementSyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class TupleElementSyntaxWrapperCSharp9UnitTests : TupleElementSyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/TupleExpressionSyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/TupleExpressionSyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..e5c6c968f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/TupleExpressionSyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class TupleExpressionSyntaxWrapperCSharp9UnitTests : TupleExpressionSyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/TupleTypeSyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/TupleTypeSyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..5ccd702e4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/TupleTypeSyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class TupleTypeSyntaxWrapperCSharp9UnitTests : TupleTypeSyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/VariableDesignationSyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/VariableDesignationSyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..3a779d0f7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/VariableDesignationSyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class VariableDesignationSyntaxWrapperCSharp9UnitTests : VariableDesignationSyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/WhenClauseSyntaxWrapperCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/WhenClauseSyntaxWrapperCSharp9UnitTests.cs new file mode 100644 index 000000000..d743f2866 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Lightup/WhenClauseSyntaxWrapperCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Lightup +{ + using StyleCop.Analyzers.Test.CSharp8.Lightup; + + public partial class WhenClauseSyntaxWrapperCSharp9UnitTests : WhenClauseSyntaxWrapperCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1119CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1119CSharp9UnitTests.cs new file mode 100644 index 000000000..262065c1f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1119CSharp9UnitTests.cs @@ -0,0 +1,156 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.MaintainabilityRules.SA1119StatementMustNotUseUnnecessaryParenthesis, + StyleCop.Analyzers.MaintainabilityRules.SA1119CodeFixProvider>; + + public partial class SA1119CSharp9UnitTests : SA1119CSharp8UnitTests + { + /// + /// Verifies that a type cast followed by a with expression is handled correctly. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3239, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3239")] + public async Task TestTypeCastFollowedByWithExpressionIsHandledCorrectlyAsync() + { + const string testCode = @" +record Foo(int Value) +{ + public object TestMethod(Foo n, int a) + { + return (object)(n with { Value = a }); + } +} +"; + + await new CSharpTest() + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestCode = testCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that a type cast followed by a with expression with unnecessary parentheses is handled + /// correctly. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3239, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3239")] + public async Task TestTypeCastFollowedByWithExpressionWithUnnecessaryParenthesesIsHandledCorrectlyAsync() + { + const string testCode = @" +record Foo(int Value) +{ + public object TestMethod(Foo n, int a) + { + return (object){|#0:{|#1:(|}(n with { Value = a }){|#2:)|}|}; + } +} +"; + + const string fixedCode = @" +record Foo(int Value) +{ + public object TestMethod(Foo n, int a) + { + return (object)(n with { Value = a }); + } +} +"; + + await new CSharpTest() + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestCode = testCode, + ExpectedDiagnostics = + { + Diagnostic(DiagnosticId).WithLocation(0), + Diagnostic(ParenthesesDiagnosticId).WithLocation(1), + Diagnostic(ParenthesesDiagnosticId).WithLocation(2), + }, + FixedCode = fixedCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that a with expression with unnecessary parentheses is handled correcly. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3239, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3239")] + public async Task TestWithExpressionWithUnnecessaryParenthesesAsync() + { + const string testCode = @" +record Foo(int Value) +{ + public void TestMethod(Foo n, int a) + { + var test = {|#0:{|#1:(|}n with { Value = a }{|#2:)|}|}; + } +} +"; + + const string fixedCode = @" +record Foo(int Value) +{ + public void TestMethod(Foo n, int a) + { + var test = n with { Value = a }; + } +} +"; + + await new CSharpTest() + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestCode = testCode, + ExpectedDiagnostics = + { + Diagnostic(DiagnosticId).WithLocation(0), + Diagnostic(ParenthesesDiagnosticId).WithLocation(1), + Diagnostic(ParenthesesDiagnosticId).WithLocation(2), + }, + FixedCode = fixedCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + [Theory] + [InlineData(".ToString()")] + [InlineData("?.ToString()")] + [InlineData("[0]")] + [InlineData("?[0]")] + [WorkItem(3239, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3239")] + public async Task TestWithExpressionFollowedByDereferenceAsync(string operation) + { + string testCode = $@" +record Foo(int Value) +{{ + public object this[int index] => null; + + public object TestMethod(Foo n, int a) + {{ + return (n with {{ Value = a }}){operation}; + }} +}} +"; + + await new CSharpTest() + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestCode = testCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1400CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1400CSharp9UnitTests.cs new file mode 100644 index 000000000..1e0d988a1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1400CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules; + + public partial class SA1400CSharp9UnitTests : SA1400CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1401CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1401CSharp9UnitTests.cs new file mode 100644 index 000000000..316213fdb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1401CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules; + + public partial class SA1401CSharp9UnitTests : SA1401CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1402ForClassCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1402ForClassCSharp9UnitTests.cs new file mode 100644 index 000000000..4abdc21e5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1402ForClassCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules; + + public partial class SA1402ForClassCSharp9UnitTests : SA1402ForClassCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1402ForDelegateCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1402ForDelegateCSharp9UnitTests.cs new file mode 100644 index 000000000..fdd9d0049 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1402ForDelegateCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules; + + public partial class SA1402ForDelegateCSharp9UnitTests : SA1402ForDelegateCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1402ForEnumCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1402ForEnumCSharp9UnitTests.cs new file mode 100644 index 000000000..8c77f2cd4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1402ForEnumCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules; + + public partial class SA1402ForEnumCSharp9UnitTests : SA1402ForEnumCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1402ForInterfaceCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1402ForInterfaceCSharp9UnitTests.cs new file mode 100644 index 000000000..757abb515 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1402ForInterfaceCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules; + + public partial class SA1402ForInterfaceCSharp9UnitTests : SA1402ForInterfaceCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1402ForRecordCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1402ForRecordCSharp9UnitTests.cs new file mode 100644 index 000000000..ccf1460ac --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1402ForRecordCSharp9UnitTests.cs @@ -0,0 +1,16 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.MaintainabilityRules; + + public class SA1402ForRecordCSharp9UnitTests : SA1402ForBlockDeclarationUnitTestsBase + { + public override string Keyword => "record"; + + protected override string SettingKeyword => "class"; + + protected override bool IsConfiguredAsTopLevelTypeByDefault => true; + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1402ForStructCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1402ForStructCSharp9UnitTests.cs new file mode 100644 index 000000000..025062982 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1402ForStructCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules; + + public partial class SA1402ForStructCSharp9UnitTests : SA1402ForStructCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1403CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1403CSharp9UnitTests.cs new file mode 100644 index 000000000..e204fbff2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1403CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules; + + public partial class SA1403CSharp9UnitTests : SA1403CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1404CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1404CSharp9UnitTests.cs new file mode 100644 index 000000000..b2da19872 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1404CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules; + + public partial class SA1404CSharp9UnitTests : SA1404CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1405CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1405CSharp9UnitTests.cs new file mode 100644 index 000000000..93eef9b1c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1405CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules; + + public partial class SA1405CSharp9UnitTests : SA1405CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1406CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1406CSharp9UnitTests.cs new file mode 100644 index 000000000..e99633f35 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1406CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules; + + public partial class SA1406CSharp9UnitTests : SA1406CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1407CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1407CSharp9UnitTests.cs new file mode 100644 index 000000000..2e34a5c7b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1407CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules; + + public partial class SA1407CSharp9UnitTests : SA1407CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1408CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1408CSharp9UnitTests.cs new file mode 100644 index 000000000..2a2cfc1b0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1408CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules; + + public partial class SA1408CSharp9UnitTests : SA1408CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1409CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1409CSharp9UnitTests.cs new file mode 100644 index 000000000..12fa23e5d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1409CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules; + + public partial class SA1409CSharp9UnitTests : SA1409CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1410CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1410CSharp9UnitTests.cs new file mode 100644 index 000000000..694299619 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1410CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules; + + public partial class SA1410CSharp9UnitTests : SA1410CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1411CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1411CSharp9UnitTests.cs new file mode 100644 index 000000000..2312d84cb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1411CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules; + + public partial class SA1411CSharp9UnitTests : SA1411CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1412CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1412CSharp9UnitTests.cs new file mode 100644 index 000000000..114e8b5bf --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1412CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules; + + public partial class SA1412CSharp9UnitTests : SA1412CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1413CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1413CSharp9UnitTests.cs new file mode 100644 index 000000000..55a2ba77a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1413CSharp9UnitTests.cs @@ -0,0 +1,69 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.MaintainabilityRules.SA1413UseTrailingCommasInMultiLineInitializers, + StyleCop.Analyzers.MaintainabilityRules.SA1413CodeFixProvider>; + + public partial class SA1413CSharp9UnitTests : SA1413CSharp8UnitTests + { + [Fact] + [WorkItem(3240, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3240")] + public async Task VerifyWithInitializerAsync() + { + var testCode = @"namespace TestNamespace +{ + public record R + { + public int A { get; set; } + + public int B { get; set; } + + void M() + { + _ = this with { A = 1, B = 2 }; + _ = this with { A = 1, B = 2, }; + _ = this with + { + A = 1, + [|B = 2|] + }; + } + } +} +"; + var fixedCode = @"namespace TestNamespace +{ + public record R + { + public int A { get; set; } + + public int B { get; set; } + + void M() + { + _ = this with { A = 1, B = 2 }; + _ = this with { A = 1, B = 2, }; + _ = this with + { + A = 1, + B = 2, + }; + } + } +} +"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1414CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1414CSharp9UnitTests.cs new file mode 100644 index 000000000..f46a3c407 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/MaintainabilityRules/SA1414CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.MaintainabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.MaintainabilityRules; + + public partial class SA1414CSharp9UnitTests : SA1414CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1300CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1300CSharp9UnitTests.cs new file mode 100644 index 000000000..807826631 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1300CSharp9UnitTests.cs @@ -0,0 +1,82 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.NamingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.NamingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.NamingRules.SA1300ElementMustBeginWithUpperCaseLetter, + StyleCop.Analyzers.NamingRules.RenameToUpperCaseCodeFixProvider>; + + public partial class SA1300CSharp9UnitTests : SA1300CSharp8UnitTests + { + [Fact] + public async Task TestPositionalRecord1Async() + { + var testCode = @" +public record {|#0:r|}(int A) +{ + public r(int a, int b) + : this(A: a) + { + } +} +"; + + var fixedCode = @" +public record R(int A) +{ + public R(int a, int b) + : this(A: a) + { + } +} +"; + + await VerifyCSharpFixAsync(testCode, this.GetExpectedResultTestPositionalRecord1(), fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestPositionalRecord2Async() + { + var testCode = @" +public record R(int [|a|]) +{ + public R(int a, int b) + : this(a: a) + { + } +} +"; + + var fixedCode = @" +public record R(int A) +{ + public R(int a, int b) + : this(A: a) + { + } +} +"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + protected virtual DiagnosticResult[] GetExpectedResultTestPositionalRecord1() + { + // NOTE: Seems like a Roslyn bug made diagnostics be reported twice. Fixed in a later version. + return new[] + { + // /0/Test0.cs(2,15): warning SA1300: Element 'r' should begin with an uppercase letter + Diagnostic().WithLocation(0).WithArguments("r"), + + // /0/Test0.cs(2,15): warning SA1300: Element 'r' should begin with an uppercase letter + Diagnostic().WithLocation(0).WithArguments("r"), + }; + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1301CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1301CSharp9UnitTests.cs new file mode 100644 index 000000000..79d4b522e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1301CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp8.NamingRules; + + public partial class SA1301CSharp9UnitTests : SA1301CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1302CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1302CSharp9UnitTests.cs new file mode 100644 index 000000000..ec51d4795 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1302CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp8.NamingRules; + + public partial class SA1302CSharp9UnitTests : SA1302CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1303CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1303CSharp9UnitTests.cs new file mode 100644 index 000000000..27a241c96 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1303CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp8.NamingRules; + + public partial class SA1303CSharp9UnitTests : SA1303CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1304CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1304CSharp9UnitTests.cs new file mode 100644 index 000000000..ad101998c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1304CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp8.NamingRules; + + public partial class SA1304CSharp9UnitTests : SA1304CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1305CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1305CSharp9UnitTests.cs new file mode 100644 index 000000000..655ccc857 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1305CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp8.NamingRules; + + public partial class SA1305CSharp9UnitTests : SA1305CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1306CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1306CSharp9UnitTests.cs new file mode 100644 index 000000000..c7299a986 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1306CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp8.NamingRules; + + public partial class SA1306CSharp9UnitTests : SA1306CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1307CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1307CSharp9UnitTests.cs new file mode 100644 index 000000000..a9eab491f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1307CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp8.NamingRules; + + public partial class SA1307CSharp9UnitTests : SA1307CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1308CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1308CSharp9UnitTests.cs new file mode 100644 index 000000000..4d341636f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1308CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp8.NamingRules; + + public partial class SA1308CSharp9UnitTests : SA1308CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1309CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1309CSharp9UnitTests.cs new file mode 100644 index 000000000..cf423d09b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1309CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp8.NamingRules; + + public partial class SA1309CSharp9UnitTests : SA1309CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1310CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1310CSharp9UnitTests.cs new file mode 100644 index 000000000..c579567ab --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1310CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp8.NamingRules; + + public partial class SA1310CSharp9UnitTests : SA1310CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1311CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1311CSharp9UnitTests.cs new file mode 100644 index 000000000..084d13b66 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1311CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp8.NamingRules; + + public partial class SA1311CSharp9UnitTests : SA1311CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1312CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1312CSharp9UnitTests.cs new file mode 100644 index 000000000..ab3ed34dd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1312CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp8.NamingRules; + + public partial class SA1312CSharp9UnitTests : SA1312CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1313CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1313CSharp9UnitTests.cs new file mode 100644 index 000000000..bd393fb24 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1313CSharp9UnitTests.cs @@ -0,0 +1,45 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.NamingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.NamingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.NamingRules.SA1313ParameterNamesMustBeginWithLowerCaseLetter, + StyleCop.Analyzers.NamingRules.RenameToLowerCaseCodeFixProvider>; + + public partial class SA1313CSharp9UnitTests : SA1313CSharp8UnitTests + { + [Fact] + [WorkItem(3168, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3168")] + [WorkItem(3181, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3181")] + public async Task TestPositionalRecordAsync() + { + var testCode = @" +public record R(int A) +{ + public R(int [|A|], int [|B|]) + : this(A) + { + } +} +"; + + var fixedCode = @" +public record R(int A) +{ + public R(int a, int b) + : this(a) + { + } +} +"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1314CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1314CSharp9UnitTests.cs new file mode 100644 index 000000000..0bb8dd9b2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1314CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp8.NamingRules; + + public partial class SA1314CSharp9UnitTests : SA1314CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1316CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1316CSharp9UnitTests.cs new file mode 100644 index 000000000..33841ff19 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SA1316CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp8.NamingRules; + + public partial class SA1316CSharp9UnitTests : SA1316CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SX1309CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SX1309CSharp9UnitTests.cs new file mode 100644 index 000000000..fadff3de8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SX1309CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp8.NamingRules; + + public partial class SX1309CSharp9UnitTests : SX1309CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SX1309SCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SX1309SCSharp9UnitTests.cs new file mode 100644 index 000000000..242e9cb7d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/NamingRules/SX1309SCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.NamingRules +{ + using StyleCop.Analyzers.Test.CSharp8.NamingRules; + + public partial class SX1309SCSharp9UnitTests : SX1309SCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1200CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1200CSharp9UnitTests.cs new file mode 100644 index 000000000..43ec92e6c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1200CSharp9UnitTests.cs @@ -0,0 +1,46 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.OrderingRules.SA1200UsingDirectivesMustBePlacedCorrectly, + StyleCop.Analyzers.OrderingRules.UsingCodeFixProvider>; + + public partial class SA1200CSharp9UnitTests : SA1200CSharp8UnitTests + { + /// + /// Verifies that having using statements in the compilation unit will not produce diagnostics for top-level + /// programs. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3243, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3243")] + public async Task TestValidUsingStatementsInTopLevelProgramAsync() + { + var testCode = @"using System; +using System.Threading; + +return 0; +"; + + await new CSharpTest() + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestState = + { + OutputKind = OutputKind.ConsoleApplication, + Sources = { testCode }, + }, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1200OutsideNamespaceCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1200OutsideNamespaceCSharp9UnitTests.cs new file mode 100644 index 000000000..951afb0fa --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1200OutsideNamespaceCSharp9UnitTests.cs @@ -0,0 +1,47 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.OrderingRules.SA1200UsingDirectivesMustBePlacedCorrectly, + StyleCop.Analyzers.OrderingRules.UsingCodeFixProvider>; + + public partial class SA1200OutsideNamespaceCSharp9UnitTests : SA1200OutsideNamespaceCSharp8UnitTests + { + /// + /// Verifies that having using statements in the compilation unit will not produce diagnostics for top-level + /// programs. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3243, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3243")] + public async Task TestValidUsingStatementsInTopLevelProgramAsync() + { + var testCode = @"using System; +using System.Threading; + +return 0; +"; + + await new CSharpTest() + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestState = + { + OutputKind = OutputKind.ConsoleApplication, + Sources = { testCode }, + }, + Settings = TestSettings, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1200PreserveCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1200PreserveCSharp9UnitTests.cs new file mode 100644 index 000000000..e0bb5b7b6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1200PreserveCSharp9UnitTests.cs @@ -0,0 +1,47 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.OrderingRules.SA1200UsingDirectivesMustBePlacedCorrectly, + StyleCop.Analyzers.OrderingRules.UsingCodeFixProvider>; + + public partial class SA1200PreserveCSharp9UnitTests : SA1200PreserveCSharp8UnitTests + { + /// + /// Verifies that having using statements in the compilation unit will not produce diagnostics for top-level + /// programs. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3243, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3243")] + public async Task TestValidUsingStatementsInTopLevelProgramAsync() + { + var testCode = @"using System; +using System.Threading; + +return 0; +"; + + await new CSharpTest() + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestState = + { + OutputKind = OutputKind.ConsoleApplication, + Sources = { testCode }, + }, + Settings = TestSettings, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1201CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1201CSharp9UnitTests.cs new file mode 100644 index 000000000..616363bfc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1201CSharp9UnitTests.cs @@ -0,0 +1,143 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.OrderingRules.SA1201ElementsMustAppearInTheCorrectOrder, + StyleCop.Analyzers.OrderingRules.ElementOrderCodeFixProvider>; + + public partial class SA1201CSharp9UnitTests : SA1201CSharp8UnitTests + { + [Fact] + [WorkItem(3236, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3236")] + public async Task TestOuterOrderWithRecordCorrectOrderAsync() + { + string testCode = @"namespace Foo { } +public delegate void bar(); +public enum TestEnum { } +public interface IFoo { } +public struct FooStruct { } +public record FooClass { } +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpDiagnosticAsync("namespace OuterNamespace { " + testCode + " }", DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3236, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3236")] + public async Task TestOuterOrderWithRecordWrongOrderAsync() + { + string testCode = @" +namespace Foo { } +public enum TestEnum { } +public delegate void {|#0:bar|}(); +public interface IFoo { } +public record FooClass { } +public struct {|#1:FooStruct|} { } +"; + var expected = new[] + { + Diagnostic().WithLocation(0).WithArguments("delegate", "enum"), + Diagnostic().WithLocation(1).WithArguments("struct", "record"), + }; + + await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpDiagnosticAsync("namespace OuterNamespace { " + testCode + " }", expected, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestTypeMemberOrderCorrectOrderRecordAsync() + { + string testCode = @"public record OuterType +{ + public string TestField; + public OuterType(int argument) { TestField = ""foo""; TestProperty = """"; } + public delegate void TestDelegate(); + public event TestDelegate TestEvent { add { } remove { } } + public enum TestEnum { } + public interface ITest { } + public string TestProperty { get; set; } + public string this[string arg] { get { return ""foo""; } set { } } + public static explicit operator bool(OuterType t1) { return t1.TestField != null; } + public static OuterType operator +(OuterType t1, OuterType t2) { return t1; } + public void TestMethod () { } + public struct TestStruct { } + public class TestClass1 { } + public record TestRecord1 { } + public class TestClass2 { } + public record TestRecord2 { } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestTypeMemberOrderWrongOrderRecordAsync() + { + string testCode = @"public record OuterType +{ + public string TestField; + public OuterType(int argument) { TestField = ""foo""; TestProperty = ""bar""; } + public interface ITest { } + public delegate void TestDelegate(); + public event TestDelegate TestEvent { add { } remove { } } + public enum TestEnum { } + public static OuterType operator +(OuterType t1, OuterType t2) { return t1; } + public static explicit operator bool(OuterType t1) { return t1.TestField != null; } + public string TestProperty { get; set; } + public struct TestStruct { } + public void TestMethod () { } + public class TestClass { } + public string this[string arg] { get { return ""foo""; } set { } } +} +"; + var expected = new[] + { + Diagnostic().WithLocation(6, 26).WithArguments("delegate", "interface"), + Diagnostic().WithLocation(10, 5).WithArguments("conversion", "operator"), + Diagnostic().WithLocation(11, 19).WithArguments("property", "conversion"), + Diagnostic().WithLocation(13, 17).WithArguments("method", "struct"), + Diagnostic().WithLocation(15, 19).WithArguments("indexer", "class"), + }; + + string fixedCode = @"public record OuterType +{ + public string TestField; + public OuterType(int argument) { TestField = ""foo""; TestProperty = ""bar""; } + public delegate void TestDelegate(); + public event TestDelegate TestEvent { add { } remove { } } + public enum TestEnum { } + public interface ITest { } + public string TestProperty { get; set; } + public string this[string arg] { get { return ""foo""; } set { } } + public static explicit operator bool(OuterType t1) { return t1.TestField != null; } + public static OuterType operator +(OuterType t1, OuterType t2) { return t1; } + public void TestMethod () { } + public struct TestStruct { } + public class TestClass { } +} +"; + + var test = new CSharpTest + { + TestCode = testCode, + FixedCode = fixedCode, + NumberOfIncrementalIterations = 7, + NumberOfFixAllIterations = 3, + }; + + test.ExpectedDiagnostics.AddRange(expected); + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1202CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1202CSharp9UnitTests.cs new file mode 100644 index 000000000..58553ae37 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1202CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + + public partial class SA1202CSharp9UnitTests : SA1202CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1203CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1203CSharp9UnitTests.cs new file mode 100644 index 000000000..3312840e3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1203CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + + public partial class SA1203CSharp9UnitTests : SA1203CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1204CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1204CSharp9UnitTests.cs new file mode 100644 index 000000000..84fa227a9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1204CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + + public partial class SA1204CSharp9UnitTests : SA1204CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1205CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1205CSharp9UnitTests.cs new file mode 100644 index 000000000..b3c4bb44b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1205CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + + public partial class SA1205CSharp9UnitTests : SA1205CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1206CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1206CSharp9UnitTests.cs new file mode 100644 index 000000000..b302caedb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1206CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + + public partial class SA1206CSharp9UnitTests : SA1206CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1206CodeFixProviderCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1206CodeFixProviderCSharp9UnitTests.cs new file mode 100644 index 000000000..9a91e56d6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1206CodeFixProviderCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + + public partial class SA1206CodeFixProviderCSharp9UnitTests : SA1206CodeFixProviderCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1207CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1207CSharp9UnitTests.cs new file mode 100644 index 000000000..1fb71999c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1207CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + + public partial class SA1207CSharp9UnitTests : SA1207CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1208CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1208CSharp9UnitTests.cs new file mode 100644 index 000000000..0f1062e47 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1208CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + + public partial class SA1208CSharp9UnitTests : SA1208CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1209CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1209CSharp9UnitTests.cs new file mode 100644 index 000000000..8ec3e8ef2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1209CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + + public partial class SA1209CSharp9UnitTests : SA1209CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1210CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1210CSharp9UnitTests.cs new file mode 100644 index 000000000..3040ffaf0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1210CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + + public partial class SA1210CSharp9UnitTests : SA1210CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1210CombinedSystemDirectivesCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1210CombinedSystemDirectivesCSharp9UnitTests.cs new file mode 100644 index 000000000..08c3ee7d9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1210CombinedSystemDirectivesCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + + public partial class SA1210CombinedSystemDirectivesCSharp9UnitTests : SA1210CombinedSystemDirectivesCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1211CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1211CSharp9UnitTests.cs new file mode 100644 index 000000000..8a110a47d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1211CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + + public partial class SA1211CSharp9UnitTests : SA1211CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1212CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1212CSharp9UnitTests.cs new file mode 100644 index 000000000..43f070246 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1212CSharp9UnitTests.cs @@ -0,0 +1,91 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.OrderingRules.SA1212PropertyAccessorsMustFollowOrder, + StyleCop.Analyzers.OrderingRules.SA1212SA1213CodeFixProvider>; + + public partial class SA1212CSharp9UnitTests : SA1212CSharp8UnitTests + { + [Fact] + [WorkItem(3652, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3652")] + public async Task TestAutoPropertyDeclarationInitBeforeGetterAsync() + { + var testCode = @" +public class Foo +{ + public int Prop { [|init;|] get; } +}"; + + var fixedCode = @" +public class Foo +{ + public int Prop { get; init; } +}"; + + await new CSharpTest + { + TestCode = testCode, + FixedCode = fixedCode, + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3652, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3652")] + public async Task TestPropertyWithBackingFieldDeclarationInitBeforeGetterAsync() + { + var testCode = @" +public class Foo +{ + private int i = 0; + + public int Prop + { + [|init + { + i = value; + }|] + + get + { + return i; + } + } +}"; + + var fixedCode = @" +public class Foo +{ + private int i = 0; + + public int Prop + { + get + { + return i; + } + + init + { + i = value; + } + } +}"; + + await new CSharpTest + { + TestCode = testCode, + FixedCode = fixedCode, + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1213CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1213CSharp9UnitTests.cs new file mode 100644 index 000000000..5c3b4bb79 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1213CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + + public partial class SA1213CSharp9UnitTests : SA1213CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1214CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1214CSharp9UnitTests.cs new file mode 100644 index 000000000..d829a2505 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1214CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + + public partial class SA1214CSharp9UnitTests : SA1214CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1215CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1215CSharp9UnitTests.cs new file mode 100644 index 000000000..fc3a8ec56 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1215CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + + public partial class SA1215CSharp9UnitTests : SA1215CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1216CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1216CSharp9UnitTests.cs new file mode 100644 index 000000000..237d650ac --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1216CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + + public partial class SA1216CSharp9UnitTests : SA1216CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1217CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1217CSharp9UnitTests.cs new file mode 100644 index 000000000..f8901ef69 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/SA1217CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + + public partial class SA1217CSharp9UnitTests : SA1217CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/UsingCodeFixProviderCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/UsingCodeFixProviderCSharp9UnitTests.cs new file mode 100644 index 000000000..258504cd4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/UsingCodeFixProviderCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + + public partial class UsingCodeFixProviderCSharp9UnitTests : UsingCodeFixProviderCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/UsingCodeFixProviderCombinedSystemDirectivesCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/UsingCodeFixProviderCombinedSystemDirectivesCSharp9UnitTests.cs new file mode 100644 index 000000000..3579b9ab3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/UsingCodeFixProviderCombinedSystemDirectivesCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + + public partial class UsingCodeFixProviderCombinedSystemDirectivesCSharp9UnitTests : UsingCodeFixProviderCombinedSystemDirectivesCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/UsingCodeFixProviderGroupSeparationCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/UsingCodeFixProviderGroupSeparationCSharp9UnitTests.cs new file mode 100644 index 000000000..ea7901063 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/UsingCodeFixProviderGroupSeparationCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + + public partial class UsingCodeFixProviderGroupSeparationCSharp9UnitTests : UsingCodeFixProviderGroupSeparationCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/UsingCodeFixProviderRegressionCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/UsingCodeFixProviderRegressionCSharp9UnitTests.cs new file mode 100644 index 000000000..dada4904d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/OrderingRules/UsingCodeFixProviderRegressionCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.OrderingRules +{ + using StyleCop.Analyzers.Test.CSharp8.OrderingRules; + + public partial class UsingCodeFixProviderRegressionCSharp9UnitTests : UsingCodeFixProviderRegressionCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Properties/AssemblyInfo.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..98d2b8263 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Properties/AssemblyInfo.cs @@ -0,0 +1,17 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: CLSCompliant(false)] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp10, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1100CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1100CSharp9UnitTests.cs new file mode 100644 index 000000000..1795fc2f2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1100CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1100CSharp9UnitTests : SA1100CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1101CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1101CSharp9UnitTests.cs new file mode 100644 index 000000000..a9119a89a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1101CSharp9UnitTests.cs @@ -0,0 +1,37 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.ReadabilityRules.SA1101PrefixLocalCallsWithThis, + StyleCop.Analyzers.ReadabilityRules.SA1101CodeFixProvider>; + + public partial class SA1101CSharp9UnitTests : SA1101CSharp8UnitTests + { + [Fact] + [WorkItem(3201, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3201")] + public async Task TestRecordWithExpressionAsync() + { + var testCode = @"public class Test +{ + public record A + { + public string Prop { get; init; } + } + + public A UpdateA(A value) + { + return value with { Prop = ""newValue"" }; + } +}"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1102CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1102CSharp9UnitTests.cs new file mode 100644 index 000000000..0f01dcde2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1102CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1102CSharp9UnitTests : SA1102CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1103CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1103CSharp9UnitTests.cs new file mode 100644 index 000000000..9a5482322 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1103CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1103CSharp9UnitTests : SA1103CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1104CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1104CSharp9UnitTests.cs new file mode 100644 index 000000000..78cf8b5d9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1104CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1104CSharp9UnitTests : SA1104CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1105CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1105CSharp9UnitTests.cs new file mode 100644 index 000000000..371e01df1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1105CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1105CSharp9UnitTests : SA1105CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1106CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1106CSharp9UnitTests.cs new file mode 100644 index 000000000..969675841 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1106CSharp9UnitTests.cs @@ -0,0 +1,32 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.ReadabilityRules.SA1106CodeMustNotContainEmptyStatements, + StyleCop.Analyzers.ReadabilityRules.SA1106CodeFixProvider>; + + public partial class SA1106CSharp9UnitTests : SA1106CSharp8UnitTests + { + [Fact] + [WorkItem(3267, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3267")] + public async Task TestNoDiagnosticForEmptyRecordDeclarationAsync() + { + var testCode = @"public record Result(int Value);"; + + await new CSharpTest() + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestCode = testCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1107CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1107CSharp9UnitTests.cs new file mode 100644 index 000000000..dbcd22a35 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1107CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1107CSharp9UnitTests : SA1107CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1108CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1108CSharp9UnitTests.cs new file mode 100644 index 000000000..de9d34404 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1108CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1108CSharp9UnitTests : SA1108CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1109CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1109CSharp9UnitTests.cs new file mode 100644 index 000000000..02ce8f582 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1109CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1109CSharp9UnitTests : SA1109CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1110CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1110CSharp9UnitTests.cs new file mode 100644 index 000000000..bdaa844bf --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1110CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1110CSharp9UnitTests : SA1110CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1111CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1111CSharp9UnitTests.cs new file mode 100644 index 000000000..e7e70f249 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1111CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1111CSharp9UnitTests : SA1111CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1112CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1112CSharp9UnitTests.cs new file mode 100644 index 000000000..bf9db5d84 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1112CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1112CSharp9UnitTests : SA1112CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1113CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1113CSharp9UnitTests.cs new file mode 100644 index 000000000..82adbfd74 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1113CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1113CSharp9UnitTests : SA1113CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1114CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1114CSharp9UnitTests.cs new file mode 100644 index 000000000..19b0020ef --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1114CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1114CSharp9UnitTests : SA1114CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1115CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1115CSharp9UnitTests.cs new file mode 100644 index 000000000..ec76a95a4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1115CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1115CSharp9UnitTests : SA1115CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1116CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1116CSharp9UnitTests.cs new file mode 100644 index 000000000..a4930b508 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1116CSharp9UnitTests.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.ReadabilityRules.SA1116SplitParametersMustStartOnLineAfterDeclaration, + StyleCop.Analyzers.ReadabilityRules.SA1116CodeFixProvider>; + + public partial class SA1116CSharp9UnitTests : SA1116CSharp8UnitTests + { + [Fact] + public async Task TestTargetTypedNewExpressionnAsync() + { + var testCode = @" +class Foo +{ + public Foo(int a, int b) + { + } + + public void Method() + { + Foo x = new(1, + 2); + } +}"; + + var fixedCode = @" +class Foo +{ + public Foo(int a, int b) + { + } + + public void Method() + { + Foo x = new( + 1, + 2); + } +}"; + + DiagnosticResult expected = Diagnostic().WithLocation(10, 21); + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1117CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1117CSharp9UnitTests.cs new file mode 100644 index 000000000..ed4d3796d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1117CSharp9UnitTests.cs @@ -0,0 +1,60 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier; + + public partial class SA1117CSharp9UnitTests : SA1117CSharp8UnitTests + { + [Fact] + public async Task TestValidTargetTypedNewExpressionAsync() + { + var testCode = @" +class Foo +{ + public Foo(int a, int b, int c) + { + } + + public void Method() + { + Foo x = new( + 1, + 2, + 3); + } +}"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestInvalidTargetTypedNewExpressionAsync() + { + var testCode = @" +class Foo +{ + public Foo(int a, int b, int c) + { + } + + public void Method() + { + Foo x = new(1, + 2, 3); + } +}"; + + DiagnosticResult expected = Diagnostic().WithLocation(11, 16); + await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1118CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1118CSharp9UnitTests.cs new file mode 100644 index 000000000..bb3bc1896 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1118CSharp9UnitTests.cs @@ -0,0 +1,112 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier; + + public partial class SA1118CSharp9UnitTests : SA1118CSharp8UnitTests + { + [Fact] + [WorkItem(3314, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3314")] + public async Task TestWithExpressionAsync() + { + var testCode = @" +class Foo +{ + public record R(int X, int Y); + + public void FunA(params object[] j) + { + } + + public void FunB(R r) + { + FunA( + 1, + r with + { + X = 1, + }); + } +}"; + + await new CSharpTest() + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestCode = testCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3314, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3314")] + public async Task TestWithExpression2Async() + { + var testCode = @" +class Foo +{ + public record R(int X, int Y); + + public void FunA(params object[] j) + { + } + + public void FunB(R r) + { + FunA( + 1, + r with + { + X = 1, + }, + 2); + } +}"; + + await new CSharpTest() + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestCode = testCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3339, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3339")] + public async Task TestNewExpressionAsync() + { + var testCode = @" + public class MyClass + { + public class MyObject + { + public string MyValue { get; init; } + } + + public void MyTestFunction() + { + MyCallingFunction(0, new() + { + MyValue = ""Test"" + }); + } + + public void MyCallingFunction(int index, MyObject myObject) + { + } + }"; + + await new CSharpTest() + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestCode = testCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1120CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1120CSharp9UnitTests.cs new file mode 100644 index 000000000..881207182 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1120CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1120CSharp9UnitTests : SA1120CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1121CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1121CSharp9UnitTests.cs new file mode 100644 index 000000000..9665cfbe1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1121CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1121CSharp9UnitTests : SA1121CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1122CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1122CSharp9UnitTests.cs new file mode 100644 index 000000000..1005f153a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1122CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1122CSharp9UnitTests : SA1122CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1123CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1123CSharp9UnitTests.cs new file mode 100644 index 000000000..b4eb606d2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1123CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1123CSharp9UnitTests : SA1123CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1124CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1124CSharp9UnitTests.cs new file mode 100644 index 000000000..67b45d4bc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1124CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1124CSharp9UnitTests : SA1124CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1125CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1125CSharp9UnitTests.cs new file mode 100644 index 000000000..ebf7ab1ef --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1125CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1125CSharp9UnitTests : SA1125CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1126CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1126CSharp9UnitTests.cs new file mode 100644 index 000000000..959cfd1b3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1126CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1126CSharp9UnitTests : SA1126CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1127CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1127CSharp9UnitTests.cs new file mode 100644 index 000000000..eaa44aa08 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1127CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1127CSharp9UnitTests : SA1127CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1128CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1128CSharp9UnitTests.cs new file mode 100644 index 000000000..5d5d8560c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1128CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1128CSharp9UnitTests : SA1128CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1129CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1129CSharp9UnitTests.cs new file mode 100644 index 000000000..acd31096d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1129CSharp9UnitTests.cs @@ -0,0 +1,50 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.ReadabilityRules.SA1129DoNotUseDefaultValueTypeConstructor, + StyleCop.Analyzers.ReadabilityRules.SA1129CodeFixProvider>; + + public partial class SA1129CSharp9UnitTests : SA1129CSharp8UnitTests + { + /// + /// Verifies that target type new expressions for value types will generate diagnostics. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3277, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3277")] + public async Task VerifyValueTypeWithTargetTypeNewAsync() + { + var testCode = @"struct S +{ + internal static S F() + { + S s = [|new()|]; + return s; + } +} +"; + + var fixedTestCode = @"struct S +{ + internal static S F() + { + S s = default(S); + return s; + } +} +"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1130CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1130CSharp9UnitTests.cs new file mode 100644 index 000000000..63f1dbf7c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1130CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1130CSharp9UnitTests : SA1130CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1131CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1131CSharp9UnitTests.cs new file mode 100644 index 000000000..b94388896 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1131CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1131CSharp9UnitTests : SA1131CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1132CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1132CSharp9UnitTests.cs new file mode 100644 index 000000000..ce03e3d7b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1132CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1132CSharp9UnitTests : SA1132CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1133CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1133CSharp9UnitTests.cs new file mode 100644 index 000000000..bcabb4b39 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1133CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1133CSharp9UnitTests : SA1133CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1134CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1134CSharp9UnitTests.cs new file mode 100644 index 000000000..ca447ba18 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1134CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1134CSharp9UnitTests : SA1134CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1135CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1135CSharp9UnitTests.cs new file mode 100644 index 000000000..9f123d60f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1135CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1135CSharp9UnitTests : SA1135CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1136CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1136CSharp9UnitTests.cs new file mode 100644 index 000000000..dac63c600 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1136CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1136CSharp9UnitTests : SA1136CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1137CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1137CSharp9UnitTests.cs new file mode 100644 index 000000000..6ca2964f4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1137CSharp9UnitTests.cs @@ -0,0 +1,63 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.ReadabilityRules.SA1137ElementsShouldHaveTheSameIndentation, + StyleCop.Analyzers.ReadabilityRules.IndentationCodeFixProvider>; + + public partial class SA1137CSharp9UnitTests : SA1137CSharp8UnitTests + { + [Fact] + [WorkItem(3668, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3668")] + public async Task TestInitAccessorAttributeListAsync() + { + string testCode = @" +using System; + +class TestClass +{ + int Property + { + [My] +[| |][My] + init { } + } +} + +[AttributeUsage(AttributeTargets.All, AllowMultiple = true)] +class MyAttribute : Attribute { } +"; + + string fixedCode = @" +using System; + +class TestClass +{ + int Property + { + [My] + [My] + init { } + } +} + +[AttributeUsage(AttributeTargets.All, AllowMultiple = true)] +class MyAttribute : Attribute { } +"; + + await new CSharpTest + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + TestCode = testCode, + FixedCode = fixedCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1139CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1139CSharp9UnitTests.cs new file mode 100644 index 000000000..48f2bc49e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1139CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1139CSharp9UnitTests : SA1139CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1141CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1141CSharp9UnitTests.cs new file mode 100644 index 000000000..4c9eb72fb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1141CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1141CSharp9UnitTests : SA1141CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1142CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1142CSharp9UnitTests.cs new file mode 100644 index 000000000..9ea8e90b9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SA1142CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SA1142CSharp9UnitTests : SA1142CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SX1101CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SX1101CSharp9UnitTests.cs new file mode 100644 index 000000000..8a79a21dc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/ReadabilityRules/SX1101CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.ReadabilityRules +{ + using StyleCop.Analyzers.Test.CSharp8.ReadabilityRules; + + public partial class SX1101CSharp9UnitTests : SX1101CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Settings/SettingsCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Settings/SettingsCSharp9UnitTests.cs new file mode 100644 index 000000000..281ade82c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Settings/SettingsCSharp9UnitTests.cs @@ -0,0 +1,47 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.Settings +{ + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.Diagnostics; + using StyleCop.Analyzers.Test.CSharp8.Settings; + + public partial class SettingsCSharp9UnitTests : SettingsCSharp8UnitTests + { + protected override AnalyzerConfigOptionsProvider CreateAnalyzerConfigOptionsProvider(AnalyzerConfigSet analyzerConfigSet) + { + return new TestAnalyzerConfigOptionsProvider(analyzerConfigSet); + } + + private sealed class TestAnalyzerConfigOptionsProvider : AnalyzerConfigOptionsProvider + { + private readonly AnalyzerConfigSet analyzerConfigSet; + + public TestAnalyzerConfigOptionsProvider(AnalyzerConfigSet analyzerConfigSet) + { + this.analyzerConfigSet = analyzerConfigSet; + } + + public override AnalyzerConfigOptions GlobalOptions + { + get + { + return new TestAnalyzerConfigOptions(this.analyzerConfigSet.GlobalConfigOptions); + } + } + + public override AnalyzerConfigOptions GetOptions(SyntaxTree tree) + { + return new TestAnalyzerConfigOptions(this.analyzerConfigSet.GetOptionsForSourcePath(tree.FilePath)); + } + + public override AnalyzerConfigOptions GetOptions(AdditionalText textFile) + { + return new TestAnalyzerConfigOptions(this.analyzerConfigSet.GetOptionsForSourcePath(textFile.Path)); + } + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Settings/SettingsFileCodeFixProviderCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Settings/SettingsFileCodeFixProviderCSharp9UnitTests.cs new file mode 100644 index 000000000..12ce04a9f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/Settings/SettingsFileCodeFixProviderCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.Settings +{ + using StyleCop.Analyzers.Test.CSharp8.Settings; + + public partial class SettingsFileCodeFixProviderCSharp9UnitTests : SettingsFileCodeFixProviderCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1000CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1000CSharp9UnitTests.cs new file mode 100644 index 000000000..51a427fca --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1000CSharp9UnitTests.cs @@ -0,0 +1,71 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + using Xunit; + + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1000KeywordsMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1000CSharp9UnitTests : SA1000CSharp8UnitTests + { + [Fact] + public async Task TestTargetTypedNewAsync() + { + string statementWithoutSpace = "int a = new();"; + + await this.TestKeywordStatementAsync(statementWithoutSpace, DiagnosticResult.EmptyDiagnosticResults, statementWithoutSpace).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3508, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3508")] + public async Task TestIsBeforeRelationalPatternAsync() + { + var statementWithoutSpace = "_ = 1 {|#0:is|}>1;"; + var statementWithSpace = "_ = 1 is >1;"; + + var expected = Diagnostic().WithArguments("is", string.Empty, "followed").WithLocation(0); + await this.TestKeywordStatementAsync(statementWithoutSpace, expected, statementWithSpace).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3508, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3508")] + public async Task TestNotBeforeRelationalPatternAsync() + { + var statementWithoutSpace = "_ = 1 is {|#0:not|}>1;"; + var statementWithSpace = "_ = 1 is not >1;"; + + var expected = Diagnostic().WithArguments("not", string.Empty, "followed").WithLocation(0); + await this.TestKeywordStatementAsync(statementWithoutSpace, expected, statementWithSpace).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3508, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3508")] + public async Task TestAndBeforeRelationalPatternAsync() + { + var statementWithoutSpace = "_ = 1 is 1 {|#0:and|}>0;"; + var statementWithSpace = "_ = 1 is 1 and >0;"; + + var expected = Diagnostic().WithArguments("and", string.Empty, "followed").WithLocation(0); + await this.TestKeywordStatementAsync(statementWithoutSpace, expected, statementWithSpace).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3508, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3508")] + public async Task TestOrBeforeRelationalPatternAsync() + { + var statementWithoutSpace = "_ = 1 is 1 {|#0:or|}>1;"; + var statementWithSpace = "_ = 1 is 1 or >1;"; + + var expected = Diagnostic().WithArguments("or", string.Empty, "followed").WithLocation(0); + await this.TestKeywordStatementAsync(statementWithoutSpace, expected, statementWithSpace).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1001CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1001CSharp9UnitTests.cs new file mode 100644 index 000000000..56ba3dfa3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1001CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1001CSharp9UnitTests : SA1001CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1002CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1002CSharp9UnitTests.cs new file mode 100644 index 000000000..0d2ae80b7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1002CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1002CSharp9UnitTests : SA1002CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1003CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1003CSharp9UnitTests.cs new file mode 100644 index 000000000..2133f5b93 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1003CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1003CSharp9UnitTests : SA1003CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1004CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1004CSharp9UnitTests.cs new file mode 100644 index 000000000..c956325cb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1004CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1004CSharp9UnitTests : SA1004CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1005CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1005CSharp9UnitTests.cs new file mode 100644 index 000000000..84cd58bee --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1005CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1005CSharp9UnitTests : SA1005CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1006CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1006CSharp9UnitTests.cs new file mode 100644 index 000000000..57bdd822d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1006CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1006CSharp9UnitTests : SA1006CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1007CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1007CSharp9UnitTests.cs new file mode 100644 index 000000000..92d78012d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1007CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1007CSharp9UnitTests : SA1007CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1008CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1008CSharp9UnitTests.cs new file mode 100644 index 000000000..e98818ab7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1008CSharp9UnitTests.cs @@ -0,0 +1,114 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using System.Linq; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + using Xunit; + using static StyleCop.Analyzers.SpacingRules.SA1008OpeningParenthesisMustBeSpacedCorrectly; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1008OpeningParenthesisMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1008CSharp9UnitTests : SA1008CSharp8UnitTests + { + [Fact] + [WorkItem(3230, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3230")] + public async Task TestParenthesizedPatternAsync() + { + const string testCode = @" +class C +{ + void Method(int b) + { + _ = b is{|#0:(|} >= 0 and <= 31) or 127; + _ = b is{|#1:(|}>= 0 and <= 31) or 127; + _ = b is {|#2:(|} >= 0 and <= 31) or 127; + } +}"; + const string fixedCode = @" +class C +{ + void Method(int b) + { + _ = b is (>= 0 and <= 31) or 127; + _ = b is (>= 0 and <= 31) or 127; + _ = b is (>= 0 and <= 31) or 127; + } +}"; + + await new CSharpTest() + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + ExpectedDiagnostics = + { + // /0/Test0.cs(6,17): warning SA1008: Opening parenthesis should be preceded by a space. + Diagnostic(DescriptorPreceded).WithLocation(0), + + // /0/Test0.cs(6,17): warning SA1008: Opening parenthesis should not be followed by a space. + Diagnostic(DescriptorNotFollowed).WithLocation(0), + + // /0/Test0.cs(7,17): warning SA1008: Opening parenthesis should be preceded by a space. + Diagnostic(DescriptorPreceded).WithLocation(1), + + // /0/Test0.cs(8,18): warning SA1008: Opening parenthesis should not be followed by a space. + Diagnostic(DescriptorNotFollowed).WithLocation(2), + }, + TestCode = testCode, + FixedCode = fixedCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3476, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3476")] + public async Task TestLogicalTuplePatternAsync() + { + const string testCode = @" +class C +{ + void Method((int, int) c) + { + _ = c is (1, 1) or (2, 2); + _ = c is (1, 1) and (1, 1); + _ = c is not (2, 2); + } +}"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Theory] + [InlineData("")] + [InlineData(" ")] + [InlineData("\n")] + [InlineData("\n ")] + [WorkItem(2354, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2354")] + public async Task TestDeconstructionInTopLevelProgramAsync(string prefix) + { + var testCode = $@"{prefix}{{|#0:(|}} var a, var b) = (1, 2);"; + var fixedCode = $@"{prefix}(var a, var b) = (1, 2);"; + + await new CSharpTest() + { + TestState = + { + OutputKind = OutputKind.ConsoleApplication, + Sources = { testCode }, + }, + ExpectedDiagnostics = + { + // /0/Test0.cs(1,1): warning SA1008: Opening parenthesis should not be followed by a space. + Diagnostic(DescriptorNotFollowed).WithLocation(0), + }, + FixedCode = fixedCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1009CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1009CSharp9UnitTests.cs new file mode 100644 index 000000000..73cbb50ff --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1009CSharp9UnitTests.cs @@ -0,0 +1,57 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + using Xunit; + using static StyleCop.Analyzers.SpacingRules.SA1009ClosingParenthesisMustBeSpacedCorrectly; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1009ClosingParenthesisMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1009CSharp9UnitTests : SA1009CSharp8UnitTests + { + [Fact] + [WorkItem(3248, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3248")] + public async Task TestRecordInheritanceAsync() + { + const string testCode = @" +public abstract record BaseQuery; +public record MyQuery1( {|#0:)|}: BaseQuery; +public record MyQuery2( {|#1:)|} : BaseQuery; +public record MyQuery3({|#2:)|}: BaseQuery;"; + const string fixedCode = @" +public abstract record BaseQuery; +public record MyQuery1() : BaseQuery; +public record MyQuery2() : BaseQuery; +public record MyQuery3() : BaseQuery;"; + + await new CSharpTest() + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + ExpectedDiagnostics = + { + // /0/Test0.cs(3,25): warning SA1009: Closing parenthesis should not be preceded by a space + Diagnostic(DescriptorNotPreceded).WithLocation(0), + + // /0/Test0.cs(3,25): warning SA1009: Closing parenthesis should be followed by a space + Diagnostic(DescriptorFollowed).WithLocation(0), + + // /0/Test0.cs(4,25): warning SA1009: Closing parenthesis should not be preceded by a space + Diagnostic(DescriptorNotPreceded).WithLocation(1), + + // /0/Test0.cs(5,24): warning SA1009: Closing parenthesis should be followed by a space + Diagnostic(DescriptorFollowed).WithLocation(2), + }, + TestCode = testCode, + FixedCode = fixedCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1010CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1010CSharp9UnitTests.cs new file mode 100644 index 000000000..6ad3b9386 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1010CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1010CSharp9UnitTests : SA1010CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1011CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1011CSharp9UnitTests.cs new file mode 100644 index 000000000..15b1f27cf --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1011CSharp9UnitTests.cs @@ -0,0 +1,44 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1011ClosingSquareBracketsMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1011CSharp9UnitTests : SA1011CSharp8UnitTests + { + [Fact] + public async Task TestFunctionPointerUnmanagedCallingConventionListAsync() + { + var testCode = @"public class TestClass +{ + unsafe delegate* unmanaged[Stdcall {|#0:]|} FuncPtr1; + unsafe delegate* unmanaged[Stdcall{|#1:]|} FuncPtr2; +} +"; + + var fixedCode = @"public class TestClass +{ + unsafe delegate* unmanaged[Stdcall] FuncPtr1; + unsafe delegate* unmanaged[Stdcall] FuncPtr2; +} +"; + + var expected = new[] + { + Diagnostic().WithArguments(" not", "preceded").WithLocation(0), + Diagnostic().WithArguments(" not", "followed").WithLocation(1), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1012CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1012CSharp9UnitTests.cs new file mode 100644 index 000000000..04b304c3d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1012CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1012CSharp9UnitTests : SA1012CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1013CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1013CSharp9UnitTests.cs new file mode 100644 index 000000000..b92b7c80e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1013CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1013CSharp9UnitTests : SA1013CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1014CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1014CSharp9UnitTests.cs new file mode 100644 index 000000000..e845e887b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1014CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1014CSharp9UnitTests : SA1014CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1015CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1015CSharp9UnitTests.cs new file mode 100644 index 000000000..32c4a9ca1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1015CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1015CSharp9UnitTests : SA1015CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1016CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1016CSharp9UnitTests.cs new file mode 100644 index 000000000..8e6e97e62 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1016CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1016CSharp9UnitTests : SA1016CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1017CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1017CSharp9UnitTests.cs new file mode 100644 index 000000000..2b7633076 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1017CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1017CSharp9UnitTests : SA1017CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1018CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1018CSharp9UnitTests.cs new file mode 100644 index 000000000..a5b4b696d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1018CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1018CSharp9UnitTests : SA1018CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1019CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1019CSharp9UnitTests.cs new file mode 100644 index 000000000..e610e85cb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1019CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1019CSharp9UnitTests : SA1019CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1020CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1020CSharp9UnitTests.cs new file mode 100644 index 000000000..31abd189f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1020CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1020CSharp9UnitTests : SA1020CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1021CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1021CSharp9UnitTests.cs new file mode 100644 index 000000000..c339c1f76 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1021CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1021CSharp9UnitTests : SA1021CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1022CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1022CSharp9UnitTests.cs new file mode 100644 index 000000000..ebaafcc68 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1022CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1022CSharp9UnitTests : SA1022CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1023CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1023CSharp9UnitTests.cs new file mode 100644 index 000000000..5f06c79df --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1023CSharp9UnitTests.cs @@ -0,0 +1,82 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + using Xunit; + using static StyleCop.Analyzers.SpacingRules.SA1023DereferenceAndAccessOfSymbolsMustBeSpacedCorrectly; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1023DereferenceAndAccessOfSymbolsMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1023CSharp9UnitTests : SA1023CSharp8UnitTests + { + [Fact] + public async Task TestFunctionPointerParameterInvalidSpacingAsync() + { + var testCode = @"public class TestClass +{ + unsafe delegate* FuncPtr1; + unsafe delegate* FuncPtr2; +} +"; + + var fixedCode = @"public class TestClass +{ + unsafe delegate* FuncPtr1; + unsafe delegate* FuncPtr2; +} +"; + + var expected = new[] + { + Diagnostic(DescriptorNotPreceded).WithLocation(0), + Diagnostic(DescriptorNotFollowed).WithLocation(1), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestFunctionPointerTypeInvalidSpacingAsync() + { + var testCode = @"public class TestClass +{ + unsafe delegate {|#0:*|} FuncPtr1; + unsafe delegate{|#1:*|} FuncPtr2; + unsafe delegate {|#2:*|} managed FuncPtr3; + unsafe delegate{|#3:*|}managed FuncPtr4; + unsafe delegate {|#4:*|} unmanaged FuncPtr5; + unsafe delegate{|#5:*|}unmanaged FuncPtr6; +} +"; + + var fixedCode = @"public class TestClass +{ + unsafe delegate* FuncPtr1; + unsafe delegate* FuncPtr2; + unsafe delegate* managed FuncPtr3; + unsafe delegate* managed FuncPtr4; + unsafe delegate* unmanaged FuncPtr5; + unsafe delegate* unmanaged FuncPtr6; +} +"; + + DiagnosticResult[] expected = + { + Diagnostic(DescriptorNotPreceded).WithLocation(0), + Diagnostic(DescriptorNotFollowed).WithLocation(1), + Diagnostic(DescriptorNotPreceded).WithLocation(2), + Diagnostic(DescriptorFollowed).WithLocation(3), + Diagnostic(DescriptorNotPreceded).WithLocation(4), + Diagnostic(DescriptorFollowed).WithLocation(5), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1024CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1024CSharp9UnitTests.cs new file mode 100644 index 000000000..f4627c9b6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1024CSharp9UnitTests.cs @@ -0,0 +1,57 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + using Xunit; + using static StyleCop.Analyzers.SpacingRules.SA1024ColonsMustBeSpacedCorrectly; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.SpacingRules.SA1024ColonsMustBeSpacedCorrectly, + StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; + + public partial class SA1024CSharp9UnitTests : SA1024CSharp8UnitTests + { + [Fact] + [WorkItem(3248, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3248")] + public async Task TestRecordInheritanceAsync() + { + const string testCode = @" +public abstract record BaseQuery; +public record MyQuery1(){|#0::|}BaseQuery; +public record MyQuery2(){|#1::|} BaseQuery; +public record MyQuery3() {|#2::|}BaseQuery;"; + const string fixedCode = @" +public abstract record BaseQuery; +public record MyQuery1() : BaseQuery; +public record MyQuery2() : BaseQuery; +public record MyQuery3() : BaseQuery;"; + + await new CSharpTest() + { + ReferenceAssemblies = ReferenceAssemblies.Net.Net50, + ExpectedDiagnostics = + { + // /0/Test0.cs(3,25): warning SA1024: Colon should be preceded by a space + Diagnostic(DescriptorPreceded).WithLocation(0), + + // /0/Test0.cs(3,25): warning SA1024: Colon should be followed by a space + Diagnostic(DescriptorFollowed).WithLocation(0), + + // /0/Test0.cs(4,25): warning SA1024: Colon should be preceded by a space + Diagnostic(DescriptorPreceded).WithLocation(1), + + // /0/Test0.cs(5,26): warning SA1024: Colon should be followed by a space + Diagnostic(DescriptorFollowed).WithLocation(2), + }, + TestCode = testCode, + FixedCode = fixedCode, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1025CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1025CSharp9UnitTests.cs new file mode 100644 index 000000000..1cfa321e6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1025CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1025CSharp9UnitTests : SA1025CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1026CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1026CSharp9UnitTests.cs new file mode 100644 index 000000000..aeb7b5490 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1026CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1026CSharp9UnitTests : SA1026CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1027AlternateIndentationCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1027AlternateIndentationCSharp9UnitTests.cs new file mode 100644 index 000000000..a70063c9b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1027AlternateIndentationCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1027AlternateIndentationCSharp9UnitTests : SA1027AlternateIndentationCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1027CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1027CSharp9UnitTests.cs new file mode 100644 index 000000000..9982c1bfc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1027CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1027CSharp9UnitTests : SA1027CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1027UseTabsCSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1027UseTabsCSharp9UnitTests.cs new file mode 100644 index 000000000..80dc2d812 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1027UseTabsCSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1027UseTabsCSharp9UnitTests : SA1027UseTabsCSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1028CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1028CSharp9UnitTests.cs new file mode 100644 index 000000000..77b46935e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpacingRules/SA1028CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpacingRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpacingRules; + + public partial class SA1028CSharp9UnitTests : SA1028CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpecialRules/SA0001CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpecialRules/SA0001CSharp9UnitTests.cs new file mode 100644 index 000000000..bd8502e52 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpecialRules/SA0001CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpecialRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpecialRules; + + public partial class SA0001CSharp9UnitTests : SA0001CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpecialRules/SA0002CSharp9UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpecialRules/SA0002CSharp9UnitTests.cs new file mode 100644 index 000000000..54d572c75 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/SpecialRules/SA0002CSharp9UnitTests.cs @@ -0,0 +1,11 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.CSharp9.SpecialRules +{ + using StyleCop.Analyzers.Test.CSharp8.SpecialRules; + + public partial class SA0002CSharp9UnitTests : SA0002CSharp8UnitTests + { + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/StyleCop.Analyzers.Test.CSharp9.csproj b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/StyleCop.Analyzers.Test.CSharp9.csproj new file mode 100644 index 000000000..9e4cf64df --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/StyleCop.Analyzers.Test.CSharp9.csproj @@ -0,0 +1,35 @@ + + + + + net472 + false + true + true + + + + ..\StyleCop.Analyzers.Internal.ruleset + + + + true + ..\..\build\keys\TestingKey.snk + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/AnalyzerConfigurationTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/AnalyzerConfigurationUnitTests.cs similarity index 89% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test/AnalyzerConfigurationTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test/AnalyzerConfigurationUnitTests.cs index 42dbaacdf..c2d72dd98 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/AnalyzerConfigurationTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/AnalyzerConfigurationUnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test { @@ -16,7 +18,7 @@ namespace StyleCop.Analyzers.Test using Microsoft.CodeAnalysis.Testing.Verifiers; using Xunit; - public class AnalyzerConfigurationTests + public class AnalyzerConfigurationUnitTests { public static IEnumerable AllAnalyzers { @@ -71,11 +73,16 @@ public CSharpTest(Type analyzerType) public override string Language => LanguageNames.CSharp; + public override Type SyntaxKindType => typeof(SyntaxKind); + protected override string DefaultFileExt => "cs"; protected override CompilationOptions CreateCompilationOptions() => new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true); + protected override ParseOptions CreateParseOptions() + => new CSharpParseOptions(LanguageVersion.CSharp6); + protected override IEnumerable GetCodeFixProviders() => new CodeFixProvider[0]; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/AnalyzerExtensionsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/AnalyzerExtensionsTests.cs index 65e11b60f..93f95b0e8 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/AnalyzerExtensionsTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/AnalyzerExtensionsTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test { @@ -69,6 +71,9 @@ public AnalyzerExtensionsTests AnalyzerExtensionsTests public override void Initialize(AnalysisContext context) { + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); + context.EnableConcurrentExecution(); + context.RegisterCompilationStartAction( compilationStartContext => { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/AttributeTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/AttributeTests.cs index fb387eac6..2fb3c57cc 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/AttributeTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/AttributeTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/FileHeaderTestBase.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/FileHeaderTestBase.cs index 4b5be2636..840b7badf 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/FileHeaderTestBase.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/FileHeaderTestBase.cs @@ -1,16 +1,18 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { using System.Collections.Generic; + using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; /// @@ -97,6 +99,9 @@ protected virtual string GetSettings() protected virtual IEnumerable GetDisabledDiagnostics() => new[] { FileHeaderAnalyzers.SA1639Descriptor.Id }; + protected virtual IEnumerable GetExplicitlyEnabledDiagnostics() + => Enumerable.Empty(); + protected Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult expected, CancellationToken cancellationToken) => this.VerifyCSharpFixAsync(source, new[] { expected }, fixedSource: null, cancellationToken); @@ -118,9 +123,11 @@ protected Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expected, Settings = this.GetSettings(), }; + test.TestBehaviors |= TestBehaviors.SkipSuppressionCheck; test.ExpectedDiagnostics.AddRange(expected); test.RemainingDiagnostics.AddRange(remainingDiagnostics); test.DisabledDiagnostics.AddRange(this.GetDisabledDiagnostics()); + test.ExplicitlyEnabledDiagnostics.AddRange(this.GetExplicitlyEnabledDiagnostics()); return test.RunAsync(cancellationToken); } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/InheritdocCodeFixProviderUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/InheritdocCodeFixProviderUnitTests.cs index 83cef1b84..3379c6968 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/InheritdocCodeFixProviderUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/InheritdocCodeFixProviderUnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; - using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< @@ -20,7 +21,7 @@ public class InheritdocCodeFixProviderUnitTests { private static readonly DiagnosticDescriptor SA1600 = new SA1600ElementsMustBeDocumented().SupportedDiagnostics[0]; private static readonly DiagnosticDescriptor CS1591 = - new DiagnosticDescriptor(nameof(CS1591), "Title", "Missing XML comment for publicly visible type or member '{0}'", "Category", DiagnosticSeverity.Error, AnalyzerConstants.EnabledByDefault); + new DiagnosticDescriptor(nameof(CS1591), "Title", "Missing XML comment for publicly visible type or member '{0}'", "Category", DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault); [Theory] [InlineData(false, null, "string TestMember { get; set; }")] @@ -83,12 +84,7 @@ public override {memberData} }, }; - if (compilerWarning) - { - test.DisabledDiagnostics.Add(SA1600.Id); - test.SolutionTransforms.Add(SetCompilerDocumentationWarningToError); - } - + test.DisabledDiagnostics.Add(compilerWarning ? SA1600.Id : CS1591.Id); await test.RunAsync(CancellationToken.None).ConfigureAwait(false); } @@ -153,12 +149,7 @@ public class ChildClass : IParent }, }; - if (compilerWarning) - { - test.DisabledDiagnostics.Add(SA1600.Id); - test.SolutionTransforms.Add(SetCompilerDocumentationWarningToError); - } - + test.DisabledDiagnostics.Add(compilerWarning ? SA1600.Id : CS1591.Id); await test.RunAsync(CancellationToken.None).ConfigureAwait(false); } @@ -193,8 +184,8 @@ public class ChildClass : ParentClass Diagnostic(SA1600).WithLocation(10, 14), Diagnostic(SA1600).WithLocation(12, 35), }, + DisabledDiagnostics = { CS1591.Id }, FixedCode = testCode, - FixedState = { InheritanceMode = StateInheritanceMode.AutoInheritAll }, NumberOfIncrementalIterations = 1, NumberOfFixAllIterations = 1, }.RunAsync(CancellationToken.None).ConfigureAwait(false); @@ -231,22 +222,11 @@ public class ChildClass : ParentClass Diagnostic(SA1600).WithLocation(10, 14), Diagnostic(SA1600).WithLocation(12, 35), }, + DisabledDiagnostics = { CS1591.Id }, FixedCode = testCode, - FixedState = { InheritanceMode = StateInheritanceMode.AutoInheritAll }, NumberOfIncrementalIterations = 1, NumberOfFixAllIterations = 1, }.RunAsync(CancellationToken.None).ConfigureAwait(false); } - - private static Solution SetCompilerDocumentationWarningToError(Solution solution, ProjectId projectId) - { - var project = solution.GetProject(projectId); - - // update the project compilation options - var modifiedSpecificDiagnosticOptions = project.CompilationOptions.SpecificDiagnosticOptions.SetItem(CS1591.Id, ReportDiagnostic.Error); - var modifiedCompilationOptions = project.CompilationOptions.WithSpecificDiagnosticOptions(modifiedSpecificDiagnosticOptions); - - return solution.WithProjectCompilationOptions(projectId, modifiedCompilationOptions); - } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/NoXmlFileHeaderUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/NoXmlFileHeaderUnitTests.cs index 60775771f..4b411bee2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/NoXmlFileHeaderUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/NoXmlFileHeaderUnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -8,7 +10,6 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -392,9 +393,6 @@ namespace Bar await VerifyCSharpFixAsync(testCode, TestSettingsWithEmptyLines, new[] { expected }, fixedCode, CancellationToken.None).ConfigureAwait(false); } - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult expected, CancellationToken cancellationToken) - => VerifyCSharpFixAsync(source, TestSettings, new[] { expected }, fixedSource: null, cancellationToken); - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) => VerifyCSharpFixAsync(source, TestSettings, expected, fixedSource: null, cancellationToken); @@ -410,6 +408,7 @@ private static Task VerifyCSharpFixAsync(string source, string testSettings, Dia Settings = testSettings, }; + test.TestBehaviors |= TestBehaviors.SkipSuppressionCheck; test.ExpectedDiagnostics.AddRange(expected); return test.RunAsync(cancellationToken); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1600UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1600UnitTests.cs index 1438a800a..593941aea 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1600UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1600UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -8,9 +10,11 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; - using StyleCop.Analyzers.Test.Verifiers; + using StyleCop.Analyzers.Test.Helpers; using Xunit; - using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.DocumentationRules.SA1600ElementsMustBeDocumented, + StyleCop.Analyzers.DocumentationRules.SA1600CodeFixProvider>; /// /// This class contains unit tests for . @@ -20,12 +24,12 @@ public class SA1600UnitTests protected virtual LanguageVersion LanguageVersion => LanguageVersion.CSharp6; [Theory] - [InlineData("public string TestMember;", 15)] - [InlineData("public string TestMember { get; set; }", 15)] - [InlineData("public void TestMember() { }", 13)] - [InlineData("public string this[int a] { get { return \"a\"; } set { } }", 15)] - [InlineData("public event EventHandler TestMember { add { } remove { } }", 27)] - public async Task TestRegressionMethodGlobalNamespaceAsync(string code, int column) + [InlineData("public string {|#0:TestMember|};")] + [InlineData("public string {|#0:TestMember|} { get; set; }")] + [InlineData("public void {|#0:TestMember|}() { }")] + [InlineData("public string {|#0:this|}[int a] { get { return \"a\"; } set { } }")] + [InlineData("public event EventHandler {|#0:TestMember|} { add { } remove { } }")] + public async Task TestRegressionMethodGlobalNamespaceAsync(string code) { // This test is a regression test for https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1416 var testCode = $@" @@ -33,61 +37,23 @@ public async Task TestRegressionMethodGlobalNamespaceAsync(string code, int colu {code}"; - DiagnosticResult[] expected = - { - DiagnosticResult.CompilerError("CS0116").WithMessage("A namespace cannot directly contain members such as fields or methods").WithLocation(4, column), - Diagnostic().WithLocation(4, column), - }; - + var expected = this.GetExpectedResultTestRegressionMethodGlobalNamespace(code); await VerifyCSharpDiagnosticAsync(this.LanguageVersion, testCode, expected, CancellationToken.None).ConfigureAwait(false); } - [Fact] - public async Task TestClassWithoutDocumentationAsync() - { - await this.TestTypeWithoutDocumentationAsync("class", false).ConfigureAwait(false); - } - - [Fact] - public async Task TestStructWithoutDocumentationAsync() - { - await this.TestTypeWithoutDocumentationAsync("struct", false).ConfigureAwait(false); - } - - [Fact] - public async Task TestEnumWithoutDocumentationAsync() - { - await this.TestTypeWithoutDocumentationAsync("enum", false).ConfigureAwait(false); - } - - [Fact] - public async Task TestInterfaceWithoutDocumentationAsync() - { - await this.TestTypeWithoutDocumentationAsync("interface", true).ConfigureAwait(false); - } - - [Fact] - public async Task TestClassWithDocumentationAsync() - { - await this.TestTypeWithDocumentationAsync("class").ConfigureAwait(false); - } - - [Fact] - public async Task TestStructWithDocumentationAsync() - { - await this.TestTypeWithDocumentationAsync("struct").ConfigureAwait(false); - } - - [Fact] - public async Task TestEnumWithDocumentationAsync() + [Theory] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task TestBaseTypeWithoutDocumentationAsync(string type) { - await this.TestTypeWithDocumentationAsync("enum").ConfigureAwait(false); + var isInterface = type == "interface"; + await this.TestTypeWithoutDocumentationAsync(type, isInterface).ConfigureAwait(false); } - [Fact] - public async Task TestInterfaceWithDocumentationAsync() + [Theory] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task TestBaseTypeWithDocumentationAsync(string type) { - await this.TestTypeWithDocumentationAsync("interface").ConfigureAwait(false); + await this.TestTypeWithDocumentationAsync(type).ConfigureAwait(false); } [Fact] @@ -612,14 +578,18 @@ public Test2(int param1, bool param2) } "; - DiagnosticResult[] expectedResults = + await new CSharpTest(this.LanguageVersion) { - Diagnostic().WithLocation(7, 12), - Diagnostic().WithLocation(11, 12), - Diagnostic().WithLocation(21, 12), - }; - - await VerifyCSharpFixAsync(this.LanguageVersion, testCode, expectedResults, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + TestCode = testCode, + ExpectedDiagnostics = + { + Diagnostic().WithLocation(7, 12), + Diagnostic().WithLocation(11, 12), + Diagnostic().WithLocation(21, 12), + }, + FixedCode = fixedTestCode, + DisabledDiagnostics = { "CS1591" }, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); } /// @@ -656,12 +626,16 @@ public class TestClass } "; - DiagnosticResult[] expectedResults = + await new CSharpTest(this.LanguageVersion) { - Diagnostic().WithLocation(7, 6), - }; - - await VerifyCSharpFixAsync(this.LanguageVersion, testCode, expectedResults, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + TestCode = testCode, + ExpectedDiagnostics = + { + Diagnostic().WithLocation(7, 6), + }, + FixedCode = fixedTestCode, + DisabledDiagnostics = { "CS1591" }, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); } /// @@ -688,13 +662,17 @@ public int DoSomething2() } "; - DiagnosticResult[] expectedResults = + await new CSharpTest(this.LanguageVersion) { - Diagnostic().WithLocation(7, 17), - Diagnostic().WithLocation(11, 16), - }; - - await VerifyCSharpFixAsync(this.LanguageVersion, testCode, expectedResults, testCode, CancellationToken.None).ConfigureAwait(false); + TestCode = testCode, + ExpectedDiagnostics = + { + Diagnostic().WithLocation(7, 17), + Diagnostic().WithLocation(11, 16), + }, + FixedCode = testCode, + DisabledDiagnostics = { "CS1591" }, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); } /// @@ -819,17 +797,21 @@ public Task TestMethod6(T param1, int param2) }} "; - DiagnosticResult[] expectedResults = + await new CSharpTest(this.LanguageVersion) { - Diagnostic().WithLocation(9, 17), - Diagnostic().WithLocation(14, 22), - Diagnostic().WithLocation(19, 20), - Diagnostic().WithLocation(24, 17), - Diagnostic().WithLocation(29, 22), - Diagnostic().WithLocation(34, 20), - }; - - await VerifyCSharpFixAsync(this.LanguageVersion, testCode, expectedResults, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + TestCode = testCode, + ExpectedDiagnostics = + { + Diagnostic().WithLocation(9, 17), + Diagnostic().WithLocation(14, 22), + Diagnostic().WithLocation(19, 20), + Diagnostic().WithLocation(24, 17), + Diagnostic().WithLocation(29, 22), + Diagnostic().WithLocation(34, 20), + }, + FixedCode = fixedTestCode, + DisabledDiagnostics = { "CS1591" }, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); } protected async Task TestTypeDeclarationDocumentationAsync(string type, string modifiers, bool requiresDiagnostic, bool hasDocumentation) @@ -1332,6 +1314,7 @@ public class OuterClass { TestCode = string.Format(hasDocumentation ? testCodeWithDocumentation : testCodeWithoutDocumentation, modifiers), Settings = testSettings, + DisabledDiagnostics = { "CS1591" }, }; if (requiresDiagnostic) @@ -1371,6 +1354,15 @@ public class OuterClass await VerifyCSharpDiagnosticAsync(this.LanguageVersion, string.Format(hasDocumentation ? testCodeWithDocumentation : testCodeWithoutDocumentation, modifiers), requiresDiagnostic ? expected : DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } + protected virtual DiagnosticResult[] GetExpectedResultTestRegressionMethodGlobalNamespace(string code) + { + return new[] + { + DiagnosticResult.CompilerError("CS0116").WithMessage("A namespace cannot directly contain members such as fields or methods").WithLocation(0), + Diagnostic().WithLocation(0), + }; + } + protected virtual async Task TestTypeWithoutDocumentationAsync(string type, bool isInterface) { await this.TestTypeDeclarationDocumentationAsync(type, string.Empty, true, false).ConfigureAwait(false); @@ -1398,51 +1390,5 @@ protected virtual async Task TestTypeWithDocumentationAsync(string type) await this.TestNestedTypeDeclarationDocumentationAsync(type, "protected internal", false, true).ConfigureAwait(false); await this.TestNestedTypeDeclarationDocumentationAsync(type, "public", false, true).ConfigureAwait(false); } - - private static Task VerifyCSharpDiagnosticAsync(LanguageVersion languageVersion, string source, DiagnosticResult expected, CancellationToken cancellationToken) - => VerifyCSharpDiagnosticAsync(languageVersion, source, new[] { expected }, cancellationToken); - - private static Task VerifyCSharpDiagnosticAsync(LanguageVersion languageVersion, string source, DiagnosticResult[] expected, CancellationToken cancellationToken) - { - var test = new CSharpTest(languageVersion) - { - TestCode = source, - }; - - test.ExpectedDiagnostics.AddRange(expected); - return test.RunAsync(cancellationToken); - } - - private static Task VerifyCSharpFixAsync(LanguageVersion languageVersion, string source, DiagnosticResult[] expected, string fixedSource, CancellationToken cancellationToken) - { - var test = new CSharpTest(languageVersion) - { - TestCode = source, - FixedCode = fixedSource, - }; - - 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); - } - - private class CSharpTest : StyleCopCodeFixVerifier.CSharpTest - { - public CSharpTest(LanguageVersion languageVersion) - { - this.SolutionTransforms.Add((solution, projectId) => - { - var parseOptions = (CSharpParseOptions)solution.GetProject(projectId).ParseOptions; - return solution.WithProjectParseOptions(projectId, parseOptions.WithLanguageVersion(languageVersion)); - }); - } - } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1601UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1601UnitTests.cs index 5366b52e3..cb38e3f81 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1601UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1601UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -8,7 +10,6 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1602UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1602UnitTests.cs index 1cdd56a4b..b600d650f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1602UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1602UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1603UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1603UnitTests.cs index 0fa3645c9..c78d6c1f9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1603UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1603UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1604UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1604UnitTests.cs index 17c3dcac6..fd6e7d8c4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1604UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1604UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -7,8 +9,8 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; + using StyleCop.Analyzers.Test.Helpers; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -18,10 +20,7 @@ namespace StyleCop.Analyzers.Test.DocumentationRules public class SA1604UnitTests { [Theory] - [InlineData("enum")] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeNoDocumentationAsync(string typeName) { var testCode = @" @@ -32,10 +31,7 @@ public async Task TestTypeNoDocumentationAsync(string typeName) } [Theory] - [InlineData("enum")] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithDocumentationAsync(string typeName) { var testCode = @" @@ -49,10 +45,7 @@ public async Task TestTypeWithDocumentationAsync(string typeName) } [Theory] - [InlineData("enum")] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithInheritedDocumentationAsync(string typeName) { var testCode = @" @@ -64,10 +57,7 @@ public async Task TestTypeWithInheritedDocumentationAsync(string typeName) } [Theory] - [InlineData("enum")] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithoutDocumentationAsync(string typeName) { var testCode = @" @@ -83,14 +73,12 @@ public async Task TestTypeWithoutDocumentationAsync(string typeName) } [Theory] - [InlineData("partial class")] - [InlineData("partial struct")] - [InlineData("partial interface")] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestPartialTypeWithoutDocumentationAsync(string typeName) { var testCode = @" /// -{0} +partial {0} TypeName {{ }}"; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1605UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1605UnitTests.cs index fda3ca1cb..cff64990e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1605UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1605UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -7,8 +9,8 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; + using StyleCop.Analyzers.Test.Helpers; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -28,9 +30,7 @@ public class SA1605UnitTests "; [Theory] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeNoDocumentationAsync(string typeName) { var testCode = @" @@ -41,9 +41,7 @@ public async Task TestTypeNoDocumentationAsync(string typeName) } [Theory] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithSummaryDocumentationAsync(string typeName) { var testCode = @" @@ -57,9 +55,7 @@ public async Task TestTypeWithSummaryDocumentationAsync(string typeName) } [Theory] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithContentDocumentationAsync(string typeName) { var testCode = @" @@ -73,9 +69,7 @@ public async Task TestTypeWithContentDocumentationAsync(string typeName) } [Theory] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithInheritedDocumentationAsync(string typeName) { var testCode = @" @@ -87,9 +81,7 @@ public async Task TestTypeWithInheritedDocumentationAsync(string typeName) } [Theory] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithoutDocumentationAsync(string typeName) { var testCode = @" @@ -105,10 +97,7 @@ public async Task TestTypeWithoutDocumentationAsync(string typeName) } [Theory] - [InlineData("enum")] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestNonPartialTypeWithoutDocumentationAsync(string typeName) { var testCode = @" diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1606UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1606UnitTests.cs index dae77067c..baed3f68d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1606UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1606UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -7,8 +9,8 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; + using StyleCop.Analyzers.Test.Helpers; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -18,10 +20,7 @@ namespace StyleCop.Analyzers.Test.DocumentationRules public class SA1606UnitTests { [Theory] - [InlineData("enum")] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeNoDocumentationAsync(string typeName) { var testCode = @" @@ -32,10 +31,7 @@ public async Task TestTypeNoDocumentationAsync(string typeName) } [Theory] - [InlineData("enum")] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithDocumentationAsync(string typeName) { var testCode = @" @@ -49,10 +45,7 @@ public async Task TestTypeWithDocumentationAsync(string typeName) } [Theory] - [InlineData("enum")] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithInheritedDocumentationAsync(string typeName) { var testCode = @" @@ -64,10 +57,7 @@ public async Task TestTypeWithInheritedDocumentationAsync(string typeName) } [Theory] - [InlineData("enum")] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithoutDocumentationAsync(string typeName) { var testCode = @" @@ -85,16 +75,14 @@ public async Task TestTypeWithoutDocumentationAsync(string typeName) } [Theory] - [InlineData("partial class")] - [InlineData("partial struct")] - [InlineData("partial interface")] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestPartialTypeWithoutDocumentationAsync(string typeName) { var testCode = @" /// /// /// -{0} +partial {0} TypeName {{ }}"; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1607UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1607UnitTests.cs index 42278288a..72216fe29 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1607UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1607UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -7,8 +9,8 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; + using StyleCop.Analyzers.Test.Helpers; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -18,9 +20,7 @@ namespace StyleCop.Analyzers.Test.DocumentationRules public class SA1607UnitTests { [Theory] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeNoDocumentationAsync(string typeName) { var testCode = @" @@ -31,9 +31,7 @@ public async Task TestTypeNoDocumentationAsync(string typeName) } [Theory] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithSummaryDocumentationAsync(string typeName) { var testCode = @" @@ -47,9 +45,7 @@ public async Task TestTypeWithSummaryDocumentationAsync(string typeName) } [Theory] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithContentDocumentationAsync(string typeName) { var testCode = @" @@ -63,9 +59,7 @@ public async Task TestTypeWithContentDocumentationAsync(string typeName) } [Theory] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithInheritedDocumentationAsync(string typeName) { var testCode = @" @@ -77,9 +71,7 @@ public async Task TestTypeWithInheritedDocumentationAsync(string typeName) } [Theory] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithoutSummaryDocumentationAsync(string typeName) { var testCode = @" @@ -97,10 +89,7 @@ public async Task TestTypeWithoutSummaryDocumentationAsync(string typeName) } [Theory] - [InlineData("enum")] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestNonPartialTypeWithoutSummaryDocumentationAsync(string typeName) { var testCode = @" @@ -115,9 +104,7 @@ public async Task TestNonPartialTypeWithoutSummaryDocumentationAsync(string type } [Theory] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithoutContentDocumentationAsync(string typeName) { var testCode = @" @@ -135,10 +122,7 @@ public async Task TestTypeWithoutContentDocumentationAsync(string typeName) } [Theory] - [InlineData("enum")] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestNonPartialTypeWithoutContentDocumentationAsync(string typeName) { var testCode = @" @@ -389,10 +373,10 @@ public partial class ClassName await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult expected, CancellationToken cancellationToken) + protected static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult expected, CancellationToken cancellationToken) => VerifyCSharpDiagnosticAsync(source, new[] { expected }, cancellationToken); - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) + protected static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) { string contentWithoutSummaryOrContent = @" diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1608UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1608UnitTests.cs index 01aaf48db..81a7133c1 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1608UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1608UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -7,8 +9,8 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; + using StyleCop.Analyzers.Test.Helpers; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -18,9 +20,7 @@ namespace StyleCop.Analyzers.Test.DocumentationRules public class SA1608UnitTests { [Theory] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeNoDocumentationAsync(string typeName) { var testCode = @" @@ -31,9 +31,7 @@ public async Task TestTypeNoDocumentationAsync(string typeName) } [Theory] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithSummaryDocumentationAsync(string typeName) { var testCode = @" @@ -47,9 +45,7 @@ public async Task TestTypeWithSummaryDocumentationAsync(string typeName) } [Theory] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithContentDocumentationAsync(string typeName) { var testCode = @" @@ -63,9 +59,7 @@ public async Task TestTypeWithContentDocumentationAsync(string typeName) } [Theory] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithInheritedDocumentationAsync(string typeName) { var testCode = @" @@ -77,9 +71,7 @@ public async Task TestTypeWithInheritedDocumentationAsync(string typeName) } [Theory] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithoutSummaryDocumentationAsync(string typeName) { var testCode = @" @@ -94,9 +86,7 @@ public async Task TestTypeWithoutSummaryDocumentationAsync(string typeName) } [Theory] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithoutContentDocumentationAsync(string typeName) { var testCode = @" @@ -111,9 +101,7 @@ public async Task TestTypeWithoutContentDocumentationAsync(string typeName) } [Theory] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithDefaultDocumentationAsync(string typeName) { var testCode = $@" @@ -146,6 +134,48 @@ public class ClassName await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); } + [Fact] + public async Task TestEnumMemberWithContentDocumentationAsync() + { + var testCode = @" +public enum EnumName +{ + /// + /// Foo. + /// + EnumMember1 = 0, +} +"; + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestEnumMemberWithDefaultDocumentationAsync() + { + var testCode = @" +public enum EnumName +{ + /// + /// Summary description for the EnumMember1 enum member. + /// + EnumMember1 = 0, + + /// + /// Summary description + /// for the EnumMember2 enum member. + /// + EnumMember2 = 1, +} +"; + DiagnosticResult[] expected = new[] + { + Diagnostic().WithLocation(4, 9), + Diagnostic().WithLocation(9, 9), + }; + + await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); + } + [Fact] public async Task TestClassWithIncludedEmptyDocumentationAsync() { @@ -157,6 +187,18 @@ public class ClassName await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } + [Fact] + [WorkItem(3150, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3150")] + public async Task TestClassWithIncludedMissingDocumentationAsync() + { + var testCode = @" +/// +public class ClassName +{ +}"; + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + [Fact] public async Task TestClassWithIncludedSummaryDocumentationAsync() { @@ -182,6 +224,35 @@ public class ClassName await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); } + [Fact] + [WorkItem(3150, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3150")] + public async Task TestFieldWithIncludedSummaryDocumentationAsync() + { + var testCode = @" +public class ClassName +{ + /// + public int FieldName; +}"; + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3150, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3150")] + public async Task TestFieldWithIncludedDefaultSummaryDocumentationAsync() + { + var testCode = @" +public class ClassName +{ + /// + public {|#0:int FieldName|}; +}"; + + DiagnosticResult expected = Diagnostic().WithLocation(0); + + await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); + } + private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult expected, CancellationToken cancellationToken) => VerifyCSharpDiagnosticAsync(source, new[] { expected }, cancellationToken); @@ -204,6 +275,20 @@ private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[ Summary description for the ClassName class. +"; + string fieldContentWithSummary = @" + + + Foo + + +"; + string fieldContentWithDefaultSummary = @" + + + Summary description for the ClassName class. + + "; var test = new StyleCopDiagnosticVerifier.CSharpTest @@ -214,6 +299,8 @@ private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[ { "ClassWithoutSummary.xml", contentWithoutSummary }, { "ClassWithSummary.xml", contentWithSummary }, { "ClassWithDefaultSummary.xml", contentWithDefaultSummary }, + { "FieldWithSummary.xml", fieldContentWithSummary }, + { "FieldWithDefaultSummary.xml", fieldContentWithDefaultSummary }, }, }; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1609UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1609UnitTests.cs index 1bd51200f..e393d0b62 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1609UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1609UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -8,7 +10,6 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -369,9 +370,6 @@ private int Property await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult expected, CancellationToken cancellationToken) - => VerifyCSharpFixAsync(source, new[] { expected }, fixedSource: null, cancellationToken); - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) => VerifyCSharpFixAsync(source, expected, fixedSource: null, cancellationToken); @@ -417,14 +415,6 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec }, }; - 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); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1610UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1610UnitTests.cs index 50d627375..992df212e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1610UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1610UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -8,7 +10,6 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -362,9 +363,6 @@ public int Property await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult expected, CancellationToken cancellationToken) - => VerifyCSharpFixAsync(source, new[] { expected }, fixedSource: null, offerEmptyFixer: false, cancellationToken); - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) => VerifyCSharpFixAsync(source, expected, fixedSource: null, offerEmptyFixer: false, cancellationToken); @@ -417,18 +415,10 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec }, }; - if (source == fixedSource) + if (source == fixedSource && offerEmptyFixer) { - 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.NumberOfIncrementalIterations = 1; + test.NumberOfFixAllIterations = 1; } test.ExpectedDiagnostics.AddRange(expected); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1611UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1611UnitTests.cs index 4055462b7..c36d12d51 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1611UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1611UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -9,7 +11,6 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -313,6 +314,85 @@ public void TestMethod(string param1, string param2, string param3) await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); } + /// + /// Verifies that included documentation with missing documentation file produces no diagnostics. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3150, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3150")] + public async Task VerifyIncludedMissingDocumentationAsync() + { + var testCode = @" +/// +/// Foo +/// +public class ClassName +{ + /// + public void TestMethod(string {|#0:param1|}, string {|#1:param2|}, string {|#2:param3|}) + { + } +}"; + + DiagnosticResult[] expected = + { + Diagnostic().WithLocation(0).WithArguments("param1"), + Diagnostic().WithLocation(1).WithArguments("param2"), + Diagnostic().WithLocation(2).WithArguments("param3"), + }; + + await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that included documentation with missing elements documented produces the expected diagnostics. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task VerifyIncludedPartialDocumentationMissingElementsAsync() + { + var testCode = @" +/// +/// Foo +/// +public class ClassName +{ + /// + public void TestMethod(string param1, string param2, string param3) + { + } +}"; + DiagnosticResult[] expected = + { + Diagnostic().WithLocation(8, 35).WithArguments("param1"), + }; + + await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that included documentation with missing elements documented produces the expected diagnostics. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task VerifyIncludedPartialDocumentationElementsAsync() + { + var testCode = @" +/// +/// Foo +/// +public class ClassName +{ + /// Param 1 + /// + public void TestMethod(string param1, string param2, string param3) + { + } +}"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + /// /// Verifies that included documentation with an <inheritdoc> tag is ignored. /// @@ -334,9 +414,6 @@ public void TestMethod(string param1, string param2, string param3) await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult expected, CancellationToken cancellationToken) - => VerifyCSharpDiagnosticAsync(source, new[] { expected }, cancellationToken); - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) { string contentWithoutElementDocumentation = @" @@ -359,6 +436,17 @@ private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[ Param 3 +"; + string contentWithPartialElementDocumentation = @" + + + + Foo + + Param 2 + Param 3 + + "; string contentWithInheritedDocumentation = @" @@ -375,6 +463,7 @@ private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[ { { "MissingElementDocumentation.xml", contentWithoutElementDocumentation }, { "WithElementDocumentation.xml", contentWithElementDocumentation }, + { "WithPartialElementDocumentation.xml", contentWithPartialElementDocumentation }, { "InheritedDocumentation.xml", contentWithInheritedDocumentation }, }, }; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1612UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1612UnitTests.cs index 41b5ad6e8..57c7f1fe4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1612UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1612UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -9,7 +11,6 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -132,7 +133,7 @@ public class ClassName }"; var diagnostic = Diagnostic() - .WithMessageFormat("The parameter documentation for '{0}' should be at position {1}."); + .WithMessageFormat("The parameter documentation for '{0}' should be at position {1}"); var expected = new[] { @@ -215,7 +216,7 @@ public class ClassName }"; var diagnostic = Diagnostic() - .WithMessageFormat("The parameter documentation for '{0}' should be at position {1}."); + .WithMessageFormat("The parameter documentation for '{0}' should be at position {1}"); var expected = new[] { @@ -248,7 +249,7 @@ public class ClassName }"; var diagnostic = Diagnostic() - .WithMessageFormat("The parameter documentation for '{0}' should be at position {1}."); + .WithMessageFormat("The parameter documentation for '{0}' should be at position {1}"); var expected = diagnostic.WithLocation(13, 22).WithArguments("bar", 2); @@ -286,6 +287,22 @@ public class ClassName await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } + [Fact] + [WorkItem(3150, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3150")] + public async Task VerifyIncludedMissingFileIsNotReportedAsync() + { + var testCode = @" +/// +/// Foo +/// +public class ClassName +{ + /// + public ClassName Method() { return null; } +}"; + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + [Fact] public async Task VerifyIncludedMemberWithValidParamsIsNotReportedAsync() { @@ -353,7 +370,7 @@ public class ClassName }"; var diagnostic = Diagnostic() - .WithMessageFormat("The parameter documentation for '{0}' should be at position {1}."); + .WithMessageFormat("The parameter documentation for '{0}' should be at position {1}"); var expected = new[] { @@ -400,7 +417,7 @@ public class ClassName }"; var diagnostic = Diagnostic() - .WithMessageFormat("The parameter documentation for '{0}' should be at position {1}."); + .WithMessageFormat("The parameter documentation for '{0}' should be at position {1}"); var expected = diagnostic.WithLocation(8, 22).WithArguments("bar", 2); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1613UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1613UnitTests.cs index d58a729fe..0dcb721f0 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1613UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1613UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -9,7 +11,6 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -155,6 +156,22 @@ public class ClassName await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } + [Fact] + [WorkItem(3150, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3150")] + public async Task VerifyIncludedMissingFileAsync() + { + var testCode = @" +/// +/// Foo +/// +public class ClassName +{ + /// + public ClassName Method(string foo, string bar) { return null; } +}"; + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + [Fact] public async Task VerifyMemberWithValidParamsAndIncludedDocumentationAsync() { @@ -218,9 +235,6 @@ public class ClassName await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); } - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult expected, CancellationToken cancellationToken) - => VerifyCSharpDiagnosticAsync(source, new[] { expected }, cancellationToken); - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) { string contentWithoutParamDocumentation = @" diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1614UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1614UnitTests.cs index cb40c5d2c..36d950c20 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1614UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1614UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -9,7 +11,6 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -155,6 +156,22 @@ public class ClassName await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } + [Fact] + [WorkItem(3150, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3150")] + public async Task VerifyIncludedMissingFileAsync() + { + var testCode = @" +/// +/// Foo +/// +public class ClassName +{ + /// + public ClassName Method(string foo, string bar) { return null; } +}"; + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + [Fact] public async Task VerifyMemberIncludedDocumentationWithoutParamsAsync() { @@ -229,9 +246,6 @@ public class ClassName await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); } - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult expected, CancellationToken cancellationToken) - => VerifyCSharpDiagnosticAsync(source, new[] { expected }, cancellationToken); - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) { string contentWithoutDocumentation = @" diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1615UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1615UnitTests.cs index 24c115c57..00d5649f3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1615UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1615UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -9,7 +11,6 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1616UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1616UnitTests.cs index 2ec016c2f..0d03b288c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1616UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1616UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -9,7 +11,6 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -444,6 +445,22 @@ public class ClassName await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } + [Fact] + [WorkItem(3150, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3150")] + public async Task VerifyMemberIncludedMissingFileAsync() + { + var testCode = @" +/// +/// Foo +/// +public class ClassName +{ + /// + public ClassName Method(string foo, string bar) { return null; } +}"; + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + [Fact] public async Task VerifyMemberIncludedDocumentationWithoutReturnsAsync() { @@ -531,9 +548,6 @@ public class ClassName await VerifyCSharpFixAsync(testCode, expected, testCode, offerEmptyFixer: true, CancellationToken.None).ConfigureAwait(false); } - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult expected, CancellationToken cancellationToken) - => VerifyCSharpFixAsync(source, new[] { expected }, fixedSource: null, offerEmptyFixer: false, cancellationToken); - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) => VerifyCSharpFixAsync(source, expected, fixedSource: null, offerEmptyFixer: false, cancellationToken); @@ -615,18 +629,10 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec }, }; - if (source == fixedSource) + if (source == fixedSource && offerEmptyFixer) { - 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.NumberOfIncrementalIterations = 1; + test.NumberOfFixAllIterations = 1; } test.ExpectedDiagnostics.AddRange(expected); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1617UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1617UnitTests.cs index 1f0e9df50..160cee863 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1617UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1617UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -8,7 +10,6 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -316,9 +317,6 @@ public void Method() { } await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult expected, CancellationToken cancellationToken) - => VerifyCSharpFixAsync(source, new[] { expected }, fixedSource: null, cancellationToken); - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) => VerifyCSharpFixAsync(source, expected, fixedSource: null, cancellationToken); @@ -362,14 +360,6 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec }, }; - 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); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1618UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1618UnitTests.cs index 27813997b..8199a1c46 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1618UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1618UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -8,8 +10,8 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -34,12 +36,23 @@ public static IEnumerable Types { get { - yield return new object[] { "class Foo { }" }; - yield return new object[] { "struct Foo { }" }; - yield return new object[] { "interface Foo { }" }; - yield return new object[] { "class Foo { }" }; - yield return new object[] { "struct Foo { }" }; - yield return new object[] { "interface Foo { }" }; + yield return new object[] { "class Foo<{|#0:Ta|}, {|#1:Tb|}> { }" }; + yield return new object[] { "struct Foo<{|#0:Ta|}, {|#1:Tb|}> { }" }; + yield return new object[] { "interface Foo<{|#0:Ta|}, {|#1:Tb|}> { }" }; + yield return new object[] { "class Foo<{|#0:Ta|}, {|#1:T\\u0062|}> { }" }; + yield return new object[] { "struct Foo<{|#0:Ta|}, {|#1:T\\u0062|}> { }" }; + yield return new object[] { "interface Foo<{|#0:Ta|}, {|#1:T\\u0062|}> { }" }; + if (LightupHelpers.SupportsCSharp9) + { + yield return new object[] { "record Foo<{|#0:Ta|}, {|#1:Tb|}> { }" }; + yield return new object[] { "record Foo<{|#0:Ta|}, {|#1:T\\u0062|}> { }" }; + } + + if (LightupHelpers.SupportsCSharp10) + { + yield return new object[] { "record class Foo<{|#0:Ta|}, {|#1:Tb|}> { }" }; + yield return new object[] { "record struct Foo<{|#0:Ta|}, {|#1:T\\u0062|}> { }" }; + } } } @@ -259,8 +272,8 @@ public async Task TestTypesWithMissingDocumentationAsync(string p) var expected = new[] { - Diagnostic().WithLocation(5, 22).WithArguments("Ta"), - Diagnostic().WithLocation(5, 26).WithArguments("Tb"), + Diagnostic().WithLocation(0).WithArguments("Ta"), + Diagnostic().WithLocation(1).WithArguments("Tb"), }; await VerifyCSharpDiagnosticAsync(testCode.Replace("##", p), expected, CancellationToken.None).ConfigureAwait(false); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1619UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1619UnitTests.cs index 7063f250f..f28c90981 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1619UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1619UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -8,8 +10,8 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -22,12 +24,23 @@ public static IEnumerable Types { get { - yield return new object[] { "class Foo { }" }; - yield return new object[] { "struct Foo { }" }; - yield return new object[] { "interface Foo { }" }; - yield return new object[] { "class Foo { }" }; - yield return new object[] { "struct Foo { }" }; - yield return new object[] { "interface Foo { }" }; + yield return new object[] { "class Foo<{|#0:Ta|}, {|#1:Tb|}> { }" }; + yield return new object[] { "struct Foo<{|#0:Ta|}, {|#1:Tb|}> { }" }; + yield return new object[] { "interface Foo<{|#0:Ta|}, {|#1:Tb|}> { }" }; + yield return new object[] { "class Foo<{|#0:Ta|}, {|#1:T\\u0062|}> { }" }; + yield return new object[] { "struct Foo<{|#0:Ta|}, {|#1:T\\u0062|}> { }" }; + yield return new object[] { "interface Foo<{|#0:Ta|}, {|#1:T\\u0062|}> { }" }; + if (LightupHelpers.SupportsCSharp9) + { + yield return new object[] { "record Foo<{|#0:Ta|}, {|#1:Tb|}> { }" }; + yield return new object[] { "record Foo<{|#0:Ta|}, {|#1:T\\u0062|}> { }" }; + } + + if (LightupHelpers.SupportsCSharp10) + { + yield return new object[] { "record class Foo<{|#0:Ta|}, {|#1:Tb|}> { }" }; + yield return new object[] { "record struct Foo<{|#0:Ta|}, {|#1:T\\u0062|}> { }" }; + } } } @@ -115,8 +128,8 @@ public async Task TestPartialTypesWithMissingDocumentationAsync(string p) var expected = new[] { - Diagnostic().WithLocation(5, 30).WithArguments("Ta"), - Diagnostic().WithLocation(5, 34).WithArguments("Tb"), + Diagnostic().WithLocation(0).WithArguments("Ta"), + Diagnostic().WithLocation(1).WithArguments("Tb"), }; await VerifyCSharpDiagnosticAsync(testCode.Replace("##", p), expected, CancellationToken.None).ConfigureAwait(false); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1620UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1620UnitTests.cs index f2595bd4a..23c9647c4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1620UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1620UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -9,7 +11,6 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1621UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1621UnitTests.cs index 97c62de65..832aacc4b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1621UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1621UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -9,7 +11,6 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -332,9 +333,6 @@ public class TestClass await VerifyCSharpDiagnosticAsync(testCode.Replace("##", p), expected, CancellationToken.None).ConfigureAwait(false); } - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult expected, CancellationToken cancellationToken) - => VerifyCSharpDiagnosticAsync(source, new[] { expected }, cancellationToken); - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) { var test = CreateTest(expected); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1622UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1622UnitTests.cs index be90b7bae..257bf2292 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1622UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1622UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -9,7 +11,6 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -306,9 +307,6 @@ public class TestClass await VerifyCSharpDiagnosticAsync(testCode.Replace("##", memberText), expected, CancellationToken.None).ConfigureAwait(false); } - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult expected, CancellationToken cancellationToken) - => VerifyCSharpDiagnosticAsync(source, new[] { expected }, cancellationToken); - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) { var test = CreateTest(expected); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1623UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1623UnitTests.cs index a09425abd..0e6503f58 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1623UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1623UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.DocumentationRules.PropertySummaryDocumentationAnalyzer, @@ -168,6 +169,106 @@ public int Property await VerifyCSharpFixAsync(testCode, expected, testCode, CancellationToken.None).ConfigureAwait(false); } + [Fact] + [WorkItem(1934, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1934")] + public async Task SummaryInParagraphIsAllowedAsync() + { + var testCode = @"public class ClassName +{ + /// Gets the first test value. + public int Property1 + { + get; + } + + /// + /// Gets the second test value. + /// + public int Property2 + { + get; + } + + /// + /// + /// Gets the third test value. + /// + /// + public int Property3 + { + get; + } +}"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(1934, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1934")] + public async Task SummaryInParagraphCanBeFixedAsync() + { + var testCode = @"public class ClassName +{ + /// Gets the first test value. + public int Property1 + { + set { } + } + + /// + /// Gets the second test value. + /// + public int Property2 + { + set { } + } + + /// + /// + /// Gets the third test value. + /// + /// + public int Property3 + { + set { } + } +}"; + var fixedTestCode = @"public class ClassName +{ + /// Sets the first test value. + public int Property1 + { + set { } + } + + /// + /// Sets the second test value. + /// + public int Property2 + { + set { } + } + + /// + /// + /// Sets the third test value. + /// + /// + public int Property3 + { + set { } + } +}"; + + DiagnosticResult[] expected = + { + Diagnostic(PropertySummaryDocumentationAnalyzer.SA1623Descriptor).WithLocation(4, 16).WithArguments("Sets"), + Diagnostic(PropertySummaryDocumentationAnalyzer.SA1623Descriptor).WithLocation(12, 16).WithArguments("Sets"), + Diagnostic(PropertySummaryDocumentationAnalyzer.SA1623Descriptor).WithLocation(22, 16).WithArguments("Sets"), + }; + await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + } + /// /// Verifies that an incorrect summary tag with a known prefix will be fixed correctly. /// @@ -192,6 +293,10 @@ public int Property [InlineData("public", "int", "{ set {} }", "Gets or sets", "Sets")] // Regression test for #2253 [InlineData("public", "int", "{ get; private set; }", "Sets", "Gets")] // Regression test for #2253 [InlineData("public", "int", "{ private get; set; }", "Gets", "Sets")] // Regression test for #2253 + [InlineData("public", "int", "{ get; }", "Returns", "Gets")] + [InlineData("public", "int", "{ get; set; }", "Returns", "Gets or sets")] + [InlineData("public", "bool", "{ get; }", "Returns a value indicating whether", "Gets a value indicating whether")] + [InlineData("public", "bool", "{ get; set; }", "Returns a value indicating whether", "Gets or sets a value indicating whether")] public async Task IncorrectSummaryTagWithKnownPrefixShouldBeFixedCorrectlyAsync(string accessibility, string type, string accessors, string summaryPrefix, string expectedArgument) { var testCode = $@" diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1624UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1624UnitTests.cs index f409e1278..fb9ce294e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1624UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1624UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1625UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1625UnitTests.cs index 8e2caef80..1ee130c30 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1625UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1625UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -8,8 +10,8 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -29,6 +31,16 @@ public static IEnumerable Members yield return new[] { "public struct Test { }" }; yield return new[] { "public enum Test { }" }; yield return new[] { "public delegate void Test();" }; + if (LightupHelpers.SupportsCSharp9) + { + yield return new[] { "public record Test { }" }; + } + + if (LightupHelpers.SupportsCSharp10) + { + yield return new[] { "public record class Test { }" }; + yield return new[] { "public record struct Test { }" }; + } } } @@ -273,6 +285,23 @@ public class TestClass await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); } + [Fact] + public async Task VerifyThatDuplicatedDocumentationForEnumMemberDoesReportADiagnosticAsync() + { + var testCode = @" +public enum EnumName +{ + /// + /// Some documentation. + /// + /// Some documentation. + EnumMember = 0, +}"; + var expected = Diagnostic().WithLocation(7, 9); + + await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); + } + [Fact] public async Task VerifyThatCorrectIncludedDocumentationDoesNotReportADiagnosticAsync() { @@ -300,6 +329,21 @@ public class TestClass2 {{ }} await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } + [Fact] + [WorkItem(3150, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3150")] + public async Task VerifyThatMissingIncludedDocumentationDoesNotReportADiagnosticAsync() + { + var testCode = $@" +public class TestClass +{{ + /// + public void Test() {{ }} +}} +public class TestClass2 {{ }} +"; + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + [Fact] public async Task VerifyThatTheAnalyzerDoesNotCrashOnIncludedInheritDocAsync() { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1626UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1626UnitTests.cs index 72fad4023..bef579acb 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1626UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1626UnitTests.cs @@ -1,13 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using StyleCop.Analyzers.DocumentationRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.DocumentationRules.SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes, @@ -15,8 +15,6 @@ namespace StyleCop.Analyzers.Test.DocumentationRules public class SA1626UnitTests { - private const string DiagnosticId = SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes.DiagnosticId; - [Fact] public async Task TestClassWithXmlCommentAsync() { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1627UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1627UnitTests.cs index 64080d814..277b51b39 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1627UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1627UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -9,7 +11,6 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1628UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1628UnitTests.cs index b54c2b05b..2e27cc408 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1628UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1628UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1629UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1629UnitTests.cs index 01e5d64e2..f86afd24e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1629UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1629UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -8,7 +10,6 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -172,6 +173,35 @@ public int TestMethod2(T arg1) await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } + [Fact] + [WorkItem(2950, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2950")] + public async Task TestEnumMemberAsync() + { + var testCode = @" +public enum TestEnum +{ + /// + /// Enum member + /// + EnumMember = 0, +} +"; + + var fixedTestCode = @" +public enum TestEnum +{ + /// + /// Enum member. + /// + EnumMember = 0, +} +"; + + var expected = Diagnostic().WithLocation(5, 20); + + await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + } + [Fact] public async Task TestAugmentedInheritedDocumentationAsync() { @@ -287,6 +317,20 @@ public class TestClass await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } + [Fact] + [WorkItem(3150, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3150")] + public async Task TestIncludedMissingFileAsync() + { + var testCode = @" +/// +public class TestClass +{ +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + [Fact] [WorkItem(2680, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2680")] public async Task TestReportingAfterEmptyElementAsync() @@ -476,6 +520,75 @@ public interface ITest await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } + [Theory] + [InlineData(",")] + [InlineData(";")] + public async Task TestSentenceEndingWithTypoAsync(string typo) + { + var testCode = $@" +/// +/// Summary{typo} +/// +public interface ITest +{{ +}} +"; + var fixedTestCode = $@" +/// +/// Summary. +/// +public interface ITest +{{ +}} +"; + + DiagnosticResult expected = Diagnostic().WithLocation(3, 12); + await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, default).ConfigureAwait(false); + } + + [Theory] + [InlineData("a", true)] + [InlineData("see", true)] + [InlineData("seealso", false)] + public async Task TestFullSentenceLinkAsync(string tag, bool insideSummary) + { + var surrounding = insideSummary ? (Start: "", End: "") : (Start: string.Empty, End: string.Empty); + + var testCode = $@" +/// {surrounding.Start}<{tag} href=""someurl"">Periods aren't required to glow white at the end of a full-sentence link.{surrounding.End} +public interface ITest +{{ +}} +"; + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, default).ConfigureAwait(false); + } + + [Theory] + [InlineData(",")] + [InlineData(";")] + public async Task TestSentenceEndingWithTypoAndParenthesisAsync(string typo) + { + var testCode = $@" +/// +/// Summary (for example{typo}) +/// +public interface ITest +{{ +}} +"; + var fixedTestCode = $@" +/// +/// Summary (for example.) +/// +public interface ITest +{{ +}} +"; + + DiagnosticResult expected = Diagnostic().WithLocation(3, 25); + await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, default).ConfigureAwait(false); + } + [Fact] public async Task TestMultipleParagraphBlocksAsync() { @@ -849,9 +962,6 @@ public interface ITest await VerifyCSharpDiagnosticAsync(testCode, testSettings, expectedResult, CancellationToken.None).ConfigureAwait(false); } - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult expected, CancellationToken cancellationToken) - => VerifyCSharpDiagnosticAsync(source, testSettings: null, new[] { expected }, cancellationToken); - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) => VerifyCSharpDiagnosticAsync(source, testSettings: null, expected, cancellationToken); @@ -872,14 +982,6 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec test.TestCode = source; test.FixedCode = fixedSource; - if (source == fixedSource) - { - test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll; - test.FixedState.MarkupHandling = MarkupMode.Allow; - test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll; - test.BatchFixedState.MarkupHandling = MarkupMode.Allow; - } - return test.RunAsync(cancellationToken); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1630UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1630UnitTests.cs index 2963f99d3..8faf6e3e3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1630UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1630UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1631UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1631UnitTests.cs index 0e1d04baf..d9b17e1d8 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1631UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1631UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1632UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1632UnitTests.cs index e715b4ea6..130896ea6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1632UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1632UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1633UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1633UnitTests.cs index 06c9b53da..7ef208ad3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1633UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1633UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -7,9 +9,7 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; - using TestHelper; using Xunit; - using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; /// /// Unit tests for the SA1633 diagnostic. diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1634UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1634UnitTests.cs index 5aaf702fc..68f709241 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1634UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1634UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1635UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1635UnitTests.cs index 86b4cd97c..203f46073 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1635UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1635UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1636UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1636UnitTests.cs index f40df82e5..293b58782 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1636UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1636UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1637UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1637UnitTests.cs index 291226651..f76bd7f53 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1637UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1637UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1638UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1638UnitTests.cs index d0089edb0..0ba970d96 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1638UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1638UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1639UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1639UnitTests.cs index febe4d433..7af4917cc 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1639UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1639UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -91,5 +93,11 @@ protected override IEnumerable GetDisabledDiagnostics() { return Enumerable.Empty(); } + + /// + protected override IEnumerable GetExplicitlyEnabledDiagnostics() + { + yield return FileHeaderAnalyzers.SA1639Descriptor.Id; + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1640UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1640UnitTests.cs index df7172571..5311ac6a2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1640UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1640UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1641UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1641UnitTests.cs index 740bf6e8e..825b31c33 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1641UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1641UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1642UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1642UnitTests.cs index 27cf86735..4433b5044 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1642UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1642UnitTests.cs @@ -1,15 +1,19 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { + using System.Collections.Generic; + using System.Diagnostics; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.Test.Helpers; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -20,8 +24,7 @@ namespace StyleCop.Analyzers.Test.DocumentationRules public class SA1642UnitTests { [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestNoDocumentationAsync(string typeKind) { var testCode = $@"namespace FooNamespace @@ -37,8 +40,7 @@ public Foo(int arg) } [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestEmptyPublicConstructorAsync(string typeKind) { await TestEmptyConstructorAsync(typeKind, "public").ConfigureAwait(false); @@ -53,62 +55,65 @@ public async Task TestEmptyNonPublicConstructorAsync(string typeKind) } [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestEmptyStaticConstructorAsync(string typeKind) { await TestEmptyConstructorAsync(typeKind, "static").ConfigureAwait(false); } [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestNonPrivateConstructorCorrectDocumentationSimpleAsync(string typeKind) { + var docTypeKind = GetDocTypeKind(typeKind); + await TestConstructorCorrectDocumentationSimpleAsync( typeKind, "public", - string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind), - string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind), + string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, docTypeKind), + string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, docTypeKind), false).ConfigureAwait(false); } [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestNonPrivateConstructorCorrectDocumentationCustomizedAsync(string typeKind) { + var docTypeKind = GetDocTypeKind(typeKind); + await TestConstructorCorrectDocumentationCustomizedAsync( typeKind, "public", - string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind), - string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind), + string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, docTypeKind), + string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, docTypeKind), false).ConfigureAwait(false); } [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestNonPrivateConstructorCorrectDocumentationGenericSimpleAsync(string typeKind) { + var docTypeKind = GetDocTypeKind(typeKind); + await TestConstructorCorrectDocumentationSimpleAsync( typeKind, "public", - string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind), - string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind), + string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, docTypeKind), + string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, docTypeKind), true).ConfigureAwait(false); } [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestNonPrivateConstructorCorrectDocumentationGenericCustomizedAsync(string typeKind) { + var docTypeKind = GetDocTypeKind(typeKind); + await TestConstructorCorrectDocumentationCustomizedAsync( typeKind, "public", - string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind), - string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind), + string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, docTypeKind), + string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, docTypeKind), true).ConfigureAwait(false); } @@ -221,56 +226,60 @@ await TestConstructorCorrectDocumentationCustomizedAsync( } [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestStaticConstructorCorrectDocumentationAsync(string typeKind) { + var docTypeKind = GetDocTypeKind(typeKind); + await TestConstructorCorrectDocumentationAsync( typeKind, "static", - string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, typeKind), - string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, typeKind), + string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, docTypeKind), + string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, docTypeKind), string.Empty, false).ConfigureAwait(false); } [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestStaticConstructorCorrectDocumentationGenericAsync(string typeKind) { + var docTypeKind = GetDocTypeKind(typeKind); + await TestConstructorCorrectDocumentationAsync( typeKind, "static", - string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, typeKind), - string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, typeKind), + string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, docTypeKind), + string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, docTypeKind), string.Empty, true).ConfigureAwait(false); } [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestNonPrivateConstructorMissingDocumentationAsync(string typeKind) { + var docTypeKind = GetDocTypeKind(typeKind); + await TestConstructorMissingDocumentationAsync( typeKind, "public", - string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind), - string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind), + string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, docTypeKind), + string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, docTypeKind), false).ConfigureAwait(false); } [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestNonPrivateConstructorMissingDocumentationGenericAsync(string typeKind) { + var docTypeKind = GetDocTypeKind(typeKind); + await TestConstructorMissingDocumentationAsync( typeKind, "public", - string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind), - string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind), + string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, docTypeKind), + string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, docTypeKind), true).ConfigureAwait(false); } @@ -301,54 +310,58 @@ await TestConstructorMissingDocumentationAsync( } [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestStaticConstructorMissingDocumentationAsync(string typeKind) { + var docTypeKind = GetDocTypeKind(typeKind); + await TestConstructorMissingDocumentationAsync( typeKind, "static", - string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, typeKind), - string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, typeKind), + string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, docTypeKind), + string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, docTypeKind), false).ConfigureAwait(false); } [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestStaticConstructorMissingDocumentationGenericAsync(string typeKind) { + var docTypeKind = GetDocTypeKind(typeKind); + await TestConstructorMissingDocumentationAsync( typeKind, "static", - string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, typeKind), - string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, typeKind), + string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, docTypeKind), + string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, docTypeKind), true).ConfigureAwait(false); } [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestNonPrivateConstructorSimpleDocumentationAsync(string typeKind) { + var docTypeKind = GetDocTypeKind(typeKind); + await TestConstructorSimpleDocumentationAsync( typeKind, "public", - string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind), - string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind), + string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, docTypeKind), + string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, docTypeKind), false).ConfigureAwait(false); } [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestNonPrivateConstructorSimpleDocumentationGenericAsync(string typeKind) { + var docTypeKind = GetDocTypeKind(typeKind); + await TestConstructorSimpleDocumentationAsync( typeKind, "public", - string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind), - string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind), + string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, docTypeKind), + string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, docTypeKind), true).ConfigureAwait(false); } @@ -379,54 +392,58 @@ await TestConstructorSimpleDocumentationAsync( } [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestStaticConstructorSimpleDocumentationAsync(string typeKind) { + var docTypeKind = GetDocTypeKind(typeKind); + await TestConstructorSimpleDocumentationAsync( typeKind, "static", - string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, typeKind), - string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, typeKind), + string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, docTypeKind), + string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, docTypeKind), false).ConfigureAwait(false); } [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestStaticConstructorSimpleDocumentationGenericAsync(string typeKind) { + var docTypeKind = GetDocTypeKind(typeKind); + await TestConstructorSimpleDocumentationAsync( typeKind, "static", - string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, typeKind), - string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, typeKind), + string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, docTypeKind), + string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, docTypeKind), true).ConfigureAwait(false); } [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestNonPrivateConstructorSimpleDocumentationWrongTypeNameAsync(string typeKind) { + var docTypeKind = GetDocTypeKind(typeKind); + await TestConstructorSimpleDocumentationWrongTypeNameAsync( typeKind, "public", - string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind), - string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind), + string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, docTypeKind), + string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, docTypeKind), false).ConfigureAwait(false); } [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestNonPrivateConstructorSimpleDocumentationGenericWrongTypeNameAsync(string typeKind) { + var docTypeKind = GetDocTypeKind(typeKind); + await TestConstructorSimpleDocumentationWrongTypeNameAsync( typeKind, "public", - string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, typeKind), - string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, typeKind), + string.Format(DocumentationResources.NonPrivateConstructorStandardTextFirstPart, docTypeKind), + string.Format(DocumentationResources.NonPrivateConstructorStandardTextSecondPart, docTypeKind), true).ConfigureAwait(false); } @@ -457,28 +474,30 @@ await TestConstructorSimpleDocumentationWrongTypeNameAsync( } [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestStaticConstructorSimpleDocumentationWrongTypeNameAsync(string typeKind) { + var docTypeKind = GetDocTypeKind(typeKind); + await TestConstructorSimpleDocumentationWrongTypeNameAsync( typeKind, "static", - string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, typeKind), - string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, typeKind), + string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, docTypeKind), + string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, docTypeKind), false).ConfigureAwait(false); } [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestStaticConstructorSimpleDocumentationGenericWrongTypeNameAsync(string typeKind) { + var docTypeKind = GetDocTypeKind(typeKind); + await TestConstructorSimpleDocumentationWrongTypeNameAsync( typeKind, "static", - string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, typeKind), - string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, typeKind), + string.Format(DocumentationResources.StaticConstructorStandardTextFirstPart, docTypeKind), + string.Format(DocumentationResources.StaticConstructorStandardTextSecondPart, docTypeKind), true).ConfigureAwait(false); } @@ -586,34 +605,66 @@ protected CustomizableBlockSubscriberBase() await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } - /// - /// Verifies that an empty see tag is handled properly. - /// - /// A representing the asynchronous unit test. - [Fact] - public async Task TestWithEmptySeeTagAsync() + [Theory] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task TestWithEmptySeeTagAsync(string typeKind) { - string testCode = @" -public class TestClass -{ + var docTypeKind = GetDocTypeKind(typeKind); + + string testCode = $@" +public {typeKind} TestClass +{{ /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the {docTypeKind}. /// - public TestClass() - { - } -} + public TestClass(int i) + {{ + }} +}} "; - string fixedCode = @" -public class TestClass -{ + string fixedCode = $@" +public {typeKind} TestClass +{{ /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the {docTypeKind}. /// - public TestClass() - { - } -} + public TestClass(int i) + {{ + }} +}} +"; + + DiagnosticResult expected = Diagnostic().WithLocation(5, 43); + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Theory] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task TestWithEmptySeeTagGenericAsync(string typeKind) + { + var docTypeKind = GetDocTypeKind(typeKind); + + string testCode = $@" +public {typeKind} TestClass +{{ + /// + /// Initializes a new instance of the {docTypeKind}. + /// + public TestClass(int i) + {{ + }} +}} +"; + string fixedCode = $@" +public {typeKind} TestClass +{{ + /// + /// Initializes a new instance of the {docTypeKind}. + /// + public TestClass(int i) + {{ + }} +}} "; DiagnosticResult expected = Diagnostic().WithLocation(5, 43); @@ -939,8 +990,7 @@ public ClassName() {{ public class ClassName {{ - /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. public ClassName() {{ }} @@ -951,6 +1001,30 @@ public ClassName() await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } + [Fact] + [WorkItem(2963, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2963")] + public async Task TestConstructorNoCRefDocumentationSingleLineAsync() + { + var testCode = @" +public class TestClass +{ + /// Initializes a new instance of the TestClass class. + public TestClass() { } +} +"; + + var fixedCode = @" +public class TestClass +{ + /// Initializes a new instance of the class. + public TestClass() { } +} +"; + + var expected = Diagnostic().WithLocation(4, 9); + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + [Theory] [WorkItem(2686, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2686")] [InlineData("")] @@ -1084,7 +1158,7 @@ private static async Task TestConstructorCorrectDocumentationCustomizedAsync(str private static async Task TestConstructorMissingDocumentationAsync(string typeKind, string modifiers, string part1, string part2, bool generic) { string typeParameters = generic ? "" : string.Empty; - string arguments = typeKind == "struct" && modifiers != "static" ? "int argument" : null; + string arguments = IsStruct(typeKind) && modifiers != "static" ? "int argument" : null; var testCode = $@"namespace FooNamespace {{ public {typeKind} Foo{typeParameters} @@ -1202,9 +1276,6 @@ private static async Task TestConstructorSimpleDocumentationWrongTypeNameAsync(s await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult expected, CancellationToken cancellationToken) - => VerifyCSharpDiagnosticAsync(source, testSettings: null, new[] { expected }, cancellationToken); - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) => VerifyCSharpDiagnosticAsync(source, testSettings: null, expected, cancellationToken); @@ -1225,14 +1296,6 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec test.TestCode = source; test.FixedCode = fixedSource; - if (source == fixedSource) - { - test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll; - test.FixedState.MarkupHandling = MarkupMode.Allow; - test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll; - test.BatchFixedState.MarkupHandling = MarkupMode.Allow; - } - return test.RunAsync(cancellationToken); } @@ -1309,5 +1372,29 @@ private static StyleCopCodeFixVerifier; @@ -346,14 +347,6 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec test.TestCode = source; test.FixedCode = fixedSource; - if (source == fixedSource) - { - test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll; - test.FixedState.MarkupHandling = MarkupMode.Allow; - test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll; - test.BatchFixedState.MarkupHandling = MarkupMode.Allow; - } - return test.RunAsync(cancellationToken); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1644UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1644UnitTests.cs new file mode 100644 index 000000000..19286eb36 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1644UnitTests.cs @@ -0,0 +1,26 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.DocumentationRules +{ + using Microsoft.CodeAnalysis; + using StyleCop.Analyzers.DocumentationRules; + using Xunit; + + /// + /// This class contains unit tests for . + /// + public class SA1644UnitTests + { + [Fact] + public void TestDisabledByDefaultAndNotConfigurable() + { + var analyzer = new SA1644DocumentationHeadersMustNotContainBlankLines(); + Assert.Single(analyzer.SupportedDiagnostics); + Assert.False(analyzer.SupportedDiagnostics[0].IsEnabledByDefault); + Assert.Contains(WellKnownDiagnosticTags.NotConfigurable, analyzer.SupportedDiagnostics[0].CustomTags); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1645UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1645UnitTests.cs index 5c15a713a..36b345b8d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1645UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1645UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1646UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1646UnitTests.cs index 642e8d6e6..e54a0082f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1646UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1646UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1647UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1647UnitTests.cs index 2442325d3..a3ee407a9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1647UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1647UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1648UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1648UnitTests.cs index 927c86f0e..9443e7a83 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1648UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1648UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -8,7 +10,6 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -306,10 +307,26 @@ public void TestMethod() { } await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); } - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult expected, CancellationToken cancellationToken) + /// + /// Verifies that a delegate declaration that includes the inheritdoc will produce diagnostics. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3291, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3291")] + public async Task TestIncorrectDelegateInheritDocAsync() + { + var testCode = @" +/// [||] +public delegate bool TestDelegate(int value); +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + protected static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult expected, CancellationToken cancellationToken) => VerifyCSharpDiagnosticAsync(source, new[] { expected }, cancellationToken); - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) + protected static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) { var test = CreateTest(expected); test.TestCode = source; @@ -330,6 +347,11 @@ private static StyleCopDiagnosticVerifier +"; + string contentDelegateInheritDoc = @" + + + "; var test = new StyleCopDiagnosticVerifier.CSharpTest @@ -338,6 +360,7 @@ private static StyleCopDiagnosticVerifier; @@ -18,7 +19,7 @@ namespace StyleCop.Analyzers.Test.DocumentationRules /// public class SA1649UnitTests { - private const string MetadataSettings = @" + protected const string MetadataSettings = @" { ""settings"": { ""documentationRules"": { @@ -28,7 +29,7 @@ public class SA1649UnitTests } "; - private const string StyleCopSettings = @" + protected const string StyleCopSettings = @" { ""settings"": { ""documentationRules"": { @@ -38,14 +39,29 @@ public class SA1649UnitTests } "; - public static IEnumerable TypeKeywords + /// + /// Verifies that a wrong file name is correctly reported. + /// + /// The type keyword to use during the test. + /// A representing the asynchronous unit test. + [Theory] + [MemberData(nameof(CommonMemberData.AllTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task VerifyWrongFileNameAsync(string typeKeyword) { - get - { - yield return new object[] { "class" }; - yield return new object[] { "struct" }; - yield return new object[] { "interface" }; - } + var testCode = $@"namespace TestNamespace +{{ + {GetTypeDeclaration(typeKeyword, "TestType", diagnosticKey: 0)} +}} +"; + + var fixedCode = $@"namespace TestNamespace +{{ + {GetTypeDeclaration(typeKeyword, "TestType")} +}} +"; + + var expectedDiagnostic = Diagnostic().WithLocation(0); + await VerifyCSharpFixAsync("WrongFileName.cs", testCode, StyleCopSettings, expectedDiagnostic, "TestType.cs", fixedCode, CancellationToken.None).ConfigureAwait(false); } /// @@ -54,27 +70,48 @@ public static IEnumerable TypeKeywords /// The type keyword to use during the test. /// A representing the asynchronous unit test. [Theory] - [MemberData(nameof(TypeKeywords))] - public async Task VerifyWrongFileNameAsync(string typeKeyword) + [MemberData(nameof(CommonMemberData.GenericTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task VerifyWrongFileNameGenericStyleCopAsync(string typeKeyword) { var testCode = $@"namespace TestNamespace {{ - public {typeKeyword} TestType - {{ - }} + {GetGenericTypeDeclaration(typeKeyword, "TestType", new[] { "T" }, diagnosticKey: 0)} }} "; var fixedCode = $@"namespace TestNamespace {{ - public {typeKeyword} TestType - {{ - }} + {GetGenericTypeDeclaration(typeKeyword, "TestType", new[] { "T" })} }} "; - var expectedDiagnostic = Diagnostic().WithLocation("WrongFileName.cs", 3, 13 + typeKeyword.Length); - await VerifyCSharpFixAsync("WrongFileName.cs", testCode, StyleCopSettings, expectedDiagnostic, "TestType.cs", fixedCode, CancellationToken.None).ConfigureAwait(false); + var expectedDiagnostic = Diagnostic().WithLocation(0); + await VerifyCSharpFixAsync("WrongFileName.cs", testCode, StyleCopSettings, expectedDiagnostic, "TestType{T}.cs", fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that a wrong file name is correctly reported. + /// + /// The type keyword to use during the test. + /// A representing the asynchronous unit test. + [Theory] + [MemberData(nameof(CommonMemberData.GenericTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task VerifyWrongFileNameGenericMetadataAsync(string typeKeyword) + { + var testCode = $@"namespace TestNamespace +{{ + {GetGenericTypeDeclaration(typeKeyword, "TestType", new[] { "T" }, diagnosticKey: 0)} +}} +"; + + var fixedCode = $@"namespace TestNamespace +{{ + {GetGenericTypeDeclaration(typeKeyword, "TestType", new[] { "T" })} +}} +"; + + var expectedDiagnostic = Diagnostic().WithLocation(0); + await VerifyCSharpFixAsync("WrongFileName.cs", testCode, MetadataSettings, expectedDiagnostic, "TestType`1.cs", fixedCode, CancellationToken.None).ConfigureAwait(false); } /// @@ -84,26 +121,22 @@ public async Task VerifyWrongFileNameAsync(string typeKeyword) /// The type keyword to use during the test. /// A representing the asynchronous unit test. [Theory] - [MemberData(nameof(TypeKeywords))] + [MemberData(nameof(CommonMemberData.AllTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task VerifyWrongFileNameMultipleExtensionsAsync(string typeKeyword) { var testCode = $@"namespace TestNamespace {{ - public {typeKeyword} TestType - {{ - }} + {GetTypeDeclaration(typeKeyword, "TestType", diagnosticKey: 0)} }} "; var fixedCode = $@"namespace TestNamespace {{ - public {typeKeyword} TestType - {{ - }} + {GetTypeDeclaration(typeKeyword, "TestType")} }} "; - var expectedDiagnostic = Diagnostic().WithLocation("WrongFileName.svc.cs", 3, 13 + typeKeyword.Length); + var expectedDiagnostic = Diagnostic().WithLocation(0); await VerifyCSharpFixAsync("WrongFileName.svc.cs", testCode, StyleCopSettings, expectedDiagnostic, "TestType.svc.cs", fixedCode, CancellationToken.None).ConfigureAwait(false); } @@ -114,26 +147,22 @@ public async Task VerifyWrongFileNameMultipleExtensionsAsync(string typeKeyword) /// The type keyword to use during the test. /// A representing the asynchronous unit test. [Theory] - [MemberData(nameof(TypeKeywords))] + [MemberData(nameof(CommonMemberData.AllTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task VerifyWrongFileNameNoExtensionAsync(string typeKeyword) { var testCode = $@"namespace TestNamespace {{ - public {typeKeyword} TestType - {{ - }} + {GetTypeDeclaration(typeKeyword, "TestType", diagnosticKey: 0)} }} "; var fixedCode = $@"namespace TestNamespace {{ - public {typeKeyword} TestType - {{ - }} + {GetTypeDeclaration(typeKeyword, "TestType")} }} "; - var expectedDiagnostic = Diagnostic().WithLocation("WrongFileName", 3, 13 + typeKeyword.Length); + var expectedDiagnostic = Diagnostic().WithLocation(0); await VerifyCSharpFixAsync("WrongFileName", testCode, StyleCopSettings, expectedDiagnostic, "TestType", fixedCode, CancellationToken.None).ConfigureAwait(false); } @@ -143,18 +172,52 @@ public async Task VerifyWrongFileNameNoExtensionAsync(string typeKeyword) /// The type keyword to use during the test. /// A representing the asynchronous unit test. [Theory] - [MemberData(nameof(TypeKeywords))] + [MemberData(nameof(CommonMemberData.AllTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task VerifyCaseInsensitivityAsync(string typeKeyword) { var testCode = $@"namespace TestNamespace {{ - public {typeKeyword} TestType - {{ - }} + {GetTypeDeclaration(typeKeyword, "TestType")} +}} +"; + + await VerifyCSharpDiagnosticAsync("testtype.cs", testCode, testSettings: null, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that the file name is not case sensitive. + /// + /// The type keyword to use during the test. + /// A representing the asynchronous unit test. + [Theory] + [MemberData(nameof(CommonMemberData.GenericTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task VerifyCaseInsensitivityGenericStyleCopAsync(string typeKeyword) + { + var testCode = $@"namespace TestNamespace +{{ + {GetGenericTypeDeclaration(typeKeyword, "TestType", new[] { "T" })} }} "; - await VerifyCSharpDiagnosticAsync("testtype.cs", testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpDiagnosticAsync("testtype{t}.cs", testCode, StyleCopSettings, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that the file name is not case sensitive. + /// + /// The type keyword to use during the test. + /// A representing the asynchronous unit test. + [Theory] + [MemberData(nameof(CommonMemberData.GenericTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task VerifyCaseInsensitivityGenericMetadataAsync(string typeKeyword) + { + var testCode = $@"namespace TestNamespace +{{ + {GetGenericTypeDeclaration(typeKeyword, "TestType", new[] { "T" })} +}} +"; + + await VerifyCSharpDiagnosticAsync("testtype`1.cs", testCode, MetadataSettings, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } /// @@ -163,22 +226,135 @@ public async Task VerifyCaseInsensitivityAsync(string typeKeyword) /// The type keyword to use during the test. /// A representing the asynchronous unit test. [Theory] - [MemberData(nameof(TypeKeywords))] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task VerifyFirstTypeIsUsedAsync(string typeKeyword) { var testCode = $@"namespace TestNamespace {{ - public {typeKeyword} TestType + public enum IgnoredEnum {{ }} + public delegate void IgnoredDelegate(); + + {GetTypeDeclaration(typeKeyword, "TestType", diagnosticKey: 0)} + + {GetTypeDeclaration(typeKeyword, "TestType2")} +}} +"; + var fixedCode = $@"namespace TestNamespace +{{ + public enum IgnoredEnum {{ }} + public delegate void IgnoredDelegate(); + + {GetTypeDeclaration(typeKeyword, "TestType")} + + {GetTypeDeclaration(typeKeyword, "TestType2")} +}} +"; + + var expectedDiagnostic = Diagnostic().WithLocation(0); + await VerifyCSharpFixAsync("TestType2.cs", testCode, StyleCopSettings, expectedDiagnostic, "TestType.cs", fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that the file name is based on the first type. + /// + /// The type keyword to use during the test. + /// A representing the asynchronous unit test. + [Theory] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task VerifyFirstTypeIsUsedGenericStyleCopAsync(string typeKeyword) + { + var testCode = $@"namespace TestNamespace +{{ + public enum IgnoredEnum {{ }} + public delegate void IgnoredDelegate(); + + {GetGenericTypeDeclaration(typeKeyword, "TestType", new[] { "T" }, diagnosticKey: 0)} + + {GetGenericTypeDeclaration(typeKeyword, "TestType2", new[] { "T" })} +}} +"; + var fixedCode = $@"namespace TestNamespace +{{ + public enum IgnoredEnum {{ }} + public delegate void IgnoredDelegate(); + + {GetGenericTypeDeclaration(typeKeyword, "TestType", new[] { "T" })} + + {GetGenericTypeDeclaration(typeKeyword, "TestType2", new[] { "T" })} +}} +"; + + var expectedDiagnostic = Diagnostic().WithLocation(0); + await VerifyCSharpFixAsync("TestType2.cs", testCode, StyleCopSettings, expectedDiagnostic, "TestType{T}.cs", fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that the file name is based on the first type. + /// + /// The type keyword to use during the test. + /// A representing the asynchronous unit test. + [Theory] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task VerifyFirstTypeIsUsedGenericMetadataAsync(string typeKeyword) + { + var testCode = $@"namespace TestNamespace +{{ + public enum IgnoredEnum {{ }} + public delegate void IgnoredDelegate(); + + {GetGenericTypeDeclaration(typeKeyword, "TestType", new[] { "T" }, diagnosticKey: 0)} + + {GetGenericTypeDeclaration(typeKeyword, "TestType2", new[] { "T" })} +}} +"; + var fixedCode = $@"namespace TestNamespace +{{ + public enum IgnoredEnum {{ }} + public delegate void IgnoredDelegate(); + + {GetGenericTypeDeclaration(typeKeyword, "TestType", new[] { "T" })} + + {GetGenericTypeDeclaration(typeKeyword, "TestType2", new[] { "T" })} +}} +"; + + var expectedDiagnostic = Diagnostic().WithLocation(0); + await VerifyCSharpFixAsync("TestType2.cs", testCode, MetadataSettings, expectedDiagnostic, "TestType`1.cs", fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3234, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3234")] + public async Task VerifyMultipleEnumTypesIgnoredAsync() + { + var testCode = $@"namespace TestNamespace +{{ + public enum TestType {{ }} - public {typeKeyword} TestType2 + public enum TestType2 {{ }} }} "; - await VerifyCSharpDiagnosticAsync("TestType.cs", testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + // File names are not checked for 'enum' if more than one is present + await VerifyCSharpDiagnosticAsync("TestType2.cs", testCode, testSettings: null, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3234, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3234")] + public async Task VerifyMultipleDelegateTypesIgnoredAsync() + { + var testCode = $@"namespace TestNamespace +{{ + public delegate void TestType(); + public delegate void TestType2(); +}} +"; + + // File names are not checked for 'delegate' if more than one is present + await VerifyCSharpDiagnosticAsync("TestType2.cs", testCode, testSettings: null, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } /// @@ -187,7 +363,7 @@ public async Task VerifyFirstTypeIsUsedAsync(string typeKeyword) /// The type keyword to use during the test. /// A representing the asynchronous unit test. [Theory] - [MemberData(nameof(TypeKeywords))] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task VerifyThatPartialTypesAreIgnoredAsync(string typeKeyword) { var testCode = $@"namespace TestNamespace @@ -198,7 +374,7 @@ public partial {typeKeyword} TestType }} "; - await VerifyCSharpDiagnosticAsync("WrongFileName.cs", testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpDiagnosticAsync("WrongFileName.cs", testCode, testSettings: null, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } /// @@ -207,19 +383,19 @@ public partial {typeKeyword} TestType /// The type keyword to use during the test. /// A representing the asynchronous unit test. [Theory] - [MemberData(nameof(TypeKeywords))] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task VerifyStyleCopNamingConventionForGenericTypeAsync(string typeKeyword) { var testCode = $@"namespace TestNamespace {{ - public {typeKeyword} TestType + public {typeKeyword} {{|#0:TestType|}} {{ }} }} "; - var expectedDiagnostic = Diagnostic().WithLocation("TestType`3.cs", 3, 13 + typeKeyword.Length); - await VerifyCSharpDiagnosticAsync("TestType.cs", testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + var expectedDiagnostic = Diagnostic().WithLocation(0); + await VerifyCSharpDiagnosticAsync("TestType.cs", testCode, testSettings: null, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); await VerifyCSharpFixAsync("TestType`3.cs", testCode, StyleCopSettings, expectedDiagnostic, "TestType{T1,T2,T3}.cs", testCode, CancellationToken.None).ConfigureAwait(false); } @@ -229,21 +405,21 @@ public async Task VerifyStyleCopNamingConventionForGenericTypeAsync(string typeK /// The type keyword to use during the test. /// A representing the asynchronous unit test. [Theory] - [MemberData(nameof(TypeKeywords))] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task VerifyMetadataNamingConventionForGenericTypeAsync(string typeKeyword) { var testCode = $@"namespace TestNamespace {{ - public {typeKeyword} TestType + public {typeKeyword} {{|#0:TestType|}} {{ }} }} "; - var expectedDiagnostic = Diagnostic().WithLocation("TestType{T1,T2,T3}.cs", 3, 13 + typeKeyword.Length); + var expectedDiagnostic = Diagnostic().WithLocation(0); await VerifyCSharpFixAsync("TestType{T1,T2,T3}.cs", testCode, MetadataSettings, expectedDiagnostic, "TestType`3.cs", testCode, CancellationToken.None).ConfigureAwait(false); - expectedDiagnostic = Diagnostic().WithLocation("TestType.cs", 3, 13 + typeKeyword.Length); + expectedDiagnostic = Diagnostic().WithLocation(0); await VerifyCSharpFixAsync("TestType.cs", testCode, MetadataSettings, expectedDiagnostic, "TestType`3.cs", testCode, CancellationToken.None).ConfigureAwait(false); } @@ -254,12 +430,12 @@ public async Task VerifyMetadataNamingConventionForGenericTypeAsync(string typeK /// The type keyword to use during the test. /// A representing the asynchronous unit test. [Theory] - [MemberData(nameof(TypeKeywords))] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task VerifyMetadataNamingConventionForGenericTypeMultipleExtensionsAsync(string typeKeyword) { var testCode = $@"namespace TestNamespace {{ - public {typeKeyword} TestType + public {typeKeyword} {{|#0:TestType|}} {{ }} }} @@ -273,7 +449,7 @@ public async Task VerifyMetadataNamingConventionForGenericTypeMultipleExtensions }} "; - var expectedDiagnostic = Diagnostic().WithLocation("TestType.svc.cs", 3, 13 + typeKeyword.Length); + var expectedDiagnostic = Diagnostic().WithLocation(0); await VerifyCSharpFixAsync("TestType.svc.cs", testCode, MetadataSettings, expectedDiagnostic, "TestType`1.svc.cs", fixedCode, CancellationToken.None).ConfigureAwait(false); } @@ -289,26 +465,78 @@ public async Task VerifyWithoutFirstTypeAsync() } "; - await VerifyCSharpDiagnosticAsync("Test0.cs", testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpDiagnosticAsync("Test0.cs", testCode, testSettings: null, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that no diagnostic is generated if an appropriate SuppressMessageAttribute is provided. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task VerifyWithSuppressMessageAttributeAsync() + { + var testCode = @" + using System.Diagnostics.CodeAnalysis; + [SuppressMessage(""StyleCop.CSharp.DocumentationRules"", ""SA1649:FileNameMustMatchTypeName"", Justification = ""Reviewed."")] + + public class Class2 + { + } + "; + + await VerifyCSharpDiagnosticAsync("Class1.cs", testCode, testSettings: null, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + protected static string GetTypeDeclaration(string typeKind, string typeName, int? diagnosticKey = null) + { + if (diagnosticKey is not null) + { + typeName = $"{{|#{diagnosticKey}:{typeName}|}}"; + } + + return typeKind switch + { + "delegate" => $"public delegate void {typeName}();", + _ => $"public {typeKind} {typeName} {{ }}", + }; } - internal static Task VerifyCSharpDiagnosticAsync(string fileName, string source, DiagnosticResult[] expected, CancellationToken cancellationToken) + protected static string GetGenericTypeDeclaration(string typeKind, string typeName, string[] parameters, int? diagnosticKey = null) { - var test = new StyleCopCodeFixVerifier.CSharpTest + if (diagnosticKey is not null) + { + typeName = $"{{|#{diagnosticKey}:{typeName}|}}"; + } + + return typeKind switch + { + "delegate" => $"public delegate void {typeName}<{string.Join(", ", parameters)}>();", + _ => $"public {typeKind} {typeName}<{string.Join(", ", parameters)}> {{ }}", + }; + } + + protected static Task VerifyCSharpDiagnosticAsync(string fileName, string source, string testSettings, DiagnosticResult[] expected, CancellationToken cancellationToken) + { + var test = new StyleCopCodeFixVerifier.CSharpTest() { TestSources = { (fileName, source) }, }; + if (testSettings != null) + { + test.Settings = testSettings; + } + test.ExpectedDiagnostics.AddRange(expected); return test.RunAsync(cancellationToken); } - internal static Task VerifyCSharpFixAsync(string oldFileName, string source, string testSettings, DiagnosticResult expected, string newFileName, string fixedSource, CancellationToken cancellationToken) + protected static Task VerifyCSharpFixAsync(string oldFileName, string source, string testSettings, DiagnosticResult expected, string newFileName, string fixedSource, CancellationToken cancellationToken) => VerifyCSharpFixAsync(oldFileName, source, testSettings, new[] { expected }, newFileName, fixedSource, cancellationToken); - internal static Task VerifyCSharpFixAsync(string oldFileName, string source, string testSettings, DiagnosticResult[] expected, string newFileName, string fixedSource, CancellationToken cancellationToken) + protected static Task VerifyCSharpFixAsync(string oldFileName, string source, string testSettings, DiagnosticResult[] expected, string newFileName, string fixedSource, CancellationToken cancellationToken) { - var test = new StyleCopCodeFixVerifier.CSharpTest + var test = new StyleCopCodeFixVerifier.CSharpTest() { TestSources = { (oldFileName, source) }, FixedSources = { (newFileName, fixedSource) }, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1650UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1650UnitTests.cs index d35e0aea2..ff722451b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1650UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1650UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1651UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1651UnitTests.cs index 76b2080d0..39257d54b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1651UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/DocumentationRules/SA1651UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.DocumentationRules { @@ -8,7 +10,6 @@ namespace StyleCop.Analyzers.Test.DocumentationRules using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.DocumentationRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -247,9 +248,6 @@ public class TestClass await VerifyCSharpFixAsync(testCode, expected, testCode, CancellationToken.None).ConfigureAwait(false); } - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult expected, CancellationToken cancellationToken) - => VerifyCSharpDiagnosticAsync(source, new[] { expected }, cancellationToken); - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) { var test = CreateTest(expected); @@ -267,14 +265,6 @@ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expec test.TestCode = source; test.FixedCode = fixedSource; - if (source == fixedSource) - { - test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll; - test.FixedState.MarkupHandling = MarkupMode.Allow; - test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll; - test.BatchFixedState.MarkupHandling = MarkupMode.Allow; - } - return test.RunAsync(cancellationToken); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ExclusionTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ExclusionTests.cs index b1df4d10b..3193aba4d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ExclusionTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ExclusionTests.cs @@ -1,11 +1,14 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test { using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier; @@ -82,7 +85,7 @@ public async Task TestIsNotExcludedAsync(string filename, string testCode) { var result = Diagnostic().WithLocation(filename, 1, 1); - await new CSharpTest + var test = new CSharpTest { TestSources = { @@ -92,7 +95,10 @@ public async Task TestIsNotExcludedAsync(string filename, string testCode) { result, }, - }.RunAsync(CancellationToken.None).ConfigureAwait(false); + }; + + test.TestBehaviors |= TestBehaviors.SkipSuppressionCheck; + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ExportCodeFixProviderAttributeNameTest.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ExportCodeFixProviderAttributeNameTest.cs index b8fb0d84b..048ba6e68 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ExportCodeFixProviderAttributeNameTest.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ExportCodeFixProviderAttributeNameTest.cs @@ -1,5 +1,5 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/AccessLevelHelperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/AccessLevelHelperTests.cs index 03d6cf289..5c3ef3598 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/AccessLevelHelperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/AccessLevelHelperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.HelperTests { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/IndentationHelperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/IndentationHelperTests.cs index e95e1ceaa..3a46f34f5 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/IndentationHelperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/IndentationHelperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.HelperTests { @@ -9,12 +11,9 @@ namespace StyleCop.Analyzers.Test.HelperTests using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Formatting; - using Microsoft.CodeAnalysis.Testing; - using Microsoft.CodeAnalysis.Testing.Verifiers; using Microsoft.CodeAnalysis.Text; using StyleCop.Analyzers.Helpers; using StyleCop.Analyzers.Settings.ObjectModel; - using StyleCop.Analyzers.Test.Helpers; using StyleCop.Analyzers.Test.Verifiers; using Xunit; @@ -114,10 +113,10 @@ public class IndentationHelperTests public async Task VerifyGetIndentationStepsAsync(string indentationString, int expectedIndentationSteps, int indentationSize, int tabSize) { var testSource = $"{indentationString}public class TestClass {{}}"; - var document = CreateTestDocument(testSource, indentationSize, false, tabSize); - StyleCopSettings settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, CancellationToken.None); + var document = await CreateTestDocumentAsync(testSource, indentationSize, false, tabSize, CancellationToken.None).ConfigureAwait(false); + var syntaxRoot = await document.GetSyntaxRootAsync(CancellationToken.None).ConfigureAwait(false); + StyleCopSettings settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, CancellationToken.None); - var syntaxRoot = await document.GetSyntaxRootAsync().ConfigureAwait(false); var firstToken = syntaxRoot.GetFirstToken(); Assert.Equal(expectedIndentationSteps, IndentationHelper.GetIndentationSteps(settings.Indentation, firstToken)); @@ -132,16 +131,16 @@ public async Task VerifyGetIndentationStepsAsync(string indentationString, int e public async Task VerifyGetIndentationStepsForTokenNotAtStartOfLineAsync() { var testSource = " public class TestClass {}"; - var document = CreateTestDocument(testSource); - StyleCopSettings settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, CancellationToken.None); + var document = await CreateTestDocumentAsync(testSource, cancellationToken: CancellationToken.None).ConfigureAwait(false); + var syntaxRoot = await document.GetSyntaxRootAsync(CancellationToken.None).ConfigureAwait(false); + StyleCopSettings settings = SettingsHelper.GetStyleCopSettings(document.Project.AnalyzerOptions, syntaxRoot.SyntaxTree, CancellationToken.None); - var syntaxRoot = await document.GetSyntaxRootAsync().ConfigureAwait(false); var secondToken = syntaxRoot.GetFirstToken().GetNextToken(); Assert.Equal(0, IndentationHelper.GetIndentationSteps(settings.Indentation, secondToken)); } - private static Document CreateTestDocument(string source, int indentationSize = 4, bool useTabs = false, int tabSize = 4) + private static async Task CreateTestDocumentAsync(string source, int indentationSize = 4, bool useTabs = false, int tabSize = 4, CancellationToken cancellationToken = default) { var workspace = GenericAnalyzerTest.CreateWorkspace(); workspace.Options = workspace.Options @@ -152,15 +151,12 @@ private static Document CreateTestDocument(string source, int indentationSize = var projectId = ProjectId.CreateNewId(); var documentId = DocumentId.CreateNewId(projectId); var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true); + var references = await GenericAnalyzerTest.ReferenceAssemblies.ResolveAsync(LanguageNames.CSharp, cancellationToken).ConfigureAwait(false); var solution = workspace.CurrentSolution .AddProject(projectId, TestProjectName, TestProjectName, LanguageNames.CSharp) .WithProjectCompilationOptions(projectId, compilationOptions) - .AddMetadataReference(projectId, MetadataReferences.CorlibReference) - .AddMetadataReference(projectId, MetadataReferences.SystemReference) - .AddMetadataReference(projectId, MetadataReferences.SystemCoreReference) - .AddMetadataReference(projectId, GenericAnalyzerTest.CSharpSymbolsReference) - .AddMetadataReference(projectId, MetadataReferences.CodeAnalysisReference) + .AddMetadataReferences(projectId, references) .AddDocument(documentId, TestFilename, SourceText.From(source)); StyleCopSettings defaultSettings = new StyleCopSettings(); @@ -179,7 +175,7 @@ private static Document CreateTestDocument(string source, int indentationSize = }} }} "; - var settingsDocumentId = DocumentId.CreateNewId(projectId); + solution = solution.AddAdditionalDocument(documentId, SettingsHelper.SettingsFileName, settings); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/ObjectPools/ObjectPoolTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/ObjectPools/ObjectPoolTests.cs index 23b5f6fc5..a8ead35f0 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/ObjectPools/ObjectPoolTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/ObjectPools/ObjectPoolTests.cs @@ -1,9 +1,10 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.HelperTests.ObjectPools { - using System; using StyleCop.Analyzers.Helpers.ObjectPools; using Xunit; @@ -13,16 +14,16 @@ public class ObjectPoolTests [Fact] public void TestDefaultConstructor() { - Func factory = () => new object(); - var pool = new ObjectPool(factory); + object Factory() => new object(); + var pool = new ObjectPool(Factory); Assert.IsType(pool.Allocate()); } [Fact] public void TestAllocateFree() { - Func factory = () => new object(); - var pool = new ObjectPool(factory); + object Factory() => new object(); + var pool = new ObjectPool(Factory); // Covers the case where no item is in the pool Assert.IsType(pool.Allocate()); @@ -52,8 +53,8 @@ public void TestAllocateFree() [Fact] public void TestObjectCanBeDropped() { - Func factory = () => new object(); - var pool = new ObjectPool(factory, 1); + object Factory() => new object(); + var pool = new ObjectPool(Factory, 1); var obj = new object(); pool.Free(obj); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/ObjectPools/SharedPoolsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/ObjectPools/SharedPoolsTests.cs index 9f2dfab7b..415c8ef07 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/ObjectPools/SharedPoolsTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/ObjectPools/SharedPoolsTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.HelperTests.ObjectPools { @@ -211,12 +213,31 @@ public void TestClearAndFreeLarge() [Fact] public void TestPooledObjectHandlesNullAllocation() { - Func, object> allocator = pool => null; - Action, object> releaser = (pool, obj) => { }; - using (var obj = new PooledObject(SharedPools.Default(), allocator, releaser)) + object NullAllocator(ObjectPool pool) + => null; + + object NonNullAllocator(ObjectPool pool) + => new object(); + + bool releaserCalled = false; + void Releaser(ObjectPool pool, object obj) + { + releaserCalled = true; + } + + using (var obj = new PooledObject(SharedPools.Default(), NullAllocator, Releaser)) { Assert.Null(obj.Object); } + + Assert.False(releaserCalled); + + using (var obj = new PooledObject(SharedPools.Default(), NonNullAllocator, Releaser)) + { + Assert.NotNull(obj.Object); + } + + Assert.True(releaserCalled); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/RequiresTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/RequiresTests.cs index 1d3b42f21..630d29883 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/RequiresTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/RequiresTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.HelperTests { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/SymbolNameHelpersUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/SymbolNameHelpersUnitTests.cs new file mode 100644 index 000000000..c7d8da7e5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/SymbolNameHelpersUnitTests.cs @@ -0,0 +1,125 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.HelperTests +{ + using System.Linq; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using Microsoft.CodeAnalysis.Text; + using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Test.Verifiers; + using Xunit; + + /// + /// Unit tests for the class. + /// + public class SymbolNameHelpersUnitTests : IAsyncLifetime + { + private const string TestProjectName = "TestProject"; + private const string TestFilename = "Test.cs"; + + private Solution testSolution; + + public async Task InitializeAsync() + { + var compilationOptions = this.GetCompilationOptions(); + this.testSolution = await CreateTestSolutionAsync(compilationOptions).ConfigureAwait(false); + } + + public Task DisposeAsync() + { + return Task.FromResult(true); + } + + /// + /// Verify the workings of + /// for standard use cases. + /// + /// A string representation of a type or namespace to process. + /// if is a namespace; + /// if is a type to be used as an alias target. + /// A representing the asynchronous unit test. + [Theory] + [InlineData("System.ValueTuple")] + [InlineData("System.ValueTuple")] + [InlineData("System.ValueTuple")] + [InlineData("System.ValueTuple")] + [InlineData("System.ValueTuple")] + [InlineData("System.ValueTuple")] + [InlineData("System.ValueTuple")] + [InlineData("System.Collections.Generic.KeyValuePair")] + [InlineData("System.Collections.Generic.KeyValuePair")] + [InlineData("System.Collections.Generic.KeyValuePair")] + [InlineData("System.Nullable")] + [InlineData("System", true)] + [InlineData("System.Collections.Generic", true)] + [WorkItem(3149, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3149")] + public Task VerifyToQualifiedStringAsync(string inputString, bool isNamespace = false) + { + return this.PerformTestAsync(inputString, isNamespace); + } + + /// + /// Performs the actual testing work. + /// + /// A string representation of a type or namespace to process. + /// if is a namespace; + /// if is a type to be used as an alias target. + /// A representing the asynchronous unit test. + protected async Task PerformTestAsync(string inputString, bool isNamespace) + { + var fileContent = isNamespace ? "using " + inputString : "using AliasType = " + inputString; + fileContent += ";"; + + var document = GetDocument(this.testSolution, fileContent); + var syntaxRoot = await document.GetSyntaxRootAsync().ConfigureAwait(false); + var semanticModel = await document.GetSemanticModelAsync().ConfigureAwait(false); + + var usingDirectiveSyntax = syntaxRoot.DescendantNodes().OfType().First(); + var typeSymbol = semanticModel.GetSymbolInfo(usingDirectiveSyntax.Name).Symbol; + + var resultString = typeSymbol.ToQualifiedString(usingDirectiveSyntax.Name); + Assert.Equal(inputString, resultString); + } + + /// + /// When overridden in derived classes, provides a instance + /// to be used for the test project in the workspace. + /// + /// An instance of describing the project compilation options. + protected virtual CSharpCompilationOptions GetCompilationOptions() + { + return new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary); + } + + private static Document GetDocument(Solution solution, string sourceCode) + { + var projectId = solution.ProjectIds[0]; + var documentId = DocumentId.CreateNewId(projectId); + solution = solution.AddDocument(documentId, TestFilename, SourceText.From(sourceCode)); + return solution.GetDocument(documentId); + } + + private static async Task CreateTestSolutionAsync(CSharpCompilationOptions compilationOptions) + { + var workspace = GenericAnalyzerTest.CreateWorkspace(); + var projectId = ProjectId.CreateNewId(); + + var references = await GenericAnalyzerTest.ReferenceAssemblies + .ResolveAsync(LanguageNames.CSharp, CancellationToken.None).ConfigureAwait(false); + + var solution = workspace.CurrentSolution + .AddProject(projectId, TestProjectName, TestProjectName, LanguageNames.CSharp) + .WithProjectCompilationOptions(projectId, compilationOptions) + .AddMetadataReferences(projectId, references); + + return solution; + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/TokenHelperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/TokenHelperTests.cs index 7216ebdb1..3d0ea7f2c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/TokenHelperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/TokenHelperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.HelperTests { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/TriviaHelperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/TriviaHelperTests.cs index acd806fc0..7a26a42ab 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/TriviaHelperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/TriviaHelperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.HelperTests { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/XmlSyntaxFactoryTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/XmlSyntaxFactoryTests.cs index 73eda3fb0..a4db59f2a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/XmlSyntaxFactoryTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/HelperTests/XmlSyntaxFactoryTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.HelperTests { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/CommonMemberData.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/CommonMemberData.cs new file mode 100644 index 000000000..3920ac2f4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/CommonMemberData.cs @@ -0,0 +1,118 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.Helpers +{ + using System.Collections.Generic; + using System.Linq; + using StyleCop.Analyzers.Lightup; + + public static class CommonMemberData + { + public static IEnumerable DataTypeDeclarationKeywords + { + get + { + yield return new[] { "class" }; + yield return new[] { "struct" }; + + if (LightupHelpers.SupportsCSharp9) + { + yield return new[] { "record" }; + } + + if (LightupHelpers.SupportsCSharp10) + { + yield return new[] { "record class" }; + yield return new[] { "record struct" }; + } + } + } + + public static IEnumerable ReferenceTypeDeclarationKeywords + { + get + { + yield return new[] { "class" }; + + if (LightupHelpers.SupportsCSharp9) + { + yield return new[] { "record" }; + } + + if (LightupHelpers.SupportsCSharp10) + { + yield return new[] { "record class" }; + } + } + } + + public static IEnumerable ValueTypeDeclarationKeywords + { + get + { + yield return new[] { "struct" }; + + if (LightupHelpers.SupportsCSharp10) + { + yield return new[] { "record struct" }; + } + } + } + + public static IEnumerable RecordTypeDeclarationKeywords + { + get + { + if (LightupHelpers.SupportsCSharp9) + { + yield return new[] { "record" }; + } + + if (LightupHelpers.SupportsCSharp10) + { + yield return new[] { "record class" }; + yield return new[] { "record struct" }; + } + } + } + + public static IEnumerable TypeDeclarationKeywords + { + get + { + return DataTypeDeclarationKeywords + .Concat(new[] { new[] { "interface" } }); + } + } + + public static IEnumerable BaseTypeDeclarationKeywords + { + get + { + return TypeDeclarationKeywords + .Concat(new[] { new[] { "enum" } }); + } + } + + public static IEnumerable AllTypeDeclarationKeywords + { + get + { + return BaseTypeDeclarationKeywords + .Concat(new[] { new[] { "delegate" } }); + } + } + + public static IEnumerable GenericTypeDeclarationKeywords + { + get + { + return TypeDeclarationKeywords + .Concat(new[] { new[] { "delegate" } }); + } + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/ExclusionTestAnalyzer.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/ExclusionTestAnalyzer.cs index a3dba3be8..eb5f7957c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/ExclusionTestAnalyzer.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/ExclusionTestAnalyzer.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace TestHelper { @@ -20,7 +22,7 @@ internal class ExclusionTestAnalyzer : DiagnosticAnalyzer internal const string DiagnosticId = "SA9999"; private const string Title = "Exclusion test"; private const string MessageFormat = "Exclusion test"; - private const string Description = "Exclusion test"; + private const string Description = "Exclusion test."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA9999.md"; private static readonly DiagnosticDescriptor Descriptor = diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/JsonTestHelper.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/JsonTestHelper.cs new file mode 100644 index 000000000..f7e05dd93 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/JsonTestHelper.cs @@ -0,0 +1,40 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.Helpers +{ + using System; + using global::LightJson; + + internal class JsonTestHelper + { + public static JsonObject MergeJsonObjects(JsonObject priority, JsonObject fallback) + { + foreach (var pair in priority) + { + if (pair.Value.IsJsonObject) + { + switch (fallback[pair.Key].Type) + { + case JsonValueType.Null: + fallback[pair.Key] = pair.Value; + break; + + case JsonValueType.Object: + fallback[pair.Key] = MergeJsonObjects(pair.Value.AsJsonObject, fallback[pair.Key].AsJsonObject); + break; + + default: + throw new InvalidOperationException($"Cannot merge objects of type '{pair.Value.Type}' and '{fallback[pair.Key].Type}'."); + } + } + else + { + fallback[pair.Key] = pair.Value; + } + } + + return fallback; + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/LanguageVersionTestExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/LanguageVersionTestExtensions.cs new file mode 100644 index 000000000..4a146ba7d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/LanguageVersionTestExtensions.cs @@ -0,0 +1,27 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.Helpers +{ + using System; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + + internal static class LanguageVersionTestExtensions + { + public static LanguageVersion? OrLaterDefault(this LanguageVersion input) + { + // Use the default version instead, if that would be a later version than the one specified + switch (input) + { + case LanguageVersionEx.CSharp7_1: + case LanguageVersionEx.CSharp7_2: + case LanguageVersionEx.CSharp7_3: + return LightupHelpers.SupportsCSharp8 ? null : input; + + default: + throw new ArgumentException($"Unexpected value {input}", nameof(input)); + } + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/StringExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/StringExtensions.cs new file mode 100644 index 000000000..4c9404e6a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/StringExtensions.cs @@ -0,0 +1,23 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.Helpers +{ + public static class StringExtensions + { + public static string ReplaceLineEndings(this string input, string replacementText) + { + // First normalize to LF + var lineFeedInput = input + .Replace("\r\n", "\n") + .Replace("\r", "\n") + .Replace("\f", "\n") + .Replace("\x0085", "\n") + .Replace("\x2028", "\n") + .Replace("\x2029", "\n"); + + // Then normalize to the replacement text + return lineFeedInput.Replace("\n", replacementText); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/TestDiagnosticProvider.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/TestDiagnosticProvider.cs deleted file mode 100644 index df3a1c849..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/TestDiagnosticProvider.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. - -namespace StyleCop.Analyzers.Test.Helpers -{ - using System.Collections.Generic; - using System.Collections.Immutable; - using System.Linq; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.CodeAnalysis; - using Microsoft.CodeAnalysis.CodeFixes; - - internal sealed class TestDiagnosticProvider : FixAllContext.DiagnosticProvider - { - private ImmutableArray diagnostics; - - private TestDiagnosticProvider(ImmutableArray diagnostics) - { - this.diagnostics = diagnostics; - } - - public override Task> GetAllDiagnosticsAsync(Project project, CancellationToken cancellationToken) - { - return Task.FromResult>(this.diagnostics); - } - - public override Task> GetDocumentDiagnosticsAsync(Document document, CancellationToken cancellationToken) - { - return Task.FromResult(this.diagnostics.Where(i => i.Location.GetLineSpan().Path == document.Name)); - } - - public override Task> GetProjectDiagnosticsAsync(Project project, CancellationToken cancellationToken) - { - return Task.FromResult(this.diagnostics.Where(i => !i.Location.IsInSource)); - } - - internal static TestDiagnosticProvider Create(ImmutableArray diagnostics) - { - return new TestDiagnosticProvider(diagnostics); - } - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/TestXmlReferenceResolver.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/TestXmlReferenceResolver.cs deleted file mode 100644 index db94515ec..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/TestXmlReferenceResolver.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. - -namespace StyleCop.Analyzers.Test.Helpers -{ - using System.Collections.Generic; - using System.IO; - using System.Runtime.CompilerServices; - using System.Text; - using Microsoft.CodeAnalysis; - - internal class TestXmlReferenceResolver : XmlReferenceResolver - { - public Dictionary XmlReferences { get; } = - new Dictionary(); - - public override bool Equals(object other) - { - return ReferenceEquals(this, other); - } - - public override int GetHashCode() - { - return RuntimeHelpers.GetHashCode(this); - } - - public override Stream OpenRead(string resolvedPath) - { - string content; - if (!this.XmlReferences.TryGetValue(resolvedPath, out content)) - { - return null; - } - - return new MemoryStream(Encoding.UTF8.GetBytes(content)); - } - - public override string ResolveReference(string path, string baseFilePath) - { - return path; - } - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/UseCultureAttribute.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/UseCultureAttribute.cs index 86402d8aa..3ab946164 100755 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/UseCultureAttribute.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Helpers/UseCultureAttribute.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Helpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.ArrayInitializers.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.ArrayInitializers.cs index 0cd708f69..0175ca87e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.ArrayInitializers.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.ArrayInitializers.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Blocks.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Blocks.cs index 9c03f2ab8..9b3c7a79a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Blocks.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Blocks.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Classes.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Classes.cs deleted file mode 100644 index cf2b2f511..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Classes.cs +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. - -namespace StyleCop.Analyzers.Test.LayoutRules -{ - using System.Threading; - using System.Threading.Tasks; - using Microsoft.CodeAnalysis.Testing; - using StyleCop.Analyzers.LayoutRules; - using TestHelper; - using Xunit; - using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< - StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, - StyleCop.Analyzers.LayoutRules.SA1500CodeFixProvider>; - - /// - /// Unit tests for . - /// - public partial class SA1500UnitTests - { - /// - /// Verifies that no diagnostics are reported for the valid classes defined in this test. - /// - /// - /// These are valid for SA1500 only, some will report other diagnostics from the layout (SA15xx) - /// series. - /// - /// A representing the asynchronous unit test. - [Fact] - public async Task TestClassValidAsync() - { - var testCode = @"public class Foo -{ - public class ValidClass1 - { - } - - public class ValidClass2 - { - public int Field; - } - - public class ValidClass3 { } /* Valid only for SA1500 */ - - public class ValidClass4 { public int Field; } /* Valid only for SA1500 */ - - public class ValidClass5 - { public int Field; } /* Valid only for SA1500 */ -}"; - - await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); - } - - /// - /// Verifies diagnostics and codefixes for all invalid class definitions. - /// - /// - /// These will normally also report SA1401, but not in the unit test. - /// - /// A representing the asynchronous unit test. - [Fact] - public async Task TestClassInvalidAsync() - { - var testCode = @"public class Foo -{ - public class InvalidClass1 { - } - - public class InvalidClass2 { - public int Field; - } - - public class InvalidClass3 { - public int Field; } - - public class InvalidClass4 { public int Field; - } - - public class InvalidClass5 - { - public int Field; } - - public class InvalidClass6 - { public int Field; - } -}"; - - var fixedTestCode = @"public class Foo -{ - public class InvalidClass1 - { - } - - public class InvalidClass2 - { - public int Field; - } - - public class InvalidClass3 - { - public int Field; - } - - public class InvalidClass4 - { - public int Field; - } - - public class InvalidClass5 - { - public int Field; - } - - public class InvalidClass6 - { - public int Field; - } -}"; - - DiagnosticResult[] expectedDiagnostics = - { - // InvalidClass1 - Diagnostic().WithLocation(3, 32), - - // InvalidClass2 - Diagnostic().WithLocation(6, 32), - - // InvalidClass3 - Diagnostic().WithLocation(10, 32), - Diagnostic().WithLocation(11, 27), - - // InvalidClass4 - Diagnostic().WithLocation(13, 32), - - // InvalidClass5 - Diagnostic().WithLocation(18, 27), - - // InvalidClass6 - Diagnostic().WithLocation(21, 5), - }; - - await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedTestCode, CancellationToken.None).ConfigureAwait(false); - } - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Constructors.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Constructors.cs index 400d106db..8099f7058 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Constructors.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Constructors.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.DataTypes.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.DataTypes.cs new file mode 100644 index 000000000..3764cde47 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.DataTypes.cs @@ -0,0 +1,150 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.LayoutRules +{ + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.LayoutRules; + using StyleCop.Analyzers.Test.Helpers; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, + StyleCop.Analyzers.LayoutRules.SA1500CodeFixProvider>; + + /// + /// Unit tests for . + /// + public partial class SA1500UnitTests + { + /// + /// Verifies that no diagnostics are reported for the valid data types defined in this test. + /// + /// + /// These are valid for SA1500 only, some will report other diagnostics. + /// + /// The data type keyword. + /// A representing the asynchronous unit test. + [Theory] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task TestDataTypeValidAsync(string keyword) + { + var testCode = $@"public class Foo +{{ + public {keyword} ValidStruct1 + {{ + }} + + public {keyword} ValidStruct2 + {{ + public int Field; + }} + + public {keyword} ValidStruct3 {{ }} /* Valid only for SA1500 */ + + public {keyword} ValidStruct4 {{ public int Field; }} /* Valid only for SA1500 */ + + public {keyword} ValidStruct5 /* Valid only for SA1500 */ + {{ public int Field; }} +}}"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that diagnostics will be reported for all invalid data type definitions. + /// + /// + /// These will normally also report SA1401, but not in the unit test. + /// + /// The data type keyword. + /// A representing the asynchronous unit test. + [Theory] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task TestDataTypeInvalidAsync(string keyword) + { + var testCode = $@"public class Foo +{{ + public {keyword} InvalidStruct1 {{|#0:{{|}} + }} + + public {keyword} InvalidStruct2 {{|#1:{{|}} + public int Field; + }} + + public {keyword} InvalidStruct3 {{|#2:{{|}} + public int Field; {{|#3:}}|}} + + public {keyword} InvalidStruct4 {{|#4:{{|}} public int Field; + }} + + public {keyword} InvalidStruct5 + {{ + public int Field; {{|#5:}}|}} + + public {keyword} InvalidStruct6 + {{|#6:{{|}} public int Field; + }} +}}"; + + var fixedTestCode = $@"public class Foo +{{ + public {keyword} InvalidStruct1 + {{ + }} + + public {keyword} InvalidStruct2 + {{ + public int Field; + }} + + public {keyword} InvalidStruct3 + {{ + public int Field; + }} + + public {keyword} InvalidStruct4 + {{ + public int Field; + }} + + public {keyword} InvalidStruct5 + {{ + public int Field; + }} + + public {keyword} InvalidStruct6 + {{ + public int Field; + }} +}}"; + + DiagnosticResult[] expectedDiagnostics = + { + // InvalidStruct1 + Diagnostic().WithLocation(0), + + // InvalidStruct2 + Diagnostic().WithLocation(1), + + // InvalidStruct3 + Diagnostic().WithLocation(2), + Diagnostic().WithLocation(3), + + // InvalidStruct4 + Diagnostic().WithLocation(4), + + // InvalidStruct5 + Diagnostic().WithLocation(5), + + // InvalidStruct6 + Diagnostic().WithLocation(6), + }; + + await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Delegates.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Delegates.cs index 648f72530..11651bd09 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Delegates.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Delegates.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Destructors.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Destructors.cs index 4b92ef08c..15a0467a3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Destructors.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Destructors.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.DoWhiles.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.DoWhiles.cs index a6b6aa2e7..b19594a52 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.DoWhiles.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.DoWhiles.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, @@ -305,5 +306,164 @@ private void Bar() await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } + + /// + /// Verifies that no diagnostics are reported for the do/while loop when the + /// expression is on the same line as the closing brace and the setting is enabled. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task TestDoWhileOnClosingBraceWithAllowSettingAsync() + { + var testSettings = @" +{ + ""settings"": { + ""layoutRules"": { + ""allowDoWhileOnClosingBrace"": true + } + } +}"; + + var testCode = @"public class Foo +{ + private void Bar() + { + var x = 0; + + do + { + x = 1; + } while (x == 0); + } +}"; + + var test = new CSharpTest + { + TestCode = testCode, + Settings = testSettings, + }; + + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that diagnostics will be reported for the invalid loop that + /// is on the same line as the closing brace which is not part of a do/while loop. This + /// ensures that the allowDoWhileOnClosingBrace setting is only applicable to a do/while + /// loop and will not mistakenly allow a plain loop after any arbitrary + /// closing brace. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task TestJustWhileLoopOnClosingBraceWithAllowDoWhileOnClosingBraceSettingAsync() + { + var testSettings = @" +{ + ""settings"": { + ""layoutRules"": { + ""allowDoWhileOnClosingBrace"": true + } + } +}"; + + var testCode = @"public class Foo +{ + private void Bar() + { + var x = 0; + + while (x == 0) + { + x = 1; + [|}|] while (x == 0) + { + x = 1; + } + } +}"; + + var fixedCode = @"public class Foo +{ + private void Bar() + { + var x = 0; + + while (x == 0) + { + x = 1; + } + while (x == 0) + { + x = 1; + } + } +}"; + + var test = new CSharpTest + { + TestCode = testCode, + FixedCode = fixedCode, + Settings = testSettings, + }; + + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that no diagnostics are reported for the do/while loop when the + /// expression is on the same line as the closing brace and the setting is allowed. + /// + /// + /// The "Invalid do ... while #6" code in the unit test + /// should account for the proper fix when the allowDoWhileOnClosingBrace is , + /// which is the default. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task TestFixDoWhileOnClosingBraceWithAllowSettingAsync() + { + var testSettings = @" +{ + ""settings"": { + ""layoutRules"": { + ""allowDoWhileOnClosingBrace"": true + } + } +}"; + + var testCode = @"public class Foo +{ + private void Bar() + { + var x = 0; + + do + { + x = 1; [|}|] while (x == 0); + } +}"; + + var fixedTestCode = @"public class Foo +{ + private void Bar() + { + var x = 0; + + do + { + x = 1; + } while (x == 0); + } +}"; + + var test = new CSharpTest + { + TestCode = testCode, + FixedCode = fixedTestCode, + Settings = testSettings, + }; + + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Enums.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Enums.cs index ff4855f2f..032d2a27e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Enums.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Enums.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Events.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Events.cs index 81e2e23fd..59d79f877 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Events.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Events.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Ifs.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Ifs.cs index 5769b9629..63a6c047f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Ifs.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Ifs.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Indexers.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Indexers.cs index febe041fc..d63d0e9bd 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Indexers.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Indexers.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Interfaces.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Interfaces.cs index f10559b62..f701c3ac9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Interfaces.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Interfaces.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.LambdaExpressions.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.LambdaExpressions.cs index ba2ecb400..3bf603a17 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.LambdaExpressions.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.LambdaExpressions.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Methods.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Methods.cs index 5e8e044c5..b72bf8a94 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Methods.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Methods.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Namespaces.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Namespaces.cs index 6f7c88e43..27891022d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Namespaces.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Namespaces.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.ObjectInitializers.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.ObjectInitializers.cs index 1caf07668..f23769add 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.ObjectInitializers.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.ObjectInitializers.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Properties.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Properties.cs index 446b746b4..018d5f681 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Properties.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Properties.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -8,7 +10,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; using StyleCop.Analyzers.Lightup; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.StatementBlocks.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.StatementBlocks.cs index e662d0b91..502750f62 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.StatementBlocks.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.StatementBlocks.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -8,7 +10,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Structs.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Structs.cs deleted file mode 100644 index bbf2db0c7..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Structs.cs +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. - -namespace StyleCop.Analyzers.Test.LayoutRules -{ - using System.Threading; - using System.Threading.Tasks; - using Microsoft.CodeAnalysis.Testing; - using StyleCop.Analyzers.LayoutRules; - using TestHelper; - using Xunit; - using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< - StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, - StyleCop.Analyzers.LayoutRules.SA1500CodeFixProvider>; - - /// - /// Unit tests for . - /// - public partial class SA1500UnitTests - { - /// - /// Verifies that no diagnostics are reported for the valid structs defined in this test. - /// - /// - /// These are valid for SA1500 only, some will report other diagnostics. - /// - /// A representing the asynchronous unit test. - [Fact] - public async Task TestStructValidAsync() - { - var testCode = @"public class Foo -{ - public struct ValidStruct1 - { - } - - public struct ValidStruct2 - { - public int Field; - } - - public struct ValidStruct3 { } /* Valid only for SA1500 */ - - public struct ValidStruct4 { public int Field; } /* Valid only for SA1500 */ - - public struct ValidStruct5 /* Valid only for SA1500 */ - { public int Field; } -}"; - - await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); - } - - /// - /// Verifies that diagnostics will be reported for all invalid struct definitions. - /// - /// - /// These will normally also report SA1401, but not in the unit test. - /// - /// A representing the asynchronous unit test. - [Fact] - public async Task TestStructInvalidAsync() - { - var testCode = @"public class Foo -{ - public struct InvalidStruct1 { - } - - public struct InvalidStruct2 { - public int Field; - } - - public struct InvalidStruct3 { - public int Field; } - - public struct InvalidStruct4 { public int Field; - } - - public struct InvalidStruct5 - { - public int Field; } - - public struct InvalidStruct6 - { public int Field; - } -}"; - - var fixedTestCode = @"public class Foo -{ - public struct InvalidStruct1 - { - } - - public struct InvalidStruct2 - { - public int Field; - } - - public struct InvalidStruct3 - { - public int Field; - } - - public struct InvalidStruct4 - { - public int Field; - } - - public struct InvalidStruct5 - { - public int Field; - } - - public struct InvalidStruct6 - { - public int Field; - } -}"; - - DiagnosticResult[] expectedDiagnostics = - { - // InvalidStruct1 - Diagnostic().WithLocation(3, 34), - - // InvalidStruct2 - Diagnostic().WithLocation(6, 34), - - // InvalidStruct3 - Diagnostic().WithLocation(10, 34), - Diagnostic().WithLocation(11, 27), - - // InvalidStruct4 - Diagnostic().WithLocation(13, 34), - - // InvalidStruct5 - Diagnostic().WithLocation(18, 27), - - // InvalidStruct6 - Diagnostic().WithLocation(21, 5), - }; - - await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedTestCode, CancellationToken.None).ConfigureAwait(false); - } - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Switches.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Switches.cs index 039917a55..707ccc881 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Switches.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.Switches.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.TryCatchFinallys.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.TryCatchFinallys.cs index 70711118f..d9e77cb0c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.TryCatchFinallys.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.TryCatchFinallys.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.cs index 657b9b4e1..0493ab764 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1500/SA1500UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1500BracesForMultiLineStatementsMustNotShareLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1501UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1501UnitTests.cs index 60fbe442a..9a543e266 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1501UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1501UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -9,7 +11,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1501StatementMustNotBeOnASingleLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Constructors.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Constructors.cs index cc04c4436..d47a40cd0 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Constructors.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Constructors.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,6 +9,7 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; + using StyleCop.Analyzers.Test.Helpers; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1502ElementMustNotBeOnASingleLine, @@ -23,8 +26,7 @@ public partial class SA1502UnitTests /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestValidEmptyConstructorAsync(string elementType) { var testCode = @"public ##PH## Foo @@ -43,8 +45,7 @@ public Foo(int parameter) /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestEmptyConstructorOnSingleLineAsync(string elementType) { var testCode = @"public ##PH## Foo @@ -62,8 +63,7 @@ public Foo(int parameter) { } /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestConstructorOnSingleLineAsync(string elementType) { var testCode = @"public ##PH## Foo @@ -81,8 +81,7 @@ public async Task TestConstructorOnSingleLineAsync(string elementType) /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestConstructorWithBlockOnSingleLineAsync(string elementType) { var testCode = @"public ##PH## Foo @@ -101,8 +100,7 @@ public Foo(int parameter) /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestConstructorWithBlockStartOnSameLineAsync(string elementType) { var testCode = @"public ##PH## Foo @@ -120,8 +118,7 @@ public Foo(int parameter) { /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestEmptyConstructorOnSingleLineCodeFixAsync(string elementType) { var testCode = @"public ##PH## Foo @@ -145,8 +142,7 @@ public Foo(int parameter) /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestConstructorOnSingleLineCodeFixAsync(string elementType) { var testCode = @"public ##PH## Foo @@ -171,8 +167,7 @@ public Foo(int parameter) /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestConstructorWithBlockOnSingleLineCodeFixAsync(string elementType) { var testCode = @"public ##PH## Foo @@ -198,8 +193,7 @@ public Foo(int parameter) /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestConstructorWithLotsOfTriviaCodeFixAsync(string elementType) { var testCode = @"public ##PH## Foo diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Destructors.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Destructors.cs index 22b3017ca..79ab016eb 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Destructors.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Destructors.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Enums.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Enums.cs index a719e3260..32af3fac1 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Enums.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Enums.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Events.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Events.cs index 692fb3d1d..f3a4de2d7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Events.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Events.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Indexers.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Indexers.cs index 71bb57d6e..c6d65643a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Indexers.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Indexers.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Interfaces.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Interfaces.cs index 939bb512f..e5ce4a67c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Interfaces.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Interfaces.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Methods.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Methods.cs index 64cddd6a2..90ed295e7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Methods.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Methods.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,6 +9,7 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; + using StyleCop.Analyzers.Test.Helpers; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1502ElementMustNotBeOnASingleLine, @@ -23,8 +26,7 @@ public partial class SA1502UnitTests /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestValidEmptyMethodAsync(string elementType) { var testCode = @"public ##PH## Foo @@ -43,8 +45,7 @@ public void Bar() /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestEmptyMethodOnSingleLineAsync(string elementType) { var testCode = @"public ##PH## Foo @@ -62,8 +63,7 @@ public void Bar() { } /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestMethodOnSingleLineAsync(string elementType) { var testCode = @"public ##PH## Foo @@ -81,8 +81,7 @@ public async Task TestMethodOnSingleLineAsync(string elementType) /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestMethodWithBlockOnSingleLineAsync(string elementType) { var testCode = @"public ##PH## Foo @@ -101,8 +100,7 @@ public bool Bar() /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestMethodWithBlockStartOnSameLineAsync(string elementType) { var testCode = @"public ##PH## Foo @@ -120,8 +118,7 @@ public bool Bar() { /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestMethodWithExpressionBodyAsync(string elementType) { var testCode = @"public ##PH## Foo @@ -138,8 +135,7 @@ public async Task TestMethodWithExpressionBodyAsync(string elementType) /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestEmptyMethodOnSingleLineCodeFixAsync(string elementType) { var testCode = @"public ##PH## Foo @@ -163,8 +159,7 @@ public void Bar() /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestMethodOnSingleLineCodeFixAsync(string elementType) { var testCode = @"public ##PH## Foo @@ -189,8 +184,7 @@ public bool Bar() /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestMethodWithBlockOnSingleLineCodeFixAsync(string elementType) { var testCode = @"public ##PH## Foo @@ -216,8 +210,7 @@ public bool Bar() /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [InlineData("class")] - [InlineData("struct")] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestMethodWithLotsOfTriviaCodeFixAsync(string elementType) { var testCode = @"public ##PH## Foo diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Namespaces.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Namespaces.cs index 9d0fad65c..f00606cfa 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Namespaces.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Namespaces.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Operators.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Operators.cs index a95b9d8f3..d19e6934b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Operators.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Operators.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1502ElementMustNotBeOnASingleLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Properties.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Properties.cs index e9bcc9719..390bf549c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Properties.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.Properties.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.TypeDeclarations.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.TypeDeclarations.cs index 497f5615b..f88493012 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.TypeDeclarations.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.TypeDeclarations.cs @@ -1,13 +1,15 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { - using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; + using StyleCop.Analyzers.Test.Helpers; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1502ElementMustNotBeOnASingleLine, @@ -18,22 +20,13 @@ namespace StyleCop.Analyzers.Test.LayoutRules /// public partial class SA1502UnitTests { - public static IEnumerable TokensToTest - { - get - { - yield return new[] { "class" }; - yield return new[] { "struct" }; - } - } - /// /// Verifies that a correct empty type will pass without diagnostic. /// /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [MemberData(nameof(TokensToTest))] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestValidEmptyTypeAsync(string token) { var testCode = @"public ##PH## Foo @@ -49,7 +42,7 @@ public async Task TestValidEmptyTypeAsync(string token) /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [MemberData(nameof(TokensToTest))] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestEmptyTypeOnSingleLineAsync(string token) { var testCode = "public ##PH## Foo { }"; @@ -64,7 +57,7 @@ public async Task TestEmptyTypeOnSingleLineAsync(string token) /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [MemberData(nameof(TokensToTest))] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeOnSingleLineAsync(string token) { var testCode = "public ##PH## Foo { private int bar; }"; @@ -79,7 +72,7 @@ public async Task TestTypeOnSingleLineAsync(string token) /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [MemberData(nameof(TokensToTest))] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithBlockOnSingleLineAsync(string token) { var testCode = @"public ##PH## Foo @@ -95,7 +88,7 @@ public async Task TestTypeWithBlockOnSingleLineAsync(string token) /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [MemberData(nameof(TokensToTest))] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithBlockStartOnSameLineAsync(string token) { var testCode = @"public ##PH## Foo { @@ -111,7 +104,7 @@ public async Task TestTypeWithBlockStartOnSameLineAsync(string token) /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [MemberData(nameof(TokensToTest))] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestEmptyTypeOnSingleLineCodeFixAsync(string token) { var testCode = "public ##PH## Foo { }"; @@ -130,7 +123,7 @@ public async Task TestEmptyTypeOnSingleLineCodeFixAsync(string token) /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [MemberData(nameof(TokensToTest))] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeOnSingleLineCodeFixAsync(string token) { var testCode = "public ##PH## Foo { private int bar; }"; @@ -150,7 +143,7 @@ public async Task TestTypeOnSingleLineCodeFixAsync(string token) /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [MemberData(nameof(TokensToTest))] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeOnSingleLineWithMultipleStatementsCodeFixAsync(string token) { var testCode = "public ##PH## Foo { private int bar; private bool baz; }"; @@ -170,7 +163,7 @@ public async Task TestTypeOnSingleLineWithMultipleStatementsCodeFixAsync(string /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [MemberData(nameof(TokensToTest))] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithBlockOnSingleLineCodeFixAsync(string token) { var testCode = @"public ##PH## Foo @@ -191,7 +184,7 @@ public async Task TestTypeWithBlockOnSingleLineCodeFixAsync(string token) /// The type of element to test. /// A representing the asynchronous unit test. [Theory] - [MemberData(nameof(TokensToTest))] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeWithLotsOfTriviaCodeFixAsync(string token) { var testCode = @"public ##PH## Foo /* TR1 */ { /* TR2 */ private int bar; /* TR3 */ private int baz; /* TR4 */ } /* TR5 */"; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.cs index 7d77121c6..299482993 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1502/SA1502UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1503UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1503UnitTests.cs index 863bea3c9..8ade1f619 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1503UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1503UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -9,7 +11,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Text; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1503BracesMustNotBeOmitted, @@ -350,8 +351,15 @@ public void Bar(int i) } }"; - var expected = Diagnostic().WithLocation(8, 13); - await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + var test = new CSharpTest + { + TestCode = testCode, + ExpectedDiagnostics = { Diagnostic().WithLocation(8, 13) }, + FixedCode = fixedTestCode, + }; + + test.TestBehaviors |= TestBehaviors.SkipSuppressionCheck; + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); } /// @@ -537,7 +545,7 @@ public void Bar(int i) /// A representing the asynchronous unit test. [Theory] [MemberData(nameof(TestStatements))] - private async Task TestCodeFixForStatementAsync(string statementText) + public async Task TestCodeFixForStatementAsync(string statementText) { var expected = Diagnostic().WithLocation(7, 13); await VerifyCSharpFixAsync(this.GenerateTestStatement(statementText), expected, this.GenerateFixedTestStatement(statementText), CancellationToken.None).ConfigureAwait(false); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1504UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1504UnitTests.cs index 0bb57a0fa..00c808438 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1504UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1504UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1504AllAccessorsMustBeSingleLineOrMultiLine, @@ -64,7 +65,7 @@ public class Foo TestCode = testCode, ExpectedDiagnostics = { expected }, FixedCode = fixedTestCodeSingle, - CodeFixIndex = 0, + CodeActionIndex = 0, }.RunAsync(CancellationToken.None).ConfigureAwait(false); await new CSharpTest @@ -72,7 +73,7 @@ public class Foo TestCode = testCode, ExpectedDiagnostics = { expected }, FixedCode = fixedTestCodeMultiple, - CodeFixIndex = 1, + CodeActionIndex = 1, }.RunAsync(CancellationToken.None).ConfigureAwait(false); } @@ -252,7 +253,7 @@ public event System.EventHandler NameChanged TestCode = testCode, ExpectedDiagnostics = { expected }, FixedCode = fixedTestCodeSingle, - CodeFixIndex = 0, + CodeActionIndex = 0, }.RunAsync(CancellationToken.None).ConfigureAwait(false); await new CSharpTest @@ -260,7 +261,7 @@ public event System.EventHandler NameChanged TestCode = testCode, ExpectedDiagnostics = { expected }, FixedCode = fixedTestCodeMultiple, - CodeFixIndex = 1, + CodeActionIndex = 1, }.RunAsync(CancellationToken.None).ConfigureAwait(false); } @@ -375,7 +376,7 @@ public int Prop TestCode = testCode, ExpectedDiagnostics = { expected }, FixedCode = fixedTestCodeSingle, - CodeFixIndex = 0, + CodeActionIndex = 0, }.RunAsync(CancellationToken.None).ConfigureAwait(false); await new CSharpTest @@ -383,7 +384,7 @@ public int Prop TestCode = testCode, ExpectedDiagnostics = { expected }, FixedCode = fixedTestCodeMultiple, - CodeFixIndex = 1, + CodeActionIndex = 1, }.RunAsync(CancellationToken.None).ConfigureAwait(false); } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1505UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1505UnitTests.cs index 65912d207..b3847ba2c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1505UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1505UnitTests.cs @@ -1,13 +1,17 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { using System.Collections.Generic; + using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; + using StyleCop.Analyzers.Test.Helpers; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1505OpeningBracesMustNotBeFollowedByBlankLine, @@ -22,9 +26,17 @@ public static IEnumerable TypeTestData { get { - yield return new object[] { "class", "public " }; - yield return new object[] { "struct", "public " }; - yield return new object[] { "interface", string.Empty }; + foreach (var data in CommonMemberData.TypeDeclarationKeywords) + { + var keyword = (string)data.Single(); + var accessModifier = keyword switch + { + "interface" => string.Empty, + _ => "public ", + }; + + yield return new[] { keyword, accessModifier }; + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1506UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1506UnitTests.cs index 2c2b05133..cd2f77ba6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1506UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1506UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -8,7 +10,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1506ElementDocumentationHeadersMustNotBeFollowedByBlankLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1507UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1507UnitTests.cs index a22a24baa..210d481ce 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1507UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1507UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1507CodeMustNotContainMultipleBlankLinesInARow, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1508UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1508UnitTests.cs index 063bd5365..091c272a9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1508UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1508UnitTests.cs @@ -1,14 +1,17 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { using System.Collections.Generic; + using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; + using StyleCop.Analyzers.Test.Helpers; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1508ClosingBracesMustNotBePrecededByBlankLine, @@ -23,9 +26,17 @@ public static IEnumerable TypeTestData { get { - yield return new object[] { "class", "public " }; - yield return new object[] { "struct", "public " }; - yield return new object[] { "interface", string.Empty }; + foreach (var data in CommonMemberData.TypeDeclarationKeywords) + { + var keyword = (string)data.Single(); + var accessModifier = keyword switch + { + "interface" => string.Empty, + _ => "public ", + }; + + yield return new[] { keyword, accessModifier }; + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1509UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1509UnitTests.cs index 012c76ff4..ffd3afe1a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1509UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1509UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1509OpeningBracesMustNotBePrecededByBlankLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1510UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1510UnitTests.cs index 8dc695ac6..b562847b3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1510UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1510UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1511UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1511UnitTests.cs index b3473b541..3f8b39517 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1511UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1511UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1511WhileDoFooterMustNotBePrecededByBlankLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1512UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1512UnitTests.cs index 001ac2ca2..776169d9b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1512UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1512UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1512SingleLineCommentsMustNotBeFollowedByBlankLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1513UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1513UnitTests.cs index 14ddbe33e..267095142 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1513UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1513UnitTests.cs @@ -1,16 +1,15 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { - using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; - using Microsoft.CodeAnalysis.CodeFixes; - using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; + using StyleCop.Analyzers.Test.Helpers; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1513ClosingBraceMustBeFollowedByBlankLine, @@ -995,5 +994,45 @@ private set await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } + + [Fact] + [WorkItem(3442, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3442")] + public async Task NestedInterpolatedStringAsync() + { + var testCode = @" +public class TestClass +{ + public void TestMethod(string extraSupport) + { + string suffix = $@""{(string.IsNullOrEmpty(extraSupport) ? string.Empty : $@"" + {extraSupport}"")} + }} +}}""; + } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3360, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3360")] + public async Task TestLineFeedEndOfLinesAsync() + { + var testCode = @" +public class TestClass +{ +}[| +|]// Hello".ReplaceLineEndings("\n"); + + var fixedCode = @" +public class TestClass +{ +} + +// Hello".ReplaceLineEndings("\n"); + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1514UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1514UnitTests.cs index 083a1ab6c..582223d19 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1514UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1514UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -8,7 +10,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1514ElementDocumentationHeaderMustBePrecededByBlankLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1515UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1515UnitTests.cs index 03d0b0dd2..894ed44aa 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1515UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1515UnitTests.cs @@ -1,12 +1,14 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { + using System; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1515SingleLineCommentMustBePrecededByBlankLine, @@ -242,5 +244,62 @@ public class TestConstants await VerifyCSharpFixAsync(testCode, expectedDiagnostic, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } + + /// + /// Verifies that the analyzer will properly handle documentation followed by a comment, + /// even if there is another non-adjacent comment earlier. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3481, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3481")] + public async Task TestDocumentationFollowedByCommentWhenThereIsAlsoAnEarlierCommentAsync() + { + var testCode = @" +public class Class1 // Comment 1 +{ + public Class1() + { + } + + /// + /// Gets value. + /// + // Comment 2 + public double Value { get; } +}"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that the analyzer does not fire in file headers (i.e. one line comments at the start of the file). + /// + /// if the source code should start with a pragma; otherwise, . + /// The number of lines in the header. + /// A representing the asynchronous unit test. + [Theory] + [CombinatorialData] + [WorkItem(3630, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3630")] + public async Task TestFileHeaderAsync( + bool startWithPragma, + [CombinatorialValues(1, 2, 3)] int numberOfHeaderLines) + { + var testCode = @" +class TestClass +{ +}"; + + for (var i = 0; i < numberOfHeaderLines; i++) + { + testCode = "// A comment line." + Environment.NewLine + testCode; + } + + if (startWithPragma) + { + testCode = "#pragma warning disable CS1591" + Environment.NewLine + testCode; + } + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1516UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1516UnitTests.cs index 94d000a3e..7ec69ac6c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1516UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1516UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -713,5 +715,33 @@ private set await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } + + [Theory] + [InlineData("namespace")] + [InlineData("public class")] + [WorkItem(1923, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1923")] + public async Task TestBlankLinesAroundAssemblyAttributesAsync(string followingElementKind) + { + string testCode = $@"using System.Runtime.CompilerServices; +[assembly: InternalsVisibleTo(""AnotherAssembly"")] +{followingElementKind} Foo +{{ +}}"; + string fixedTestCode = $@"using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo(""AnotherAssembly"")] + +{followingElementKind} Foo +{{ +}}"; + + var expected = new[] + { + Diagnostic().WithLocation(2, 1), + Diagnostic().WithLocation(3, 1), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1516UsingGroupsUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1516UsingGroupsUnitTests.cs index 4a3bf4643..4a477f5d6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1516UsingGroupsUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1516UsingGroupsUnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1517UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1517UnitTests.cs index f42625fbf..bb26031b2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1517UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1517UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.LayoutRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1517CodeMustNotContainBlankLinesAtStartOfFile, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1518UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1518UnitTests.cs index c857a75c0..828070f66 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1518UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1518UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -10,7 +12,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using StyleCop.Analyzers.LayoutRules; using StyleCop.Analyzers.Settings.ObjectModel; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1519UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1519UnitTests.cs index ba33fc731..8e1800e34 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1519UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1519UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.LayoutRules using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1519BracesMustNotBeOmittedFromMultiLineChildStatement, @@ -29,6 +30,7 @@ public static IEnumerable TestStatements yield return new[] { "while (i == 0)" }; yield return new[] { "for (var j = 0; j < i; j++)" }; yield return new[] { "foreach (var j in new[] { 1, 2, 3 })" }; + yield return new[] { "lock (new object())" }; yield return new[] { "using (default(System.IDisposable))" }; } } @@ -363,6 +365,84 @@ public void Bar(int i) await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); } + [Fact] + public async Task TestSingleLineFixedStatementWithoutBracesAsync() + { + var testCode = @"public class C { + unsafe private static void TestMethod() + { + var a = new int[] { 1, 2, 3 }; + fixed (int* n = &a[0]) + *n = a[1] + a[2]; + } +}"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestMultiLineFixedStatementWithoutBracesAsync() + { + var testCode = @"public class C { + unsafe private static void TestMethod() + { + var a = new int[] { 1, 2, 3 }; + fixed (int* n = &a[0]) + *n = a[1] + + a[2]; + } +}"; + var fixedCode = @"public class C { + unsafe private static void TestMethod() + { + var a = new int[] { 1, 2, 3 }; + fixed (int* n = &a[0]) + { + *n = a[1] + + a[2]; + } + } +}"; + + var expected = Diagnostic().WithLocation(6, 13); + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestSingleLineFixedStatementWithBracesAsync() + { + var testCode = @"public class C { + unsafe private static void TestMethod() + { + var a = new int[] { 1, 2, 3 }; + fixed (int* n = &a[0]) + { + *n = a[1] + a[2]; + } + } +}"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestMultiLineFixedStatementWithBracesAsync() + { + var testCode = @"public class C { + unsafe private static void TestMethod() + { + var a = new int[] { 1, 2, 3 }; + fixed (int* n = &a[0]) + { + *n = a[1] + + a[2]; + } + } +}"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + /// /// Verifies that the code fix provider will work properly for a statement. /// @@ -582,8 +662,15 @@ public void Bar(int i) } }"; - var expected = Diagnostic().WithLocation(8, 13); - await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + var test = new CSharpTest + { + TestCode = testCode, + ExpectedDiagnostics = { Diagnostic().WithLocation(8, 13) }, + FixedCode = fixedTestCode, + }; + + test.TestBehaviors |= TestBehaviors.SkipSuppressionCheck; + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); } /// diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1520UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1520UnitTests.cs index e2585662a..a44ce2bad 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1520UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1520UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LayoutRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.LayoutRules.SA1520UseBracesConsistently, @@ -395,8 +396,15 @@ public void Bar(int i) } }"; - var expected = Diagnostic().WithLocation(8, 13); - await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + var test = new CSharpTest + { + TestCode = testCode, + ExpectedDiagnostics = { Diagnostic().WithLocation(8, 13) }, + FixedCode = fixedTestCode, + }; + + test.TestBehaviors |= TestBehaviors.SkipSuppressionCheck; + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); } /// diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/JsonArrayTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/JsonArrayTests.cs index 05a7dadcc..644822d8a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/JsonArrayTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/JsonArrayTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LightJson { @@ -26,7 +28,7 @@ public void TestConstructor() Assert.Equal(1, obj2[0].AsInteger); Assert.Equal("test2", obj2[1].AsString); - Assert.Throws("values", () => new JsonArray(default(JsonValue[]))); + Assert.Throws("values", () => new JsonArray(default)); } [Fact] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/JsonObjectTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/JsonObjectTests.cs index 8a8fa92d7..06a973507 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/JsonObjectTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/JsonObjectTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LightJson { @@ -107,6 +109,8 @@ public void TestRename() Assert.Same(value, obj["y"].AsString); } +#pragma warning disable IDE0060 // Remove unused parameter private static Type StaticType(T value) => typeof(T); +#pragma warning restore IDE0060 // Remove unused parameter } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/JsonValueTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/JsonValueTests.cs index 5b155476a..ae2078056 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/JsonValueTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/JsonValueTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LightJson { @@ -308,7 +310,7 @@ public void TestConversionOperators() [Fact] public void TestOpInequality() { - Assert.False(JsonValue.Null != default(JsonValue)); + Assert.False(JsonValue.Null != default); Assert.True(new JsonValue(true) != new JsonValue(0)); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/Serialization/JsonParseExceptionTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/Serialization/JsonParseExceptionTests.cs index 2599162de..b982e39de 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/Serialization/JsonParseExceptionTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/Serialization/JsonParseExceptionTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LightJson.Serialization { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/Serialization/JsonReaderTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/Serialization/JsonReaderTests.cs index 2aba7b2ea..2154fda20 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/Serialization/JsonReaderTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/Serialization/JsonReaderTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LightJson.Serialization { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/Serialization/JsonSerializationExceptionTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/Serialization/JsonSerializationExceptionTests.cs index 43dd4149d..c31f80b6e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/Serialization/JsonSerializationExceptionTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/Serialization/JsonSerializationExceptionTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LightJson.Serialization { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/Serialization/JsonWriterTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/Serialization/JsonWriterTests.cs index 60f7e5f83..fb290f9af 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/Serialization/JsonWriterTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/Serialization/JsonWriterTests.cs @@ -1,9 +1,10 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LightJson.Serialization { - using System; using global::LightJson; using global::LightJson.Serialization; using Xunit; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/Serialization/TextScannerTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/Serialization/TextScannerTests.cs index 45194c5c3..aedc69b70 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/Serialization/TextScannerTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LightJson/Serialization/TextScannerTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LightJson.Serialization { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/AccessorDeclarationSyntaxExtensionsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/AccessorDeclarationSyntaxExtensionsTests.cs index 268a9d5f3..0c9bde49d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/AccessorDeclarationSyntaxExtensionsTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/AccessorDeclarationSyntaxExtensionsTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ArgumentSyntaxExtensionsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ArgumentSyntaxExtensionsTests.cs new file mode 100644 index 000000000..cbdb8a0d6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ArgumentSyntaxExtensionsTests.cs @@ -0,0 +1,36 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class ArgumentSyntaxExtensionsTests + { + [Fact] + public void TestRefKindKeyword() + { + var argumentSyntax = SyntaxFactory.Argument(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)); + Assert.Equal(default, ArgumentSyntaxExtensions.RefKindKeyword(argumentSyntax)); + } + + [Fact] + public void TestWithRefKindKeyword() + { + var argumentSyntax = SyntaxFactory.Argument(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression)); + + // With default value is allowed + var argumentWithDefaultRefKind = ArgumentSyntaxExtensions.WithRefKindKeyword(argumentSyntax, default); + Assert.Equal(default, ArgumentSyntaxExtensions.RefKindKeyword(argumentWithDefaultRefKind)); + + // Non-default throws an exception + var refKind = SyntaxFactory.Token(SyntaxKind.RefKeyword); + Assert.Throws(() => ArgumentSyntaxExtensions.WithRefKindKeyword(argumentSyntax, refKind)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/AutoWrapSeparatedSyntaxListTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/AutoWrapSeparatedSyntaxListTests.cs index 4f4f27372..534ce7f4c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/AutoWrapSeparatedSyntaxListTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/AutoWrapSeparatedSyntaxListTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { @@ -11,7 +13,7 @@ public class AutoWrapSeparatedSyntaxListTests : SeparatedSyntaxListWrapperTestBa { internal override SeparatedSyntaxListWrapper CreateList() { - return new SeparatedSyntaxListWrapper.AutoWrapSeparatedSyntaxList(default(SeparatedSyntaxList)); + return new SeparatedSyntaxListWrapper.AutoWrapSeparatedSyntaxList(default); } internal override bool TryCreateNonEmptyList(out SeparatedSyntaxListWrapper list) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/BaseMethodDeclarationSyntaxExtensionsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/BaseMethodDeclarationSyntaxExtensionsTests.cs index a190f596d..b1a2704c9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/BaseMethodDeclarationSyntaxExtensionsTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/BaseMethodDeclarationSyntaxExtensionsTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/CasePatternSwitchLabelSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/CasePatternSwitchLabelSyntaxWrapperTests.cs index 8d43bf7c3..3ca07b759 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/CasePatternSwitchLabelSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/CasePatternSwitchLabelSyntaxWrapperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/CommonForEachStatementSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/CommonForEachStatementSyntaxWrapperTests.cs new file mode 100644 index 000000000..d5e8bd483 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/CommonForEachStatementSyntaxWrapperTests.cs @@ -0,0 +1,186 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class CommonForEachStatementSyntaxWrapperTests + { + [Fact] + public void TestNull() + { + var syntaxNode = default(SyntaxNode); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Null(wrapper.SyntaxNode); + Assert.Throws(() => wrapper.AwaitKeyword); + Assert.Throws(() => wrapper.ForEachKeyword); + Assert.Throws(() => wrapper.OpenParenToken); + Assert.Throws(() => wrapper.InKeyword); + Assert.Throws(() => wrapper.Expression); + Assert.Throws(() => wrapper.CloseParenToken); + Assert.Throws(() => wrapper.Statement); + Assert.Throws(() => wrapper.WithAwaitKeyword(SyntaxFactory.Token(SyntaxKind.AwaitKeyword))); + Assert.Throws(() => wrapper.WithForEachKeyword(SyntaxFactory.Token(SyntaxKind.ForEachKeyword))); + Assert.Throws(() => wrapper.WithOpenParenToken(SyntaxFactory.Token(SyntaxKind.OpenParenToken))); + Assert.Throws(() => wrapper.WithInKeyword(SyntaxFactory.Token(SyntaxKind.InKeyword))); + Assert.Throws(() => wrapper.WithExpression(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + Assert.Throws(() => wrapper.WithCloseParenToken(SyntaxFactory.Token(SyntaxKind.CloseParenToken))); + Assert.Throws(() => wrapper.WithStatement(SyntaxFactory.EmptyStatement())); + } + + [Fact] + public void TestWrapperIdentity() + { + var syntaxNode = this.CreateForEachStatement(); + Assert.True(syntaxNode.IsKind(SyntaxKind.ForEachStatement)); + + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Same(syntaxNode, wrapper.SyntaxNode); + } + + [Fact] + public void TestAwaitKeyword() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Equal(default, wrapper.AwaitKeyword); + + Assert.Throws(() => wrapper.WithAwaitKeyword(SyntaxFactory.Token(SyntaxKind.AwaitKeyword))); + } + + [Fact] + public void TestForEachKeyword() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Equal(syntaxNode.ForEachKeyword, wrapper.ForEachKeyword); + + wrapper = wrapper.WithForEachKeyword(SpacingExtensions.WithoutTrivia(SyntaxFactory.Token(SyntaxKind.ForEachKeyword))); + Assert.NotNull(wrapper.SyntaxNode); + Assert.NotSame(syntaxNode, wrapper.SyntaxNode); + Assert.False(syntaxNode.ForEachKeyword.IsEquivalentTo(wrapper.ForEachKeyword)); + } + + [Fact] + public void TestOpenParenToken() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Equal(syntaxNode.OpenParenToken, wrapper.OpenParenToken); + + wrapper = wrapper.WithOpenParenToken(SpacingExtensions.WithoutTrivia(SyntaxFactory.Token(SyntaxKind.OpenParenToken))); + Assert.NotNull(wrapper.SyntaxNode); + Assert.NotSame(syntaxNode, wrapper.SyntaxNode); + Assert.False(syntaxNode.OpenParenToken.IsEquivalentTo(wrapper.OpenParenToken)); + } + + [Fact] + public void TestInKeyword() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Equal(syntaxNode.InKeyword, wrapper.InKeyword); + + wrapper = wrapper.WithInKeyword(SpacingExtensions.WithoutTrivia(SyntaxFactory.Token(SyntaxKind.InKeyword))); + Assert.NotNull(wrapper.SyntaxNode); + Assert.NotSame(syntaxNode, wrapper.SyntaxNode); + Assert.False(syntaxNode.InKeyword.IsEquivalentTo(wrapper.InKeyword)); + } + + [Fact] + public void TestExpression() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Same(syntaxNode.Expression, wrapper.Expression); + + wrapper = wrapper.WithExpression(SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal(0))); + Assert.NotNull(wrapper.SyntaxNode); + Assert.NotSame(syntaxNode, wrapper.SyntaxNode); + Assert.NotSame(syntaxNode.Expression, wrapper.Expression); + Assert.False(syntaxNode.Expression.IsEquivalentTo(wrapper.Expression)); + } + + [Fact] + public void TestCloseParenToken() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Equal(syntaxNode.CloseParenToken, wrapper.CloseParenToken); + + wrapper = wrapper.WithCloseParenToken(SpacingExtensions.WithoutTrivia(SyntaxFactory.Token(SyntaxKind.CloseParenToken))); + Assert.NotNull(wrapper.SyntaxNode); + Assert.NotSame(syntaxNode, wrapper.SyntaxNode); + Assert.False(syntaxNode.CloseParenToken.IsEquivalentTo(wrapper.CloseParenToken)); + } + + [Fact] + public void TestStatement() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + Assert.Same(syntaxNode.Statement, wrapper.Statement); + + wrapper = wrapper.WithStatement(SyntaxFactory.Block()); + Assert.NotNull(wrapper.SyntaxNode); + Assert.NotSame(syntaxNode, wrapper.SyntaxNode); + Assert.NotSame(syntaxNode.Statement, wrapper.Statement); + Assert.False(syntaxNode.Statement.IsEquivalentTo(wrapper.Statement)); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(CommonForEachStatementSyntaxWrapper.IsInstance(null)); + Assert.False(CommonForEachStatementSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + + var syntaxNode = this.CreateForEachStatement(); + Assert.True(CommonForEachStatementSyntaxWrapper.IsInstance(syntaxNode)); + } + + [Fact] + public void TestConversionsNull() + { + var syntaxNode = default(SyntaxNode); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + + StatementSyntax syntax = wrapper; + Assert.Null(syntax); + } + + [Fact] + public void TestConversions() + { + var syntaxNode = this.CreateForEachStatement(); + var wrapper = (CommonForEachStatementSyntaxWrapper)syntaxNode; + + StatementSyntax syntax = wrapper; + Assert.Same(syntaxNode, syntax); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (CommonForEachStatementSyntaxWrapper)syntaxNode); + } + + private ForEachStatementSyntax CreateForEachStatement() + { + return SyntaxFactory.ForEachStatement( + SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword)), + "x", + SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression), + SyntaxFactory.EmptyStatement()); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ConstantPatternSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ConstantPatternSyntaxWrapperTests.cs index c3d239ac2..3a2cf32e6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ConstantPatternSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ConstantPatternSyntaxWrapperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ConstructorDeclarationSyntaxExtensionsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ConstructorDeclarationSyntaxExtensionsTests.cs index ecfc4a69d..212f251fd 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ConstructorDeclarationSyntaxExtensionsTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ConstructorDeclarationSyntaxExtensionsTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/CrefParameterSyntaxExtensionsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/CrefParameterSyntaxExtensionsTests.cs new file mode 100644 index 000000000..39ad7879e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/CrefParameterSyntaxExtensionsTests.cs @@ -0,0 +1,36 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class CrefParameterSyntaxExtensionsTests + { + [Fact] + public void TestRefKindKeyword() + { + var crefParameterSyntax = SyntaxFactory.CrefParameter(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword))); + Assert.Equal(default, CrefParameterSyntaxExtensions.RefKindKeyword(crefParameterSyntax)); + } + + [Fact] + public void TestWithRefKindKeyword() + { + var crefParameterSyntax = SyntaxFactory.CrefParameter(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword))); + + // With default value is allowed + var crefParameterWithDefaultRefKind = CrefParameterSyntaxExtensions.WithRefKindKeyword(crefParameterSyntax, default); + Assert.Equal(default, CrefParameterSyntaxExtensions.RefKindKeyword(crefParameterWithDefaultRefKind)); + + // Non-default throws an exception + var refKind = SyntaxFactory.Token(SyntaxKind.RefKeyword); + Assert.Throws(() => CrefParameterSyntaxExtensions.WithRefKindKeyword(crefParameterSyntax, refKind)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DeclarationExpressionSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DeclarationExpressionSyntaxWrapperTests.cs index 452fcc314..fa08548f7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DeclarationExpressionSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DeclarationExpressionSyntaxWrapperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DeclarationPatternSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DeclarationPatternSyntaxWrapperTests.cs index 2ac427edd..83287b677 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DeclarationPatternSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DeclarationPatternSyntaxWrapperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DestructorDeclarationSyntaxExtensionsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DestructorDeclarationSyntaxExtensionsTests.cs index 181c0df4a..d5ab596d3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DestructorDeclarationSyntaxExtensionsTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DestructorDeclarationSyntaxExtensionsTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DiscardDesignationSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DiscardDesignationSyntaxWrapperTests.cs index 343dbb9d7..150f7a2c0 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DiscardDesignationSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/DiscardDesignationSyntaxWrapperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/INamedTypeSymbolExtensionsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/INamedTypeSymbolExtensionsTests.cs new file mode 100644 index 000000000..d0f73db10 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/INamedTypeSymbolExtensionsTests.cs @@ -0,0 +1,24 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class INamedTypeSymbolExtensionsTests + { + [Fact] + public void TestNull() + { + INamedTypeSymbol symbol = null; + Assert.Throws(() => INamedTypeSymbolExtensions.IsSerializable(symbol)); + Assert.Throws(() => INamedTypeSymbolExtensions.TupleElements(symbol)); + Assert.Throws(() => INamedTypeSymbolExtensions.TupleUnderlyingType(symbol)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ITypeParameterSymbolExtensionsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ITypeParameterSymbolExtensionsTests.cs new file mode 100644 index 000000000..bb892ab84 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ITypeParameterSymbolExtensionsTests.cs @@ -0,0 +1,22 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class ITypeParameterSymbolExtensionsTests + { + [Fact] + public void TestNull() + { + ITypeParameterSymbol symbol = null; + Assert.Throws(() => ITypeParameterSymbolExtensions.HasUnmanagedTypeConstraint(symbol)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapperTests.cs new file mode 100644 index 000000000..3e421ad09 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapperTests.cs @@ -0,0 +1,58 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class ImplicitStackAllocArrayCreationExpressionSyntaxWrapperTests + { + [Fact] + public void TestNull() + { + var syntaxNode = default(SyntaxNode); + var wrapper = (ImplicitStackAllocArrayCreationExpressionSyntaxWrapper)syntaxNode; + Assert.Null(wrapper.SyntaxNode); + Assert.Throws(() => wrapper.StackAllocKeyword); + Assert.Throws(() => wrapper.OpenBracketToken); + Assert.Throws(() => wrapper.CloseBracketToken); + Assert.Throws(() => wrapper.Initializer); + Assert.Throws(() => wrapper.WithStackAllocKeyword(SyntaxFactory.Token(SyntaxKind.StackAllocKeyword))); + Assert.Throws(() => wrapper.WithOpenBracketToken(SyntaxFactory.Token(SyntaxKind.OpenBracketToken))); + Assert.Throws(() => wrapper.WithCloseBracketToken(SyntaxFactory.Token(SyntaxKind.CloseBracketToken))); + Assert.Throws(() => wrapper.WithInitializer(SyntaxFactory.InitializerExpression(SyntaxKind.ArrayInitializerExpression))); + Assert.Throws(() => wrapper.AddInitializerExpressions()); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(ImplicitStackAllocArrayCreationExpressionSyntaxWrapper.IsInstance(null)); + Assert.False(ImplicitStackAllocArrayCreationExpressionSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + } + + [Fact] + public void TestConversionsNull() + { + var syntaxNode = default(SyntaxNode); + var wrapper = (ImplicitStackAllocArrayCreationExpressionSyntaxWrapper)syntaxNode; + + ExpressionSyntax syntax = wrapper; + Assert.Null(syntax); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (ImplicitStackAllocArrayCreationExpressionSyntaxWrapper)syntaxNode); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/IsPatternExpressionSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/IsPatternExpressionSyntaxWrapperTests.cs index ef47f24f4..4e3955450 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/IsPatternExpressionSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/IsPatternExpressionSyntaxWrapperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/LanguageVersionExUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/LanguageVersionExUnitTests.cs new file mode 100644 index 000000000..52ce4d4b3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/LanguageVersionExUnitTests.cs @@ -0,0 +1,63 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System.Collections.Generic; + using System.Reflection; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class LanguageVersionExUnitTests + { + private static readonly Dictionary LanguageVersionToName; + private static readonly Dictionary NameToLanguageVersion; + + static LanguageVersionExUnitTests() + { + LanguageVersionToName = new Dictionary(); + NameToLanguageVersion = new Dictionary(); + + foreach (var field in typeof(LanguageVersion).GetTypeInfo().DeclaredFields) + { + if (!field.IsStatic) + { + continue; + } + + var value = (LanguageVersion)field.GetRawConstantValue(); + var name = field.Name; + LanguageVersionToName.Add(value, name); + NameToLanguageVersion.Add(name, value); + } + } + + public static IEnumerable LanguageVersions + { + get + { + foreach (var field in typeof(LanguageVersionEx).GetTypeInfo().DeclaredFields) + { + yield return new object[] { field.Name, (LanguageVersion)field.GetRawConstantValue() }; + } + } + } + + [Theory] + [MemberData(nameof(LanguageVersions))] + public void TestLanguageVersion(string name, LanguageVersion languageVersion) + { + if (LanguageVersionToName.TryGetValue(languageVersion, out var expectedName)) + { + Assert.Equal(expectedName, name); + } + else + { + Assert.False(NameToLanguageVersion.TryGetValue(name, out _)); + } + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/LightupHelpersTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/LightupHelpersUnitTests.cs similarity index 97% rename from StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/LightupHelpersTests.cs rename to StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/LightupHelpersUnitTests.cs index 5b054901e..1c2f7b3cc 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/LightupHelpersTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/LightupHelpersUnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { @@ -10,7 +12,7 @@ namespace StyleCop.Analyzers.Test.Lightup using StyleCop.Analyzers.Lightup; using Xunit; - public class LightupHelpersTests + public class LightupHelpersUnitTests { [Fact] public void TestCanWrapNullNode() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/LocalFunctionStatementSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/LocalFunctionStatementSyntaxWrapperTests.cs index 0aa2f65a1..dfcd7f4be 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/LocalFunctionStatementSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/LocalFunctionStatementSyntaxWrapperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/MethodKindExUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/MethodKindExUnitTests.cs new file mode 100644 index 000000000..f7c542da9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/MethodKindExUnitTests.cs @@ -0,0 +1,68 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System.Collections.Generic; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class MethodKindExUnitTests + { + private static readonly Dictionary MethodKindToName; + private static readonly Dictionary NameToMethodKind; + + static MethodKindExUnitTests() + { + MethodKindToName = new Dictionary(); + NameToMethodKind = new Dictionary(); + + foreach (var field in typeof(MethodKind).GetTypeInfo().DeclaredFields) + { + if (!field.IsStatic) + { + continue; + } + + var value = (MethodKind)field.GetRawConstantValue(); + var name = field.Name; + if (!MethodKindToName.ContainsKey(value)) + { + MethodKindToName[value] = name; + } + + NameToMethodKind.Add(name, value); + } + } + + public static IEnumerable MethodKinds + { + get + { + foreach (var field in typeof(MethodKindEx).GetTypeInfo().DeclaredFields) + { + yield return new object[] { field.Name, (MethodKind)field.GetRawConstantValue() }; + } + } + } + + [Theory] + [MemberData(nameof(MethodKinds))] + public void TestMethodKind(string name, MethodKind methodKind) + { + if (MethodKindToName.TryGetValue(methodKind, out var expectedName)) + { + Assert.Equal(expectedName, name); + } + else + { + Assert.False(NameToMethodKind.TryGetValue(name, out _)); + } + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ParenthesizedVariableDesignationSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ParenthesizedVariableDesignationSyntaxWrapperTests.cs index 1afa24ea0..44bbb2949 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ParenthesizedVariableDesignationSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ParenthesizedVariableDesignationSyntaxWrapperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/PatternSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/PatternSyntaxWrapperTests.cs index 3b0725776..c3f8b8a54 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/PatternSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/PatternSyntaxWrapperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/RefExpressionSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/RefExpressionSyntaxWrapperTests.cs index 8a2889a05..97716c422 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/RefExpressionSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/RefExpressionSyntaxWrapperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/RefTypeSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/RefTypeSyntaxWrapperTests.cs index aaa477fe6..7125ffdad 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/RefTypeSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/RefTypeSyntaxWrapperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { @@ -20,8 +22,10 @@ public void TestNull() Assert.Null(wrapper.SyntaxNode); Assert.Throws(() => wrapper.Type); Assert.Throws(() => wrapper.RefKeyword); + Assert.Throws(() => wrapper.ReadOnlyKeyword); Assert.Throws(() => wrapper.WithType(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword)))); - Assert.Throws(() => wrapper.WithRefKeyword(SyntaxFactory.Token(SyntaxKind.IsKeyword))); + Assert.Throws(() => wrapper.WithRefKeyword(SyntaxFactory.Token(SyntaxKind.RefKeyword))); + Assert.Throws(() => wrapper.WithReadOnlyKeyword(SyntaxFactory.Token(SyntaxKind.ReadOnlyKeyword))); } [Fact] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SeparatedSyntaxListWrapperTestBase.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SeparatedSyntaxListWrapperTestBase.cs index d5b4675ca..fe370051d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SeparatedSyntaxListWrapperTestBase.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SeparatedSyntaxListWrapperTestBase.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SingleVariableDesignationSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SingleVariableDesignationSyntaxWrapperTests.cs index 7b92d8723..81dd60bad 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SingleVariableDesignationSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SingleVariableDesignationSyntaxWrapperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/StackAllocArrayCreationExpressionSyntaxExtensionsTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/StackAllocArrayCreationExpressionSyntaxExtensionsTests.cs new file mode 100644 index 000000000..1e82db5bd --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/StackAllocArrayCreationExpressionSyntaxExtensionsTests.cs @@ -0,0 +1,36 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class StackAllocArrayCreationExpressionSyntaxExtensionsTests + { + [Fact] + public void TestInitializer() + { + var stackAllocSyntax = SyntaxFactory.StackAllocArrayCreationExpression(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword))); + Assert.Null(StackAllocArrayCreationExpressionSyntaxExtensions.Initializer(stackAllocSyntax)); + } + + [Fact] + public void TestWithInitializer() + { + var stackAllocSyntax = SyntaxFactory.StackAllocArrayCreationExpression(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.IntKeyword))); + + // With default value is allowed + var stackAllocWithDefaultInitializer = StackAllocArrayCreationExpressionSyntaxExtensions.WithInitializer(stackAllocSyntax, null); + Assert.Null(StackAllocArrayCreationExpressionSyntaxExtensions.Initializer(stackAllocWithDefaultInitializer)); + + // Non-default throws an exception + var initializer = SyntaxFactory.InitializerExpression(SyntaxKind.ArrayInitializerExpression); + Assert.Throws(() => StackAllocArrayCreationExpressionSyntaxExtensions.WithInitializer(stackAllocSyntax, initializer)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SwitchExpressionArmSyntaxWrapperUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SwitchExpressionArmSyntaxWrapperUnitTests.cs new file mode 100644 index 000000000..59f022002 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SwitchExpressionArmSyntaxWrapperUnitTests.cs @@ -0,0 +1,47 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class SwitchExpressionArmSyntaxWrapperUnitTests + { + [Fact] + public void TestNull() + { + var switchExpressionSyntax = (SwitchExpressionArmSyntaxWrapper)default(SyntaxNode); + + Assert.Null(switchExpressionSyntax.SyntaxNode); + + Assert.Throws(() => switchExpressionSyntax.Pattern); + Assert.Throws(() => switchExpressionSyntax.WhenClause); + Assert.Throws(() => switchExpressionSyntax.Expression); + Assert.Throws(() => switchExpressionSyntax.EqualsGreaterThanToken); + Assert.Throws(() => switchExpressionSyntax.WithExpression(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + Assert.Throws(() => switchExpressionSyntax.WithEqualsGreaterThanToken(SyntaxFactory.Token(SyntaxKind.EqualsGreaterThanToken))); + } + + [Fact] + public void TestConversionNull() + { + var wrapper = (SwitchExpressionArmSyntaxWrapper)default(SyntaxNode); + + CSharpSyntaxNode syntax = wrapper; + Assert.Null(syntax); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (SwitchExpressionArmSyntaxWrapper)syntaxNode); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SwitchExpressionSyntaxWrapperUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SwitchExpressionSyntaxWrapperUnitTests.cs new file mode 100644 index 000000000..2ccda0ded --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SwitchExpressionSyntaxWrapperUnitTests.cs @@ -0,0 +1,58 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class SwitchExpressionSyntaxWrapperUnitTests + { + [Fact] + public void TestNull() + { + var syntaxNode = default(ExpressionSyntax); + var switchExpressionSyntaxWrapper = (SwitchExpressionSyntaxWrapper)syntaxNode; + + Assert.Null(switchExpressionSyntaxWrapper.SyntaxNode); + Assert.Throws(() => switchExpressionSyntaxWrapper.Arms); + Assert.Throws(() => switchExpressionSyntaxWrapper.CloseBraceToken); + Assert.Throws(() => switchExpressionSyntaxWrapper.GoverningExpression); + Assert.Throws(() => switchExpressionSyntaxWrapper.OpenBraceToken); + Assert.Throws(() => switchExpressionSyntaxWrapper.AddArms((SwitchExpressionArmSyntaxWrapper)null)); + Assert.Throws(() => switchExpressionSyntaxWrapper.WithArms(SeparatedSyntaxListWrapper.UnsupportedEmpty)); + Assert.Throws(() => switchExpressionSyntaxWrapper.WithCloseBraceToken(SyntaxFactory.Token(SyntaxKind.CloseBracketToken))); + Assert.Throws(() => switchExpressionSyntaxWrapper.WithOpenBraceToken(SyntaxFactory.Token(SyntaxKind.OpenBraceToken))); + Assert.Throws(() => switchExpressionSyntaxWrapper.WithSwitchKeyword(SyntaxFactory.Token(SyntaxKind.SwitchKeyword))); + } + + [Fact] + public void TestIsInstance() + { + Assert.False(SwitchExpressionSyntaxWrapper.IsInstance(null)); + Assert.False(SwitchExpressionSyntaxWrapper.IsInstance(SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression))); + } + + [Fact] + public void TestConversionsNull() + { + var syntaxNode = default(ExpressionSyntax); + var switchExpressionSyntaxWrapper = (SwitchExpressionSyntaxWrapper)syntaxNode; + + Assert.Null(switchExpressionSyntaxWrapper.SyntaxNode); + Assert.Null((ExpressionSyntax)switchExpressionSyntaxWrapper); + } + + [Fact] + public void TestInvalidConversion() + { + var syntaxNode = SyntaxFactory.LiteralExpression(SyntaxKind.NullLiteralExpression); + Assert.Throws(() => (SwitchExpressionSyntaxWrapper)syntaxNode); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SyntaxKindExUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SyntaxKindExUnitTests.cs new file mode 100644 index 000000000..c22f2d259 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SyntaxKindExUnitTests.cs @@ -0,0 +1,63 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System.Collections.Generic; + using System.Reflection; + using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class SyntaxKindExUnitTests + { + private static readonly Dictionary SyntaxKindToName; + private static readonly Dictionary NameToSyntaxKind; + + static SyntaxKindExUnitTests() + { + SyntaxKindToName = new Dictionary(); + NameToSyntaxKind = new Dictionary(); + + foreach (var field in typeof(SyntaxKind).GetTypeInfo().DeclaredFields) + { + if (!field.IsStatic) + { + continue; + } + + var value = (SyntaxKind)field.GetRawConstantValue(); + var name = field.Name; + SyntaxKindToName.Add(value, name); + NameToSyntaxKind.Add(name, value); + } + } + + public static IEnumerable SyntaxKinds + { + get + { + foreach (var field in typeof(SyntaxKindEx).GetTypeInfo().DeclaredFields) + { + yield return new object[] { field.Name, (SyntaxKind)field.GetRawConstantValue() }; + } + } + } + + [Theory] + [MemberData(nameof(SyntaxKinds))] + public void TestSyntaxKind(string name, SyntaxKind syntaxKind) + { + if (SyntaxKindToName.TryGetValue(syntaxKind, out var expectedName)) + { + Assert.Equal(expectedName, name); + } + else + { + Assert.False(NameToSyntaxKind.TryGetValue(name, out _)); + } + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SyntaxWrapperHelperUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SyntaxWrapperHelperUnitTests.cs new file mode 100644 index 000000000..1a2e4f6ba --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SyntaxWrapperHelperUnitTests.cs @@ -0,0 +1,67 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Test.Lightup +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Reflection; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using StyleCop.Analyzers.Lightup; + using Xunit; + + public class SyntaxWrapperHelperUnitTests + { + public static IEnumerable SyntaxWrapperClasses + { + get + { + var wrapperTypes = typeof(ISyntaxWrapper<>).Assembly.GetTypes() + .Where(t => t.GetTypeInfo().ImplementedInterfaces.Any(i => i.IsGenericType && (i.GetGenericTypeDefinition() == typeof(ISyntaxWrapper<>)))); + + foreach (var wrapperType in wrapperTypes) + { + yield return new object[] { wrapperType }; + } + } + } + + [Theory] + [MemberData(nameof(SyntaxWrapperClasses))] + public void VerifyThatWrapperClassIsPresent(Type wrapperType) + { + var wrappedTypeName = $"Microsoft.CodeAnalysis.CSharp.Syntax.{wrapperType.Name.Substring(0, wrapperType.Name.Length - "Wrapper".Length)}"; + if (typeof(CSharpSyntaxNode).Assembly.GetType(wrappedTypeName) is { } expected) + { + var wrappedType = SyntaxWrapperHelper.GetWrappedType(wrapperType); + Assert.Same(expected, wrappedType); + } + else if (wrapperType == typeof(CommonForEachStatementSyntaxWrapper)) + { + // Special case for C# 6 analysis compatibility + Assert.False(LightupHelpers.SupportsCSharp7); + Assert.Same(typeof(ForEachStatementSyntax), SyntaxWrapperHelper.GetWrappedType(wrapperType)); + } + else if (wrapperType == typeof(BaseObjectCreationExpressionSyntaxWrapper)) + { + // Special case for C# 6-8 analysis compatibility + Assert.False(LightupHelpers.SupportsCSharp9); + Assert.Same(typeof(ObjectCreationExpressionSyntax), SyntaxWrapperHelper.GetWrappedType(wrapperType)); + } + else if (wrapperType == typeof(BaseNamespaceDeclarationSyntaxWrapper)) + { + // Special case for C# 6-9 analysis compatibility + Assert.False(LightupHelpers.SupportsCSharp10); + Assert.Same(typeof(NamespaceDeclarationSyntax), SyntaxWrapperHelper.GetWrappedType(wrapperType)); + } + else + { + Assert.Null(SyntaxWrapperHelper.GetWrappedType(wrapperType)); + } + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SyntaxWrapperTests.cs index b3636a905..32bbcdf16 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/SyntaxWrapperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ThrowExpressionSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ThrowExpressionSyntaxWrapperTests.cs index fba81ff8c..fb50d10d1 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ThrowExpressionSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/ThrowExpressionSyntaxWrapperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/TupleElementSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/TupleElementSyntaxWrapperTests.cs index 891306f02..01a45102d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/TupleElementSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/TupleElementSyntaxWrapperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/TupleExpressionSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/TupleExpressionSyntaxWrapperTests.cs index e2b5b021b..98566b696 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/TupleExpressionSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/TupleExpressionSyntaxWrapperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/TupleTypeSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/TupleTypeSyntaxWrapperTests.cs index 64e0fd436..7013659c0 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/TupleTypeSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/TupleTypeSyntaxWrapperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/UnsupportedSyntaxListTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/UnsupportedSyntaxListTests.cs index 12c55ad5a..2b84007ce 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/UnsupportedSyntaxListTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/UnsupportedSyntaxListTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/VariableDesignationSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/VariableDesignationSyntaxWrapperTests.cs index 9a84489ec..b262cbdfc 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/VariableDesignationSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/VariableDesignationSyntaxWrapperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/WhenClauseSyntaxWrapperTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/WhenClauseSyntaxWrapperTests.cs index 3f03aa2a3..759c6fb31 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/WhenClauseSyntaxWrapperTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Lightup/WhenClauseSyntaxWrapperTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LinqHelpers/SyntaxTriviaListEnumerableTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LinqHelpers/SyntaxTriviaListEnumerableTests.cs index 9674d5193..0f7ace3e6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/LinqHelpers/SyntaxTriviaListEnumerableTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/LinqHelpers/SyntaxTriviaListEnumerableTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.LinqHelpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/DebugMessagesUnitTestsBase.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/DebugMessagesUnitTestsBase.cs index 3d901e58c..49e91a050 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/DebugMessagesUnitTestsBase.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/DebugMessagesUnitTestsBase.cs @@ -1,9 +1,12 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { using System.Collections.Generic; + using System.Diagnostics; using System.Linq; using System.Text; using System.Threading; @@ -12,6 +15,7 @@ namespace StyleCop.Analyzers.Test.MaintainabilityRules using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Text; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.Test.Verifiers; using Xunit; @@ -44,10 +48,11 @@ public async Task TestConstantMessage_Field_PassExpressionAsync() [Fact] public async Task TestConstantMessage_Field_PassWrongTypeAsync() { - LinePosition linePosition = new LinePosition(3, 27); + var startLinePosition = new LinePosition(3, 27); + var endLinePosition = new LinePosition(3, 28); DiagnosticResult[] expected = { - DiagnosticResult.CompilerError("CS0029").WithSpan(new FileLinePositionSpan("Test0.cs", linePosition, linePosition)).WithMessage("Cannot implicitly convert type 'int' to 'string'"), + DiagnosticResult.CompilerError("CS0029").WithSpan(new FileLinePositionSpan("/0/Test0.cs", startLinePosition, endLinePosition)).WithMessage("Cannot implicitly convert type 'int' to 'string'"), }; await this.TestConstantMessage_Field_PassExecuterAsync("3", expected).ConfigureAwait(false); @@ -68,10 +73,11 @@ public async Task TestConstantMessage_Local_PassExpressionAsync() [Fact] public async Task TestConstantMessage_Local_PassWrongTypeAsync() { - LinePosition linePosition = new LinePosition(5, 31); + var startLinePosition = new LinePosition(5, 31); + var endLinePosition = new LinePosition(5, 32); DiagnosticResult[] expected = { - DiagnosticResult.CompilerError("CS0029").WithSpan(new FileLinePositionSpan("Test0.cs", linePosition, linePosition)).WithMessage("Cannot implicitly convert type 'int' to 'string'"), + DiagnosticResult.CompilerError("CS0029").WithSpan(new FileLinePositionSpan("/0/Test0.cs", startLinePosition, endLinePosition)).WithMessage("Cannot implicitly convert type 'int' to 'string'"), }; await this.TestConstantMessage_Local_PassExecuterAsync("3", expected).ConfigureAwait(false); @@ -92,11 +98,25 @@ public async Task TestConstantMessage_Inline_PassExpressionAsync() [Fact] public async Task TestConstantMessage_Inline_PassWrongTypeAsync() { - LinePosition linePosition = new LinePosition(5, 15 + this.MethodName.Length + this.InitialArguments.Sum(i => i.Length + ", ".Length)); - DiagnosticResult[] expected = + var startLinePosition = new LinePosition(5, 15 + this.MethodName.Length + this.InitialArguments.Sum(i => i.Length + ", ".Length)); + var endLinePosition = new LinePosition(startLinePosition.Line, startLinePosition.Character + 1); + DiagnosticResult[] expected; + if (LightupHelpers.SupportsCSharp11 && this.MethodName == nameof(Debug.Assert)) { - DiagnosticResult.CompilerError("CS1503").WithSpan(new FileLinePositionSpan("Test0.cs", linePosition, linePosition)).WithMessage($"Argument {1 + this.InitialArguments.Count()}: cannot convert from 'int' to 'string'"), - }; + // For some reason this case wants to bind to Debug.Assert(bool, ref Debug.AssertInterpolatedStringHandler) + expected = new[] + { + DiagnosticResult.CompilerError("CS1620").WithSpan(new FileLinePositionSpan("/0/Test0.cs", startLinePosition, endLinePosition)).WithMessage($"Argument {1 + this.InitialArguments.Count()} must be passed with the 'ref' keyword"), + }; + } + else + { + var expectedType = LightupHelpers.SupportsCSharp8 ? "string?" : "string"; + expected = new[] + { + DiagnosticResult.CompilerError("CS1503").WithSpan(new FileLinePositionSpan("/0/Test0.cs", startLinePosition, endLinePosition)).WithMessage($"Argument {1 + this.InitialArguments.Count()}: cannot convert from 'int' to '{expectedType}'"), + }; + } await this.TestConstantMessage_Inline_PassExecuterAsync("3", expected).ConfigureAwait(false); } @@ -294,16 +314,7 @@ protected Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] exp protected virtual string BuildTestCode(string format) { StringBuilder argumentList = new StringBuilder(); - foreach (var argument in this.InitialArguments) - { - if (argumentList.Length > 0) - { - argumentList.Append(", "); - } - - argumentList.Append(argument); - } - + argumentList.Append(string.Join(", ", this.InitialArguments)); if (argumentList.Length > 0) { argumentList.Append(", "); @@ -403,7 +414,7 @@ public void Bar() await this.VerifyCSharpDiagnosticAsync(string.Format(this.BuildTestCode(testCodeFormat), argument), expected, CancellationToken.None).ConfigureAwait(false); } - private class CSharpTest : StyleCopDiagnosticVerifier.CSharpTest + private class CSharpTest : StyleCopDiagnosticVerifier.CSharpTest { private readonly DebugMessagesUnitTestsBase testFixture; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/FileMayOnlyContainTestBase.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/FileMayOnlyContainTestBase.cs index 0af4a6fc2..2e899e531 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/FileMayOnlyContainTestBase.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/FileMayOnlyContainTestBase.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { @@ -10,7 +12,6 @@ namespace StyleCop.Analyzers.Test.MaintainabilityRules using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; - using Microsoft.CodeAnalysis.Testing.Verifiers; using StyleCop.Analyzers.Test.Verifiers; using Xunit; @@ -48,7 +49,7 @@ public async Task TestTwoElementsAsync() var fixedCode = new[] { - ("Test0.cs", @"%1 Foo + ("/0/Test0.cs", @"%1 Foo { } "), @@ -91,7 +92,7 @@ public async Task TestThreeElementsAsync() var fixedCode = new[] { - ("Test0.cs", @"%1 Foo + ("/0/Test0.cs", @"%1 Foo { } "), @@ -141,7 +142,7 @@ public async Task TestRemoveWarningSuppressionAsync() var fixedCode = new[] { - ("Test0.cs", @"%1 Foo + ("/0/Test0.cs", @"%1 Foo { } "), @@ -185,7 +186,7 @@ public async Task TestPreserveWarningSuppressionAsync() // See https://github.com/dotnet/roslyn/issues/3999 var fixedCode = new[] { - ("Test0.cs", @"%1 Foo + ("/0/Test0.cs", @"%1 Foo { } "), @@ -226,7 +227,7 @@ public async Task TestRemovePreprocessorDirectivesAsync() var fixedCode = new[] { - ("Test0.cs", @"%1 Foo + ("/0/Test0.cs", @"%1 Foo { } "), @@ -271,7 +272,7 @@ public async Task TestPreservePreprocessorDirectivesAsync() // See https://github.com/dotnet/roslyn/issues/3999 var fixedCode = new[] { - ("Test0.cs", @"%1 Foo + ("/0/Test0.cs", @"%1 Foo { #if true } @@ -339,23 +340,13 @@ protected Task VerifyCSharpFixAsync(string source, string testSettings, Diagnost test.FixedSources.Add(fixedSource); } - if (fixedSources.Length == 1 - && (fixedSources[0].fileName == string.Empty || fixedSources[0].fileName == "Test0.cs") - && source == fixedSources[0].content) - { - 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 virtual string GetSettings() => null; - private class CSharpTest : StyleCopCodeFixVerifier.CSharpTest + private class CSharpTest : StyleCopCodeFixVerifier.CSharpTest { private readonly FileMayOnlyContainTestBase testFixture; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1119UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1119UnitTests.cs index d80da9d2b..6ce90b14b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1119UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1119UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { @@ -1040,6 +1042,9 @@ public void Bar() string data = $""{(flag)}""; } }"; + + string fixedCode = this.GetFixedCodeTestParenthesisInInterpolatedStringThatShouldBeRemoved(); + DiagnosticResult[] expected = { Diagnostic(DiagnosticId).WithSpan(6, 26, 6, 32), @@ -1047,7 +1052,7 @@ public void Bar() Diagnostic(ParenthesesDiagnosticId).WithLocation(6, 31), }; - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } [Fact] @@ -1429,5 +1434,57 @@ public static void Main(string[] args) await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } + + [Fact] + [WorkItem(2992, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2992")] + public async Task VerifyCodeFixDoesNotInsertUnnecessarySpacesAsync() + { + var testCode = @"using System; +internal class Program +{ + private static readonly DateTime MaxDate = new DateTime((new DateTime(2101, 1, 28, 23, 59, 59, 999)).Ticks + 9999); + + private static void Main() + { + Console.WriteLine(MaxDate); + } +} +"; + + var fixedCode = @"using System; +internal class Program +{ + private static readonly DateTime MaxDate = new DateTime(new DateTime(2101, 1, 28, 23, 59, 59, 999).Ticks + 9999); + + private static void Main() + { + Console.WriteLine(MaxDate); + } +} +"; + + DiagnosticResult[] expected = + { + Diagnostic(DiagnosticId).WithSpan(4, 61, 4, 105), + Diagnostic(ParenthesesDiagnosticId).WithLocation(4, 61), + Diagnostic(ParenthesesDiagnosticId).WithLocation(4, 104), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + // In this version of Roslyn, we end up with an extra space between the opening brace + // and the identifier. Fixed in a later version. + protected virtual string GetFixedCodeTestParenthesisInInterpolatedStringThatShouldBeRemoved() + { + return @"class Foo +{ + public void Bar() + { + bool flag = false; + string data = $""{ flag}""; + } +}"; + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1400UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1400UnitTests.cs index a3e9c5af6..5e528e13c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1400UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1400UnitTests.cs @@ -1,12 +1,14 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; + using StyleCop.Analyzers.Test.Helpers; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.MaintainabilityRules.SA1400AccessModifierMustBeDeclared, @@ -16,202 +18,67 @@ public class SA1400UnitTests { private const string Tab = "\t"; - [Fact] - public async Task TestClassDeclarationAsync() - { - await this.TestTypeDeclarationAsync("class").ConfigureAwait(false); - } - - [Fact] - public async Task TestClassDeclarationWithAttributesAsync() - { - await this.TestTypeDeclarationWithAttributesAsync("class").ConfigureAwait(false); - } - - [Fact] - public async Task TestClassDeclarationWithDirectivesAsync() - { - await this.TestTypeDeclarationWithDirectivesAsync("class").ConfigureAwait(false); - } - - [Fact] - public async Task TestNestedClassDeclarationAsync() - { - await this.TestNestedTypeDeclarationAsync("class").ConfigureAwait(false); - } - - [Fact] - public async Task TestNestedClassDeclarationWithAttributesAsync() - { - await this.TestNestedTypeDeclarationWithAttributesAsync("class").ConfigureAwait(false); - } - - [Fact] - public async Task TestNestedClassDeclarationWithDirectivesAsync() - { - await this.TestNestedTypeDeclarationWithDirectivesAsync("class").ConfigureAwait(false); - } - - [Fact] - public async Task TestPartialClassDeclarationAsync() - { - await this.TestTypeDeclarationAsync("partial class", warning: false).ConfigureAwait(false); - } - - [Fact] - public async Task TestPartialClassDeclarationWithAttributesAsync() - { - await this.TestTypeDeclarationWithAttributesAsync("partial class", warning: false).ConfigureAwait(false); - } - - [Fact] - public async Task TestPartialClassDeclarationWithDirectivesAsync() - { - await this.TestTypeDeclarationWithDirectivesAsync("partial class", warning: false).ConfigureAwait(false); - } - - [Fact] - public async Task TestInterfaceDeclarationAsync() - { - await this.TestTypeDeclarationAsync("interface").ConfigureAwait(false); - } - - [Fact] - public async Task TestInterfaceDeclarationWithAttributesAsync() - { - await this.TestTypeDeclarationWithAttributesAsync("interface").ConfigureAwait(false); - } - - [Fact] - public async Task TestInterfaceDeclarationWithDirectivesAsync() - { - await this.TestTypeDeclarationWithDirectivesAsync("interface").ConfigureAwait(false); - } - - [Fact] - public async Task TestNestedInterfaceDeclarationAsync() - { - await this.TestNestedTypeDeclarationAsync("interface").ConfigureAwait(false); - } - - [Fact] - public async Task TestNestedInterfaceDeclarationWithAttributesAsync() + [Theory] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task TestTypeDeclarationAsync(string typeName) { - await this.TestNestedTypeDeclarationWithAttributesAsync("interface").ConfigureAwait(false); + await this.TestTypeDeclarationImplAsync(typeName).ConfigureAwait(false); } - [Fact] - public async Task TestNestedInterfaceDeclarationWithDirectivesAsync() + [Theory] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task TestPartialTypeDeclarationAsync(string typeName) { - await this.TestNestedTypeDeclarationWithDirectivesAsync("interface").ConfigureAwait(false); + await this.TestTypeDeclarationImplAsync($"partial {typeName}", warning: false).ConfigureAwait(false); } - [Fact] - public async Task TestPartialInterfaceDeclarationAsync() - { - await this.TestTypeDeclarationAsync("partial interface", warning: false).ConfigureAwait(false); - } - - [Fact] - public async Task TestPartialInterfaceDeclarationWithAttributesAsync() + [Theory] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task TestTypeDeclarationWithAttributesAsync(string typeName) { - await this.TestTypeDeclarationWithAttributesAsync("partial interface", warning: false).ConfigureAwait(false); + await this.TestTypeDeclarationWithAttributesImplAsync(typeName).ConfigureAwait(false); } - [Fact] - public async Task TestPartialInterfaceDeclarationWithDirectivesAsync() + [Theory] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task TestPartialTypeDeclarationWithAttributesAsync(string typeName) { - await this.TestTypeDeclarationWithDirectivesAsync("partial interface", warning: false).ConfigureAwait(false); + await this.TestTypeDeclarationWithAttributesImplAsync($"partial {typeName}", warning: false).ConfigureAwait(false); } - [Fact] - public async Task TestStructDeclarationAsync() + [Theory] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task TestTypeDeclarationWithDirectivesAsync(string typeName) { - await this.TestTypeDeclarationAsync("struct").ConfigureAwait(false); + await this.TestTypeDeclarationWithDirectivesImplAsync(typeName).ConfigureAwait(false); } - [Fact] - public async Task TestStructDeclarationWithAttributesAsync() + [Theory] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task TestPartialTypeDeclarationWithDirectivesAsync(string typeName) { - await this.TestTypeDeclarationWithAttributesAsync("struct").ConfigureAwait(false); + await this.TestTypeDeclarationWithDirectivesImplAsync($"partial {typeName}", warning: false).ConfigureAwait(false); } - [Fact] - public async Task TestStructDeclarationWithDirectivesAsync() + [Theory] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task TestNestedTypeDeclarationAsync(string typeName) { - await this.TestTypeDeclarationWithDirectivesAsync("struct").ConfigureAwait(false); + await this.TestNestedTypeDeclarationImplAsync(typeName).ConfigureAwait(false); } - [Fact] - public async Task TestNestedStructDeclarationAsync() + [Theory] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task TestNestedTypeDeclarationWithAttributesAsync(string typeName) { - await this.TestNestedTypeDeclarationAsync("struct").ConfigureAwait(false); + await this.TestNestedTypeDeclarationWithAttributesImplAsync(typeName).ConfigureAwait(false); } - [Fact] - public async Task TestNestedStructDeclarationWithAttributesAsync() - { - await this.TestNestedTypeDeclarationWithAttributesAsync("struct").ConfigureAwait(false); - } - - [Fact] - public async Task TestNestedStructDeclarationWithDirectivesAsync() - { - await this.TestNestedTypeDeclarationWithDirectivesAsync("struct").ConfigureAwait(false); - } - - [Fact] - public async Task TestPartialStructDeclarationAsync() - { - await this.TestTypeDeclarationAsync("partial struct", warning: false).ConfigureAwait(false); - } - - [Fact] - public async Task TestPartialStructDeclarationWithAttributesAsync() - { - await this.TestTypeDeclarationWithAttributesAsync("partial struct", warning: false).ConfigureAwait(false); - } - - [Fact] - public async Task TestPartialStructDeclarationWithDirectivesAsync() - { - await this.TestTypeDeclarationWithDirectivesAsync("partial struct", warning: false).ConfigureAwait(false); - } - - [Fact] - public async Task TestEnumDeclarationAsync() - { - await this.TestTypeDeclarationAsync("enum").ConfigureAwait(false); - } - - [Fact] - public async Task TestEnumDeclarationWithAttributesAsync() - { - await this.TestTypeDeclarationWithAttributesAsync("enum").ConfigureAwait(false); - } - - [Fact] - public async Task TestEnumDeclarationWithDirectivesAsync() - { - await this.TestTypeDeclarationWithDirectivesAsync("enum").ConfigureAwait(false); - } - - [Fact] - public async Task TestNestedEnumDeclarationAsync() - { - await this.TestNestedTypeDeclarationAsync("enum").ConfigureAwait(false); - } - - [Fact] - public async Task TestNestedEnumDeclarationWithAttributesAsync() - { - await this.TestNestedTypeDeclarationWithAttributesAsync("enum").ConfigureAwait(false); - } - - [Fact] - public async Task TestNestedEnumDeclarationWithDirectivesAsync() + [Theory] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task TestNestedTypeDeclarationWithDirectivesAsync(string typeName) { - await this.TestNestedTypeDeclarationWithDirectivesAsync("enum").ConfigureAwait(false); + await this.TestNestedTypeDeclarationWithDirectivesImplAsync(typeName).ConfigureAwait(false); } [Fact] @@ -652,32 +519,32 @@ public async Task TestStaticConstructorDeclarationWithDirectivesAsync() await this.TestNestedDeclarationWithDirectivesAsync("private", "OuterTypeName", "static OuterTypeName(", " ) { }", warning: false).ConfigureAwait(false); } - private async Task TestTypeDeclarationAsync(string keyword, bool warning = true) + private async Task TestTypeDeclarationImplAsync(string keyword, bool warning = true) { await this.TestDeclarationAsync("internal", "TypeName", $"{keyword} TypeName", "{\n}", warning: warning).ConfigureAwait(false); } - private async Task TestTypeDeclarationWithAttributesAsync(string keyword, bool warning = true) + private async Task TestTypeDeclarationWithAttributesImplAsync(string keyword, bool warning = true) { await this.TestDeclarationWithAttributesAsync("internal", "TypeName", $"{keyword} TypeName", "{\n}", warning: warning).ConfigureAwait(false); } - private async Task TestTypeDeclarationWithDirectivesAsync(string keyword, bool warning = true) + private async Task TestTypeDeclarationWithDirectivesImplAsync(string keyword, bool warning = true) { await this.TestDeclarationWithDirectivesAsync("internal", "TypeName", $"{keyword} TypeName", "{\n}", warning: warning).ConfigureAwait(false); } - private async Task TestNestedTypeDeclarationAsync(string keyword, bool warning = true) + private async Task TestNestedTypeDeclarationImplAsync(string keyword, bool warning = true) { await this.TestNestedDeclarationAsync("private", "TypeName", $"{keyword} TypeName", "{\n}", warning: warning).ConfigureAwait(false); } - private async Task TestNestedTypeDeclarationWithAttributesAsync(string keyword, bool warning = true) + private async Task TestNestedTypeDeclarationWithAttributesImplAsync(string keyword, bool warning = true) { await this.TestNestedDeclarationWithAttributesAsync("private", "TypeName", $"{keyword} TypeName", "{\n}", warning: warning).ConfigureAwait(false); } - private async Task TestNestedTypeDeclarationWithDirectivesAsync(string keyword, bool warning = true) + private async Task TestNestedTypeDeclarationWithDirectivesImplAsync(string keyword, bool warning = true) { await this.TestNestedDeclarationWithDirectivesAsync("private", "TypeName", $"{keyword} TypeName", "{\n}", warning: warning).ConfigureAwait(false); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1401UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1401UnitTests.cs index 471535c11..eec46d26a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1401UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1401UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.MaintainabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.MaintainabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForBlockDeclarationUnitTestsBase.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForBlockDeclarationUnitTestsBase.cs index 1f7633de0..9e2fa2bd8 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForBlockDeclarationUnitTestsBase.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForBlockDeclarationUnitTestsBase.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { @@ -22,6 +24,8 @@ public abstract class SA1402ForBlockDeclarationUnitTestsBase : FileMayOnlyContai protected SA1402SettingsConfiguration SettingsConfiguration { get; set; } = SA1402SettingsConfiguration.ConfigureAsTopLevelType; + protected virtual string SettingKeyword => this.Keyword; + protected abstract bool IsConfiguredAsTopLevelTypeByDefault { get; } [Fact] @@ -36,7 +40,7 @@ public async Task TestTwoGenericElementsAsync() var fixedCode = new[] { - ("Test0.cs", @"%1 Foo + ("/0/Test0.cs", @"%1 Foo { } "), @@ -83,7 +87,7 @@ public async Task TestTwoElementsWithDefaultRuleConfigurationAsync() var fixedCode = new[] { - ("Test0.cs", @"%1 Foo + ("/0/Test0.cs", @"%1 Foo { } "), @@ -133,7 +137,7 @@ public partial {this.Keyword} Bar var fixedCode = new[] { - ("Test0.cs", $@"public partial {this.Keyword} Foo + ("/0/Test0.cs", $@"public partial {this.Keyword} Foo {{ }} "), @@ -159,7 +163,7 @@ public async Task TestPreferFilenameTypeAsync() var fixedCode = new[] { - ("Test0.cs", $@"public {this.Keyword} Test0 + ("/0/Test0.cs", $@"public {this.Keyword} Test0 {{ }}"), ("Foo.cs", $@"public {this.Keyword} Foo @@ -188,7 +192,7 @@ public async Task TestNestedTypesAsync() protected override string GetSettings() { - return this.SettingsConfiguration.GetSettings(this.Keyword); + return this.SettingsConfiguration.GetSettings(this.SettingKeyword); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForClassUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForClassUnitTests.cs index ac9d308de..84098478e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForClassUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForClassUnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForDelegateUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForDelegateUnitTests.cs index 1ad22e609..dc60a3d0a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForDelegateUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForDelegateUnitTests.cs @@ -1,13 +1,17 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { + using System; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; + using StyleCop.Analyzers.Settings.ObjectModel; using Xunit; + using Xunit.Sdk; public class SA1402ForDelegateUnitTests : SA1402ForNonBlockDeclarationUnitTestsBase { @@ -30,7 +34,7 @@ public async Task TestTwoElementsAsync() var fixedCode = new[] { - ("Test0.cs", @"public delegate void Foo(); + ("/0/Test0.cs", @"public delegate void Foo(); "), ("Bar.cs", @"public delegate void Bar(); "), @@ -40,23 +44,32 @@ public async Task TestTwoElementsAsync() await VerifyCSharpFixAsync(testCode, this.GetSettings(), expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } - [Fact] - public async Task TestTwoGenericElementsAsync() + [Theory] + [InlineData(FileNamingConvention.StyleCop)] + [InlineData(FileNamingConvention.Metadata)] + public async Task TestTwoGenericElementsAsync(object namingConvention) { var testCode = @"public delegate void Foo(); public delegate void Bar(T1 x, T2 y, T3 z); "; + var expectedName = (FileNamingConvention)namingConvention switch + { + FileNamingConvention.StyleCop => "Bar{T1,T2,T3}.cs", + FileNamingConvention.Metadata => "Bar`3.cs", + _ => throw new NotImplementedException(), + }; + var fixedCode = new[] { - ("Test0.cs", @"public delegate void Foo(); + ("/0/Test0.cs", @"public delegate void Foo(); "), - ("Bar.cs", @"public delegate void Bar(T1 x, T2 y, T3 z); + (expectedName, @"public delegate void Bar(T1 x, T2 y, T3 z); "), }; DiagnosticResult expected = Diagnostic().WithLocation(2, 22); - await VerifyCSharpFixAsync(testCode, this.GetSettings(), expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpFixAsync(testCode, this.GetSettings((FileNamingConvention)namingConvention), expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } [Fact] @@ -93,7 +106,7 @@ public async Task TestThreeElementsAsync() var fixedCode = new[] { - ("Test0.cs", @"public delegate void Foo(); + ("/0/Test0.cs", @"public delegate void Foo(); "), ("Bar.cs", @"public delegate void Bar(); "), @@ -119,7 +132,7 @@ public async Task TestPreferFilenameTypeAsync() var fixedCode = new[] { - ("Test0.cs", $@"public delegate void Test0(); + ("/0/Test0.cs", $@"public delegate void Test0(); "), ("Foo.cs", $@"public delegate void Foo(); "), diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForEnumUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForEnumUnitTests.cs index 4ac4421e5..69c8a7d7a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForEnumUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForEnumUnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; public class SA1402ForEnumUnitTests : SA1402ForNonBlockDeclarationUnitTestsBase @@ -40,7 +41,7 @@ enum Bar var fixedCode = new[] { - ("Test0.cs", @"enum Foo + ("/0/Test0.cs", @"enum Foo { A, B, C } @@ -111,7 +112,7 @@ enum FooBar var fixedCode = new[] { - ("Test0.cs", @"enum Foo + ("/0/Test0.cs", @"enum Foo { A, B, C } @@ -152,7 +153,7 @@ enum Test0 var fixedCode = new[] { - ("Test0.cs", @"enum Test0 + ("/0/Test0.cs", @"enum Test0 { D, E } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForInterfaceUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForInterfaceUnitTests.cs index d23f37906..ed485b3bc 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForInterfaceUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForInterfaceUnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForNonBlockDeclarationUnitTestsBase.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForNonBlockDeclarationUnitTestsBase.cs index 7fb2c0acc..14d47cf77 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForNonBlockDeclarationUnitTestsBase.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForNonBlockDeclarationUnitTestsBase.cs @@ -1,14 +1,18 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { using System.Threading; using System.Threading.Tasks; + using global::LightJson.Serialization; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.MaintainabilityRules; + using StyleCop.Analyzers.Settings.ObjectModel; + using StyleCop.Analyzers.Test.Helpers; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; public abstract class SA1402ForNonBlockDeclarationUnitTestsBase { @@ -54,9 +58,30 @@ protected static Task VerifyCSharpFixAsync(string source, string testSettings, D return test.RunAsync(cancellationToken); } - protected virtual string GetSettings() + private protected virtual string GetSettings(FileNamingConvention namingConvention = FileNamingConvention.StyleCop) { - return this.SettingsConfiguration.GetSettings(this.Keyword); + var settings = this.SettingsConfiguration.GetSettings(this.Keyword); + if (settings is null && namingConvention == FileNamingConvention.StyleCop) + { + return null; + } + + var namingSettings = $@" +{{ + ""settings"": {{ + ""documentationRules"": {{ + ""fileNamingConvention"": ""{namingConvention.ToString().ToLowerInvariant()}"" + }} + }} +}}"; + + if (settings is null) + { + return namingSettings; + } + + var merged = JsonTestHelper.MergeJsonObjects(JsonReader.Parse(settings).AsJsonObject, JsonReader.Parse(namingSettings).AsJsonObject); + return new JsonWriter(pretty: true).Serialize(merged); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForStructUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForStructUnitTests.cs index cb28bd08c..34626ab66 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForStructUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402ForStructUnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402SettingsConfiguration.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402SettingsConfiguration.cs index 1e7d52471..248ed6cea 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402SettingsConfiguration.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402SettingsConfiguration.cs @@ -1,22 +1,22 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.MaintainabilityRules { public enum SA1402SettingsConfiguration { /// - /// Provide no custom settings + /// Provide no custom settings. /// KeepDefaultConfiguration, /// - /// Provide custom settings that configure the tested type as being a top level type + /// Provide custom settings that configure the tested type as being a top-level type. /// ConfigureAsTopLevelType, /// - /// Provide custom settings that configure the tested type as not being a top level type + /// Provide custom settings that configure the tested type as not being a top-level type. /// ConfigureAsNonTopLevelType, } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402SettingsConfigurationExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402SettingsConfigurationExtensions.cs index eafbe5af3..ca9e24fd5 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402SettingsConfigurationExtensions.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402SettingsConfigurationExtensions.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1403UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1403UnitTests.cs index d1fc419ee..95d9a2fa7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1403UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1403UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1404UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1404UnitTests.cs index 9efa19c2f..038030a92 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1404UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1404UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.MaintainabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.MaintainabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.MaintainabilityRules.SA1404CodeAnalysisSuppressionMustHaveJustification, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1405UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1405UnitTests.cs index 2e95b1893..44ec2e3f0 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1405UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1405UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1406UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1406UnitTests.cs index 36be095e4..89078ca66 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1406UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1406UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1407UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1407UnitTests.cs index 016640bad..8902378aa 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1407UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1407UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.MaintainabilityRules.SA1407ArithmeticExpressionsMustDeclarePrecedence, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1408UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1408UnitTests.cs index 39f63cefb..df90c2cfa 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1408UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1408UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.MaintainabilityRules.SA1408ConditionalExpressionsMustDeclarePrecedence, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1409UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1409UnitTests.cs index 97b03305b..77e11f37b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1409UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1409UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1410UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1410UnitTests.cs index 23226e0ec..306ddc796 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1410UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1410UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.MaintainabilityRules.SA1410RemoveDelegateParenthesisWhenPossible, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1411UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1411UnitTests.cs index 9131fc830..486215da4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1411UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1411UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.MaintainabilityRules.SA1411AttributeConstructorMustNotUseUnnecessaryParenthesis, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1412UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1412UnitTests.cs index 18ae1578d..8d0803383 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1412UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1412UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { @@ -8,6 +10,7 @@ namespace StyleCop.Analyzers.Test.MaintainabilityRules using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeFixes; + using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Text; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< @@ -38,12 +41,15 @@ public async Task TestFileWithWrongEncodingAsync(int codepage) var expected = Diagnostic().WithLocation(1, 1); - await new CSharpTest + var test = new CSharpTest { TestSources = { testCode }, ExpectedDiagnostics = { expected }, FixedSources = { fixedCode }, - }.RunAsync(CancellationToken.None).ConfigureAwait(false); + }; + + test.TestBehaviors |= TestBehaviors.SkipSuppressionCheck; + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); } [Fact] @@ -54,12 +60,15 @@ public async Task TestFileWithUtf8EncodingWithoutBOMAsync() var expected = Diagnostic().WithLocation(1, 1); - await new CSharpTest + var test = new CSharpTest { TestSources = { testCode }, ExpectedDiagnostics = { expected }, FixedSources = { fixedCode }, - }.RunAsync(CancellationToken.None).ConfigureAwait(false); + }; + + test.TestBehaviors |= TestBehaviors.SkipSuppressionCheck; + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); } [Theory] @@ -73,7 +82,7 @@ public async Task TestFixAllAsync(int codepage) [Fact] public async Task TestFixAllWithMultipleEncodingsAsync() { - await new CSharpTest + var test = new CSharpTest { TestSources = { @@ -83,9 +92,9 @@ public async Task TestFixAllWithMultipleEncodingsAsync() }, ExpectedDiagnostics = { - Diagnostic().WithLocation("Test0.cs", 1, 1), - Diagnostic().WithLocation("Test1.cs", 1, 1), - Diagnostic().WithLocation("Test2.cs", 1, 1), + Diagnostic().WithLocation("/0/Test0.cs", 1, 1), + Diagnostic().WithLocation("/0/Test1.cs", 1, 1), + Diagnostic().WithLocation("/0/Test2.cs", 1, 1), }, FixedSources = { @@ -95,12 +104,18 @@ public async Task TestFixAllWithMultipleEncodingsAsync() }, NumberOfFixAllIterations = 2, NumberOfFixAllInDocumentIterations = 3, - }.RunAsync(CancellationToken.None).ConfigureAwait(false); + }; + + test.TestBehaviors |= TestBehaviors.SkipSuppressionCheck; + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); } private async Task TestFixAllExecuterAsync(int codepage, FixAllScope scope) { - await new CSharpTest + // Currently unused + _ = scope; + + var test = new CSharpTest { TestSources = { @@ -109,8 +124,8 @@ private async Task TestFixAllExecuterAsync(int codepage, FixAllScope scope) }, ExpectedDiagnostics = { - Diagnostic().WithLocation("Test0.cs", 1, 1), - Diagnostic().WithLocation("Test1.cs", 1, 1), + Diagnostic().WithLocation("/0/Test0.cs", 1, 1), + Diagnostic().WithLocation("/0/Test1.cs", 1, 1), }, FixedSources = { @@ -119,7 +134,10 @@ private async Task TestFixAllExecuterAsync(int codepage, FixAllScope scope) }, NumberOfFixAllIterations = 1, NumberOfFixAllInDocumentIterations = 2, - }.RunAsync(CancellationToken.None).ConfigureAwait(false); + }; + + test.TestBehaviors |= TestBehaviors.SkipSuppressionCheck; + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1413UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1413UnitTests.cs index ea922ab4a..eab0fee6f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1413UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1413UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.MaintainabilityRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.MaintainabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.MaintainabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.MaintainabilityRules.SA1413UseTrailingCommasInMultiLineInitializers, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1300UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1300UnitTests.cs index 6ab51355c..2146b87cd 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1300UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1300UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.NamingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.NamingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.Helpers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.NamingRules.SA1300ElementMustBeginWithUpperCaseLetter, @@ -44,6 +45,31 @@ public async Task TestLowerCaseNamespaceAsync() await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } + [Fact] + public async Task TestAllowedLowerCaseNamespaceIsNotReportedAsync() + { + var customTestSettings = @" +{ + ""settings"": { + ""namingRules"": { + ""allowedNamespaceComponents"": [ ""eBay"" ] + } + } +} +"; + + var testCode = @"namespace eBay +{ + +}"; + + await new CSharpTest + { + TestCode = testCode, + Settings = customTestSettings, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + [Fact] public async Task TestLowerCaseComlicatedNamespaceAsync() { @@ -67,6 +93,31 @@ public async Task TestLowerCaseComlicatedNamespaceAsync() await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } + [Fact] + public async Task TestAllowedLowerCaseComplicatedNamespaceIsNotReportedAsync() + { + var customTestSettings = @" +{ + ""settings"": { + ""namingRules"": { + ""allowedNamespaceComponents"": [ ""iPod"" ] + } + } +} +"; + + var testCode = @"namespace Apple.iPod.Library +{ + +}"; + + await new CSharpTest + { + TestCode = testCode, + Settings = customTestSettings, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + [Fact] public async Task TestUpperCaseClassAsync() { @@ -931,5 +982,30 @@ public async Task TestUnderscoreExclusionAsync() await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } + + [Theory] + [InlineData("_")] + [InlineData("__")] + [WorkItem(3636, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3636")] + public async Task TestUnderscoreMethodAsync(string name) + { + var testCode = $@" +public class TestClass +{{ + public void [|{name}|]() + {{ + }} +}}"; + + var fixedCode = $@" +public class TestClass +{{ + public void [|{name}|]() + {{ + }} +}}"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1301UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1301UnitTests.cs index 1de0e7012..29f9637f4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1301UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1301UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.NamingRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1302UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1302UnitTests.cs index 1cbbea869..631c7a761 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1302UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1302UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.NamingRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.NamingRules.SA1302InterfaceNamesMustBeginWithI, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1303UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1303UnitTests.cs index d6db79c9e..3d9f096a6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1303UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1303UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.NamingRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.NamingRules.SA1303ConstFieldNamesMustBeginWithUpperCaseLetter, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1304UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1304UnitTests.cs index 754afb845..75d7314dc 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1304UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1304UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.NamingRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.NamingRules.SA1304NonPrivateReadonlyFieldsMustBeginWithUpperCaseLetter, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1305UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1305UnitTests.cs index 762ad755c..fb10c4f40 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1305UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1305UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.NamingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.NamingRules using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1306UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1306UnitTests.cs index 8900225bf..331940be1 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1306UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1306UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.NamingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.NamingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.NamingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.NamingRules.SA1306FieldNamesMustBeginWithLowerCaseLetter, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1307UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1307UnitTests.cs index 1bc8a9dde..a54606a8a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1307UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1307UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.NamingRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.NamingRules.SA1307AccessibleFieldsMustBeginWithUpperCaseLetter, @@ -150,6 +151,23 @@ public async Task TestThatDiagnosticIsReported_MultipleFieldsWithConflictAsync(s await test.RunAsync(CancellationToken.None).ConfigureAwait(false); } + [Fact] + public async Task TestFieldStartingWithVerbatimIdentifierAsync() + { + var testCode = @"public class Foo +{ + public string @bar = ""baz""; +}"; + + var fixedCode = @"public class Foo +{ + public string Bar = ""baz""; +}"; + + var expected = Diagnostic().WithArguments("bar").WithLocation(3, 19); + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + [Fact] public async Task TestFieldStartingWithAnUnderscoreAsync() { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1308UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1308UnitTests.cs index 191c5a993..ff60a28e6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1308UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1308UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.NamingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.NamingRules using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.NamingRules.SA1308VariableNamesMustNotBePrefixed, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1309UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1309UnitTests.cs index ecc38f331..f5eed87ba 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1309UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1309UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.NamingRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.NamingRules.SA1309FieldNamesMustNotBeginWithUnderscore, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1310UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1310UnitTests.cs index 028846e37..02240e3bc 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1310UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1310UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.NamingRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.NamingRules.SA1310FieldNamesMustNotContainUnderscore, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1311UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1311UnitTests.cs index 89d5a4ec3..c935dd76d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1311UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1311UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.NamingRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.NamingRules.SA1311StaticReadonlyFieldsMustBeginWithUpperCaseLetter, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1312UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1312UnitTests.cs index 3659d220d..24d942c61 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1312UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1312UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.NamingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.NamingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.Helpers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.NamingRules.SA1312VariableNamesMustBeginWithLowerCaseLetter, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1313UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1313UnitTests.cs index 04dc617f2..216a0e9b8 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1313UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1313UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.NamingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.NamingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.Test.Helpers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.NamingRules.SA1313ParameterNamesMustBeginWithLowerCaseLetter, @@ -276,6 +277,57 @@ public void Method(int Param1, int param2, int Other) await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); } + [Fact] + [WorkItem(3555, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3555")] + public async Task TestNoViolationOnExplicitlyImplementedInterfaceParameterNameAsync() + { + var testCode = @" +public interface ITest +{ + void Method(int param1, int {|#0:Param2|}); +} + +public class Test : ITest +{ + void ITest.Method(int param1, int Param2) + { + } +}"; + + var expected = new[] + { + Diagnostic().WithLocation(0).WithArguments("Param2"), + }; + + await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3555, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3555")] + public async Task TestViolationOnRenamedExplicitlyImplementedInterfaceParameterNameAsync() + { + var testCode = @" +public interface ITest +{ + void Method(int param1, int {|#0:Param2|}); +} + +public class Test : ITest +{ + public void Method(int param1, int {|#1:Other|}) + { + } +}"; + + var expected = new[] + { + Diagnostic().WithLocation(0).WithArguments("Param2"), + Diagnostic().WithLocation(1).WithArguments("Other"), + }; + + await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); + } + [Fact] public async Task TestNoViolationOnAbstractParameterNameAsync() { @@ -560,7 +612,14 @@ public override void TestMethod(int p1, X int P2) } } "; - DiagnosticResult[] expected = + DiagnosticResult[] expected = this.GetInvalidMethodOverrideShouldNotProduceDiagnosticAsyncDiagnostics(); + + await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); + } + + protected virtual DiagnosticResult[] GetInvalidMethodOverrideShouldNotProduceDiagnosticAsyncDiagnostics() + { + return new DiagnosticResult[] { DiagnosticResult.CompilerError("CS0534").WithLocation(9, 18).WithMessage("'TestClass' does not implement inherited abstract member 'BaseClass.TestMethod(int, int)'"), DiagnosticResult.CompilerError("CS0115").WithLocation(11, 30).WithMessage("'TestClass.TestMethod(int, X, int)': no suitable method found to override"), @@ -568,8 +627,6 @@ public override void TestMethod(int p1, X int P2) DiagnosticResult.CompilerError("CS1001").WithLocation(11, 51).WithMessage("Identifier expected"), DiagnosticResult.CompilerError("CS1003").WithLocation(11, 51).WithMessage("Syntax error, ',' expected"), }; - - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1314UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1314UnitTests.cs index 95d576944..929c0c88d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1314UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SA1314UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.NamingRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.NamingRules.SA1314TypeParameterNamesMustBeginWithT, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SX1309SUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SX1309SUnitTests.cs index d1e0675b7..cfa473626 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SX1309SUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SX1309SUnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.NamingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.NamingRules using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.NamingRules.SX1309SStaticFieldNamesMustBeginWithUnderscore, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SX1309UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SX1309UnitTests.cs index d4c8a71c7..dbc9f791a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SX1309UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/NamingRules/SX1309UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.NamingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.NamingRules using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.NamingRules.SX1309FieldNamesMustBeginWithUnderscore, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/CombinedUsingDirectivesVerifier.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/CombinedUsingDirectivesVerifier.cs index 60c1608a8..9bc537866 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/CombinedUsingDirectivesVerifier.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/CombinedUsingDirectivesVerifier.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { @@ -9,7 +11,6 @@ namespace StyleCop.Analyzers.Test.OrderingRules using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.OrderingRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; internal static class CombinedUsingDirectivesVerifier { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1200OutsideNamespaceUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1200OutsideNamespaceUnitTests.cs index 6b3c35dbe..d309d6adc 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1200OutsideNamespaceUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1200OutsideNamespaceUnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { @@ -10,7 +12,6 @@ namespace StyleCop.Analyzers.Test.OrderingRules using StyleCop.Analyzers.OrderingRules; using StyleCop.Analyzers.Settings.ObjectModel; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; /// @@ -19,7 +20,7 @@ namespace StyleCop.Analyzers.Test.OrderingRules /// public class SA1200OutsideNamespaceUnitTests { - private const string TestSettings = @" + protected const string TestSettings = @" { ""settings"": { ""orderingRules"": { @@ -235,7 +236,7 @@ namespace TestNamespace public async Task TestFileHeaderIsProperlyPreservedWhenMovingUsingStatementsAsync() { var testCode = @"// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace TestNamespace { @@ -243,7 +244,7 @@ namespace TestNamespace } "; var fixedTestCode = @"// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. using System; @@ -264,7 +265,7 @@ namespace TestNamespace public async Task TestFileHeaderIsProperlyPreservedWhenMovingUsingStatementsWithCommentsAsync() { var testCode = @"// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace TestNamespace { @@ -276,7 +277,7 @@ namespace TestNamespace } "; var fixedTestCode = @"// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. // Separated Comment @@ -298,10 +299,60 @@ namespace TestNamespace await VerifyCSharpFixAsync(testCode, expectedResults, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } - private static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) + [Fact] + [WorkItem(2928, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2928")] + public async Task TestMovingValueTupleAliasOutsideAsync() + { + var testCode = @"using System; + +namespace MyNamespace +{ + using QuotesRange = ValueTuple; + + public class QuoteType + { + } + + public class UseClass + { + private void Test() + { + QuotesRange t; + } + } +} +"; + var fixedTestCode = @"using System; +using QuotesRange = System.ValueTuple; + +namespace MyNamespace +{ + public class QuoteType + { + } + + public class UseClass + { + private void Test() + { + QuotesRange t; + } + } +} +"; + + DiagnosticResult[] expectedResults = + { + Diagnostic(SA1200UsingDirectivesMustBePlacedCorrectly.DescriptorOutside).WithLocation(5, 5), + }; + + await VerifyCSharpFixAsync(testCode, expectedResults, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + } + + protected static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) => StyleCopCodeFixVerifier.Diagnostic(descriptor); - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) + protected static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) { var test = new StyleCopCodeFixVerifier.CSharpTest { @@ -313,7 +364,7 @@ private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[ return test.RunAsync(cancellationToken); } - private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expected, string fixedSource, CancellationToken cancellationToken) + protected static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expected, string fixedSource, CancellationToken cancellationToken) { var test = new StyleCopCodeFixVerifier.CSharpTest { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1200PreserveUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1200PreserveUnitTests.cs index 3ca7e0649..747a6f0f1 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1200PreserveUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1200PreserveUnitTests.cs @@ -1,16 +1,16 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { using System.Threading; using System.Threading.Tasks; - using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.OrderingRules; using StyleCop.Analyzers.Settings.ObjectModel; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; /// @@ -19,7 +19,7 @@ namespace StyleCop.Analyzers.Test.OrderingRules /// public class SA1200PreserveUnitTests { - private const string TestSettings = @" + protected const string TestSettings = @" { ""settings"": { ""orderingRules"": { @@ -126,27 +126,11 @@ namespace TestNamespace await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } - private static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) - => StyleCopCodeFixVerifier.Diagnostic(descriptor); - - private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) - { - var test = new StyleCopCodeFixVerifier.CSharpTest - { - TestCode = source, - Settings = TestSettings, - }; - - test.ExpectedDiagnostics.AddRange(expected); - return test.RunAsync(cancellationToken); - } - - private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expected, string fixedSource, CancellationToken cancellationToken) + protected static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) { var test = new StyleCopCodeFixVerifier.CSharpTest { TestCode = source, - FixedCode = fixedSource, Settings = TestSettings, }; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1200UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1200UnitTests.cs index e0f8a2f69..3b4146da7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1200UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1200UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.OrderingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.OrderingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.OrderingRules.SA1200UsingDirectivesMustBePlacedCorrectly, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1201UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1201UnitTests.cs index 0fa545e85..745de4f8b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1201UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1201UnitTests.cs @@ -1,16 +1,14 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.OrderingRules { + using System.Collections.Generic; + using System.Linq; using System.Threading; using System.Threading.Tasks; - - using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Testing; - using Microsoft.CodeAnalysis.Text; - - using TestHelper; + using StyleCop.Analyzers.Test.Helpers; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< @@ -19,6 +17,20 @@ namespace StyleCop.Analyzers.Test.OrderingRules public class SA1201UnitTests { + public static IEnumerable ValueTypesAndReferenceTypes + { + get + { + foreach (var valueTypeKeyword in CommonMemberData.ValueTypeDeclarationKeywords) + { + foreach (var referenceTypeKeyword in CommonMemberData.ReferenceTypeDeclarationKeywords) + { + yield return new object[] { valueTypeKeyword.Single(), referenceTypeKeyword.Single() }; + } + } + } + } + [Fact] public async Task TestOuterOrderCorrectOrderAsync() { @@ -55,6 +67,35 @@ public struct FooStruct { } await VerifyCSharpDiagnosticAsync("namespace OuterNamespace { " + testCode + " }", expected, CancellationToken.None).ConfigureAwait(false); } + [Theory] + [MemberData(nameof(ValueTypesAndReferenceTypes))] + public async Task TestClassBeforeStructAsync( + string structKeyword, + string classKeyword) + { + string testCode = $@" +public {classKeyword} FooClass {{ }} +public {structKeyword} {{|#0:FooStruct|}} {{ }} +"; + string fixedCode = $@"public {structKeyword} FooStruct {{ }} + +public {classKeyword} FooClass {{ }} +"; + + var reportedClassKind = classKeyword switch + { + "record class" => "record", + _ => classKeyword, + }; + + var expected = new[] + { + Diagnostic().WithLocation(0).WithArguments(structKeyword, reportedClassKind), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + [Fact] public async Task TestTypeMemberOrderCorrectOrderClassAsync() { @@ -285,8 +326,11 @@ public string // We don't care about the syntax errors. var expected = new[] { - DiagnosticResult.CompilerError("CS1585").WithLocation(5, 5).WithMessage("Member modifier 'public' must precede the member type and name"), - DiagnosticResult.CompilerError("CS1519").WithLocation(6, 1).WithMessage("Invalid token '}' in class, struct, or interface member declaration"), + // /0/Test0.cs(5,5): error CS1585: Member modifier 'public' must precede the member type and name + DiagnosticResult.CompilerError("CS1585").WithLocation(5, 5).WithArguments("public"), + + // /0/Test0.cs(6,1): error CS1519: Invalid token '}' in class, record, struct, or interface member declaration + DiagnosticResult.CompilerError("CS1519").WithLocation(6, 1).WithArguments("}"), }; await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1202UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1202UnitTests.cs index 9177b7be7..8d27bfcd2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1202UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1202UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { @@ -7,7 +9,7 @@ namespace StyleCop.Analyzers.Test.OrderingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.OrderingRules; - using TestHelper; + using StyleCop.Analyzers.Test.Helpers; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.OrderingRules.SA1202ElementsMustBeOrderedByAccess, @@ -102,20 +104,22 @@ private class TestClass10 { } } /// - /// Verifies that the analyzer will properly handle class access levels. + /// Verifies that the analyzer will properly handle type access levels. /// + /// The keyword used to declare the type. /// A representing the asynchronous unit test. - [Fact] - public async Task TestClassOrderingAsync() + [Theory] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task TestTypeOrderingAsync(string keyword) { - var testCode = @"internal class TestClass1 { } -public class TestClass2 { } + var testCode = $@"internal {keyword} TestClass1 {{ }} +public {keyword} {{|#0:TestClass2|}} {{ }} "; - var expected = Diagnostic().WithLocation(2, 14).WithArguments("public", "internal"); + var expected = Diagnostic().WithLocation(0).WithArguments("public", "internal"); - var fixedCode = @"public class TestClass2 { } -internal class TestClass1 { } + var fixedCode = $@"public {keyword} TestClass2 {{ }} +internal {keyword} TestClass1 {{ }} "; await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -124,12 +128,14 @@ internal class TestClass1 { } /// /// Verifies that the analyzer will properly handle interfaces before classes. /// + /// The keyword used to declare the type. /// A representing the asynchronous unit test. - [Fact] - public async Task TestInternalInterfaceBeforePublicClassAsync() + [Theory] + [MemberData(nameof(CommonMemberData.DataTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task TestInternalInterfaceBeforePublicClassAsync(string keyword) { - var testCode = @"internal interface ITestInterface { } -public class TestClass2 { } + var testCode = $@"internal interface ITestInterface {{ }} +public {keyword} TestClass2 {{ }} "; await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); @@ -138,18 +144,20 @@ public class TestClass2 { } /// /// Verifies that the analyzer will properly handle property access levels. /// + /// The keyword used to declare the type. /// A representing the asynchronous unit test. - [Fact] - public async Task TestPropertiesAsync() + [Theory] + [MemberData(nameof(CommonMemberData.ReferenceTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task TestPropertiesOfClassAsync(string keyword) { - var testCode = @"public class TestClass -{ - private string TestProperty1 { get; set; } - protected string TestProperty2 { get; set; } - protected internal string TestProperty3 { get; set; } - internal string TestProperty4 { get; set; } - public string TestProperty5 { get; set; } -} + var testCode = $@"public {keyword} TestClass +{{ + private string TestProperty1 {{ get; set; }} + protected string TestProperty2 {{ get; set; }} + protected internal string TestProperty3 {{ get; set; }} + internal string TestProperty4 {{ get; set; }} + public string TestProperty5 {{ get; set; }} +}} "; DiagnosticResult[] expected = @@ -160,14 +168,48 @@ public async Task TestPropertiesAsync() Diagnostic().WithLocation(7, 19).WithArguments("public", "internal"), }; - var fixedCode = @"public class TestClass -{ - public string TestProperty5 { get; set; } - internal string TestProperty4 { get; set; } - protected internal string TestProperty3 { get; set; } - protected string TestProperty2 { get; set; } - private string TestProperty1 { get; set; } -} + var fixedCode = $@"public {keyword} TestClass +{{ + public string TestProperty5 {{ get; set; }} + internal string TestProperty4 {{ get; set; }} + protected internal string TestProperty3 {{ get; set; }} + protected string TestProperty2 {{ get; set; }} + private string TestProperty1 {{ get; set; }} +}} +"; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that the analyzer will properly handle property access levels. + /// + /// The keyword used to declare the type. + /// A representing the asynchronous unit test. + [Theory] + [MemberData(nameof(CommonMemberData.ValueTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task TestPropertiesOfStructAsync(string keyword) + { + var testCode = $@"public {keyword} TestClass +{{ + private string TestProperty1 {{ get; set; }} + internal string {{|#0:TestProperty4|}} {{ get; set; }} + public string {{|#1:TestProperty5|}} {{ get; set; }} +}} +"; + + DiagnosticResult[] expected = + { + Diagnostic().WithLocation(0).WithArguments("internal", "private"), + Diagnostic().WithLocation(1).WithArguments("public", "internal"), + }; + + var fixedCode = $@"public {keyword} TestClass +{{ + public string TestProperty5 {{ get; set; }} + internal string TestProperty4 {{ get; set; }} + private string TestProperty1 {{ get; set; }} +}} "; await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -643,6 +685,36 @@ class TestClass1 { } await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } + [Fact] + public async Task TestDefaultAccessModifierOrderInCompilationUnitAsync() + { + string testCode = @" +public class Class1 { } +internal class Class2 { } +class Class3 { } +internal class Class4 { } +class Class5 { } +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestDefaultAccessModifierOrderInNamespaceAsync() + { + string testCode = @"namespace Foo +{ + public class Class1 { } + internal class Class2 { } + class Class3 { } + internal class Class4 { } + class Class5 { } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + /// /// Verifies that the analyzer will properly handle static constructors. /// @@ -880,8 +952,11 @@ public string // We don't care about the syntax errors. var expected = new[] { - DiagnosticResult.CompilerError("CS1585").WithMessage("Member modifier 'public' must precede the member type and name").WithLocation(5, 5), - DiagnosticResult.CompilerError("CS1519").WithMessage("Invalid token '}' in class, struct, or interface member declaration").WithLocation(6, 1), + // /0/Test0.cs(5,5): error CS1585: Member modifier 'public' must precede the member type and name + DiagnosticResult.CompilerError("CS1585").WithLocation(5, 5).WithArguments("public"), + + // /0/Test0.cs(6,1): error CS1519: Invalid token '}' in class, record, struct, or interface member declaration + DiagnosticResult.CompilerError("CS1519").WithLocation(6, 1).WithArguments("}"), }; await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); @@ -905,8 +980,11 @@ public string // We don't care about the syntax errors. DiagnosticResult[] expected = { - DiagnosticResult.CompilerError("CS1585").WithMessage("Member modifier 'public' must precede the member type and name").WithLocation(5, 5), - DiagnosticResult.CompilerError("CS1519").WithMessage("Invalid token '}' in class, struct, or interface member declaration").WithLocation(6, 1), + // /0/Test0.cs(5,5): error CS1585: Member modifier 'public' must precede the member type and name + DiagnosticResult.CompilerError("CS1585").WithLocation(5, 5).WithArguments("public"), + + // /0/Test0.cs(6,1): error CS1519: Invalid token '}' in class, record, struct, or interface member declaration + DiagnosticResult.CompilerError("CS1519").WithLocation(6, 1).WithArguments("}"), }; await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1203UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1203UnitTests.cs index 83ff9739d..0a3079770 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1203UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1203UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1204UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1204UnitTests.cs index 96173b859..c9a5b2667 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1204UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1204UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.OrderingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.OrderingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.OrderingRules.SA1204StaticElementsMustAppearBeforeInstanceElements, @@ -545,8 +546,11 @@ public static string // We don't care about the syntax errors. DiagnosticResult[] expected = { - DiagnosticResult.CompilerError("CS1585").WithMessage("Member modifier 'public' must precede the member type and name").WithLocation(5, 5), - DiagnosticResult.CompilerError("CS1519").WithMessage("Invalid token '}' in class, struct, or interface member declaration").WithLocation(6, 1), + // /0/Test0.cs(5,5): error CS1585: Member modifier 'public' must precede the member type and name + DiagnosticResult.CompilerError("CS1585").WithLocation(5, 5).WithArguments("public"), + + // /0/Test0.cs(6,1): error CS1519: Invalid token '}' in class, record, struct, or interface member declaration + DiagnosticResult.CompilerError("CS1519").WithLocation(6, 1).WithArguments("}"), }; await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1205UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1205UnitTests.cs index 18f06dc46..9c2a59b84 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1205UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1205UnitTests.cs @@ -1,12 +1,16 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.OrderingRules; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< @@ -45,6 +49,27 @@ public static IEnumerable ValidDeclarations yield return new object[] { "class" }; yield return new object[] { "struct" }; yield return new object[] { "interface" }; + if (LightupHelpers.SupportsCSharp9) + { + yield return new object[] { "public partial record" }; + yield return new object[] { "internal partial record" }; + yield return new object[] { "public sealed partial record" }; + yield return new object[] { "internal sealed partial record" }; + yield return new object[] { "record" }; + } + + if (LightupHelpers.SupportsCSharp10) + { + yield return new object[] { "public partial record class" }; + yield return new object[] { "internal partial record class" }; + yield return new object[] { "public sealed partial record class" }; + yield return new object[] { "internal sealed partial record class" }; + yield return new object[] { "record class" }; + + yield return new object[] { "public partial record struct" }; + yield return new object[] { "internal partial record struct" }; + yield return new object[] { "record struct" }; + } } } @@ -57,6 +82,19 @@ public static IEnumerable InvalidDeclarations yield return new object[] { "static partial class" }; yield return new object[] { "partial struct" }; yield return new object[] { "partial interface" }; + if (LightupHelpers.SupportsCSharp9) + { + yield return new object[] { "partial record" }; + yield return new object[] { "sealed partial record" }; + } + + if (LightupHelpers.SupportsCSharp10) + { + yield return new object[] { "partial record class" }; + yield return new object[] { "sealed partial record class" }; + + yield return new object[] { "partial record struct" }; + } } } @@ -81,6 +119,40 @@ public static IEnumerable ValidNestedDeclarations yield return new object[] { "internal", "interface" }; yield return new object[] { "protected internal", "interface" }; yield return new object[] { "private", "interface" }; + + if (LightupHelpers.SupportsCSharp72) + { + yield return new object[] { "private protected", "class" }; + yield return new object[] { "private protected", "struct" }; + yield return new object[] { "private protected", "interface" }; + } + + if (LightupHelpers.SupportsCSharp9) + { + yield return new object[] { "public", "record" }; + yield return new object[] { "protected", "record" }; + yield return new object[] { "internal", "record" }; + yield return new object[] { "protected internal", "record" }; + yield return new object[] { "private", "record" }; + yield return new object[] { "private protected", "record" }; + } + + if (LightupHelpers.SupportsCSharp10) + { + yield return new object[] { "public", "record class" }; + yield return new object[] { "protected", "record class" }; + yield return new object[] { "internal", "record class" }; + yield return new object[] { "protected internal", "record class" }; + yield return new object[] { "private", "record class" }; + yield return new object[] { "private protected", "record class" }; + + yield return new object[] { "public", "record struct" }; + yield return new object[] { "protected", "record struct" }; + yield return new object[] { "internal", "record struct" }; + yield return new object[] { "protected internal", "record struct" }; + yield return new object[] { "private", "record struct" }; + yield return new object[] { "private protected", "record struct" }; + } } } @@ -202,7 +274,14 @@ internal static partial class TestPartial }} "; - await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + var languageVersion = (LightupHelpers.SupportsCSharp8, LightupHelpers.SupportsCSharp72) switch + { + // Make sure to use C# 7.2 if supported, unless we are going to default to something greater + (false, true) => LanguageVersionEx.CSharp7_2, + _ => (LanguageVersion?)null, + }; + + await VerifyCSharpDiagnosticAsync(languageVersion, testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } /// @@ -271,7 +350,14 @@ public class Foo }} "; - await VerifyCSharpFixAsync(testCode, Diagnostic().WithLocation(8, 14 + typeKeyword.Length), fixedTestCode, CancellationToken.None).ConfigureAwait(false); + var languageVersion = (LightupHelpers.SupportsCSharp8, LightupHelpers.SupportsCSharp72) switch + { + // Make sure to use C# 7.2 if supported, unless we are going to default to something greater + (false, true) => LanguageVersionEx.CSharp7_2, + _ => (LanguageVersion?)null, + }; + + await VerifyCSharpFixAsync(languageVersion, testCode, Diagnostic().WithLocation(8, 14 + typeKeyword.Length), fixedTestCode, CancellationToken.None).ConfigureAwait(false); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1206CodeFixProviderUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1206CodeFixProviderUnitTests.cs index 622b86851..1a0a97353 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1206CodeFixProviderUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1206CodeFixProviderUnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.OrderingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.OrderingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.OrderingRules.SA1206DeclarationKeywordsMustFollowOrder, @@ -116,7 +117,6 @@ public async Task VerifyKeywordReorderingInMethodDeclarationAsync() DiagnosticResult[] expected = { Diagnostic().WithLocation(1, 38).WithArguments("static", "new"), - Diagnostic().WithLocation(1, 45).WithArguments("public", "static"), Diagnostic().WithLocation(1, 45).WithArguments("public", "new"), }; await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1206UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1206UnitTests.cs index 465eec17f..b7a3d37ca 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1206UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1206UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.OrderingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.OrderingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.OrderingRules.SA1206DeclarationKeywordsMustFollowOrder, @@ -40,7 +41,6 @@ public async Task TestKeywordsWithExpressionBodiedMemberAndAsyncKeywordAsync() DiagnosticResult[] expected = new[] { Diagnostic().WithLocation(3, 11).WithArguments("static", "async"), - Diagnostic().WithLocation(3, 18).WithArguments("public", "static"), Diagnostic().WithLocation(3, 18).WithArguments("public", "async"), }; @@ -75,7 +75,6 @@ static public void ThirdMethod() {} Diagnostic().WithLocation(7, 32).WithArguments("protected", "async"), Diagnostic().WithLocation(8, 16).WithArguments("static", "new"), Diagnostic().WithLocation(9, 9).WithArguments("static", "new"), - Diagnostic().WithLocation(9, 16).WithArguments("public", "static"), Diagnostic().WithLocation(9, 16).WithArguments("public", "new"), Diagnostic().WithLocation(10, 13).WithArguments("public", "virtual"), Diagnostic().WithLocation(11, 12).WithArguments("public", "extern"), @@ -160,7 +159,6 @@ public async Task TestKeywordsWithOperatorDeclarationsAsync() Diagnostic().WithLocation(3, 12).WithArguments("public", "extern"), Diagnostic().WithLocation(3, 19).WithArguments("static", "extern"), Diagnostic().WithLocation(4, 12).WithArguments("static", "extern"), - Diagnostic().WithLocation(4, 19).WithArguments("public", "static"), Diagnostic().WithLocation(4, 19).WithArguments("public", "extern"), Diagnostic().WithLocation(5, 19).WithArguments("static", "extern"), }; @@ -194,7 +192,8 @@ public async Task TestWithIncompleteMembersAsync() DiagnosticResult[] expected = { - DiagnosticResult.CompilerError("CS1519").WithMessage("Invalid token '}' in class, struct, or interface member declaration").WithLocation(4, 1), + // /0/Test0.cs(4,1): error CS1519: Invalid token '}' in class, record, struct, or interface member declaration + DiagnosticResult.CompilerError("CS1519").WithSpan(4, 1, 4, 2).WithArguments("}"), }; await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1207UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1207UnitTests.cs index 9294c2e4c..342a7ff3b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1207UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1207UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { @@ -129,7 +131,8 @@ public async Task TestInvalidDeclarationAsync(string invalidDeclaration, int dia var testCode = TestCodeTemplate.Replace("$$", invalidDeclaration); var fixedTestCode = TestCodeTemplate.Replace("$$", fixedDeclaration); - await VerifyCSharpFixAsync(testCode, Diagnostic().WithLocation(4, 4 + diagnosticColumn), fixedTestCode, CancellationToken.None).ConfigureAwait(false); + DiagnosticResult expected = Diagnostic().WithArguments("protected", "internal").WithLocation(4, 4 + diagnosticColumn); + await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1208UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1208UnitTests.cs index 6ab391999..bfd65002c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1208UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1208UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.OrderingRules.SA1208SystemUsingDirectivesMustBePlacedBeforeOtherUsingDirectives, @@ -78,9 +79,9 @@ class A }, ExpectedDiagnostics = { - Diagnostic().WithLocation("Test2.cs", 2, 1).WithArguments("System", "Xyz"), - Diagnostic().WithLocation("Test2.cs", 3, 1).WithArguments("System.IO", "Xyz"), - Diagnostic().WithLocation("Test2.cs", 5, 1).WithArguments("System.Threading.Tasks", "Xyz"), + Diagnostic().WithLocation("/0/Test2.cs", 2, 1).WithArguments("System", "Xyz"), + Diagnostic().WithLocation("/0/Test2.cs", 3, 1).WithArguments("System.IO", "Xyz"), + Diagnostic().WithLocation("/0/Test2.cs", 5, 1).WithArguments("System.Threading.Tasks", "Xyz"), }, }.RunAsync(CancellationToken.None).ConfigureAwait(false); } @@ -108,8 +109,8 @@ class A }, ExpectedDiagnostics = { - Diagnostic().WithLocation("Test2.cs", 4, 5).WithArguments("System.Threading", "Namespace"), - Diagnostic().WithLocation("Test2.cs", 5, 5).WithArguments("System.IO", "Namespace"), + Diagnostic().WithLocation("/0/Test2.cs", 4, 5).WithArguments("System.Threading", "Namespace"), + Diagnostic().WithLocation("/0/Test2.cs", 5, 5).WithArguments("System.IO", "Namespace"), }, }.RunAsync(CancellationToken.None).ConfigureAwait(false); } @@ -141,9 +142,9 @@ class A }, ExpectedDiagnostics = { - Diagnostic().WithLocation("Test3.cs", 2, 1).WithArguments("System.IO", "AnotherNamespace"), - Diagnostic().WithLocation("Test3.cs", 8, 5).WithArguments("System.Threading", "Xyz"), - Diagnostic().WithLocation("Test3.cs", 9, 5).WithArguments("System", "Xyz"), + Diagnostic().WithLocation("/0/Test3.cs", 2, 1).WithArguments("System.IO", "AnotherNamespace"), + Diagnostic().WithLocation("/0/Test3.cs", 8, 5).WithArguments("System.Threading", "Xyz"), + Diagnostic().WithLocation("/0/Test3.cs", 9, 5).WithArguments("System", "Xyz"), }, }.RunAsync(CancellationToken.None).ConfigureAwait(false); } @@ -175,7 +176,7 @@ class A }, ExpectedDiagnostics = { - Diagnostic().WithLocation("Test3.cs", 8, 5).WithArguments("System.Threading", "Xyz"), + Diagnostic().WithLocation("/0/Test3.cs", 8, 5).WithArguments("System.Threading", "Xyz"), }, }.RunAsync(CancellationToken.None).ConfigureAwait(false); } @@ -216,7 +217,7 @@ class A }, ExpectedDiagnostics = { - Diagnostic().WithLocation("Test2.cs", 6, 5).WithArguments("System.IO", "System.IO.Path"), + Diagnostic().WithLocation("/0/Test2.cs", 6, 5).WithArguments("System.IO", "System.IO.Path"), }, }.RunAsync(CancellationToken.None).ConfigureAwait(false); } @@ -271,7 +272,7 @@ class A }, ExpectedDiagnostics = { - Diagnostic().WithLocation("Test2.cs", 5, 5).WithArguments("System.Threading", "Namespace"), + Diagnostic().WithLocation("/0/Test2.cs", 5, 5).WithArguments("System.Threading", "Namespace"), }, }.RunAsync(CancellationToken.None).ConfigureAwait(false); } @@ -299,8 +300,8 @@ class A }, ExpectedDiagnostics = { - Diagnostic().WithLocation("Test2.cs", 4, 5).WithArguments("System.Threading", "Namespace"), - Diagnostic().WithLocation("Test2.cs", 5, 5).WithArguments("System.IO", "Namespace"), + Diagnostic().WithLocation("/0/Test2.cs", 4, 5).WithArguments("System.Threading", "Namespace"), + Diagnostic().WithLocation("/0/Test2.cs", 5, 5).WithArguments("System.IO", "Namespace"), }, }.RunAsync(CancellationToken.None).ConfigureAwait(false); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1209UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1209UnitTests.cs index 7b006e5b0..035501346 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1209UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1209UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.OrderingRules.SA1209UsingAliasDirectivesMustBePlacedAfterOtherUsingDirectives, @@ -136,7 +137,7 @@ class A } }"; - DiagnosticResult expected = Diagnostic().WithLocation("Test0.cs", 2, 1); + DiagnosticResult expected = Diagnostic().WithLocation("/0/Test0.cs", 2, 1); await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } @@ -188,7 +189,7 @@ class A } }"; - DiagnosticResult expected = Diagnostic().WithLocation("Test0.cs", 4, 5); + DiagnosticResult expected = Diagnostic().WithLocation("/0/Test0.cs", 4, 5); await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } @@ -222,7 +223,7 @@ class A } }"; - DiagnosticResult expected = Diagnostic().WithLocation("Test0.cs", 4, 5); + DiagnosticResult expected = Diagnostic().WithLocation("/0/Test0.cs", 4, 5); await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1210CombinedSystemDirectivesUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1210CombinedSystemDirectivesUnitTests.cs index d3726b976..2d1bc8a31 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1210CombinedSystemDirectivesUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1210CombinedSystemDirectivesUnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { @@ -9,7 +11,6 @@ namespace StyleCop.Analyzers.Test.OrderingRules using StyleCop.Analyzers.OrderingRules; using StyleCop.Analyzers.Settings.ObjectModel; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.CustomDiagnosticVerifier; @@ -19,6 +20,16 @@ namespace StyleCop.Analyzers.Test.OrderingRules /// public class SA1210CombinedSystemDirectivesUnitTests { + protected const string CombinedUsingDirectivesTestSettings = @" +{ + ""settings"": { + ""orderingRules"": { + ""systemUsingDirectivesFirst"": false + } + } +} +"; + [Fact] public async Task TestProperOrderedUsingDirectivesInNamespaceDeclarationAsync() { @@ -213,16 +224,6 @@ private static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[ private static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expected, string fixedSource, CancellationToken cancellationToken) { - const string CombinedUsingDirectivesTestSettings = @" -{ - ""settings"": { - ""orderingRules"": { - ""systemUsingDirectivesFirst"": false - } - } -} -"; - var test = new StyleCopCodeFixVerifier.CSharpTest { TestCode = source, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1210UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1210UnitTests.cs index ba587cfdd..cb04e58a3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1210UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1210UnitTests.cs @@ -1,14 +1,14 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { - using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.OrderingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.OrderingRules.SA1210UsingDirectivesMustBeOrderedAlphabeticallyByNamespace, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1211UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1211UnitTests.cs index 1d4be00ef..a616b7d6c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1211UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1211UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.OrderingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.OrderingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.OrderingRules.SA1211UsingAliasDirectivesMustBeOrderedAlphabeticallyByAliasName, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1212UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1212UnitTests.cs index 0134a9099..987e709b2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1212UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1212UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.OrderingRules.SA1212PropertyAccessorsMustFollowOrder, @@ -338,7 +339,7 @@ public int Prop } [Fact] - public async Task TestAutoPropertydDeclarationSetterBeforeGetterAsync() + public async Task TestAutoPropertyDeclarationSetterBeforeGetterAsync() { var testCode = @" public class Foo diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1213UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1213UnitTests.cs index bae5bfd80..108d17801 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1213UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1213UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.OrderingRules.SA1213EventAccessorsMustFollowOrder, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1214UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1214UnitTests.cs index 814dbf97d..ff7f98063 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1214UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1214UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1215UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1215UnitTests.cs index ac44ea68e..0203087a2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1215UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1215UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.OrderingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.OrderingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.OrderingRules.SA1214ReadonlyElementsMustAppearBeforeNonReadonlyElements, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1216UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1216UnitTests.cs index c8788b98e..a50510fa2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1216UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1216UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.OrderingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.OrderingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.OrderingRules.SA1216UsingStaticDirectivesMustBePlacedAtTheCorrectLocation, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1217UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1217UnitTests.cs index c563d0bd1..e0b800f65 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1217UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/SA1217UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { @@ -7,17 +9,36 @@ namespace StyleCop.Analyzers.Test.OrderingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.OrderingRules; - using TestHelper; + using StyleCop.Analyzers.Test.Verifiers; using Xunit; - using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< - StyleCop.Analyzers.OrderingRules.SA1217UsingStaticDirectivesMustBeOrderedAlphabetically, - StyleCop.Analyzers.OrderingRules.UsingCodeFixProvider>; /// /// Unit tests for . /// public class SA1217UnitTests { + private const string TestSettings = @" +{ + ""settings"": { + ""orderingRules"": { + ""systemUsingDirectivesFirst"": true + } + } +} +"; + + private const string TestSettingsNoSystemDirectivesFirst = @" +{ + ""settings"": { + ""orderingRules"": { + ""systemUsingDirectivesFirst"": false + } + } +} +"; + + private bool useSystemUsingDirectivesFirst; + /// /// Verifies that the analyzer will not produce diagnostics for correctly ordered using directives inside a namespace. /// @@ -34,7 +55,7 @@ public async Task TestValidUsingDirectivesInNamespaceAsync() } "; - await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + await this.VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } /// @@ -61,7 +82,7 @@ namespace Bar } "; - await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + await this.VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } /// @@ -81,7 +102,7 @@ public class Foo } "; - await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + await this.VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } /// @@ -131,7 +152,7 @@ namespace Bar Diagnostic().WithLocation(11, 5).WithArguments("System.Math", "System.Array"), }; - await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + await this.VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } /// @@ -150,7 +171,7 @@ public async Task TestValidUsingDirectivesWithInlineCommentsAsync() } "; - await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + await this.VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } /// @@ -178,9 +199,12 @@ public async Task TestInvalidUsingDirectivesWithGlobalPrefixAsync() } "; - var expectedDiagnostic = Diagnostic().WithLocation(5, 5).WithArguments("System.Math", "global::System.Array"); + DiagnosticResult[] expectedDiagnostic = + { + Diagnostic().WithLocation(5, 5).WithArguments("System.Math", "global::System.Array"), + }; - await VerifyCSharpFixAsync(testCode, expectedDiagnostic, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + await this.VerifyCSharpFixAsync(testCode, expectedDiagnostic, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } /// @@ -191,8 +215,8 @@ public async Task TestInvalidUsingDirectivesWithGlobalPrefixAsync() public async Task TestPreprocessorDirectivesAsync() { var testCode = @" -using System; using Microsoft.Win32; +using System; using MyList = System.Collections.Generic.List; using static System.Tuple; @@ -205,8 +229,8 @@ public async Task TestPreprocessorDirectivesAsync() #endif"; var fixedTestCode = @" -using System; using Microsoft.Win32; +using System; using static System.Tuple; using MyList = System.Collections.Generic.List; @@ -219,9 +243,136 @@ public async Task TestPreprocessorDirectivesAsync() #endif"; // else block is skipped - var expected = Diagnostic().WithLocation(8, 1).WithArguments("System.String", "System.Math"); + DiagnosticResult[] expectedDiagnostic = + { + Diagnostic().WithLocation(8, 1).WithArguments("System.String", "System.Math"), + }; + + await this.VerifyCSharpFixAsync(testCode, expectedDiagnostic, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verify that the systemUsingDirectivesFirst setting is honored correctly. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(2163, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2163")] + public async Task VerifySystemUsingDirectivesFirstAsync() + { + this.useSystemUsingDirectivesFirst = true; + + var testCode = @" +using static MyNamespace.TestClass; +using static System.Math; + +namespace MyNamespace +{ + public static class TestClass + { + public static void TestMethod() + { + } + } +} +"; + + var fixedTestCode = @" +using static System.Math; +using static MyNamespace.TestClass; + +namespace MyNamespace +{ + public static class TestClass + { + public static void TestMethod() + { + } + } +} +"; + + DiagnosticResult[] expectedDiagnostic = + { + Diagnostic().WithLocation(2, 1).WithArguments("MyNamespace.TestClass", "System.Math"), + }; + + await this.VerifyCSharpFixAsync(testCode, expectedDiagnostic, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verify that the systemUsingDirectivesFirst setting is honored correctly when using multiple static system usings. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(2163, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2163")] + public async Task VerifyMultipleStaticSystemUsingDirectivesAsync() + { + this.useSystemUsingDirectivesFirst = true; + + var testCode = @" +using static System.Math; +using static System.Activator; + +namespace MyNamespace +{ + public static class TestClass + { + public static void TestMethod() + { + } + } +} +"; + + var fixedTestCode = @" +using static System.Activator; +using static System.Math; + +namespace MyNamespace +{ + public static class TestClass + { + public static void TestMethod() + { + } + } +} +"; + + DiagnosticResult[] expectedDiagnostic = + { + Diagnostic().WithLocation(2, 1).WithArguments("System.Math", "System.Activator"), + }; + + await this.VerifyCSharpFixAsync(testCode, expectedDiagnostic, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + } + + private static DiagnosticResult Diagnostic() + => StyleCopCodeFixVerifier.Diagnostic(); + + private Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) + { + var test = new StyleCopCodeFixVerifier.CSharpTest + { + TestCode = source, + Settings = this.useSystemUsingDirectivesFirst ? TestSettings : TestSettingsNoSystemDirectivesFirst, + }; + + test.ExpectedDiagnostics.AddRange(expected); + return test.RunAsync(cancellationToken); + } + + private Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expected, string fixedSource, CancellationToken cancellationToken) + { + var test = new StyleCopCodeFixVerifier.CSharpTest + { + TestCode = source, + FixedCode = fixedSource, + Settings = this.useSystemUsingDirectivesFirst ? TestSettings : TestSettingsNoSystemDirectivesFirst, + }; - await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + test.ExpectedDiagnostics.AddRange(expected); + return test.RunAsync(cancellationToken); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/UsingCodeFixProviderCombinedSystemDirectivesUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/UsingCodeFixProviderCombinedSystemDirectivesUnitTests.cs index ee3006c49..12f23d19a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/UsingCodeFixProviderCombinedSystemDirectivesUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/UsingCodeFixProviderCombinedSystemDirectivesUnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { @@ -9,7 +11,6 @@ namespace StyleCop.Analyzers.Test.OrderingRules using StyleCop.Analyzers.OrderingRules; using StyleCop.Analyzers.Settings.ObjectModel; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static CombinedUsingDirectivesVerifier; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/UsingCodeFixProviderGroupSeparationUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/UsingCodeFixProviderGroupSeparationUnitTests.cs index 19fa138e9..82252dccd 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/UsingCodeFixProviderGroupSeparationUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/UsingCodeFixProviderGroupSeparationUnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { @@ -9,7 +11,6 @@ namespace StyleCop.Analyzers.Test.OrderingRules using StyleCop.Analyzers.OrderingRules; using StyleCop.Analyzers.Settings.ObjectModel; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static CombinedUsingDirectivesVerifier; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/UsingCodeFixProviderRegressionUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/UsingCodeFixProviderRegressionUnitTests.cs index 1bae4414d..3e64edbc3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/UsingCodeFixProviderRegressionUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/UsingCodeFixProviderRegressionUnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { @@ -8,7 +10,6 @@ namespace StyleCop.Analyzers.Test.OrderingRules using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.OrderingRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static CombinedUsingDirectivesVerifier; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/UsingCodeFixProviderUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/UsingCodeFixProviderUnitTests.cs index e5007ab64..075e7e5c0 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/UsingCodeFixProviderUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/UsingCodeFixProviderUnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.OrderingRules { @@ -9,7 +11,6 @@ namespace StyleCop.Analyzers.Test.OrderingRules using StyleCop.Analyzers.OrderingRules; using StyleCop.Analyzers.Settings.ObjectModel; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; using static CombinedUsingDirectivesVerifier; @@ -660,14 +661,6 @@ private Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expected, st Settings = testSettings, }; - 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); test.RemainingDiagnostics.AddRange(remainingDiagnostics); return test.RunAsync(cancellationToken); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Properties/AssemblyInfo.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Properties/AssemblyInfo.cs index dfe20d623..99c4753f5 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Properties/AssemblyInfo.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Properties/AssemblyInfo.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable using System; using System.Runtime.CompilerServices; @@ -13,3 +15,8 @@ [assembly: ComVisible(false)] [assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp7, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp8, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp9, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp10, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp11, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp12, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/PublicApiTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/PublicApiTests.cs deleted file mode 100644 index 4254199e8..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/PublicApiTests.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. - -namespace StyleCop.Analyzers.Test -{ - using System; - using System.Text; - using Xunit; - - /// - /// Unit tests related to the public API surface of StyleCop.Analyzers.dll. - /// - public class PublicApiTests - { - /// - /// This test ensures all types in StyleCop.Analyzers.dll are marked internal. - /// - [Fact] - public void TestAllTypesAreInternal() - { - StringBuilder publicTypes = new StringBuilder(); - foreach (Type type in typeof(AnalyzerCategory).Assembly.ExportedTypes) - { - if (publicTypes.Length > 0) - { - publicTypes.Append(", "); - } - - publicTypes.Append(type.Name); - } - - Assert.Equal(string.Empty, publicTypes.ToString()); - } - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1100UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1100UnitTests.cs index dbc2cd263..18f455718 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1100UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1100UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1101UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1101UnitTests.cs index 48ee4c51d..3fc6fde6a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1101UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1101UnitTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.ReadabilityRules { @@ -368,6 +368,194 @@ public class Foo await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } + [Fact] + [WorkItem(2845, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2845")] + public async Task TestExpressionBodiedPropertyAsync() + { + var testCode = @" +public class Foo +{ + private readonly int bar = 0; + + public int Bar => bar; +} +"; + + var fixedCode = @" +public class Foo +{ + private readonly int bar = 0; + + public int Bar => this.bar; +} +"; + + var expected = new[] + { + Diagnostic().WithLocation(6, 23), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2845, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2845")] + public async Task TestPropertyWithInitializerAsync() + { + var testCode = @" +public class Foo +{ + private static int bar = 0; + + public int Bar { get; set; } = bar; +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2845, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2845")] + public async Task TestIndexerAsync() + { + var testCode = @" +public class Foo +{ + private T[] arr = new T[100]; + + public T this[int i] + { + get { return arr[i]; } + set { arr[i] = value; } + } +} +"; + + var fixedCode = @" +public class Foo +{ + private T[] arr = new T[100]; + + public T this[int i] + { + get { return this.arr[i]; } + set { this.arr[i] = value; } + } +} +"; + + var expected = new[] + { + Diagnostic().WithLocation(8, 20), + Diagnostic().WithLocation(9, 13), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2845, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2845")] + public async Task TestExpressionBodiedIndexerAsync() + { + var testCode = @" +public class Foo +{ + private T[] arr = new T[100]; + + public T this[int i] => arr[i]; +} +"; + + var fixedCode = @" +public class Foo +{ + private T[] arr = new T[100]; + + public T this[int i] => this.arr[i]; +} +"; + + var expected = new[] + { + Diagnostic().WithLocation(6, 28), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2845, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2845")] + public async Task TestEventAsync() + { + var testCode = @" +using System; + +public class Foo +{ + private EventHandler bar; + + public event EventHandler Bar + { + add { bar += value; } + remove { bar -= value; } + } +} +"; + + var fixedCode = @" +using System; + +public class Foo +{ + private EventHandler bar; + + public event EventHandler Bar + { + add { this.bar += value; } + remove { this.bar -= value; } + } +} +"; + + var expected = new[] + { + Diagnostic().WithLocation(10, 15), + Diagnostic().WithLocation(11, 18), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2845, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2845")] + public async Task TestExpressionBodiedMethodAsync() + { + var testCode = @" +public class Foo +{ + private readonly object bar; + + public object Bar() => bar; +} +"; + + var fixedCode = @" +public class Foo +{ + private readonly object bar; + + public object Bar() => this.bar; +} +"; + + var expected = new[] + { + Diagnostic().WithLocation(6, 28), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + [Fact] [WorkItem(2799, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2799")] public async Task TestNameofInConstructorCallAsync() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1102UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1102UnitTests.cs index 37fe9882b..9e782c376 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1102UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1102UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.ReadabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA110xQueryClauses, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1103UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1103UnitTests.cs index 9cc4e695d..80287d87d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1103UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1103UnitTests.cs @@ -1,13 +1,15 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA110xQueryClauses, @@ -116,7 +118,7 @@ public void TestMethod() var test = new CSharpTest { TestCode = testCode, - CodeFixIndex = 1, + CodeActionIndex = 1, FixedCode = fixedTestCode, }; @@ -194,7 +196,7 @@ orderby g.Key var test = new CSharpTest { TestCode = testCode, - CodeFixIndex = 1, + CodeActionIndex = 1, FixedCode = fixedTestCode, }; @@ -300,7 +302,7 @@ public void TestMethod() var test = new CSharpTest { TestCode = testCode, - CodeFixIndex = 1, + CodeActionIndex = 1, FixedCode = fixedTestCode, }; @@ -365,5 +367,91 @@ public void TestMethod() await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } + + [Fact] + [WorkItem(2888, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2888")] + public async Task TestQueryExpressionWithMissingSelectAsync() + { + var testCode = @"namespace TestNamespace +{ + using System.Linq; + + public class TestClass + { + private int[] testArray = { 1, 2, 3, 4, 5 }; + + public void TestMethod() + { + var x = from element in testArray + where element > 1; + } + } +} +"; + + var expectedDiagnostics = new DiagnosticResult("CS0742", DiagnosticSeverity.Error).WithLocation(12, 38).WithMessage("A query body must end with a select clause or a group clause"); + await VerifyCSharpFixAsync(testCode, expectedDiagnostics, testCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2888, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2888")] + public async Task TestQueryExpressionWithMissingSelect2Async() + { + var testCode = @"namespace TestNamespace +{ + using System.Linq; + + public class TestClass + { + private int[] testArray = { 1, 2, 3, 4, 5 }; + + public void TestMethod() + { + var x = from element in testArray where element < 3 + where element > 1; + } + } +} +"; + var fixedTestCode = @"namespace TestNamespace +{ + using System.Linq; + + public class TestClass + { + private int[] testArray = { 1, 2, 3, 4, 5 }; + + public void TestMethod() + { + var x = from element in testArray + where element < 3 + where element > 1; + } + } +} +"; + + await new CSharpTest + { + TestState = + { + Sources = { testCode }, + ExpectedDiagnostics = + { + Diagnostic(SA110xQueryClauses.SA1103Descriptor).WithLocation(11, 21), + new DiagnosticResult("CS0742", DiagnosticSeverity.Error).WithLocation(12, 38).WithMessage("A query body must end with a select clause or a group clause"), + }, + }, + FixedState = + { + Sources = { fixedTestCode }, + ExpectedDiagnostics = + { + new DiagnosticResult("CS0742", DiagnosticSeverity.Error).WithLocation(13, 38).WithMessage("A query body must end with a select clause or a group clause"), + }, + }, + CodeActionIndex = 1, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1104UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1104UnitTests.cs index 2e548f3b4..27a371044 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1104UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1104UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.ReadabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA110xQueryClauses, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1105UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1105UnitTests.cs index a1ae62e19..309c617e9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1105UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1105UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.ReadabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA110xQueryClauses, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1106UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1106UnitTests.cs index 7e92ee368..9d71223ab 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1106UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1106UnitTests.cs @@ -1,12 +1,14 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; + using StyleCop.Analyzers.Test.Helpers; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1106CodeMustNotContainEmptyStatements, @@ -307,17 +309,14 @@ public void TestMethod() } [Theory] - [InlineData("class Foo { }")] - [InlineData("struct Foo { }")] - [InlineData("interface IFoo { }")] - [InlineData("enum Foo { }")] - [InlineData("namespace Foo { }")] - public async Task TestMemberAsync(string declaration) + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + [InlineData("namespace")] + public async Task TestMemberAsync(string declarationKeyword) { - var testCode = declaration + ";"; - var fixedCode = declaration; + var testCode = declarationKeyword + " Foo { }{|#0:;|}"; + var fixedCode = declarationKeyword + " Foo { }"; - DiagnosticResult expected = Diagnostic().WithLocation(1, declaration.Length + 1); + DiagnosticResult expected = Diagnostic().WithLocation(0); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1107UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1107UnitTests.cs index 1e7680784..6629acc5f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1107UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1107UnitTests.cs @@ -1,14 +1,14 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { using System.Threading; using System.Threading.Tasks; - using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1107CodeMustNotContainMultipleStatementsOnOneLine, @@ -142,5 +142,31 @@ int i DiagnosticResult expected = DiagnosticResult.CompilerError("CS1002").WithLocation(7, 14).WithMessage("; expected"); await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); } + + [Fact] + [WorkItem(2862, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2862")] + public async Task TestEmptyStatementAfterBlockAsync() + { + string testCode = @" +class Program +{ + static void Main(string[] args) + { + { + }[|;|] + } +} +"; + + await new CSharpTest + { + TestCode = testCode, + FixedCode = testCode, + + // A code fix is offered even though no changes are applied by it + NumberOfIncrementalIterations = 1, + NumberOfFixAllIterations = 1, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1108UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1108UnitTests.cs index aa3d6477b..cfb979267 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1108UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1108UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1109UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1109UnitTests.cs index 9b5fdcd25..4a0dd0c4b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1109UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1109UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1110UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1110UnitTests.cs index 8620e199d..9e1832e8a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1110UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1110UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1110OpeningParenthesisMustBeOnDeclarationLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1111UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1111UnitTests.cs index ac1aa20e9..0283c15bf 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1111UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1111UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1111ClosingParenthesisMustBeOnLineOfLastParameter, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1112UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1112UnitTests.cs index 685897c52..47fdf016c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1112UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1112UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1112ClosingParenthesisMustBeOnLineOfOpeningParenthesis, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1113UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1113UnitTests.cs index 117c1be73..3ec4d09d2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1113UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1113UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1113CommaMustBeOnSameLineAsPreviousParameter, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1114UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1114UnitTests.cs index 9351d6f3c..3093e1fc6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1114UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1114UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1115UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1115UnitTests.cs index 9b5598846..df60b2f4d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1115UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1115UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1116UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1116UnitTests.cs index 5fbfd0c2d..45761dd9e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1116UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1116UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable // Several test methods in this file use the same member data, but in some cases the test does not use all of the // supported parameters. See https://github.com/xunit/xunit/issues/1556. @@ -11,7 +13,6 @@ namespace StyleCop.Analyzers.Test.ReadabilityRules using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1116SplitParametersMustStartOnLineAfterDeclaration, @@ -57,6 +58,10 @@ public static IEnumerable ValidTestExpressions() [MemberData(nameof(GetTestDeclarations), "", "")] public async Task TestValidDeclarationAsync(string declaration, string fixedDeclaration, int column) { + // Not needed for this test + _ = fixedDeclaration; + _ = column; + var testCode = $@" class Foo {{ @@ -87,6 +92,9 @@ class Foo [MemberData(nameof(GetTestConstructorInitializers), "", "")] public async Task TestValidConstructorInitializerAsync(string initializer, string fixedInitializer) { + // Not needed for this test + _ = fixedInitializer; + var testCode = $@" class Base {{ @@ -165,6 +173,10 @@ public Derived(int i, string z) [MemberData(nameof(ValidTestExpressions))] public async Task TestValidExpressionAsync(string expression, string fixedExpression, int column) { + // Not needed for this test + _ = fixedExpression; + _ = column; + var testCode = $@" class Foo {{ diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1117UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1117UnitTests.cs index 490c6687b..ce70484f2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1117UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1117UnitTests.cs @@ -1,9 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. -// Several test methods in this file use the same member data, but in some cases the test does not use all of the -// supported parameters. See https://github.com/xunit/xunit/issues/1556. -#pragma warning disable xUnit1026 // Theory methods should use all of their parameters +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { @@ -11,7 +9,6 @@ namespace StyleCop.Analyzers.Test.ReadabilityRules using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier; @@ -19,36 +16,77 @@ public class SA1117UnitTests { public static IEnumerable GetTestDeclarations(string delimiter) { - yield return new object[] { $"public Foo(int a, int b,{delimiter} string s) {{ }}" }; - yield return new object[] { $"public object Bar(int a, int b,{delimiter} string s) => null;" }; - yield return new object[] { $"public object this[int a, int b,{delimiter} string s] => null;" }; - yield return new object[] { $"public delegate void Bar(int a, int b,{delimiter} string s);" }; + yield return new object[] { $"public Foo(int a, int b,{delimiter} {{|#0:string s|}}) {{ }}" }; + yield return new object[] { $"public object Bar(int a, int b,{delimiter} {{|#0:string s|}}) => null;" }; + yield return new object[] { $"public object this[int a, int b,{delimiter} {{|#0:string s|}}] => null;" }; + yield return new object[] { $"public delegate void Bar(int a, int b,{delimiter} {{|#0:string s|}});" }; + } + + public static IEnumerable GetMultilineTestDeclarations(string delimiter) + { + yield return new object[] { $"public Foo(int a,{delimiter} string\r\ns) {{ }}" }; + yield return new object[] { $"public object Bar(int a,{delimiter} string\r\ns) => null;" }; + yield return new object[] { $"public object this[int a,{delimiter} string\r\ns] => null;" }; + yield return new object[] { $"public delegate void Bar(int a,{delimiter} string\r\ns);" }; } public static IEnumerable GetTestConstructorInitializers(string delimiter) { - yield return new object[] { $"this(42, 43, {delimiter} \"hello\")" }; - yield return new object[] { $"base(42, 43, {delimiter} \"hello\")" }; + yield return new object[] { $"this(42, 43, {delimiter} {{|#0:\"hello\"|}})" }; + yield return new object[] { $"base(42, 43, {delimiter} {{|#0:\"hello\"|}})" }; + } + + public static IEnumerable GetMultilineTestConstructorInitializers(string delimiter) + { + yield return new object[] { $"this(42\r\n+ 1, {delimiter} {{|#0:43|}}, {delimiter} \"hello\")" }; + yield return new object[] { $"base(42\r\n+ 1, {delimiter} {{|#0:43|}}, {delimiter} \"hello\")" }; } public static IEnumerable GetTestExpressions(string delimiter) { - yield return new object[] { $"Bar(1, 2, {delimiter} 2)", 13 }; - yield return new object[] { $"System.Action func = (int x, int y, {delimiter} int z) => Bar(x, y, z)", 41 }; - yield return new object[] { $"System.Action func = delegate(int x, int y, {delimiter} int z) {{ Bar(x, y, z); }}", 49 }; - yield return new object[] { $"new System.DateTime(2015, 9, {delimiter} 14)", 20 }; - yield return new object[] { $"var arr = new string[2, 2, {delimiter} 2];", 30 }; - yield return new object[] { $"char cc = (new char[3, 3, 3])[2, 2,{delimiter} 2];", 36 }; - yield return new object[] { $"char? c = (new char[3, 3, 3])?[2, 2,{delimiter} 2];", 37 }; - yield return new object[] { $"long ll = this[2, 2,{delimiter} 2];", 24 }; + yield return new object[] { $"Bar(1, 2, {delimiter} {{|#0:2|}})" }; + yield return new object[] { $"System.Action func = (int x, int y, {delimiter} {{|#0:int z|}}) => Bar(x, y, z)" }; + yield return new object[] { $"System.Action func = delegate(int x, int y, {delimiter} {{|#0:int z|}}) {{ Bar(x, y, z); }}" }; + yield return new object[] { $"new System.DateTime(2015, 9, {delimiter} {{|#0:14|}})" }; + yield return new object[] { $"var arr = new string[2, 2, {delimiter} {{|#0:2|}}];" }; + yield return new object[] { $"char cc = (new char[3, 3, 3])[2, 2,{delimiter} {{|#0:2|}}];" }; + yield return new object[] { $"char? c = (new char[3, 3, 3])?[2, 2,{delimiter} {{|#0:2|}}];" }; + yield return new object[] { $"long ll = this[2, 2,{delimiter} {{|#0:2|}}];" }; + } + + public static IEnumerable GetTrailingMultilineTestExpressions(string delimiter) + { + yield return new object[] { $"System.Action func = (int x, {delimiter} int y, {delimiter} int\r\nz) => Bar(x, y, z)" }; + yield return new object[] { $"System.Action func = delegate(int x, {delimiter} int y, {delimiter} int\r\nz) {{ Bar(x, y, z); }}" }; + yield return new object[] { $"var arr = new string[2, {delimiter} 2\r\n+ 2];" }; + yield return new object[] { $"char cc = (new char[3, 3])[2, {delimiter} 2\r\n+ 2];" }; + yield return new object[] { $"char? c = (new char[3, 3])?[2, {delimiter} 2\r\n+ 2];" }; + yield return new object[] { $"long ll = this[2,{delimiter} 2,{delimiter} 2\r\n+ 1];" }; + yield return new object[] { $"var str = string.Join(\r\n\"def\",{delimiter}\"abc\"\r\n + \"cba\");" }; + } + + public static IEnumerable GetLeadingMultilineTestExpressions(string delimiter) + { + yield return new object[] { $"var str = string.Join(\r\n\"abc\"\r\n + \"cba\",{delimiter}{{|#0:\"def\"|}});" }; + yield return new object[] { $"Bar(\r\n1\r\n + 2,{delimiter}{{|#0:3|}},\r\n 4);" }; + } + + public static IEnumerable GetTestAttributes(string delimiter) + { + yield return new object[] { $"[MyAttribute(1, {delimiter}2, {{|#0:3|}})]" }; + } + + public static IEnumerable GetMultilineTestAttributes(string delimiter) + { + yield return new object[] { $"[MyAttribute(1, {delimiter}2, {delimiter}3\r\n+ 5)]" }; } public static IEnumerable ValidTestExpressions() { - yield return new object[] { $"System.Action func = () => Bar(0, 2, 3)", 0 }; - yield return new object[] { $"System.Action func = x => Bar(x, 2, 3)", 0 }; - yield return new object[] { $"System.Action func = delegate {{ Bar(0, 0, 0); }}", 0 }; - yield return new object[] { "var weird = new int[10][,,,];", 0 }; + yield return new object[] { $"System.Action func = () => Bar(0, 2, 3)" }; + yield return new object[] { $"System.Action func = x => Bar(x, 2, 3)" }; + yield return new object[] { $"System.Action func = delegate {{ Bar(0, 0, 0); }}" }; + yield return new object[] { "var weird = new int[10][,,,];" }; } public static IEnumerable ValidTestDeclarations() @@ -67,8 +105,28 @@ public static IEnumerable ValidTestDeclarations() }; } + public static IEnumerable ValidTestAttribute() + { + // This is a regression test for https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1211 + yield return new object[] { @"[System.Obsolete]" }; + yield return new object[] + { + @"[MyAttribute( + 1, 2, 3)]", + }; + yield return new object[] + { + @"[MyAttribute( + 1, + 2, + 3)]", + }; + } + [Theory] [MemberData(nameof(GetTestDeclarations), "")] + [MemberData(nameof(GetMultilineTestDeclarations), "\r\n")] + [MemberData(nameof(GetMultilineTestDeclarations), "")] [MemberData(nameof(ValidTestDeclarations))] public async Task TestValidDeclarationAsync(string declaration) { @@ -90,12 +148,13 @@ class Foo {declaration} }}"; - DiagnosticResult expected = Diagnostic().WithLocation(5, 2); + DiagnosticResult expected = Diagnostic().WithLocation(0); await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); } [Theory] [MemberData(nameof(GetTestConstructorInitializers), "")] + [MemberData(nameof(GetMultilineTestConstructorInitializers), "\r\n")] public async Task TestValidConstructorInitializerAsync(string initializer) { var testCode = $@" @@ -124,6 +183,7 @@ public Derived(int i, int j, string z) [Theory] [MemberData(nameof(GetTestConstructorInitializers), "\r\n")] + [MemberData(nameof(GetMultilineTestConstructorInitializers), "")] public async Task TestInvalidConstructorInitializerAsync(string initializer) { var testCode = $@" @@ -147,14 +207,17 @@ public Derived(int i, int j, string z) }} }}"; - DiagnosticResult expected = Diagnostic().WithLocation(13, 2); + DiagnosticResult expected = Diagnostic().WithLocation(0); await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); } [Theory] [MemberData(nameof(GetTestExpressions), "")] + [MemberData(nameof(GetLeadingMultilineTestExpressions), "\r\n")] + [MemberData(nameof(GetTrailingMultilineTestExpressions), "\r\n")] + [MemberData(nameof(GetTrailingMultilineTestExpressions), "")] [MemberData(nameof(ValidTestExpressions))] - public async Task TestValidExpressionAsync(string expression, int column) + public async Task TestValidExpressionAsync(string expression) { var testCode = $@" class Foo @@ -176,7 +239,8 @@ public void Baz() [Theory] [MemberData(nameof(GetTestExpressions), "\r\n")] - public async Task TestInvalidExpressionAsync(string expression, int column) + [MemberData(nameof(GetLeadingMultilineTestExpressions), "")] + public async Task TestInvalidExpressionAsync(string expression) { var testCode = $@" class Foo @@ -193,56 +257,54 @@ public void Baz() public long this[int a, int b, int s] => a + b + s; }}"; - DiagnosticResult expected = Diagnostic().WithLocation(11, 2); + DiagnosticResult expected = Diagnostic().WithLocation(0); await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); } - [Fact] - public async Task TestValidAttributeAsync() + [Theory] + [MemberData(nameof(GetTestAttributes), "")] + [MemberData(nameof(GetMultilineTestAttributes), "\r\n")] + [MemberData(nameof(GetMultilineTestAttributes), "")] + [MemberData(nameof(ValidTestAttribute))] + public async Task TestValidAttributeAsync(string attribute) { - var testCode = @" + var testCode = $@" [System.AttributeUsage(System.AttributeTargets.Class)] public class MyAttribute : System.Attribute -{ +{{ public MyAttribute(int a, int b, int c) - { - } -} + {{ + }} +}} -[MyAttribute(1, 2, 3)] +{attribute} class Foo -{ -} - -// This is a regression test for https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1211 -[System.Obsolete] -class ObsoleteType -{ -}"; +{{ +}}"; await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } - [Fact] - public async Task TestInvalidAttributeAsync() + [Theory] + [MemberData(nameof(GetTestAttributes), "\r\n")] + public async Task TestInvalidAttributeAsync(string attribute) { - var testCode = @" + var testCode = $@" [System.AttributeUsage(System.AttributeTargets.Class)] public class MyAttribute : System.Attribute -{ +{{ public MyAttribute(int a, int b, int c) - { - } -} + {{ + }} +}} -[MyAttribute( - 1, - 2, 3)] +{attribute} class Foo -{ -}"; +{{ +}}"; + + DiagnosticResult expected = Diagnostic().WithLocation(0); - DiagnosticResult expected = Diagnostic().WithLocation(12, 8); await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1118UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1118UnitTests.cs index 23503ea02..f74abee62 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1118UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1118UnitTests.cs @@ -1,17 +1,39 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { + using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier; public class SA1118UnitTests { + public static IEnumerable ArrayCreationExpressions { get; } = new List + { + new object[] + { + @"new[] + { + 0, + 1 + }", + }, + new object[] + { + @"new int[] + { + 0, + 1 + }", + }, + }; + [Fact] public async Task TestMethodCallWithTwoParametersSecondSpansMoreThanOneLineAsync() { @@ -276,7 +298,7 @@ public void Bar() } [Fact] - public async Task TestLambdaCallSecondParameterIsAnonynousMethodAsync() + public async Task TestLambdaCallSecondParameterIsAnonymousMethodAsync() { var testCode = @" class Foo @@ -341,7 +363,7 @@ public void Bar() } [Fact] - public async Task TestAttributeSecondParameterSpandsMultipleLinesAsync() + public async Task TestAttributeSecondParameterSpansMultipleLinesAsync() { var testCode = @" [System.AttributeUsage(System.AttributeTargets.Class,AllowMultiple = true)] @@ -363,5 +385,27 @@ public class Foo await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); } + + [Theory] + [MemberData(nameof(ArrayCreationExpressions))] + public async Task TestArrayCreationSpansMultipleLinesAsync(string arrayCreationExpression) + { + var testCode = $@" +class Foo +{{ + public void Fun(int i, int[] j) + {{ + }} + + public void Bar() + {{ + Fun( + 1, + {arrayCreationExpression}); + }} +}}"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1120UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1120UnitTests.cs index d82b2c397..9a2887d2d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1120UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1120UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1120CommentsMustContainText, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1121UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1121UnitTests.cs index 6273b8fd4..d134fe4e4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1121UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1121UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable // Several test methods in this file use the same member data, but in some cases the test does not use all of the // supported parameters. See https://github.com/xunit/xunit/issues/1556. @@ -14,7 +16,6 @@ namespace StyleCop.Analyzers.Test.ReadabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1121UseBuiltInTypeAlias, @@ -668,6 +669,9 @@ public class Bar {{ }} [MemberData(nameof(AllTypes))] public async Task TestNameOfAsync(string predefined, string fullName) { + // Not needed for this test + _ = predefined; + string testCode = @" namespace System {{ diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1122UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1122UnitTests.cs index 953b9fbb5..5f9bce304 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1122UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1122UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.ReadabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1122UseStringEmptyForEmptyStrings, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1123UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1123UnitTests.cs index 987139fbd..0fa2dd6e8 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1123UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1123UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.ReadabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1123DoNotPlaceRegionsWithinElements, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1124UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1124UnitTests.cs index 5133dd5c6..0b6c3901d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1124UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1124UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.ReadabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1124DoNotUseRegions, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1125UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1125UnitTests.cs index 3e3c858b6..52fc09db2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1125UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1125UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { @@ -10,7 +12,6 @@ namespace StyleCop.Analyzers.Test.ReadabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1126UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1126UnitTests.cs index ca984d80f..850f67d69 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1126UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1126UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1127UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1127UnitTests.cs index cd90cca9f..6047d573a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1127UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1127UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.ReadabilityRules using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1127GenericTypeConstraintsMustBeOnOwnLine, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1128UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1128UnitTests.cs index 8641b1f65..3318c4f04 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1128UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1128UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1129UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1129UnitTests.cs index 940a23532..3cfff7e47 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1129UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1129UnitTests.cs @@ -1,13 +1,15 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { + using System; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1129DoNotUseDefaultValueTypeConstructor, @@ -90,9 +92,9 @@ public async Task VerifyInvalidValueTypeCreationAsync() { public void TestMethod() { - var v1 = new TestStruct(); + var v1 = {|#0:new TestStruct()|}; - System.Console.WriteLine(new TestStruct()); + System.Console.WriteLine({|#1:new TestStruct()|}); } private struct TestStruct @@ -120,13 +122,68 @@ private struct TestStruct DiagnosticResult[] expected = { - Diagnostic().WithLocation(5, 18), - Diagnostic().WithLocation(7, 34), + Diagnostic().WithLocation(0), + Diagnostic().WithLocation(1), }; await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } + [Fact] + public async Task VerifyInvalidValueTypeCreationFromMetadataAsync() + { + var testCode = @"public class TestClass +{ + public void TestMethod() + { + var v1 = [|new TestStruct()|]; + + System.Console.WriteLine([|new TestStruct()|]); + } +} +"; + + var fixedTestCode = @"public class TestClass +{ + public void TestMethod() + { + var v1 = default(TestStruct); + + System.Console.WriteLine(default(TestStruct)); + } +} +"; + + DiagnosticResult[] expected = + { + Diagnostic().WithLocation(0), + Diagnostic().WithLocation(1), + }; + + await new CSharpTest + { + TestState = + { + Sources = { testCode }, + AdditionalProjects = + { + ["Reference"] = + { + Sources = + { + @"public struct TestStruct { public int TestProperty { get; set; } }", + }, + }, + }, + AdditionalProjectReferences = { "Reference" }, + }, + FixedState = + { + Sources = { fixedTestCode }, + }, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + /// /// Verifies that the codefix will preserve surrounding trivia. /// @@ -138,11 +195,11 @@ public async Task VerifyTriviaPreservationAsync() { public void TestMethod() { - var v1 = /* c1 */ new TestStruct(); // c2 + var v1 = /* c1 */ {|#0:new TestStruct()|}; // c2 var v2 = #if true - new TestStruct(); + {|#1:new TestStruct()|}; #else new TestStruct() { TestProperty = 3 }; #endif @@ -178,8 +235,8 @@ private struct TestStruct DiagnosticResult[] expected = { - Diagnostic().WithLocation(5, 27), - Diagnostic().WithLocation(9, 13), + Diagnostic().WithLocation(0), + Diagnostic().WithLocation(1), }; await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); @@ -197,7 +254,7 @@ public async Task VerifyGenericsTypeCreationAsync() public T TestMethod1() where T : struct { - return new T(); + return {|#0:new T()|}; } public T TestMethod2() @@ -226,7 +283,7 @@ public T TestMethod2() DiagnosticResult[] expected = { - Diagnostic().WithLocation(6, 16), + Diagnostic().WithLocation(0), }; await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); @@ -235,193 +292,206 @@ public T TestMethod2() /// /// Verifies that new CancellationToken() is replaced by CancellationToken.None. /// + /// The namespace of the special type. + /// The name of the special type. + /// The name of the field providing the default value for the type. /// A representing the asynchronous unit test. - [Fact] - public async Task VerifyCancellationTokenFixUsesNoneSyntaxAsync() + [Theory] + [InlineData("System.Threading", nameof(CancellationToken), nameof(CancellationToken.None))] + [InlineData("System", nameof(IntPtr), nameof(IntPtr.Zero))] + [InlineData("System", nameof(UIntPtr), nameof(UIntPtr.Zero))] + [InlineData("System", nameof(Guid), nameof(Guid.Empty))] + public async Task VerifySpecialTypeFixUsesSpecialSyntaxAsync(string typeNamespace, string typeName, string fieldName) { - var testCode = @" -using System.Threading; + var testCode = $@" +using {typeNamespace}; public class TestClass -{ +{{ public void TestMethod() - { - var ct = new CancellationToken(); - } -} + {{ + var value = [|new {typeName}()|]; + }} +}} "; - var fixedTestCode = @" -using System.Threading; + var fixedTestCode = $@" +using {typeNamespace}; public class TestClass -{ +{{ public void TestMethod() - { - var ct = CancellationToken.None; - } -} + {{ + var value = {typeName}.{fieldName}; + }} +}} "; - DiagnosticResult[] expected = - { - Diagnostic().WithLocation(8, 18), - }; - - await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } /// /// Verifies that the codefix will preserve trivia surrounding new CancellationToken(). /// + /// The namespace of the special type. + /// The name of the special type. + /// The name of the field providing the default value for the type. /// A representing the asynchronous unit test. - [Fact] - public async Task VerifyCancellationTokenTriviaPreservationAsync() + [Theory] + [InlineData("System.Threading", nameof(CancellationToken), nameof(CancellationToken.None))] + [InlineData("System", nameof(IntPtr), nameof(IntPtr.Zero))] + [InlineData("System", nameof(UIntPtr), nameof(UIntPtr.Zero))] + [InlineData("System", nameof(Guid), nameof(Guid.Empty))] + public async Task VerifySpecialTypeTriviaPreservationAsync(string typeNamespace, string typeName, string fieldName) { - var testCode = @" -using System.Threading; + var testCode = $@" +using {typeNamespace}; public class TestClass -{ +{{ public void TestMethod() - { - var ct1 = /* c1 */ new CancellationToken(); // c2 - } -} + {{ + var value = /* c1 */ [|new {typeName}()|]; // c2 + }} +}} "; - var fixedTestCode = @" -using System.Threading; + var fixedTestCode = $@" +using {typeNamespace}; public class TestClass -{ +{{ public void TestMethod() - { - var ct1 = /* c1 */ CancellationToken.None; // c2 - } -} + {{ + var value = /* c1 */ {typeName}.{fieldName}; // c2 + }} +}} "; - DiagnosticResult[] expected = - { - Diagnostic().WithLocation(8, 28), - }; - - await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } /// /// Verifies that new CancellationToken() is replaced by CancellationToken.None, /// and a fully-qualified name is preserved correctly. /// + /// The namespace of the special type. + /// The name of the special type. + /// The name of the field providing the default value for the type. /// A representing the asynchronous unit test. - [Fact] - public async Task VerifyQualifiedCancellationTokenFixUsesNoneSyntaxAsync() + [Theory] + [InlineData("System.Threading", nameof(CancellationToken), nameof(CancellationToken.None))] + [InlineData("System", nameof(IntPtr), nameof(IntPtr.Zero))] + [InlineData("System", nameof(UIntPtr), nameof(UIntPtr.Zero))] + [InlineData("System", nameof(Guid), nameof(Guid.Empty))] + public async Task VerifyQualifiedSpecialTypeFixUsesFieldSyntaxAsync(string typeNamespace, string typeName, string fieldName) { - var testCode = @" + var testCode = $@" public class TestClass -{ +{{ public void TestMethod() - { - var ct = new System.Threading.CancellationToken(); - } -} + {{ + var value = [|new {typeNamespace}.{typeName}()|]; + }} +}} "; - var fixedTestCode = @" + var fixedTestCode = $@" public class TestClass -{ +{{ public void TestMethod() - { - var ct = System.Threading.CancellationToken.None; - } -} + {{ + var value = {typeNamespace}.{typeName}.{fieldName}; + }} +}} "; - DiagnosticResult[] expected = + await new CSharpTest { - Diagnostic().WithLocation(6, 18), - }; - - await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + TestCode = testCode, + FixedCode = fixedTestCode, + CodeActionValidationMode = CodeActionValidationMode.None, // Differences in syntax nodes (SimpleMemberAccessExpression vs QualifiedName) + }.RunAsync(CancellationToken.None).ConfigureAwait(false); } /// /// Verifies that new CancellationToken() is not replaced by CancellationToken.None /// if the qualified name is not exactly System.Threading.CancellationToken. /// + /// The name of the special type. /// A representing the asynchronous unit test. - [Fact] - public async Task VerifyCustomCancellationTokenClassIsNotReplacedAsync() + [Theory] + [InlineData(nameof(CancellationToken))] + [InlineData(nameof(IntPtr))] + [InlineData(nameof(UIntPtr))] + [InlineData(nameof(Guid))] + public async Task VerifyCustomSpecialTypeStructIsNotReplacedAsync(string typeName) { - var testCode = @"public class TestClass -{ + var testCode = $@"public class TestClass +{{ public void TestMethod() - { - var ct = new CancellationToken(); - } + {{ + var value = [|new {typeName}()|]; + }} - private struct CancellationToken - { - public int TestProperty { get; set; } - } -} + private struct {typeName} + {{ + public int TestProperty {{ get; set; }} + }} +}} "; - var fixedTestCode = @"public class TestClass -{ + var fixedTestCode = $@"public class TestClass +{{ public void TestMethod() - { - var ct = default(CancellationToken); - } + {{ + var value = default({typeName}); + }} - private struct CancellationToken - { - public int TestProperty { get; set; } - } -} + private struct {typeName} + {{ + public int TestProperty {{ get; set; }} + }} +}} "; - DiagnosticResult[] expected = - { - Diagnostic().WithLocation(5, 18), - }; - - await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } /// /// Verifies that new CancellationToken() is replaced by CancellationToken.None, /// even when aliased by a using statement. /// + /// The namespace of the special type. + /// The name of the special type. + /// The name of the field providing the default value for the type. /// A representing the asynchronous unit test. - [Fact] - public async Task VerifyAliasedCancellationTokenUsesNoneSyntaxAsync() + [Theory] + [InlineData("System.Threading", nameof(CancellationToken), nameof(CancellationToken.None))] + [InlineData("System", nameof(IntPtr), nameof(IntPtr.Zero))] + [InlineData("System", nameof(UIntPtr), nameof(UIntPtr.Zero))] + [InlineData("System", nameof(Guid), nameof(Guid.Empty))] + public async Task VerifyAliasedSpecialTypeUsesFieldSyntaxAsync(string typeNamespace, string typeName, string fieldName) { - var testCode = @" -using SystemToken = System.Threading.CancellationToken; + var testCode = $@" +using SystemType = {typeNamespace}.{typeName}; public class TestClass -{ - private SystemToken ct = new SystemToken(); -} +{{ + private SystemType value = [|new SystemType()|]; +}} "; - var fixedTestCode = @" -using SystemToken = System.Threading.CancellationToken; + var fixedTestCode = $@" +using SystemType = {typeNamespace}.{typeName}; public class TestClass -{ - private SystemToken ct = SystemToken.None; -} +{{ + private SystemType value = SystemType.{fieldName}; +}} "; - DiagnosticResult[] expected = - { - Diagnostic().WithLocation(6, 30), - }; - - await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } /// @@ -442,7 +512,7 @@ public async Task VerifyEnumMemberReplacementBehaviorAsync(string declarationBod {{ public void TestMethod() {{ - var v1 = new MyEnum(); + var v1 = {{|#0:new MyEnum()|}}; }} private enum MyEnum {{ {declarationBody} }} @@ -460,7 +530,7 @@ private enum MyEnum {{ {declarationBody} }} DiagnosticResult[] expected = { - Diagnostic().WithLocation(5, 18), + Diagnostic().WithLocation(0), }; await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); @@ -483,7 +553,7 @@ public async Task VerifyEnumMemberDefaultBehaviorAsync(string declarationBody) {{ public void TestMethod() {{ - var v1 = new MyEnum(); + var v1 = {{|#0:new MyEnum()|}}; }} private enum MyEnum {{ {declarationBody} }} @@ -501,7 +571,7 @@ private enum MyEnum {{ {declarationBody} }} DiagnosticResult[] expected = { - Diagnostic().WithLocation(5, 18), + Diagnostic().WithLocation(0), }; await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); @@ -510,46 +580,46 @@ private enum MyEnum {{ {declarationBody} }} /// /// Verifies that new CancellationToken() is replaced by default(CancellationToken) when its used for a default parameter. /// + /// The namespace of the special type. + /// The name of the special type. /// A representing the asynchronous unit test. - [Fact] + [Theory] + [InlineData("System.Threading", nameof(CancellationToken))] + [InlineData("System", nameof(IntPtr))] + [InlineData("System", nameof(UIntPtr))] + [InlineData("System", nameof(Guid))] [WorkItem(2740, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2740")] - public async Task VerifyCancellationTokenDefaultParameterAsync() + public async Task VerifySpecialTypeDefaultParameterAsync(string typeNamespace, string typeName) { - var testCode = @"using System.Threading; + var testCode = $@"using {typeNamespace}; public class TestClass -{ - public TestClass(CancellationToken cancellationToken = new CancellationToken()) - { - } +{{ + public TestClass({typeName} cancellationToken = [|new {typeName}()|]) + {{ + }} - public void TestMethod(CancellationToken cancellationToken = new CancellationToken()) - { - } -} + public void TestMethod({typeName} cancellationToken = [|new {typeName}()|]) + {{ + }} +}} "; - var fixedTestCode = @"using System.Threading; + var fixedTestCode = $@"using {typeNamespace}; public class TestClass -{ - public TestClass(CancellationToken cancellationToken = default(CancellationToken)) - { - } +{{ + public TestClass({typeName} cancellationToken = default({typeName})) + {{ + }} - public void TestMethod(CancellationToken cancellationToken = default(CancellationToken)) - { - } -} + public void TestMethod({typeName} cancellationToken = default({typeName})) + {{ + }} +}} "; - DiagnosticResult[] expected = - { - Diagnostic().WithLocation(5, 60), - Diagnostic().WithLocation(9, 66), - }; - - await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1130UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1130UnitTests.cs index d43b84ba3..a38b7eea2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1130UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1130UnitTests.cs @@ -1,13 +1,16 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { + using System.Diagnostics.CodeAnalysis; + using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1130UseLambdaSyntax, @@ -15,9 +18,11 @@ namespace StyleCop.Analyzers.Test.ReadabilityRules public class SA1130UnitTests { + [SuppressMessage("MicrosoftCodeAnalysisDesign", "RS1032:Define diagnostic message correctly", Justification = "The message here matches the compiler.")] private static readonly DiagnosticDescriptor CS1065 = new DiagnosticDescriptor(nameof(CS1065), "Title", "Default values are not valid in this context.", "Category", DiagnosticSeverity.Error, AnalyzerConstants.EnabledByDefault); + [SuppressMessage("MicrosoftCodeAnalysisDesign", "RS1032:Define diagnostic message correctly", Justification = "The message here matches the compiler.")] private static readonly DiagnosticDescriptor CS7014 = new DiagnosticDescriptor(nameof(CS7014), "Title", "Attributes are not valid in this context.", "Category", DiagnosticSeverity.Error, AnalyzerConstants.EnabledByDefault); @@ -186,14 +191,14 @@ internal class TypeName { private void Method(object o) { - Action a = delegate() { Console.WriteLine(); }; - Action b = delegate() { Console.WriteLine(); }; - Action c = delegate(int x) { Console.WriteLine(); }; - Action d = delegate(int x, int y) { Console.WriteLine(); }; - Action e = delegate (int x, int y = 0) { Console.WriteLine(); }; - Action f = delegate (int x, [Obsolete]int y) { Console.WriteLine(); }; - Action g = delegate (int x, params int y) { Console.WriteLine(); }; - Action h = delegate (int x, __arglist) { Console.WriteLine(); }; + Action a = [|delegate|]() { Console.WriteLine(); }; + Action b = [|delegate|]() { Console.WriteLine(); }; + Action c = [|delegate|](int x) { Console.WriteLine(); }; + Action d = [|delegate|](int x, int y) { Console.WriteLine(); }; + Action e = [|delegate|] (int x, int y = 0) { Console.WriteLine(); }; + Action f = [|delegate|] (int x, [Obsolete]int y) { Console.WriteLine(); }; + Action g = [|delegate|] (int x, params int y) { Console.WriteLine(); }; + Action h = [|delegate|] (int x, __arglist) { Console.WriteLine(); }; } }"; @@ -214,33 +219,17 @@ private void Method(object o) Action h = delegate (int x, __arglist) { Console.WriteLine(); }; } }"; - var expected = new[] - { - Diagnostic().WithLocation(8, 20), - Diagnostic().WithLocation(9, 20), - Diagnostic().WithLocation(10, 25), - Diagnostic().WithLocation(11, 30), - Diagnostic().WithLocation(12, 30), - Diagnostic(CS1065).WithLocation(12, 53), - Diagnostic().WithLocation(13, 30), - Diagnostic(CS7014).WithLocation(13, 47), - Diagnostic().WithLocation(14, 30), - Diagnostic(CS1670).WithLocation(14, 47), - Diagnostic().WithLocation(15, 25), - Diagnostic(CS1669).WithLocation(15, 42), - }; - var expectedAfterFix = new[] - { - Diagnostic().WithLocation(12, 30), - Diagnostic(CS1065).WithLocation(12, 53), - Diagnostic().WithLocation(13, 30), - Diagnostic(CS7014).WithLocation(13, 47), - Diagnostic().WithLocation(14, 30), - Diagnostic(CS1670).WithLocation(14, 47), - Diagnostic().WithLocation(15, 25), - Diagnostic(CS1669).WithLocation(15, 42), - }; + var expected = this.GetCompilerExpectedResultCodeFixSpecialCases(); + + var expectedAfterFix = this.GetCompilerExpectedResultCodeFixSpecialCases() + .Concat(new[] + { + Diagnostic().WithLocation(12, 30), + Diagnostic().WithLocation(13, 30), + Diagnostic().WithLocation(14, 30), + Diagnostic().WithLocation(15, 25), + }); var test = new CSharpTest { @@ -276,7 +265,7 @@ public class TypeName { public void Test() { - Action action1 = /*a*/()/*b*/ => { }; + Action action1 = /*a*/() =>/*b*/{ }; Action action2 = /*a*//*b*/(/*c*/)/*d*/ => { }; Action action3 = /*a*//*b*//*c*//*d*/i/*e*//*f*/ => { }; Action> action4 = i => { }; @@ -710,5 +699,311 @@ static void Main(string[] args) await VerifyCSharpFixAsync(testCode, expected, testCode, CancellationToken.None).ConfigureAwait(false); } + + [Fact] + [WorkItem(2902, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2902")] + public async Task VerifyThatCodeFixDoesNotCrashOnDelegateReturnAsync() + { + var testCode = @"using System; +public class TestClass +{ + public static EventHandler TestMethod1() + { + return delegate + { + }; + } + + public static EventHandler TestMethod2() => delegate + { + }; + + public static EventHandler TestProperty1 + { + get + { + return delegate + { + }; + } + } + + public static EventHandler TestProperty2 => delegate + { + }; +}"; + + var fixedCode = @"using System; +public class TestClass +{ + public static EventHandler TestMethod1() + { + return (sender, e) => + { + }; + } + + public static EventHandler TestMethod2() => (sender, e) => + { + }; + + public static EventHandler TestProperty1 + { + get + { + return (sender, e) => + { + }; + } + } + + public static EventHandler TestProperty2 => (sender, e) => + { + }; +}"; + + DiagnosticResult[] expected = + { + Diagnostic().WithLocation(6, 16), + Diagnostic().WithLocation(11, 49), + Diagnostic().WithLocation(19, 20), + Diagnostic().WithLocation(25, 49), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2902, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2902")] + public async Task VerifyThatEventInitializersWorkAsExpectedAsync() + { + var testCode = @"using System; +public class TestClass +{ + public static event EventHandler StaticEvent = delegate { }; + public event EventHandler InstanceEvent = delegate { }; +} +"; + + var fixedCode = @"using System; +public class TestClass +{ + public static event EventHandler StaticEvent = (sender, e) => { }; + public event EventHandler InstanceEvent = (sender, e) => { }; +} +"; + + DiagnosticResult[] expected = + { + Diagnostic().WithLocation(4, 52), + Diagnostic().WithLocation(5, 47), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2902, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2902")] + public async Task VerifyInvalidCodeConstructionsAsync() + { + var testCode = @"using System; +public class TestClass +{ + public static EventHandler[] TestMethod() => [|delegate|] { }; +} +"; + + var expected = new[] + { + DiagnosticResult.CompilerError("CS1660").WithLocation(4, 50), + }; + + var test = new CSharpTest + { + TestCode = testCode, + FixedCode = testCode, + }; + + test.ExpectedDiagnostics.AddRange(expected); + test.RemainingDiagnostics.AddRange(expected); + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2997, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2997")] + public async Task VerifyDelegateConstructionAsync() + { + var testCode = @"using System; +using System.Collections.Generic; + +public class TestClass +{ + private Dictionary> items = new Dictionary>() + { + { ""a"", delegate { return 0; } }, + { ""b"", () => 1 }, + }; +} +"; + + var fixedCode = @"using System; +using System.Collections.Generic; + +public class TestClass +{ + private Dictionary> items = new Dictionary>() + { + { ""a"", () => { return 0; } }, + { ""b"", () => 1 }, + }; +} +"; + + DiagnosticResult[] expected = + { + Diagnostic().WithLocation(8, 16), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3279, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3279")] + public async Task TestDelegateUsedAsSecondNamedArgumentAsync() + { + var testCode = @" +using System; +using System.Linq; +public class TypeName +{ + public void Test() + { + Test2(resolve: delegate + { + return """"; + }); + } + + private void Test2(string description = null, Func resolve = null) + { + resolve(0); + } +}"; + + string fixedCode = @" +using System; +using System.Linq; +public class TypeName +{ + public void Test() + { + Test2(resolve: arg => + { + return """"; + }); + } + + private void Test2(string description = null, Func resolve = null) + { + resolve(0); + } +}"; + + var expected = new[] + { + Diagnostic().WithSpan(8, 24, 8, 32), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3279, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3279")] + public async Task VerifyThatUnknownNamedParameterWontCauseCrashAsync() + { + var testCode = @" +using System; +using System.Linq; +public class TypeName +{ + public void Test() + { + Test2(unknownParam: delegate + { + return """"; + }); + } + + private void Test2(string description = null, Func resolve = null) + { + resolve(0); + } +}"; + + var expected = DiagnosticResult.CompilerError("CS1739") + .WithMessage("The best overload for 'Test2' does not have a parameter named 'unknownParam'") + .WithSpan(8, 15, 8, 27) + .WithArguments("Test2", "unknownParam"); + + await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); + } + + [Theory] + [InlineData( + "(Func)[|delegate|] { return 1; }", + "(Func)(() => { return 1; })")] + [InlineData( + "(Func)[|delegate|]() { return 1; }", + "(Func)(() => { return 1; })")] + [InlineData( + "(Func)[|delegate|] { return 1; }", + "(Func)(arg => { return 1; })")] + [InlineData( + "(Func)[|delegate|](int x) { return 1; }", + "(Func)(x => { return 1; })")] + [InlineData( + "(Func)[|delegate|] { return 1; }", + "(Func)((arg1, arg2) => { return 1; })")] + [InlineData( + "(Func)[|delegate|](int x, int y) { return 1; }", + "(Func)((x, y) => { return 1; })")] + [WorkItem(3510, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3510")] + public async Task TestDelegateUsedInCastAsync(string testExpression, string fixedExpression) + { + var testCode = $@" +using System; + +public class TypeName +{{ + public void Test() + {{ + var z = {testExpression}; + }} +}}"; + + var fixedCode = $@" +using System; + +public class TypeName +{{ + public void Test() + {{ + var z = {fixedExpression}; + }} +}}"; + + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + protected virtual DiagnosticResult[] GetCompilerExpectedResultCodeFixSpecialCases() + { + return new[] + { + Diagnostic(CS1065).WithLocation(12, 53), + Diagnostic(CS7014).WithLocation(13, 47), + Diagnostic(CS1670).WithLocation(14, 47), + Diagnostic(CS1669).WithLocation(15, 42), + }; + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1131UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1131UnitTests.cs index 931353695..ae5fd8f42 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1131UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1131UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1131UseReadableConditions, @@ -507,5 +508,81 @@ public void Test() }; await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } + + [Theory] + [InlineData("Method1", "arg", true)] + [InlineData("Method2", "arg", true)] + [InlineData("Method1", "field1", true)] + [InlineData("Method2", "field1", true)] + [InlineData("Method1", "field2", true)] + [InlineData("Method2", "field2", true)] + [InlineData("Const1", "Method1", false)] + [InlineData("Const1", "Method2", false)] + [InlineData("Method1", "Const1", false)] + [InlineData("Method2", "Const1", false)] + [WorkItem(3677, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3677")] + public async Task TestMethodsAsync(string expr1, string expr2, bool shouldTrigger) + { + var testExpr = $"{expr1} == {expr2}"; + var testCode = $@" +using System; + +public class TestClass +{{ + private static readonly Action Const1 = Method1; + + private Action field1 = Method1; + private readonly Action field2 = Method1; + + public bool TestMethod(Action arg) + {{ + return {(shouldTrigger ? $"[|{testExpr}|]" : testExpr)}; + }} + + private static void Method1() + {{ + }} + + private void Method2() + {{ + }} +}} +"; + + var fixedExpr = $"{expr2} == {expr1}"; + var fixedCode = $@" +using System; + +public class TestClass +{{ + private static readonly Action Const1 = Method1; + + private Action field1 = Method1; + private readonly Action field2 = Method1; + + public bool TestMethod(Action arg) + {{ + return {fixedExpr}; + }} + + private static void Method1() + {{ + }} + + private void Method2() + {{ + }} +}} +"; + + if (shouldTrigger) + { + await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + else + { + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1132UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1132UnitTests.cs index 07d042904..c59286148 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1132UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1132UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1132DoNotCombineFields, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1133UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1133UnitTests.cs index 25c46e4d3..5121b0570 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1133UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1133UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.ReadabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1133DoNotCombineAttributes, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1134UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1134UnitTests.cs index 2d5d10e31..28ae9160a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1134UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1134UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1134AttributesMustNotShareLine, @@ -409,5 +410,35 @@ public class TestClass<[Test(""Test1"")][Test(""Test2"")]T> await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } + + /// + /// Verifies that passing an invalid member syntax into the codefix will not change the code. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(2894, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2894")] + public virtual async Task VerifyInvalidMemberSyntaxInCodeFixAsync() + { + string testCode = @"class Program +{ + static void Main(string[] args) + { + { + }[;] + } +} +"; + + DiagnosticResult[] expected = + { + DiagnosticResult.CompilerError("CS1513").WithLocation(6, 10), + Diagnostic().WithLocation(6, 10), + DiagnosticResult.CompilerError("CS1001").WithLocation(6, 11), + DiagnosticResult.CompilerError("CS1001").WithLocation(6, 11), + DiagnosticResult.CompilerError("CS1022").WithLocation(8, 1), + }; + + await VerifyCSharpFixAsync(testCode, expected, testCode, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1135UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1135UnitTests.cs index e666451f7..4d870a547 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1135UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1135UnitTests.cs @@ -1,13 +1,15 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1135UsingDirectivesMustBeQualified, @@ -103,18 +105,6 @@ namespace System.Threading await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } - [Fact] - public async Task TestStaticUsingsAsync() - { - const string testCode = @" -namespace System.Threading -{ - using static Console; -}"; - - await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); - } - [Fact] public async Task TestFixAllAsync() { @@ -230,5 +220,256 @@ namespace Test { await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } + + [Fact] + public async Task TestFullyQualifiedAliasWithWrappedTypeArgumentsAsync() + { + var testCode = @" +using Example = System.ValueTuple< + System.Int32, + System.Int32>; +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2820, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2820")] + public async Task TestAliasWithWrappedTypeArgumentsInsideNamespaceAsync() + { + var testCode = @" +using System; +using MyAlias = System.Exception; + +namespace Test +{ + using Example = System.ValueTuple< + Exception, + Exception>; + + using Example2 = ValueTuple< + Exception[], + Exception[,,]>; + + using Example3 = ValueTuple< + ValueTuple< + Exception, + Exception>, + Exception>; + + using Example4 = ValueTuple< + MyAlias, + Exception>; +} +"; + var fixedCode = @" +using System; +using MyAlias = System.Exception; + +namespace Test +{ + using Example = System.ValueTuple< + System.Exception, + System.Exception>; + + using Example2 = System.ValueTuple< + System.Exception[], + System.Exception[,,]>; + + using Example3 = System.ValueTuple< + System.ValueTuple< + System.Exception, + System.Exception>, + System.Exception>; + + using Example4 = System.ValueTuple< + System.Exception, + System.Exception>; +} +"; + + DiagnosticResult[] expected = + { + Diagnostic(SA1135UsingDirectivesMustBeQualified.DescriptorType).WithLocation(7, 5).WithArguments("System.ValueTuple"), + Diagnostic(SA1135UsingDirectivesMustBeQualified.DescriptorType).WithLocation(11, 5).WithArguments("System.ValueTuple"), + Diagnostic(SA1135UsingDirectivesMustBeQualified.DescriptorType).WithLocation(15, 5).WithArguments("System.ValueTuple, System.Exception>"), + Diagnostic(SA1135UsingDirectivesMustBeQualified.DescriptorType).WithLocation(21, 5).WithArguments("System.ValueTuple"), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + public async Task TestFullyQualifiedTopLevelNamespaceAsync() + { + var testCode = @" +namespace MyNamespace { + using System; +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2879, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2879")] + public async Task TestOmittedTypeInGenericAsync() + { + var testCode = @" +namespace TestNamespace +{ + using Example = System.Collections.Generic.List<>; +} +"; + + var expected = new DiagnosticResult("CS7003", DiagnosticSeverity.Error).WithLocation(4, 48).WithMessage("Unexpected use of an unbound generic name"); + await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2879, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2879")] + public async Task TestNullableTypeInGenericAsync() + { + var testCode = @" +namespace TestNamespace +{ + using Example = System.Collections.Generic.List; +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2879, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2879")] + public async Task TestGlobalQualifiedTypeInGenericAsync() + { + var testCode = @" +namespace TestNamespace +{ + using Example = System.Collections.Generic.List; +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2879, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2879")] + public async Task TestTypeInGlobalNamespaceAsync() + { + var testCode = @" +namespace TestNamespace +{ + using Example = MyClass; +} + +class MyClass +{ +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2879, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2879")] + public async Task TestAliasTypeNestedInGenericAsync() + { + var testCode = @" +namespace TestNamespace +{ + using Example = System.Collections.Immutable.ImmutableDictionary.Builder; +} +"; + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2879, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2879")] + public async Task TestValueTupleInUsingAliasAsync() + { + var testCode = @" +namespace System +{ + using Example = System.Collections.Generic.List>; +} +"; + var fixedCode = @" +namespace System +{ + using Example = System.Collections.Generic.List>; +} +"; + + var expected = Diagnostic(SA1135UsingDirectivesMustBeQualified.DescriptorType).WithLocation(4, 5).WithArguments("System.Collections.Generic.List>"); + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3149, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3149")] + public async Task TestAliasTypeClrTypeAsync() + { + var testCode = @" +namespace TestNamespace +{ + using Example = System.Collections.Generic.List; +} +"; + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3149, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3149")] + public async Task TestAliasTypeGenericNullableAsync() + { + var testCode = @" +namespace TestNamespace +{ + using Example = System.Nullable; +} +"; + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(3166, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3166")] + public async Task TestAliasClrTypeAsync() + { + var testCode = @" +namespace System +{ + using Float = System.Double; +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2618, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2618")] + public async Task TestUnqualifiedStaticUsingsAsync() + { + const string testCode = @" +namespace System.Threading +{ + using static Console; +} +"; + + const string fixedCode = @" +namespace System.Threading +{ + using static System.Console; +} +"; + + DiagnosticResult[] expected = + { + Diagnostic(SA1135UsingDirectivesMustBeQualified.DescriptorType).WithLocation(4, 5).WithArguments("System.Console"), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1136UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1136UnitTests.cs index 81f9a142a..bab35e867 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1136UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1136UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.ReadabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1136EnumValuesShouldBeOnSeparateLines, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1137UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1137UnitTests.cs index ecd625927..7c21d381a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1137UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1137UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { @@ -7,7 +9,7 @@ namespace StyleCop.Analyzers.Test.ReadabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.ReadabilityRules; - using TestHelper; + using StyleCop.Analyzers.Test.Helpers; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1137ElementsShouldHaveTheSameIndentation, @@ -19,10 +21,7 @@ namespace StyleCop.Analyzers.Test.ReadabilityRules public class SA1137UnitTests { [Theory] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] - [InlineData("enum")] + [MemberData(nameof(CommonMemberData.BaseTypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestNamespaceDeclarationAsync(string baseTypeKind) { string testCode = $@" @@ -149,9 +148,7 @@ class MyAttribute : Attribute {{ }} } [Theory] - [InlineData("class")] - [InlineData("struct")] - [InlineData("interface")] + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] public async Task TestTypeDeclarationConstraintClausesAsync(string typeKind) { string testCode = $@" @@ -220,11 +217,20 @@ public async Task TestTypeDeclarationConstraintClausesAsync(string typeKind) } [Theory] - [InlineData("class", "int", " { }")] - [InlineData("struct", "int", " { }")] - [InlineData("interface", "event System.EventHandler", ";")] - public async Task TestTypeDeclarationMembersAsync(string typeKind, string fieldType, string methodBody) + [MemberData(nameof(CommonMemberData.TypeDeclarationKeywords), MemberType = typeof(CommonMemberData))] + public async Task TestTypeDeclarationMembersAsync(string typeKind) { + string fieldType = typeKind switch + { + "interface" => "event System.EventHandler", + _ => "int", + }; + string methodBody = typeKind switch + { + "interface" => ";", + _ => " { }", + }; + string testCode = $@" {typeKind} Container1 {{ @@ -2015,5 +2021,34 @@ private class TestClass2 await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } + + [Fact] + [WorkItem(2774, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2774")] + public async Task VerifyThatBraceOnSameLineAsOtherCodeAsync() + { + var testCode = @" +public class TestClass +{ + public void TestMethod() + { + var x = TestMethod2(new TestClass2 { + TestValue = 12, + }); + } + + public int TestMethod2(TestClass2 input) + { + return 0; + } +} + +public class TestClass2 +{ + public int TestValue { get; set; } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1139UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1139UnitTests.cs index 4242848e0..afa07d8e0 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1139UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1139UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.ReadabilityRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.ReadabilityRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SA1139UseLiteralSuffixNotationInsteadOfCasting, @@ -266,5 +267,53 @@ public void Method() await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } + + /// + /// Verifies that the codefix will not insert extraneous spaces. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(2901, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2901")] + public async Task TestCodeFixDoesNotAddExtraneousSpacesAsync() + { + var testCode = @" +public class TestClass +{ + public void TestMethod() + { + var x = (long)64 * 1024; + var y = (double)64 /* test */ * 1024; + var z = (long) /* test */ 64 * 1024; + var a = (double)64 // dividend + / (double)4; // divisor + } +} +"; + + var fixedCode = @" +public class TestClass +{ + public void TestMethod() + { + var x = 64L * 1024; + var y = 64D /* test */ * 1024; + var z = /* test */ 64L * 1024; + var a = 64D // dividend + / 4D; // divisor + } +} +"; + + DiagnosticResult[] expectedDiagnosticResult = + { + Diagnostic().WithLocation(6, 17), + Diagnostic().WithLocation(7, 17), + Diagnostic().WithLocation(8, 17), + Diagnostic().WithLocation(9, 17), + Diagnostic().WithLocation(10, 15), + }; + + await VerifyCSharpFixAsync(testCode, expectedDiagnosticResult, fixedCode, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1141UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1141UnitTests.cs new file mode 100644 index 000000000..2e2e8d2b5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SA1141UnitTests.cs @@ -0,0 +1,50 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Test.ReadabilityRules +{ + using System; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.Testing; + using StyleCop.Analyzers.ReadabilityRules; + using Xunit; + using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< + StyleCop.Analyzers.ReadabilityRules.SA1141UseTupleSyntax, + StyleCop.Analyzers.ReadabilityRules.SA1141CodeFixProvider>; + + /// + /// This class contains the unit tests for SA1141. + /// + /// + /// + public class SA1141UnitTests + { + /// + /// Verifies that usage of will not produce a diagnostic when the language + /// version is restricted to C# 6. + /// + /// A representing the asynchronous operation. + [Fact] + public async Task ValueTupleTypesDoNotProduceDiagnosticAsync() + { + var testCode = @"using System; + +public class TestClass +{ + public ValueTuple TestMethod(ValueTuple value) + { + return new ValueTuple(1, 2); + } + + public ValueTuple TestProperty { get; set; } +} +"; + + await VerifyCSharpDiagnosticAsync(LanguageVersion.CSharp6, testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + + //// TODO: Make sure that all paths are covered! + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SX1101UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SX1101UnitTests.cs index fa8c70de6..b7ef4fc77 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SX1101UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/ReadabilityRules/SX1101UnitTests.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.ReadabilityRules { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.ReadabilityRules.SX1101DoNotPrefixLocalMembersWithThis, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SequentialTestCollection.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SequentialTestCollection.cs index 256e8b9d3..93338eb7d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SequentialTestCollection.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SequentialTestCollection.cs @@ -1,5 +1,5 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Settings/SettingsFileCodeFixProviderUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Settings/SettingsFileCodeFixProviderUnitTests.cs index c30889f28..f3002e57e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Settings/SettingsFileCodeFixProviderUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Settings/SettingsFileCodeFixProviderUnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Settings { @@ -31,7 +33,7 @@ namespace NamespaceName [Fact] public async Task TestMissingFileHeaderWithLeadingTriviaAsync() { - await new CSharpTest + var test = new CSharpTest { TestCode = TestCode, ExpectedDiagnostics = { Diagnostic(FileHeaderAnalyzers.SA1633DescriptorMissing).WithLocation(1, 1) }, @@ -42,7 +44,10 @@ public async Task TestMissingFileHeaderWithLeadingTriviaAsync() (SettingsHelper.SettingsFileName, SettingsFileCodeFixProvider.DefaultSettingsFileContent), }, Settings = null, - }.RunAsync(CancellationToken.None).ConfigureAwait(false); + }; + + test.TestBehaviors |= TestBehaviors.SkipSuppressionCheck; + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); } /// @@ -52,7 +57,7 @@ public async Task TestMissingFileHeaderWithLeadingTriviaAsync() [Fact] public async Task TestSettingsFileDoesNotExistAsync() { - await new CSharpTest + var test = new CSharpTest { TestCode = TestCode, ExpectedDiagnostics = { Diagnostic(FileHeaderAnalyzers.SA1633DescriptorMissing).WithLocation(1, 1) }, @@ -63,7 +68,10 @@ public async Task TestSettingsFileDoesNotExistAsync() (SettingsHelper.SettingsFileName, SettingsFileCodeFixProvider.DefaultSettingsFileContent), }, Settings = null, - }.RunAsync(CancellationToken.None).ConfigureAwait(false); + }; + + test.TestBehaviors |= TestBehaviors.SkipSuppressionCheck; + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); } /// @@ -73,15 +81,17 @@ public async Task TestSettingsFileDoesNotExistAsync() [Fact] public async Task TestSettingsFileAlreadyExistsAsync() { - await new CSharpTest + var test = new CSharpTest { TestCode = TestCode, ExpectedDiagnostics = { Diagnostic(FileHeaderAnalyzers.SA1633DescriptorMissing).WithLocation(1, 1) }, FixedCode = TestCode, - FixedState = { InheritanceMode = StateInheritanceMode.AutoInheritAll }, Settings = "{}", SettingsFileName = SettingsHelper.SettingsFileName, - }.RunAsync(CancellationToken.None).ConfigureAwait(false); + }; + + test.TestBehaviors |= TestBehaviors.SkipSuppressionCheck; + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); } /// @@ -91,15 +101,17 @@ public async Task TestSettingsFileAlreadyExistsAsync() [Fact] public async Task TestDotPrefixedSettingsFileAlreadyExistsAsync() { - await new CSharpTest + var test = new CSharpTest { TestCode = TestCode, ExpectedDiagnostics = { Diagnostic(FileHeaderAnalyzers.SA1633DescriptorMissing).WithLocation(1, 1) }, FixedCode = TestCode, - FixedState = { InheritanceMode = StateInheritanceMode.AutoInheritAll }, Settings = "{}", SettingsFileName = SettingsHelper.AltSettingsFileName, - }.RunAsync(CancellationToken.None).ConfigureAwait(false); + }; + + test.TestBehaviors |= TestBehaviors.SkipSuppressionCheck; + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Settings/SettingsUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Settings/SettingsUnitTests.cs index 4faf040fc..ac0f16e83 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Settings/SettingsUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Settings/SettingsUnitTests.cs @@ -1,9 +1,12 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Settings { using System.Collections.Immutable; + using System.Globalization; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; @@ -27,8 +30,11 @@ public void VerifySettingsDefaults() Assert.Equal("PlaceholderCompany", styleCopSettings.DocumentationRules.CompanyName); Assert.Equal("Copyright (c) PlaceholderCompany. All rights reserved.", styleCopSettings.DocumentationRules.GetCopyrightText("unused")); + Assert.Equal("en-US", styleCopSettings.DocumentationRules.DocumentationCulture); + Assert.Same(CultureInfo.InvariantCulture, styleCopSettings.DocumentationRules.DocumentationCultureInfo); Assert.True(styleCopSettings.NamingRules.AllowCommonHungarianPrefixes); Assert.Empty(styleCopSettings.NamingRules.AllowedHungarianPrefixes); + Assert.Empty(styleCopSettings.NamingRules.AllowedNamespaceComponents); Assert.NotNull(styleCopSettings.OrderingRules); Assert.Equal(UsingDirectivesPlacement.InsideNamespace, styleCopSettings.OrderingRules.UsingDirectivesPlacement); @@ -36,12 +42,35 @@ public void VerifySettingsDefaults() Assert.NotNull(styleCopSettings.LayoutRules); Assert.Equal(OptionSetting.Allow, styleCopSettings.LayoutRules.NewlineAtEndOfFile); + Assert.True(styleCopSettings.LayoutRules.AllowConsecutiveUsings); + Assert.False(styleCopSettings.LayoutRules.AllowDoWhileOnClosingBrace); Assert.NotNull(styleCopSettings.SpacingRules); Assert.NotNull(styleCopSettings.ReadabilityRules); Assert.NotNull(styleCopSettings.MaintainabilityRules); } + [Fact] + [WorkItem(3402, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3402")] + public async Task VerifyDefaultCultureIsReadCorrectlyAsync() + { + var settings = @" +{ + ""settings"": { + ""documentationRules"": { + ""documentationCulture"": ""en-US"" + }, + } +} +"; + var context = await CreateAnalysisContextAsync(settings).ConfigureAwait(false); + + var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None); + + Assert.Equal("en-US", styleCopSettings.DocumentationRules.DocumentationCulture); + Assert.Same(CultureInfo.InvariantCulture, styleCopSettings.DocumentationRules.DocumentationCultureInfo); + } + /// /// Verifies that the settings are properly read. /// @@ -61,6 +90,7 @@ public async Task VerifySettingsAreReadCorrectlyAsync() ""namingRules"": { ""allowCommonHungarianPrefixes"": false, ""allowedHungarianPrefixes"": [""a"", ""ab"", ""ignoredTooLong""], + ""allowedNamespaceComponents"": [""eBay"", ""iMac""], ""unrecognizedValue"": 3 }, ""layoutRules"": { @@ -93,6 +123,7 @@ public async Task VerifySettingsAreReadCorrectlyAsync() Assert.Equal("ru-RU", styleCopSettings.DocumentationRules.DocumentationCulture); Assert.False(styleCopSettings.NamingRules.AllowCommonHungarianPrefixes); Assert.Equal(new[] { "a", "ab" }, styleCopSettings.NamingRules.AllowedHungarianPrefixes); + Assert.Equal(new[] { "eBay", "iMac" }, styleCopSettings.NamingRules.AllowedNamespaceComponents); Assert.NotNull(styleCopSettings.LayoutRules); Assert.Equal(OptionSetting.Require, styleCopSettings.LayoutRules.NewlineAtEndOfFile); @@ -168,25 +199,28 @@ public async Task VerifyDocumentationVariablesAsync() /// /// Verifies that the settings will use the read company name in the default copyright text. /// + /// The company name to test. /// A representing the asynchronous unit test. - [Fact] - public async Task VerifySettingsWillUseCompanyNameInDefaultCopyrightTextAsync() + [Theory] + [InlineData("TestCompany")] + [InlineData("TestCompany2")] + public async Task VerifySettingsWillUseCompanyNameInDefaultCopyrightTextAsync(string companyName) { - var settings = @" -{ - ""settings"": { - ""documentationRules"": { - ""companyName"": ""TestCompany"" - } - } -} + var settings = $@" +{{ + ""settings"": {{ + ""documentationRules"": {{ + ""companyName"": ""{companyName}"" + }} + }} +}} "; var context = await CreateAnalysisContextAsync(settings).ConfigureAwait(false); var styleCopSettings = context.GetStyleCopSettings(CancellationToken.None); - Assert.Equal("TestCompany", styleCopSettings.DocumentationRules.CompanyName); - Assert.Equal("Copyright (c) TestCompany. All rights reserved.", styleCopSettings.DocumentationRules.GetCopyrightText("unused")); + Assert.Equal(companyName, styleCopSettings.DocumentationRules.CompanyName); + Assert.Equal($"Copyright (c) {companyName}. All rights reserved.", styleCopSettings.DocumentationRules.GetCopyrightText("unused")); } [Fact] @@ -371,7 +405,7 @@ private static async Task CreateAnalysisContextAsync( var additionalFiles = ImmutableArray.Create(stylecopJSONFile); var analyzerOptions = new AnalyzerOptions(additionalFiles); - return new SyntaxTreeAnalysisContext(syntaxTree, analyzerOptions, rd => { }, isd => { return true; }, CancellationToken.None); + return new SyntaxTreeAnalysisContext(syntaxTree, analyzerOptions, reportDiagnostic: _ => { }, isSupportedDiagnostic: _ => true, CancellationToken.None); } private class AdditionalTextHelper : AdditionalText @@ -386,7 +420,7 @@ public AdditionalTextHelper(string path, string text) public override string Path { get; } - public override SourceText GetText(CancellationToken cancellationToken = default(CancellationToken)) + public override SourceText GetText(CancellationToken cancellationToken = default) { return this.sourceText; } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/NumberSignSpacingTestBase.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/NumberSignSpacingTestBase.cs index a05fee87d..4dd952f0f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/NumberSignSpacingTestBase.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/NumberSignSpacingTestBase.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -590,19 +592,11 @@ private Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expected, st FixedCode = fixedSource, }; - 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); } - private class CSharpTest : StyleCopCodeFixVerifier.CSharpTest + private class CSharpTest : StyleCopCodeFixVerifier.CSharpTest { private readonly NumberSignSpacingTestBase testFixture; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1000UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1000UnitTests.cs index f4ff3c176..ec494e9ff 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1000UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1000UnitTests.cs @@ -1,13 +1,15 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { using System.Threading; using System.Threading.Tasks; + using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1000KeywordsMustBeSpacedCorrectly, @@ -931,12 +933,12 @@ void MethodName() await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } - protected Task TestKeywordStatementAsync(string statement, DiagnosticResult expected, string fixedStatement, string returnType = "void", bool asyncMethod = false) + protected Task TestKeywordStatementAsync(string statement, DiagnosticResult expected, string fixedStatement, string returnType = "void", bool asyncMethod = false, LanguageVersion? languageVersion = default) { - return this.TestKeywordStatementAsync(statement, new[] { expected }, fixedStatement, returnType, asyncMethod); + return this.TestKeywordStatementAsync(statement, new[] { expected }, fixedStatement, returnType, asyncMethod, languageVersion); } - protected async Task TestKeywordStatementAsync(string statement, DiagnosticResult[] expected, string fixedStatement, string returnType = "void", bool asyncMethod = false) + protected async Task TestKeywordStatementAsync(string statement, DiagnosticResult[] expected, string fixedStatement, string returnType = "void", bool asyncMethod = false, LanguageVersion? languageVersion = default) { string testCodeFormat = @" using System; @@ -962,14 +964,7 @@ namespace Namespace string testCode = string.Format(testCodeFormat, asyncModifier, statement, unsafeModifier, awaitMethod, returnType); string fixedTest = string.Format(testCodeFormat, asyncModifier, fixedStatement, unsafeModifier, awaitMethod, returnType); - var test = new CSharpTest - { - TestCode = testCode, - FixedCode = fixedTest, - }; - - test.ExpectedDiagnostics.AddRange(expected); - await test.RunAsync(CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpFixAsync(languageVersion, testCode, expected, fixedTest, CancellationToken.None).ConfigureAwait(false); } private Task TestKeywordDeclarationAsync(string statement, DiagnosticResult expected, string fixedStatement) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1001UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1001UnitTests.cs index 4931392f8..082829819 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1001UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1001UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -8,7 +10,6 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1001CommasMustBeSpacedCorrectly, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1002UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1002UnitTests.cs index 7e5a4b2e4..738596989 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1002UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1002UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1002SemicolonsMustBeSpacedCorrectly, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1003UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1003UnitTests.cs index b4459b129..cf2586ce8 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1003UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1003UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.SpacingRules.SA1003SymbolsMustBeSpacedCorrectly; @@ -976,6 +977,142 @@ public void TestMethod() await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } + /// + /// Verifies that colon in a ternary operator triggers SA1003. + /// + /// The postfix operator to verify. + /// A representing the asynchronous unit test. + [Theory] + [InlineData("++")] + [InlineData("--")] + public async Task TestTernaryFollowedByColonAsync(string postfixOperator) + { + var testCode = $@"public class TestClass +{{ + public void TestMethod() + {{ + int x = 0; + var y1 = x > 0 ? x{postfixOperator}:x{postfixOperator}; + var y2 = x > 0 ? x{postfixOperator} :x{postfixOperator}; + var y3 = x > 0 ? x{postfixOperator}: x{postfixOperator}; + var y4 = x > 0 ? x{postfixOperator} : x{postfixOperator}; + }} +}} +"; + var fixedCode = $@"public class TestClass +{{ + public void TestMethod() + {{ + int x = 0; + var y1 = x > 0 ? x{postfixOperator} : x{postfixOperator}; + var y2 = x > 0 ? x{postfixOperator} : x{postfixOperator}; + var y3 = x > 0 ? x{postfixOperator} : x{postfixOperator}; + var y4 = x > 0 ? x{postfixOperator} : x{postfixOperator}; + }} +}} +"; + + DiagnosticResult[] expected = + { + Diagnostic(DescriptorFollowedByWhitespace).WithSpan(6, 27, 6, 29).WithArguments(postfixOperator), + Diagnostic(DescriptorPrecededByWhitespace).WithSpan(6, 29, 6, 30).WithArguments(":"), + Diagnostic(DescriptorFollowedByWhitespace).WithSpan(6, 29, 6, 30).WithArguments(":"), + Diagnostic(DescriptorFollowedByWhitespace).WithSpan(7, 30, 7, 31).WithArguments(":"), + Diagnostic(DescriptorFollowedByWhitespace).WithSpan(8, 27, 8, 29).WithArguments(postfixOperator), + Diagnostic(DescriptorPrecededByWhitespace).WithSpan(8, 29, 8, 30).WithArguments(":"), + }; + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that colon in a ternary operator triggers SA1003. + /// + /// The prefix operator to verify. + /// A representing the asynchronous unit test. + [Theory] + [InlineData("++")] + [InlineData("--")] + public async Task TestTernaryPrecededByColonAsync(string prefixOperator) + { + var testCode = $@"public class TestClass +{{ + public void TestMethod() + {{ + int x = 0; + var y1 = x > 0 ? {prefixOperator}x:{prefixOperator}x; + var y2 = x > 0 ? {prefixOperator}x :{prefixOperator}x; + var y3 = x > 0 ? {prefixOperator}x: {prefixOperator}x; + var y4 = x > 0 ? {prefixOperator}x : {prefixOperator}x; + }} +}} +"; + var fixedCode = $@"public class TestClass +{{ + public void TestMethod() + {{ + int x = 0; + var y1 = x > 0 ? {prefixOperator}x : {prefixOperator}x; + var y2 = x > 0 ? {prefixOperator}x : {prefixOperator}x; + var y3 = x > 0 ? {prefixOperator}x : {prefixOperator}x; + var y4 = x > 0 ? {prefixOperator}x : {prefixOperator}x; + }} +}} +"; + + DiagnosticResult[] expected = + { + Diagnostic(DescriptorPrecededByWhitespace).WithSpan(6, 29, 6, 30).WithArguments(":"), + Diagnostic(DescriptorFollowedByWhitespace).WithSpan(6, 29, 6, 30).WithArguments(":"), + Diagnostic(DescriptorFollowedByWhitespace).WithSpan(7, 30, 7, 31).WithArguments(":"), + Diagnostic(DescriptorPrecededByWhitespace).WithSpan(8, 29, 8, 30).WithArguments(":"), + }; + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + /// + /// Verifies that interpolated string format triggers SA1003, and does not require a preceding space. + /// + /// The postfix operator to verify. + /// A representing the asynchronous unit test. + [Theory] + [InlineData("++")] + [InlineData("--")] + [WorkItem(3073, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3073")] + public async Task TestInterpolatedStringFormatAsync(string postfixOperator) + { + var testCode = $@"public class TestClass +{{ + public void TestMethod() + {{ + int x = 0; + var y1 = $""{{x{postfixOperator}:N}}""; + var y2 = $""{{x{postfixOperator} :N}}""; + var y3 = $""{{x{postfixOperator}: N}}""; + var y4 = $""{{x{postfixOperator} : N}}""; + }} +}} +"; + var fixedCode = $@"public class TestClass +{{ + public void TestMethod() + {{ + int x = 0; + var y1 = $""{{x{postfixOperator}:N}}""; + var y2 = $""{{x{postfixOperator}:N}}""; + var y3 = $""{{x{postfixOperator}: N}}""; + var y4 = $""{{x{postfixOperator}: N}}""; + }} +}} +"; + + DiagnosticResult[] expected = + { + Diagnostic(DescriptorNotFollowedByWhitespace).WithSpan(7, 22, 7, 24).WithArguments(postfixOperator), + Diagnostic(DescriptorNotFollowedByWhitespace).WithSpan(9, 22, 9, 24).WithArguments(postfixOperator), + }; + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + /// /// Verifies that spacing errors in conditional directives are fixed correctly. This is a regression test for /// DotNetAnalyzers/StyleCopAnalyzers#1831. diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1004UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1004UnitTests.cs index 7e05c97f9..8f90dfcab 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1004UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1004UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1004DocumentationLinesMustBeginWithSingleSpace, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1005UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1005UnitTests.cs index 1cbbebfd8..d281df73f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1005UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1005UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -271,14 +273,10 @@ public class Bar // Verify that this works if the project was configured to treat documentation comments as regular comments await new CSharpTest { - TestCode = testCode, - SolutionTransforms = + TestState = { - (solution, projectId) => - { - var project = solution.GetProject(projectId); - return solution.WithProjectParseOptions(projectId, project.ParseOptions.WithDocumentationMode(DocumentationMode.None)); - }, + DocumentationMode = DocumentationMode.None, + Sources = { testCode }, }, }.RunAsync(CancellationToken.None).ConfigureAwait(false); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1006UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1006UnitTests.cs index bff934b1b..ba1341813 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1006UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1006UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1006PreprocessorKeywordsMustNotBePrecededBySpace, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1007UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1007UnitTests.cs index 84eab40c2..8a86bc5c7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1007UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1007UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1007OperatorKeywordMustBeFollowedBySpace, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1008UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1008UnitTests.cs index 98c17d6ec..ef93d0f0f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1008UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1008UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.SpacingRules.SA1008OpeningParenthesisMustBeSpacedCorrectly; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< @@ -137,11 +138,61 @@ public void TestMethod1( int z) { } + + public void TestMethod2 ( + int x, + int y, + int z) + { + } + + // Opening parenthesis followed by space + public void TestMethod3( + int x, + int y, + int z) + { + } } } "; - await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + var fixedTestCode = @"namespace TestNamespace +{ + public class TestClass + { + public void TestMethod1( + int x, + int y, + int z) + { + } + + public void TestMethod2( + int x, + int y, + int z) + { + } + + // Opening parenthesis followed by space + public void TestMethod3( + int x, + int y, + int z) + { + } + } +} +"; + + DiagnosticResult[] expectedDiagnostics = + { + Diagnostic(DescriptorNotPreceded).WithLocation(12, 33), + Diagnostic(DescriptorNotFollowed).WithLocation(20, 32), + }; + + await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } /// @@ -781,6 +832,72 @@ public TestClass() await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } + /// + /// Verifies that spacing for multiline argument lists is handled properly. + /// + /// A representing the asynchronous unit test. + [Fact] + public async Task TestMultiLineArgumentListAsync() + { + var testCode = @"using System; + +namespace TestNamespace +{ + public class TestClass + { + public TestClass(int x, int y) + { + var s1 = new String( + 'a', + x); + + var s2 = new String ( + 'a', + y); + + // Opening parenthesis followed by space + var s3 = new String( + 'a', + x); + } + } +} +"; + + var fixedTestCode = @"using System; + +namespace TestNamespace +{ + public class TestClass + { + public TestClass(int x, int y) + { + var s1 = new String( + 'a', + x); + + var s2 = new String( + 'a', + y); + + // Opening parenthesis followed by space + var s3 = new String( + 'a', + x); + } + } +} +"; + + DiagnosticResult[] expectedDiagnostics = + { + Diagnostic(DescriptorNotPreceded).WithLocation(13, 33), + Diagnostic(DescriptorNotFollowed).WithLocation(18, 32), + }; + + await VerifyCSharpFixAsync(testCode, expectedDiagnostics, fixedTestCode, CancellationToken.None).ConfigureAwait(false); + } + /// /// Verifies that spacing for while statements is handled properly. /// @@ -2041,5 +2158,22 @@ public void TestMethod() await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } + + [Fact] + [WorkItem(2354, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2354")] + public async Task TestNoPreviousTokenAsync() + { + var testCode = "("; + + var test = new CSharpTest() + { + TestCode = testCode, + + // Compiler diagnostics differ between Roslyn versions. The main thing is that the analyzer doesn't throw an exception. + CompilerDiagnostics = CompilerDiagnostics.None, + }; + + await test.RunAsync(CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1009UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1009UnitTests.cs index 7de352eab..e25de0de3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1009UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1009UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -7,8 +9,8 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; + using static StyleCop.Analyzers.SpacingRules.SA1009ClosingParenthesisMustBeSpacedCorrectly; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1009ClosingParenthesisMustBeSpacedCorrectly, StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; @@ -53,7 +55,7 @@ public void Method() } }"; - DiagnosticResult expected = Diagnostic().WithArguments(" not", "preceded").WithLocation(5, 25); + DiagnosticResult expected = Diagnostic(DescriptorNotPreceded).WithLocation(5, 25); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } @@ -78,7 +80,34 @@ public void Method() } }"; - DiagnosticResult expected = Diagnostic().WithArguments(" not", "preceded").WithLocation(4, 28); + DiagnosticResult expected = Diagnostic(DescriptorNotPreceded).WithLocation(4, 28); + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Fact] + [WorkItem(2985, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2985")] + public async Task TestDocumentationMethodReferenceInSingleQuotesWithWhitespaceAfterClosingParenthesisAsync() + { + const string testCode = @" +public class Foo +{ + /// + public void Method() + { + } +}"; + + const string fixedCode = @" +public class Foo +{ + /// + public void Method() + { + } +}"; + + DiagnosticResult expected = Diagnostic(DescriptorNotFollowed).WithLocation(0); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } @@ -119,34 +148,18 @@ public void Method(int param1, int param2) } }"; - DiagnosticResult expected = Diagnostic().WithArguments(" not", "preceded").WithLocation(5, 47); + DiagnosticResult expected = Diagnostic(DescriptorNotPreceded).WithLocation(5, 47); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } - [Fact] - public async Task TestAttributeWithParametersAndNoSpaceAfterClosingParenthesisAsync() - { - const string testCode = @"using System; -using System.Security.Permissions; - -[PermissionSet(SecurityAction.LinkDemand, Name = ""FullTrust"")] -public class Foo -{ - public void Method(int param1, int param2) - { - } -}"; - await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); - } - [Fact] public async Task TestAttributeWithParametersAndSpaceAfterClosingParenthesisAsync() { const string testCode = @"using System; -using System.Security.Permissions; +using System.Runtime.InteropServices; -[PermissionSet(SecurityAction.LinkDemand, Name = ""FullTrust"") ] +[StructLayout(LayoutKind.Auto, CharSet = CharSet.Auto{|#0:)|} ] public class Foo { public void Method(int param1, int param2) @@ -155,9 +168,9 @@ public void Method(int param1, int param2) }"; const string fixedCode = @"using System; -using System.Security.Permissions; +using System.Runtime.InteropServices; -[PermissionSet(SecurityAction.LinkDemand, Name = ""FullTrust"")] +[StructLayout(LayoutKind.Auto, CharSet = CharSet.Auto)] public class Foo { public void Method(int param1, int param2) @@ -165,7 +178,7 @@ public void Method(int param1, int param2) } }"; - DiagnosticResult expected = Diagnostic().WithArguments(" not", "followed").WithLocation(4, 61); + DiagnosticResult expected = Diagnostic(DescriptorNotFollowed).WithLocation(0); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } @@ -206,7 +219,7 @@ public Foo(int i) : base() } }"; - DiagnosticResult expected = Diagnostic().WithArguments(string.Empty, "followed").WithLocation(5, 21); + DiagnosticResult expected = Diagnostic(DescriptorFollowed).WithLocation(5, 21); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } @@ -217,7 +230,7 @@ public async Task TestLambdaExpressionWithNoSpaceAfterClosingParenthesisAsync() var invalidStatement = @"System.EventHandler handler = (s, e)=> { };"; var validStatement = @"System.EventHandler handler = (s, e) => { };"; - DiagnosticResult expected = Diagnostic().WithArguments(string.Empty, "followed").WithLocation(7, 48); + DiagnosticResult expected = Diagnostic(DescriptorFollowed).WithLocation(7, 48); await this.TestWhitespaceInStatementOrDeclAsync(invalidStatement, validStatement, expected).ConfigureAwait(false); } @@ -251,7 +264,7 @@ public async Task TestSpaceBeforeParenthisInIncrementingForLoopAsync() { }"; - DiagnosticResult expected = Diagnostic().WithArguments(" not", "preceded").WithLocation(7, 41); + DiagnosticResult expected = Diagnostic(DescriptorNotPreceded).WithLocation(7, 41); await this.TestWhitespaceInStatementOrDeclAsync(invalidStatement, validStatement, expected).ConfigureAwait(false); } @@ -266,7 +279,7 @@ public async Task TestSpaceBeforeParenthisInDecrementingForLoopAsync() { }"; - DiagnosticResult expected = Diagnostic().WithArguments(" not", "preceded").WithLocation(7, 41); + DiagnosticResult expected = Diagnostic(DescriptorNotPreceded).WithLocation(7, 41); await this.TestWhitespaceInStatementOrDeclAsync(invalidStatement, validStatement, expected).ConfigureAwait(false); } @@ -277,7 +290,7 @@ public async Task TestSpaceInCastAsync() var invalidStatement = @"var i = (int) 1;"; var validStatement = @"var i = (int)1;"; - DiagnosticResult expected = Diagnostic().WithArguments(" not", "followed").WithLocation(7, 25); + DiagnosticResult expected = Diagnostic(DescriptorNotFollowed).WithLocation(7, 25); await this.TestWhitespaceInStatementOrDeclAsync(invalidStatement, validStatement, expected).ConfigureAwait(false); } @@ -288,7 +301,7 @@ public async Task TestSpaceInConstructorCallAsync() var invalidStatement = @"var o = new object() ;"; var validStatement = @"var o = new object();"; - DiagnosticResult expected = Diagnostic().WithArguments(" not", "followed").WithLocation(7, 32); + DiagnosticResult expected = Diagnostic(DescriptorNotFollowed).WithLocation(7, 32); await this.TestWhitespaceInStatementOrDeclAsync(invalidStatement, validStatement, expected).ConfigureAwait(false); } @@ -299,7 +312,7 @@ public async Task TestSpaceMethodCallFollowedByPropertyGetAsync() var invalidStatement = @"var o = new Baz() .Test;"; var validStatement = @"var o = new Baz().Test;"; - DiagnosticResult expected = Diagnostic().WithArguments(" not", "followed").WithLocation(7, 29); + DiagnosticResult expected = Diagnostic(DescriptorNotFollowed).WithLocation(7, 29); await this.TestWhitespaceInStatementOrDeclAsync(invalidStatement, validStatement, expected).ConfigureAwait(false); } @@ -310,7 +323,7 @@ public async Task TestSpaceMethodCallFollowedByConditionalAccessPropertyGetAsync var invalidStatement = @"var o = new Baz() ?.Test;"; var validStatement = @"var o = new Baz()?.Test;"; - DiagnosticResult expected = Diagnostic().WithArguments(" not", "followed").WithLocation(7, 29); + DiagnosticResult expected = Diagnostic(DescriptorNotFollowed).WithLocation(7, 29); await this.TestWhitespaceInStatementOrDeclAsync(invalidStatement, validStatement, expected).ConfigureAwait(false); } @@ -321,7 +334,7 @@ public async Task TestSpaceMethodCallFollowedByPointerDereferenceAsync() var invalidStatement = @"var o = GetPointer() ->ToString();"; var validStatement = @"var o = GetPointer()->ToString();"; - DiagnosticResult expected = Diagnostic().WithArguments(" not", "followed").WithLocation(7, 32); + DiagnosticResult expected = Diagnostic(DescriptorNotFollowed).WithLocation(7, 32); await this.TestWhitespaceInStatementOrDeclAsync(invalidStatement, validStatement, expected).ConfigureAwait(false); } @@ -334,8 +347,8 @@ public async Task TestSpaceOperationInDoubleSetOfParenthesisAsync() DiagnosticResult[] expected = { - Diagnostic().WithArguments(" not", "followed").WithLocation(7, 28), - Diagnostic().WithArguments(" not", "preceded").WithLocation(7, 30), + Diagnostic(DescriptorNotFollowed).WithLocation(7, 28), + Diagnostic(DescriptorNotPreceded).WithLocation(7, 30), }; await this.TestWhitespaceInStatementOrDeclAsync(invalidStatement, validStatement, expected).ConfigureAwait(false); @@ -355,7 +368,7 @@ public async Task TestSpaceIncrementOrDecrementOperatorFollowingParenthesisAsync (i){0};", operatorValue); - DiagnosticResult expected = Diagnostic().WithArguments(" not", "followed").WithLocation(8, 15); + DiagnosticResult expected = Diagnostic(DescriptorNotFollowed).WithLocation(8, 15); await this.TestWhitespaceInStatementOrDeclAsync(invalidStatement, validStatement, expected).ConfigureAwait(false); } @@ -366,7 +379,7 @@ public async Task TestSpaceBetweenClosingBraceAndParenthesisAsync() var invalidStatement = @"var x = new System.Action(() => { } );"; var validStatement = @"var x = new System.Action(() => { });"; - DiagnosticResult expected = Diagnostic().WithArguments(" not", "preceded").WithLocation(7, 49); + DiagnosticResult expected = Diagnostic(DescriptorNotPreceded).WithLocation(7, 49); await this.TestWhitespaceInStatementOrDeclAsync(invalidStatement, validStatement, expected).ConfigureAwait(false); } @@ -377,7 +390,7 @@ public async Task TestSpaceClosingParenthesisFollowedByParenthesisPairAsync() var invalidStatement = @"new System.Action(() => { }) ();"; var validStatement = @"new System.Action(() => { })();"; - DiagnosticResult expected = Diagnostic().WithArguments(" not", "followed").WithLocation(7, 40); + DiagnosticResult expected = Diagnostic(DescriptorNotFollowed).WithLocation(7, 40); await this.TestWhitespaceInStatementOrDeclAsync(invalidStatement, validStatement, expected).ConfigureAwait(false); } @@ -388,7 +401,7 @@ public async Task TestSpaceParenthesisFollowedByBracketAsync() var invalidStatement = @"var a = GetA() [0];"; var validStatement = @"var a = GetA()[0];"; - DiagnosticResult expected = Diagnostic().WithArguments(" not", "followed").WithLocation(7, 26); + DiagnosticResult expected = Diagnostic(DescriptorNotFollowed).WithLocation(7, 26); await this.TestWhitespaceInStatementOrDeclAsync(invalidStatement, validStatement, expected).ConfigureAwait(false); } @@ -399,7 +412,7 @@ public async Task TestNoSpaceParenthesisFollowedByColonAsync() var invalidStatement = @"var x = true ? GetA(): GetB();"; var validStatement = @"var x = true ? GetA() : GetB();"; - DiagnosticResult expected = Diagnostic().WithArguments(string.Empty, "followed").WithLocation(7, 33); + DiagnosticResult expected = Diagnostic(DescriptorFollowed).WithLocation(7, 33); await this.TestWhitespaceInStatementOrDeclAsync(invalidStatement, validStatement, expected).ConfigureAwait(false); } @@ -410,7 +423,7 @@ public async Task TestNoSpaceParenthesisFollowedByQuestionAsync() var invalidStatement = @"var x = (true == true)? GetA() : GetB();"; var validStatement = @"var x = (true == true) ? GetA() : GetB();"; - DiagnosticResult expected = Diagnostic().WithArguments(string.Empty, "followed").WithLocation(7, 34); + DiagnosticResult expected = Diagnostic(DescriptorFollowed).WithLocation(7, 34); await this.TestWhitespaceInStatementOrDeclAsync(invalidStatement, validStatement, expected).ConfigureAwait(false); } @@ -421,7 +434,7 @@ public async Task TestWithSpaceFollowingInInterpolatedStringAsync() var invalidStatement = @"var x = $""{typeof(string).ToString() }"";"; var validStatement = @"var x = $""{typeof(string).ToString()}"";"; - DiagnosticResult expected = Diagnostic().WithArguments(" not", "followed").WithLocation(7, 48); + DiagnosticResult expected = Diagnostic(DescriptorNotFollowed).WithLocation(7, 48); await this.TestWhitespaceInStatementOrDeclAsync(invalidStatement, validStatement, expected).ConfigureAwait(false); } @@ -555,12 +568,12 @@ public void TestMethod3(bool a, bool b) { } DiagnosticResult[] expected = { - Diagnostic().WithLocation(8, 21).WithArguments(string.Empty, "followed"), - Diagnostic().WithLocation(11, 25).WithArguments(string.Empty, "followed"), - Diagnostic().WithLocation(18, 9).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(24, 12).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(33, 12).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(42, 12).WithArguments(" not", "preceded"), + Diagnostic(DescriptorFollowed).WithLocation(8, 21), + Diagnostic(DescriptorFollowed).WithLocation(11, 25), + Diagnostic(DescriptorNotPreceded).WithLocation(18, 9), + Diagnostic(DescriptorNotPreceded).WithLocation(24, 12), + Diagnostic(DescriptorNotPreceded).WithLocation(33, 12), + Diagnostic(DescriptorNotPreceded).WithLocation(42, 12), }; await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -611,8 +624,8 @@ public void TestMethod3(bool a, bool b) { } DiagnosticResult[] expected = { - Diagnostic().WithLocation(8, 21).WithArguments(string.Empty, "followed"), - Diagnostic().WithLocation(11, 25).WithArguments(string.Empty, "followed"), + Diagnostic(DescriptorFollowed).WithLocation(8, 21), + Diagnostic(DescriptorFollowed).WithLocation(11, 25), }; await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -706,17 +719,17 @@ public int TestMethod4(string[] args) TestCode = testCode, ExpectedDiagnostics = { - Diagnostic().WithLocation(10, 9).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(16, 7).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(21, 19).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(25, 17).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(32, 16).WithArguments(" not", "preceded"), + Diagnostic(DescriptorNotPreceded).WithLocation(10, 9), + Diagnostic(DescriptorNotPreceded).WithLocation(16, 7), + Diagnostic(DescriptorNotPreceded).WithLocation(21, 19), + Diagnostic(DescriptorNotPreceded).WithLocation(25, 17), + Diagnostic(DescriptorNotPreceded).WithLocation(32, 16), }, FixedCode = fixedCode, RemainingDiagnostics = { - Diagnostic().WithLocation(10, 9).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(25, 17).WithArguments(" not", "preceded"), + Diagnostic(DescriptorNotPreceded).WithLocation(10, 9), + Diagnostic(DescriptorNotPreceded).WithLocation(25, 17), }, NumberOfFixAllIterations = 2, }.RunAsync(CancellationToken.None).ConfigureAwait(false); @@ -745,7 +758,7 @@ public void TestMethod() } "; - DiagnosticResult expected = Diagnostic().WithLocation(6, 52).WithArguments(" not", "preceded"); + DiagnosticResult expected = Diagnostic(DescriptorNotPreceded).WithLocation(6, 52); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } @@ -782,7 +795,7 @@ void Method() } "; - DiagnosticResult expected = Diagnostic().WithLocation(8, 15).WithArguments(" not", "followed"); + DiagnosticResult expected = Diagnostic(DescriptorNotFollowed).WithLocation(8, 15); await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } @@ -814,7 +827,7 @@ public async Task TestFollowedByBinaryOperatorAsync(string operatorToken) string testCode = $"var x = (3 + 2){operatorToken} 4;"; string fixedCode = $"var x = (3 + 2) {operatorToken} 4;"; - DiagnosticResult expected = Diagnostic().WithLocation(7, 27).WithArguments(string.Empty, "followed"); + DiagnosticResult expected = Diagnostic(DescriptorFollowed).WithLocation(7, 27); await this.TestWhitespaceInStatementOrDeclAsync(testCode, fixedCode, expected).ConfigureAwait(false); } @@ -832,7 +845,7 @@ public async Task TestFollowedByConditionalOperatorAsync(string operatorToken) string testCode = $"var x = (true){operatorToken} false;"; string fixedCode = $"var x = (true) {operatorToken} false;"; - DiagnosticResult expected = Diagnostic().WithLocation(7, 26).WithArguments(string.Empty, "followed"); + DiagnosticResult expected = Diagnostic(DescriptorFollowed).WithLocation(7, 26); await this.TestWhitespaceInStatementOrDeclAsync(testCode, fixedCode, expected).ConfigureAwait(false); } @@ -859,7 +872,7 @@ public async Task TestFollowedByAssignmentOperatorAsync(string operatorToken) string testCode = $"var x = 0; (x){operatorToken} 4;"; string fixedCode = $"var x = 0; (x) {operatorToken} 4;"; - DiagnosticResult expected = Diagnostic().WithLocation(7, 26).WithArguments(string.Empty, "followed"); + DiagnosticResult expected = Diagnostic(DescriptorFollowed).WithLocation(7, 26); await this.TestWhitespaceInStatementOrDeclAsync(testCode, fixedCode, expected).ConfigureAwait(false); } @@ -930,7 +943,7 @@ public async void TestMethod() DiagnosticResult[] expected = { - Diagnostic().WithLocation(8, 13).WithArguments(" not", "preceded"), + Diagnostic(DescriptorNotPreceded).WithLocation(8, 13), }; await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -966,7 +979,50 @@ await Task.Delay(1000) DiagnosticResult[] expected = { - Diagnostic().WithLocation(8, 13).WithArguments(" not", "preceded"), + Diagnostic(DescriptorNotPreceded).WithLocation(8, 13), + }; + + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + [Theory] + [InlineData("if (true)")] + [InlineData("while (true)")] + [InlineData("for (var i = 0; i < 10; i++)")] + [InlineData("foreach (var i in a)")] + [WorkItem(3731, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3731")] + public async Task TestControlStatementWithBodyOnSameLineAsync(string stmt) + { + var testCode = $@" +public class TestClass +{{ + public async void TestMethod(int x, int[] a) + {{ + {stmt}++x; + {stmt}--x; + {stmt}x++; + {stmt}{{ x++; }} + }} +}}"; + + var fixedCode = $@" +public class TestClass +{{ + public async void TestMethod(int x, int[] a) + {{ + {stmt} ++x; + {stmt} --x; + {stmt} x++; + {stmt} {{ x++; }} + }} +}}"; + + var expected = new[] + { + Diagnostic(DescriptorFollowed).WithLocation(6, 8 + stmt.Length), + Diagnostic(DescriptorFollowed).WithLocation(7, 8 + stmt.Length), + Diagnostic(DescriptorFollowed).WithLocation(8, 8 + stmt.Length), + Diagnostic(DescriptorFollowed).WithLocation(9, 8 + stmt.Length), }; await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1010UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1010UnitTests.cs index 482188f9e..317f3f0f9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1010UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1010UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -7,8 +9,8 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; + using static StyleCop.Analyzers.SpacingRules.SA1010OpeningSquareBracketsMustBeSpacedCorrectly; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1010OpeningSquareBracketsMustBeSpacedCorrectly, StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; @@ -67,14 +69,14 @@ public int this [[CLSCompliant(true)]int index] DiagnosticResult[] expected = { - Diagnostic().WithLocation(5, 21).WithArguments("not be preceded"), - Diagnostic().WithLocation(9, 17).WithArguments("not be preceded"), - Diagnostic().WithLocation(9, 20).WithArguments("not be preceded"), - Diagnostic().WithLocation(9, 38).WithArguments("not be preceded"), - Diagnostic().WithLocation(9, 41).WithArguments("not be preceded"), - Diagnostic().WithLocation(12, 27).WithArguments("not be preceded"), - Diagnostic().WithLocation(15, 25).WithArguments("not be preceded"), - Diagnostic().WithLocation(15, 29).WithArguments("not be preceded"), + Diagnostic(DescriptorNotPreceded).WithLocation(5, 21), + Diagnostic(DescriptorNotPreceded).WithLocation(9, 17), + Diagnostic(DescriptorNotPreceded).WithLocation(9, 20), + Diagnostic(DescriptorNotPreceded).WithLocation(9, 38), + Diagnostic(DescriptorNotPreceded).WithLocation(9, 41), + Diagnostic(DescriptorNotPreceded).WithLocation(12, 27), + Diagnostic(DescriptorNotPreceded).WithLocation(15, 25), + Diagnostic(DescriptorNotPreceded).WithLocation(15, 29), }; await VerifyCSharpFixAsync(testCode, expected, ExpectedCode, CancellationToken.None).ConfigureAwait(false); @@ -104,13 +106,13 @@ public int this[ [CLSCompliant(true)]int index] DiagnosticResult[] expected = { - Diagnostic().WithLocation(5, 20).WithArguments("not be followed"), - Diagnostic().WithLocation(9, 16).WithArguments("not be followed"), - Diagnostic().WithLocation(9, 19).WithArguments("not be followed"), - Diagnostic().WithLocation(9, 37).WithArguments("not be followed"), - Diagnostic().WithLocation(12, 24).WithArguments("not be followed"), - Diagnostic().WithLocation(15, 24).WithArguments("not be followed"), - Diagnostic().WithLocation(15, 28).WithArguments("not be followed"), + Diagnostic(DescriptorNotFollowed).WithLocation(5, 20), + Diagnostic(DescriptorNotFollowed).WithLocation(9, 16), + Diagnostic(DescriptorNotFollowed).WithLocation(9, 19), + Diagnostic(DescriptorNotFollowed).WithLocation(9, 37), + Diagnostic(DescriptorNotFollowed).WithLocation(12, 24), + Diagnostic(DescriptorNotFollowed).WithLocation(15, 24), + Diagnostic(DescriptorNotFollowed).WithLocation(15, 28), }; await VerifyCSharpFixAsync(testCode, expected, ExpectedCode, CancellationToken.None).ConfigureAwait(false); @@ -140,20 +142,20 @@ public int this [ [CLSCompliant(true)]int index] DiagnosticResult[] expected = { - Diagnostic().WithLocation(5, 21).WithArguments("not be preceded"), - Diagnostic().WithLocation(5, 21).WithArguments("not be followed"), - Diagnostic().WithLocation(9, 17).WithArguments("not be preceded"), - Diagnostic().WithLocation(9, 17).WithArguments("not be followed"), - Diagnostic().WithLocation(9, 21).WithArguments("not be preceded"), - Diagnostic().WithLocation(9, 21).WithArguments("not be followed"), - Diagnostic().WithLocation(9, 40).WithArguments("not be preceded"), - Diagnostic().WithLocation(9, 40).WithArguments("not be followed"), - Diagnostic().WithLocation(12, 27).WithArguments("not be preceded"), - Diagnostic().WithLocation(12, 27).WithArguments("not be followed"), - Diagnostic().WithLocation(15, 25).WithArguments("not be preceded"), - Diagnostic().WithLocation(15, 25).WithArguments("not be followed"), - Diagnostic().WithLocation(15, 30).WithArguments("not be preceded"), - Diagnostic().WithLocation(15, 30).WithArguments("not be followed"), + Diagnostic(DescriptorNotPreceded).WithLocation(5, 21), + Diagnostic(DescriptorNotFollowed).WithLocation(5, 21), + Diagnostic(DescriptorNotPreceded).WithLocation(9, 17), + Diagnostic(DescriptorNotFollowed).WithLocation(9, 17), + Diagnostic(DescriptorNotPreceded).WithLocation(9, 21), + Diagnostic(DescriptorNotFollowed).WithLocation(9, 21), + Diagnostic(DescriptorNotPreceded).WithLocation(9, 40), + Diagnostic(DescriptorNotFollowed).WithLocation(9, 40), + Diagnostic(DescriptorNotPreceded).WithLocation(12, 27), + Diagnostic(DescriptorNotFollowed).WithLocation(12, 27), + Diagnostic(DescriptorNotPreceded).WithLocation(15, 25), + Diagnostic(DescriptorNotFollowed).WithLocation(15, 25), + Diagnostic(DescriptorNotPreceded).WithLocation(15, 30), + Diagnostic(DescriptorNotFollowed).WithLocation(15, 30), }; await VerifyCSharpFixAsync(testCode, expected, ExpectedCode, CancellationToken.None).ConfigureAwait(false); @@ -211,7 +213,7 @@ public void TestMethod(IDictionary items) } } "; - var expected = Diagnostic().WithLocation(8, 62).WithArguments("not be preceded"); + var expected = Diagnostic(DescriptorNotPreceded).WithLocation(8, 62); await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1011UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1011UnitTests.cs index f46328cad..731803639 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1011UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1011UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1011ClosingSquareBracketsMustBeSpacedCorrectly, @@ -260,7 +261,8 @@ public async Task TestClosingBracketFollowedByNoSpaceAndIncrementOrDecrementOper { string validStatament = string.Format( @"var i = new int[1]; - i[0]{0};", operatorText); + i[0]{0};", + operatorText); await this.TestWhitespaceInStatementOrDeclAsync(validStatament, null, DiagnosticResult.EmptyDiagnosticResults).ConfigureAwait(false); } @@ -272,11 +274,13 @@ public async Task TestClosingBracketFollowedBySpaceAndIncrementOrDecrementOperat { string invalidStatament = string.Format( @"var i = new int[1]; - i[0] {0};", operatorText); + i[0] {0};", + operatorText); string fixedStatament = string.Format( @"var i = new int[1]; - i[0]{0};", operatorText); + i[0]{0};", + operatorText); DiagnosticResult expected = Diagnostic().WithLocation(8, 16).WithArguments(" not", "followed"); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1012UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1012UnitTests.cs index 4ffd08752..a36abef7d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1012UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1012UnitTests.cs @@ -1,14 +1,14 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { using System.Threading; using System.Threading.Tasks; - using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1012OpeningBracesMustBeSpacedCorrectly, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1013UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1013UnitTests.cs index 89ad79544..550bf0750 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1013UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1013UnitTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.SpacingRules { @@ -7,7 +7,6 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1013ClosingBracesMustBeSpacedCorrectly, @@ -53,15 +52,17 @@ public async Task TestStringInterpolationAsync() { public class TestClass { - public void TestMethod() + public void TestMethod(int a, int b) { var test = 2; var x = $""{test}""; x = $""{test}""; x = $""({test})""; x = $""({test} )""; - x = $""{test }""; - x = $""{test } ""; + x = $""{test {|#0:}|}""; + x = $""{test {|#1:}|} ""; + x = $""{new { a, b{|#2:}|}}""; + x = $""{new { a, b } {|#3:}|}""; } } } @@ -71,7 +72,7 @@ public void TestMethod() { public class TestClass { - public void TestMethod() + public void TestMethod(int a, int b) { var test = 2; var x = $""{test}""; @@ -80,6 +81,8 @@ public void TestMethod() x = $""({test} )""; x = $""{test}""; x = $""{test} ""; + x = $""{new { a, b }}""; + x = $""{new { a, b }}""; } } } @@ -87,8 +90,10 @@ public void TestMethod() DiagnosticResult[] expected = { - Diagnostic().WithLocation(12, 25).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(13, 25).WithArguments(" not", "preceded"), + Diagnostic().WithLocation(0).WithArguments(" not", "preceded"), + Diagnostic().WithLocation(1).WithArguments(" not", "preceded"), + Diagnostic().WithLocation(2).WithArguments(string.Empty, "preceded"), + Diagnostic().WithLocation(3).WithArguments(" not", "preceded"), }; await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -106,7 +111,7 @@ public async Task TestPropertyDeclarationAsync() public class TestClass { public int TestProperty1 { get; set; } - public int TestProperty2 { get; set;} + public int TestProperty2 { get; set;{|#0:}|} } } "; @@ -123,7 +128,7 @@ public class TestClass DiagnosticResult[] expected = { - Diagnostic().WithLocation(6, 45).WithArguments(string.Empty, "preceded"), + Diagnostic().WithLocation(0).WithArguments(string.Empty, "preceded"), }; await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -145,9 +150,9 @@ public class TestClass public void TestMethod() { new Dictionary { { 1, 1 } }; - new Dictionary { { 1, 1} }; - new Dictionary { { 1, 1 }}; - new Dictionary { { 1, 1}}; + new Dictionary { { 1, 1{|#0:}|} }; + new Dictionary { { 1, 1 {|#1:}|}{|#2:}|}; + new Dictionary { { 1, 1{|#3:}|}{|#4:}|}; } } } @@ -172,12 +177,12 @@ public void TestMethod() DiagnosticResult[] expected = { - Diagnostic().WithLocation(10, 46).WithArguments(string.Empty, "preceded"), - Diagnostic().WithLocation(11, 47).WithArguments(string.Empty, "followed"), - Diagnostic().WithLocation(11, 48).WithArguments(string.Empty, "preceded"), - Diagnostic().WithLocation(12, 46).WithArguments(string.Empty, "preceded"), - Diagnostic().WithLocation(12, 46).WithArguments(string.Empty, "followed"), - Diagnostic().WithLocation(12, 47).WithArguments(string.Empty, "preceded"), + Diagnostic().WithLocation(0).WithArguments(string.Empty, "preceded"), + Diagnostic().WithLocation(1).WithArguments(string.Empty, "followed"), + Diagnostic().WithLocation(2).WithArguments(string.Empty, "preceded"), + Diagnostic().WithLocation(3).WithArguments(string.Empty, "preceded"), + Diagnostic().WithLocation(3).WithArguments(string.Empty, "followed"), + Diagnostic().WithLocation(4).WithArguments(string.Empty, "preceded"), }; await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -296,9 +301,9 @@ public void TestMethod1(object[] a) public void TestMethod2() { TestMethod1(new object[] { }); - TestMethod1(new object[] {}); + TestMethod1(new object[] {{|#0:}|}); TestMethod1(new object[] { } ); - TestMethod1(new object[] {} ); + TestMethod1(new object[] {{|#1:}|} ); } } } @@ -326,8 +331,8 @@ public void TestMethod2() // space between closing brace and closing parenthesis should be reported by SA1009 DiagnosticResult[] expected = { - Diagnostic().WithLocation(12, 39).WithArguments(string.Empty, "preceded"), - Diagnostic().WithLocation(14, 39).WithArguments(string.Empty, "preceded"), + Diagnostic().WithLocation(0).WithArguments(string.Empty, "preceded"), + Diagnostic().WithLocation(1).WithArguments(string.Empty, "preceded"), }; await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -382,12 +387,12 @@ public async Task TestMissingTokenAsync() { string testCode = @" class ClassName -{ +{{|#0:|} "; DiagnosticResult[] expected = { - DiagnosticResult.CompilerError("CS1513").WithMessage("} expected").WithLocation(3, 2), + DiagnosticResult.CompilerError("CS1513").WithMessage("} expected").WithLocation(0), }; await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1014UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1014UnitTests.cs index 70d813e89..ab64426ad 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1014UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1014UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1014OpeningGenericBracketsMustBeSpacedCorrectly, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1015UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1015UnitTests.cs index b7f4372b2..e6e7822be 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1015UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1015UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -7,8 +9,8 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; + using static StyleCop.Analyzers.SpacingRules.SA1015ClosingGenericBracketsMustBeSpacedCorrectly; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1015ClosingGenericBracketsMustBeSpacedCorrectly, StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; @@ -83,9 +85,9 @@ public class TestClass3 where T : IEnumerable DiagnosticResult[] expected = { - Diagnostic().WithLocation(7, 27).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(7, 58).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(11, 26).WithArguments(string.Empty, "followed"), + Diagnostic(DescriptorNotPreceded).WithLocation(7, 27), + Diagnostic(DescriptorNotPreceded).WithLocation(7, 58), + Diagnostic(DescriptorFollowed).WithLocation(11, 26), }; await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -124,12 +126,12 @@ public class TestClass DiagnosticResult[] expected = { - Diagnostic().WithLocation(6, 33).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(7, 34).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(8, 33).WithArguments(string.Empty, "followed"), - Diagnostic().WithLocation(9, 33).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(9, 35).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(9, 35).WithArguments(string.Empty, "followed"), + Diagnostic(DescriptorNotPreceded).WithLocation(6, 33), + Diagnostic(DescriptorNotPreceded).WithLocation(7, 34), + Diagnostic(DescriptorFollowed).WithLocation(8, 33), + Diagnostic(DescriptorNotPreceded).WithLocation(9, 33), + Diagnostic(DescriptorNotPreceded).WithLocation(9, 35), + Diagnostic(DescriptorFollowed).WithLocation(9, 35), }; await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -206,17 +208,17 @@ public Action> TestMethod5() DiagnosticResult[] expected = { - Diagnostic().WithLocation(10, 33).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(10, 51).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(15, 34).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(15, 34).WithArguments(string.Empty, "followed"), - Diagnostic().WithLocation(15, 48).WithArguments(" not", "followed"), - Diagnostic().WithLocation(20, 33).WithArguments(string.Empty, "followed"), - Diagnostic().WithLocation(25, 33).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(25, 35).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(25, 35).WithArguments(string.Empty, "followed"), - Diagnostic().WithLocation(25, 50).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(25, 50).WithArguments(" not", "followed"), + Diagnostic(DescriptorNotPreceded).WithLocation(10, 33), + Diagnostic(DescriptorNotPreceded).WithLocation(10, 51), + Diagnostic(DescriptorNotPreceded).WithLocation(15, 34), + Diagnostic(DescriptorFollowed).WithLocation(15, 34), + Diagnostic(DescriptorNotFollowed).WithLocation(15, 48), + Diagnostic(DescriptorFollowed).WithLocation(20, 33), + Diagnostic(DescriptorNotPreceded).WithLocation(25, 33), + Diagnostic(DescriptorNotPreceded).WithLocation(25, 35), + Diagnostic(DescriptorFollowed).WithLocation(25, 35), + Diagnostic(DescriptorNotPreceded).WithLocation(25, 50), + Diagnostic(DescriptorNotFollowed).WithLocation(25, 50), }; await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -285,16 +287,16 @@ public void TestMethod2() DiagnosticResult[] expected = { - Diagnostic().WithLocation(12, 29).WithArguments(" not", "preceded"), + Diagnostic(DescriptorNotPreceded).WithLocation(12, 29), // 13, 29 should be reported by SA1009 - Diagnostic().WithLocation(14, 29).WithArguments(" not", "preceded"), + Diagnostic(DescriptorNotPreceded).WithLocation(14, 29), // 14, 30 should be reported by SA1009 - Diagnostic().WithLocation(18, 28).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(19, 27).WithArguments(" not", "followed"), - Diagnostic().WithLocation(20, 28).WithArguments(" not", "preceded"), - Diagnostic().WithLocation(20, 28).WithArguments(" not", "followed"), + Diagnostic(DescriptorNotPreceded).WithLocation(18, 28), + Diagnostic(DescriptorNotFollowed).WithLocation(19, 27), + Diagnostic(DescriptorNotPreceded).WithLocation(20, 28), + Diagnostic(DescriptorNotFollowed).WithLocation(20, 28), }; await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); @@ -372,14 +374,68 @@ void Method() Type x = typeof(Action values; + + public void TestMethod2(object input) + { + var x = values[input as List]; + x = values[input as List|}]; + x = values[input as List|} ]; + x = values[input as List|} ]; + } +} +"; + + var fixedCode = @"using System; +using System.Collections.Generic; + +public class TestClass +{ + private Dictionary values; + + public void TestMethod2(object input) + { + var x = values[input as List]; + x = values[input as List]; + x = values[input as List]; + x = values[input as List]; + } +} "; DiagnosticResult[] expected = { - DiagnosticResult.CompilerError("CS1003").WithMessage("Syntax error, '>' expected").WithLocation(7, 35), + Diagnostic(DescriptorNotPreceded).WithLocation(0), + Diagnostic(DescriptorNotFollowed).WithLocation(1), + Diagnostic(DescriptorNotPreceded).WithLocation(2), + Diagnostic(DescriptorNotFollowed).WithLocation(2), }; - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); + await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); + } + + protected virtual DiagnosticResult[] GetExpectedResultMissingToken() + { + return new[] + { + DiagnosticResult.CompilerError("CS1003").WithMessage("Syntax error, '>' expected").WithLocation(7, 35), + }; } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1016UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1016UnitTests.cs index b7a6a3835..f0b08e7d2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1016UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1016UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1016OpeningAttributeBracketsMustBeSpacedCorrectly, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1017UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1017UnitTests.cs index 5cb36dd5e..ec7a78a90 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1017UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1017UnitTests.cs @@ -1,14 +1,14 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { using System.Threading; using System.Threading.Tasks; - using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1017ClosingAttributeBracketsMustBeSpacedCorrectly, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1018UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1018UnitTests.cs index 701948d46..9ed256e69 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1018UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1018UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1018NullableTypeSymbolsMustNotBePrecededBySpace, @@ -128,12 +129,17 @@ private void Test() ? "; - DiagnosticResult[] expected = + var expected = this.GetExpectedResultSyntaxErrorAtEndOfFile(); + + await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); + } + + protected virtual DiagnosticResult[] GetExpectedResultSyntaxErrorAtEndOfFile() + { + return new[] { DiagnosticResult.CompilerError("CS1031").WithMessage("Type expected").WithLocation(10, 2), }; - - await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1019UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1019UnitTests.cs index 751c26e4e..68d059a62 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1019UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1019UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -10,8 +12,8 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; + using static StyleCop.Analyzers.SpacingRules.SA1019MemberAccessSymbolsMustBeSpacedCorrectly; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1019MemberAccessSymbolsMustBeSpacedCorrectly, StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; @@ -46,7 +48,7 @@ public async Task TestSpaceBeforeOperatorAsync(string op) string template = this.GetTemplate($" {op}"); var fixedCode = this.GetTemplate($"{op}"); - DiagnosticResult expected = Diagnostic().WithLocation(16, 27).WithArguments(op[0], "preceded"); + DiagnosticResult expected = Diagnostic(DescriptorNotPreceded).WithLocation(16, 27).WithArguments(op[0]); await VerifyCSharpFixAsync(template, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } @@ -63,7 +65,7 @@ public async Task TestSpaceAfterOperatorAsync(string op) string template = this.GetTemplate($"{op} "); string fixedCode = this.GetTemplate($"{op}"); - DiagnosticResult expected = Diagnostic().WithLocation(16, 25 + op.Length).WithArguments(op.Last(), "followed"); + DiagnosticResult expected = Diagnostic(DescriptorNotFollowed).WithLocation(16, 25 + op.Length).WithArguments(op.Last()); await VerifyCSharpFixAsync(template, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); } @@ -142,7 +144,7 @@ public async Task TestCommentOnLineFollowingOperatorDoesNotReportAsync(string op public async Task TestCommentOnSameLineSeparatedByWhitespaceReportsAsync(string op) { string template = this.GetTemplate($"{op} // This is a comment{Environment.NewLine}"); - DiagnosticResult expected = Diagnostic().WithLocation(16, 25 + op.Length).WithArguments(".", "followed"); + DiagnosticResult expected = Diagnostic(DescriptorNotFollowed).WithLocation(16, 25 + op.Length).WithArguments("."); await VerifyCSharpDiagnosticAsync(template, expected, CancellationToken.None).ConfigureAwait(false); } @@ -253,35 +255,35 @@ public unsafe void MethodName() "; DiagnosticResult[] expected = { - Diagnostic().WithLocation(8, 13).WithArguments(".", "preceded"), - Diagnostic().WithLocation(8, 13).WithArguments(".", "followed"), - Diagnostic().WithLocation(9, 13).WithArguments(".", "preceded"), - Diagnostic().WithLocation(10, 12).WithArguments(".", "followed"), - - Diagnostic().WithLocation(12, 13).WithArguments(".", "preceded"), - Diagnostic().WithLocation(12, 13).WithArguments(".", "followed"), - Diagnostic().WithLocation(13, 13).WithArguments(".", "preceded"), - Diagnostic().WithLocation(14, 12).WithArguments(".", "followed"), - - Diagnostic().WithLocation(16, 13).WithArguments("?", "preceded"), - Diagnostic().WithLocation(16, 14).WithArguments(".", "followed"), - Diagnostic().WithLocation(17, 13).WithArguments("?", "preceded"), - Diagnostic().WithLocation(18, 13).WithArguments(".", "followed"), - - Diagnostic().WithLocation(20, 13).WithArguments("?", "preceded"), - Diagnostic().WithLocation(20, 14).WithArguments(".", "followed"), - Diagnostic().WithLocation(21, 13).WithArguments("?", "preceded"), - Diagnostic().WithLocation(22, 13).WithArguments(".", "followed"), - - Diagnostic().WithLocation(24, 13).WithArguments("->", "preceded"), - Diagnostic().WithLocation(24, 13).WithArguments("->", "followed"), - Diagnostic().WithLocation(25, 13).WithArguments("->", "preceded"), - Diagnostic().WithLocation(26, 12).WithArguments("->", "followed"), - - Diagnostic().WithLocation(28, 13).WithArguments("->", "preceded"), - Diagnostic().WithLocation(28, 13).WithArguments("->", "followed"), - Diagnostic().WithLocation(29, 13).WithArguments("->", "preceded"), - Diagnostic().WithLocation(30, 12).WithArguments("->", "followed"), + Diagnostic(DescriptorNotPreceded).WithLocation(8, 13).WithArguments("."), + Diagnostic(DescriptorNotFollowed).WithLocation(8, 13).WithArguments("."), + Diagnostic(DescriptorNotPreceded).WithLocation(9, 13).WithArguments("."), + Diagnostic(DescriptorNotFollowed).WithLocation(10, 12).WithArguments("."), + + Diagnostic(DescriptorNotPreceded).WithLocation(12, 13).WithArguments("."), + Diagnostic(DescriptorNotFollowed).WithLocation(12, 13).WithArguments("."), + Diagnostic(DescriptorNotPreceded).WithLocation(13, 13).WithArguments("."), + Diagnostic(DescriptorNotFollowed).WithLocation(14, 12).WithArguments("."), + + Diagnostic(DescriptorNotPreceded).WithLocation(16, 13).WithArguments("?"), + Diagnostic(DescriptorNotFollowed).WithLocation(16, 14).WithArguments("."), + Diagnostic(DescriptorNotPreceded).WithLocation(17, 13).WithArguments("?"), + Diagnostic(DescriptorNotFollowed).WithLocation(18, 13).WithArguments("."), + + Diagnostic(DescriptorNotPreceded).WithLocation(20, 13).WithArguments("?"), + Diagnostic(DescriptorNotFollowed).WithLocation(20, 14).WithArguments("."), + Diagnostic(DescriptorNotPreceded).WithLocation(21, 13).WithArguments("?"), + Diagnostic(DescriptorNotFollowed).WithLocation(22, 13).WithArguments("."), + + Diagnostic(DescriptorNotPreceded).WithLocation(24, 13).WithArguments("->"), + Diagnostic(DescriptorNotFollowed).WithLocation(24, 13).WithArguments("->"), + Diagnostic(DescriptorNotPreceded).WithLocation(25, 13).WithArguments("->"), + Diagnostic(DescriptorNotFollowed).WithLocation(26, 12).WithArguments("->"), + + Diagnostic(DescriptorNotPreceded).WithLocation(28, 13).WithArguments("->"), + Diagnostic(DescriptorNotFollowed).WithLocation(28, 13).WithArguments("->"), + Diagnostic(DescriptorNotPreceded).WithLocation(29, 13).WithArguments("->"), + Diagnostic(DescriptorNotFollowed).WithLocation(30, 12).WithArguments("->"), }; await VerifyCSharpFixAsync(testCode, expected, fixedTestCode, CancellationToken.None).ConfigureAwait(false); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1020UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1020UnitTests.cs index f90ff0686..62c6ee1d3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1020UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1020UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1020IncrementDecrementSymbolsMustBeSpacedCorrectly, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1021UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1021UnitTests.cs index f8486b4d9..d72754776 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1021UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1021UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1022UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1022UnitTests.cs index f50d6e731..73a02ec9d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1022UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1022UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1023UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1023UnitTests.cs index 01d1afd54..1e11cb7f2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1023UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1023UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -7,8 +9,8 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; + using static StyleCop.Analyzers.SpacingRules.SA1023DereferenceAndAccessOfSymbolsMustBeSpacedCorrectly; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1023DereferenceAndAccessOfSymbolsMustBeSpacedCorrectly, StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; @@ -50,6 +52,33 @@ unsafe void TestMethod() await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } + /// + /// Verifies that the analyzer will properly handle valid dereference. + /// + /// A representing the asynchronous unit test. + [Fact] + [WorkItem(3538, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3538")] + public async Task TestNotReportedWhenFirstInForeachWithoutBracesAsync() + { + var testCode = @" +public unsafe class TestClass +{ + internal void TestMethod(Obj[] objs) + { + foreach (var o in objs) + *o.I = 1; + } + + internal struct Obj + { + public int* I; + } +} +"; + + await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); + } + /// /// Verifies that the analyzer will properly handle invalid dereference and access of symbols. /// @@ -109,26 +138,26 @@ unsafe void TestMethod() DiagnosticResult[] expected = { - Diagnostic().WithLocation(6, 12).WithArguments("be followed by a space"), - Diagnostic().WithLocation(8, 13).WithArguments("not be preceded by a space"), - Diagnostic().WithLocation(8, 13).WithArguments("not be followed by a space"), - Diagnostic().WithLocation(9, 21).WithArguments("not be preceded by a space"), - Diagnostic().WithLocation(9, 21).WithArguments("not be followed by a space"), - Diagnostic().WithLocation(11, 1).WithArguments("not appear at the beginning of a line"), - Diagnostic().WithLocation(12, 13).WithArguments("not appear at the end of a line"), - Diagnostic().WithLocation(16, 18).WithArguments("not be preceded by a space"), - Diagnostic().WithLocation(16, 18).WithArguments("not be followed by a space"), - Diagnostic().WithLocation(17, 13).WithArguments("not be followed by a space"), - Diagnostic().WithLocation(17, 19).WithArguments("not be followed by a space"), - Diagnostic().WithLocation(17, 21).WithArguments("not be preceded by a space"), - Diagnostic().WithLocation(17, 21).WithArguments("not be followed by a space"), - Diagnostic().WithLocation(18, 29).WithArguments("not be preceded by a space"), - Diagnostic().WithLocation(19, 24).WithArguments("not be followed by a space"), - Diagnostic().WithLocation(19, 26).WithArguments("not be preceded by a space"), - Diagnostic().WithLocation(20, 30).WithArguments("not be followed by a space"), - Diagnostic().WithLocation(21, 31).WithArguments("not be followed by a space"), - Diagnostic().WithLocation(22, 13).WithArguments("not be followed by a space"), - Diagnostic().WithLocation(22, 17).WithArguments("not be followed by a space"), + Diagnostic(DescriptorFollowed).WithLocation(6, 12), + Diagnostic(DescriptorNotPreceded).WithLocation(8, 13), + Diagnostic(DescriptorNotFollowed).WithLocation(8, 13), + Diagnostic(DescriptorNotPreceded).WithLocation(9, 21), + Diagnostic(DescriptorNotFollowed).WithLocation(9, 21), + Diagnostic(DescriptorNotAtBeginningOfLine).WithLocation(11, 1), + Diagnostic(DescriptorNotAtEndOfLine).WithLocation(12, 13), + Diagnostic(DescriptorNotPreceded).WithLocation(16, 18), + Diagnostic(DescriptorNotFollowed).WithLocation(16, 18), + Diagnostic(DescriptorNotFollowed).WithLocation(17, 13), + Diagnostic(DescriptorNotFollowed).WithLocation(17, 19), + Diagnostic(DescriptorNotPreceded).WithLocation(17, 21), + Diagnostic(DescriptorNotFollowed).WithLocation(17, 21), + Diagnostic(DescriptorNotPreceded).WithLocation(18, 29), + Diagnostic(DescriptorNotFollowed).WithLocation(19, 24), + Diagnostic(DescriptorNotPreceded).WithLocation(19, 26), + Diagnostic(DescriptorNotFollowed).WithLocation(20, 30), + Diagnostic(DescriptorNotFollowed).WithLocation(21, 31), + Diagnostic(DescriptorNotFollowed).WithLocation(22, 13), + Diagnostic(DescriptorNotFollowed).WithLocation(22, 17), }; await VerifyCSharpFixAsync(testCode, expected, fixedCode, CancellationToken.None).ConfigureAwait(false); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1024UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1024UnitTests.cs index acc115693..6808037d8 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1024UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1024UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -7,8 +9,8 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; + using static StyleCop.Analyzers.SpacingRules.SA1024ColonsMustBeSpacedCorrectly; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1024ColonsMustBeSpacedCorrectly, StyleCop.Analyzers.SpacingRules.TokenSpacingCodeFixProvider>; @@ -168,11 +170,11 @@ private int Bar(int value) DiagnosticResult[] expected = { - Diagnostic().WithLocation(3, 21).WithArguments(string.Empty, "followed", string.Empty), - Diagnostic().WithLocation(3, 37).WithArguments(string.Empty, "followed", string.Empty), - Diagnostic().WithLocation(5, 28).WithArguments(string.Empty, "followed", string.Empty), - Diagnostic().WithLocation(8, 23).WithArguments(string.Empty, "followed", string.Empty), - Diagnostic().WithLocation(10, 30).WithArguments(string.Empty, "followed", string.Empty), + Diagnostic(DescriptorFollowed).WithLocation(3, 21), + Diagnostic(DescriptorFollowed).WithLocation(3, 37), + Diagnostic(DescriptorFollowed).WithLocation(5, 28), + Diagnostic(DescriptorFollowed).WithLocation(8, 23), + Diagnostic(DescriptorFollowed).WithLocation(10, 30), }; await VerifyCSharpFixAsync(testCode, expected, ExpectedCode, CancellationToken.None).ConfigureAwait(false); @@ -216,11 +218,11 @@ private int Bar(int value) DiagnosticResult[] expected = { - Diagnostic().WithLocation(3, 20).WithArguments(string.Empty, "preceded", string.Empty), - Diagnostic().WithLocation(3, 36).WithArguments(string.Empty, "preceded", string.Empty), - Diagnostic().WithLocation(5, 27).WithArguments(string.Empty, "preceded", string.Empty), - Diagnostic().WithLocation(8, 22).WithArguments(string.Empty, "preceded", string.Empty), - Diagnostic().WithLocation(10, 29).WithArguments(string.Empty, "preceded", string.Empty), + Diagnostic(DescriptorPreceded).WithLocation(3, 20), + Diagnostic(DescriptorPreceded).WithLocation(3, 36), + Diagnostic(DescriptorPreceded).WithLocation(5, 27), + Diagnostic(DescriptorPreceded).WithLocation(8, 22), + Diagnostic(DescriptorPreceded).WithLocation(10, 29), }; await VerifyCSharpFixAsync(testCode, expected, ExpectedCode, CancellationToken.None).ConfigureAwait(false); @@ -264,12 +266,12 @@ private int Bar(int value) DiagnosticResult[] expected = { - Diagnostic().WithLocation(10, 19).WithArguments(" not", "preceded", string.Empty), - Diagnostic().WithLocation(15, 12).WithArguments(" not", "preceded", string.Empty), - Diagnostic().WithLocation(19, 20).WithArguments(" not", "preceded", string.Empty), - Diagnostic().WithLocation(22, 51).WithArguments(" not", "preceded", string.Empty), - Diagnostic().WithLocation(23, 51).WithArguments(" not", "preceded", string.Empty), - Diagnostic().WithLocation(24, 21).WithArguments(" not", "preceded", string.Empty), + Diagnostic(DescriptorNotPreceded).WithLocation(10, 19), + Diagnostic(DescriptorNotPreceded).WithLocation(15, 12), + Diagnostic(DescriptorNotPreceded).WithLocation(19, 20), + Diagnostic(DescriptorNotPreceded).WithLocation(22, 51), + Diagnostic(DescriptorNotPreceded).WithLocation(23, 51), + Diagnostic(DescriptorNotPreceded).WithLocation(24, 21), }; await VerifyCSharpFixAsync(testCode, expected, ExpectedCode, CancellationToken.None).ConfigureAwait(false); @@ -313,16 +315,16 @@ private int Bar(int value) DiagnosticResult[] expected = { - Diagnostic().WithLocation(3, 20).WithArguments(string.Empty, "preceded", string.Empty), - Diagnostic().WithLocation(3, 20).WithArguments(string.Empty, "followed", string.Empty), - Diagnostic().WithLocation(3, 35).WithArguments(string.Empty, "preceded", string.Empty), - Diagnostic().WithLocation(3, 35).WithArguments(string.Empty, "followed", string.Empty), - Diagnostic().WithLocation(5, 27).WithArguments(string.Empty, "preceded", string.Empty), - Diagnostic().WithLocation(5, 27).WithArguments(string.Empty, "followed", string.Empty), - Diagnostic().WithLocation(8, 22).WithArguments(string.Empty, "preceded", string.Empty), - Diagnostic().WithLocation(8, 22).WithArguments(string.Empty, "followed", string.Empty), - Diagnostic().WithLocation(10, 29).WithArguments(string.Empty, "preceded", string.Empty), - Diagnostic().WithLocation(10, 29).WithArguments(string.Empty, "followed", string.Empty), + Diagnostic(DescriptorPreceded).WithLocation(3, 20), + Diagnostic(DescriptorFollowed).WithLocation(3, 20), + Diagnostic(DescriptorPreceded).WithLocation(3, 35), + Diagnostic(DescriptorFollowed).WithLocation(3, 35), + Diagnostic(DescriptorPreceded).WithLocation(5, 27), + Diagnostic(DescriptorFollowed).WithLocation(5, 27), + Diagnostic(DescriptorPreceded).WithLocation(8, 22), + Diagnostic(DescriptorFollowed).WithLocation(8, 22), + Diagnostic(DescriptorPreceded).WithLocation(10, 29), + Diagnostic(DescriptorFollowed).WithLocation(10, 29), }; await VerifyCSharpFixAsync(testCode, expected, ExpectedCode, CancellationToken.None).ConfigureAwait(false); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1025UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1025UnitTests.cs index 575fc44eb..83b2b566a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1025UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1025UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -8,7 +10,6 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1025CodeMustNotContainMultipleWhitespaceInARow, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1026UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1026UnitTests.cs index a34f6da8e..f7c1586c9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1026UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1026UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1026CodeMustNotContainSpaceAfterNewKeywordInImplicitlyTypedArrayAllocation, @@ -45,7 +46,7 @@ public async Task TestInvalidSpacingOfImplicitlyTypedArrayAsync(string space) { string testCode = string.Format("public class Foo {{ public Foo() {{ var ints = new{0}[] {{ 1, 2, 3 }}; }} }}", space); const string expectedCode = "public class Foo { public Foo() { var ints = new[] { 1, 2, 3 }; } }"; - DiagnosticResult expected = Diagnostic().WithLocation(1, 46); + DiagnosticResult expected = Diagnostic().WithArguments("new").WithLocation(1, 46); await VerifyCSharpFixAsync(testCode, expected, expectedCode, CancellationToken.None).ConfigureAwait(false); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1027AlternateIndentationUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1027AlternateIndentationUnitTests.cs index 8183c4544..8a59cdbf6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1027AlternateIndentationUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1027AlternateIndentationUnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -9,7 +11,6 @@ namespace StyleCop.Analyzers.Test.SpacingRules using StyleCop.Analyzers.Settings.ObjectModel; using StyleCop.Analyzers.SpacingRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; /// diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1027UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1027UnitTests.cs index 0a67beb61..4b72d6275 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1027UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1027UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -7,7 +9,6 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1027UseTabsCorrectly, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1027UseTabsUnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1027UseTabsUnitTests.cs index 673ec96fd..0b16b159f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1027UseTabsUnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1027UseTabsUnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -9,7 +11,6 @@ namespace StyleCop.Analyzers.Test.SpacingRules using StyleCop.Analyzers.Settings.ObjectModel; using StyleCop.Analyzers.SpacingRules; using StyleCop.Analyzers.Test.Verifiers; - using TestHelper; using Xunit; /// diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1028UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1028UnitTests.cs index eb6a528bd..2468f63f7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1028UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpacingRules/SA1028UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpacingRules { @@ -8,7 +10,6 @@ namespace StyleCop.Analyzers.Test.SpacingRules using System.Threading.Tasks; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpacingRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopCodeFixVerifier< StyleCop.Analyzers.SpacingRules.SA1028CodeMustNotContainTrailingWhitespace, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpecialRules/SA0001UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpecialRules/SA0001UnitTests.cs index b47260727..9f0d2e072 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpecialRules/SA0001UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpecialRules/SA0001UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpecialRules { @@ -8,7 +10,6 @@ namespace StyleCop.Analyzers.Test.SpecialRules using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Testing; using StyleCop.Analyzers.SpecialRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier; @@ -29,14 +30,10 @@ public async Task TestEnabledDocumentationModesAsync(DocumentationMode documenta await new CSharpTest { - TestCode = testCode, - SolutionTransforms = + TestState = { - (solution, projectId) => - { - var project = solution.GetProject(projectId); - return solution.WithProjectParseOptions(projectId, project.ParseOptions.WithDocumentationMode(documentationMode)); - }, + DocumentationMode = documentationMode, + Sources = { testCode }, }, }.RunAsync(CancellationToken.None).ConfigureAwait(false); } @@ -55,15 +52,11 @@ public async Task TestDisabledDocumentationModesAsync(DocumentationMode document await new CSharpTest { - TestCode = testCode, - ExpectedDiagnostics = { expected }, - SolutionTransforms = + TestState = { - (solution, projectId) => - { - var project = solution.GetProject(projectId); - return solution.WithProjectParseOptions(projectId, project.ParseOptions.WithDocumentationMode(documentationMode)); - }, + DocumentationMode = documentationMode, + Sources = { testCode }, + ExpectedDiagnostics = { expected }, }, }.RunAsync(CancellationToken.None).ConfigureAwait(false); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpecialRules/SA0002UnitTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpecialRules/SA0002UnitTests.cs index 03c24dcfa..9bfa73197 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpecialRules/SA0002UnitTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/SpecialRules/SA0002UnitTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.SpecialRules { @@ -14,7 +16,6 @@ namespace StyleCop.Analyzers.Test.SpecialRules using Microsoft.CodeAnalysis.Text; using StyleCop.Analyzers.Settings; using StyleCop.Analyzers.SpecialRules; - using TestHelper; using Xunit; using static StyleCop.Analyzers.Test.Verifiers.StyleCopDiagnosticVerifier; @@ -33,6 +34,30 @@ public async Task TestMissingSettingsAsync() await VerifyCSharpDiagnosticAsync(TestCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); } + [Fact] + [WorkItem(3453, "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3453")] + public async Task TestNoSourceFilesAsync() + { + string emptySettings = @"{ ""settings"": { } }"; + await new CSharpTest + { + TestState = + { + Sources = { string.Empty }, + AdditionalFiles = { ("stylecop.json", emptySettings) }, + AdditionalProjects = + { + ["EmptyProjectWithSettings"] = + { + // The main test state doesn't allow empty Sources, so we use a second project to validate + // the completely empty case. + AdditionalFiles = { ("stylecop.json", emptySettings) }, + }, + }, + }, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); + } + [Fact] public async Task TestValidSettingsAsync() { @@ -328,18 +353,33 @@ public async Task TestEmptySettingsAsync() } [Fact] - public void TestUnexpectedExceptionNotCaught() + public async Task TestUnexpectedExceptionNotCaughtAsync() { - var analysisContext = new AnalysisContextMissingOptions(); - var analyzer = new SA0002InvalidSettingsFile(); - analyzer.Initialize(analysisContext); - Assert.NotNull(analysisContext.CompilationAction); - - var additionalFiles = ImmutableArray.Create(new InvalidAdditionalText()); - Assert.Null(additionalFiles[0].Path); - Assert.Null(additionalFiles[0].GetText(CancellationToken.None)); - var context = new CompilationAnalysisContext(compilation: null, options: new AnalyzerOptions(additionalFiles), reportDiagnostic: null, isSupportedDiagnostic: null, cancellationToken: CancellationToken.None); - Assert.Throws(() => analysisContext.CompilationAction(context)); + await new CSharpTest + { + TestSources = { string.Empty }, + SolutionTransforms = + { + // Run additional validation here with access to a Compilation + (solution, projectId) => + { + var compilation = solution.GetProject(projectId).GetCompilationAsync(CancellationToken.None).GetAwaiter().GetResult(); + + var analysisContext = new AnalysisContextMissingOptions(); + var analyzer = new SA0002InvalidSettingsFile(); + analyzer.Initialize(analysisContext); + Assert.NotNull(analysisContext.CompilationAction); + + var additionalFiles = ImmutableArray.Create(new InvalidAdditionalText()); + Assert.Null(additionalFiles[0].Path); + Assert.Null(additionalFiles[0].GetText(CancellationToken.None)); + var context = new CompilationAnalysisContext(compilation, options: new AnalyzerOptions(additionalFiles), reportDiagnostic: null, isSupportedDiagnostic: null, cancellationToken: CancellationToken.None); + Assert.Throws(() => analysisContext.CompilationAction(context)); + + return solution; + }, + }, + }.RunAsync(CancellationToken.None).ConfigureAwait(false); } private class InvalidAdditionalText : AdditionalText @@ -408,6 +448,14 @@ public override void RegisterSyntaxTreeAction(Action { throw new NotImplementedException(); } + + public override void ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags analysisMode) + { + } + + public override void EnableConcurrentExecution() + { + } } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/StyleCop.Analyzers.Test.csproj b/StyleCop.Analyzers/StyleCop.Analyzers.Test/StyleCop.Analyzers.Test.csproj index d9ee91a95..b131a0cad 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/StyleCop.Analyzers.Test.csproj +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/StyleCop.Analyzers.Test.csproj @@ -3,6 +3,7 @@ net452 + false true true @@ -17,17 +18,27 @@ - - - + + + - - + + + + + + + + + + PreserveNewest + + \ No newline at end of file diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/CustomDiagnosticVerifier`1.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/CustomDiagnosticVerifier`1.cs index 9a6bb8d0d..a3b84a5b3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/CustomDiagnosticVerifier`1.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/CustomDiagnosticVerifier`1.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Verifiers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/DiagnosticVerifierTests.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/DiagnosticVerifierTests.cs index 8ec677bde..0a1571f7b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/DiagnosticVerifierTests.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/DiagnosticVerifierTests.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Verifiers { @@ -41,7 +43,7 @@ void MethodName() { await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); }).ConfigureAwait(false); - Assert.StartsWith("Mismatch between number of diagnostics returned, expected \"1\" actual \"0\"", ex.Message); + Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Mismatch between number of diagnostics returned, expected \"1\" actual \"0\"", ex.Message); } [Fact] @@ -104,7 +106,24 @@ int PropertyName { await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); }).ConfigureAwait(false); - Assert.StartsWith("Expected:\nA project diagnostic with No location\nActual:\n", ex.Message); + + var expectedMessage = $"Context: Diagnostics of test state{Environment.NewLine}" + + $"Expected a project diagnostic with no location:{Environment.NewLine}" + + $"{Environment.NewLine}" + + $"Expected diagnostic:{Environment.NewLine}" + + $" // warning SA1002: Semicolons should be followed by a space{Environment.NewLine}" + + $"new DiagnosticResult(SA1002SemicolonsMustBeSpacedCorrectly.SA1002).WithArguments(\"\", \"followed\"),{Environment.NewLine}" + + $"{Environment.NewLine}" + + $"Actual diagnostic:{Environment.NewLine}" + + $" // /0/Test0.cs(7,33): warning SA1002: Semicolons should be followed by a space{Environment.NewLine}" + + $"VerifyCS.Diagnostic().WithSpan(7, 33, 7, 34).WithArguments(\"\", \"followed\"),{Environment.NewLine}" + + $"{Environment.NewLine}" + + $"{Environment.NewLine}" + + $"Assert.Equal() Failure{Environment.NewLine}" + + $"Expected: None{Environment.NewLine}" + + $"Actual: SourceFile(/0/Test0.cs[102..103))"; + + new XUnitVerifier().EqualOrDiff(expectedMessage, ex.Message); } [Fact] @@ -126,7 +145,7 @@ int PropertyName { await VerifyCSharpDiagnosticAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, CancellationToken.None).ConfigureAwait(false); }).ConfigureAwait(false); - Assert.StartsWith("Mismatch between number of diagnostics returned, expected \"0\" actual \"1\"", ex.Message); + Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Mismatch between number of diagnostics returned, expected \"0\" actual \"1\"", ex.Message); Assert.Contains("warning SA1002", ex.Message); } @@ -148,7 +167,7 @@ void MethodName() { await CSharpCodeFixVerifier.VerifyAnalyzerAsync(testCode, DiagnosticResult.EmptyDiagnosticResults).ConfigureAwait(false); }).ConfigureAwait(false); - Assert.StartsWith("Mismatch between number of diagnostics returned, expected \"0\" actual \"2\"", ex.Message); + Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Mismatch between number of diagnostics returned, expected \"0\" actual \"1\"", ex.Message); Assert.Contains("error AD0001", ex.Message); } @@ -173,7 +192,7 @@ Int32 PropertyName { await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); }).ConfigureAwait(false); - Assert.StartsWith("Mismatch between number of diagnostics returned, expected \"1\" actual \"2\"", ex.Message); + Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Mismatch between number of diagnostics returned, expected \"1\" actual \"2\"", ex.Message); Assert.Contains("error CS0246", ex.Message); } @@ -199,7 +218,7 @@ Int32 PropertyName { await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); }).ConfigureAwait(false); - Assert.StartsWith("Mismatch between number of diagnostics returned, expected \"1\" actual \"2\"", ex.Message); + Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Mismatch between number of diagnostics returned, expected \"1\" actual \"2\"", ex.Message); Assert.Contains("error CS0246", ex.Message); } @@ -225,7 +244,7 @@ int PropertyName { await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); }).ConfigureAwait(false); - Assert.StartsWith("Expected diagnostic id to be \"SA9999\" was \"SA1002\"", ex.Message); + Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Expected diagnostic id to be \"SA9999\" was \"SA1002\"", ex.Message); } [Fact] @@ -249,7 +268,7 @@ int PropertyName { await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); }).ConfigureAwait(false); - Assert.StartsWith("Expected diagnostic severity to be \"Error\" was \"Warning\"", ex.Message); + Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Expected diagnostic severity to be \"Error\" was \"Warning\"", ex.Message); } [Fact] @@ -273,7 +292,7 @@ int PropertyName { await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); }).ConfigureAwait(false); - Assert.StartsWith("Expected diagnostic to start on line \"8\" was actually on line \"7\"", ex.Message); + Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Expected diagnostic to start on line \"8\" was actually on line \"7\"", ex.Message); } [Fact] @@ -302,7 +321,7 @@ int PropertyName { await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); }).ConfigureAwait(false); - Assert.StartsWith("Expected diagnostic to start on line \"7\" was actually on line \"8\"", ex.Message); + Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Expected diagnostic to start on line \"7\" was actually on line \"8\"", ex.Message); } [Fact] @@ -326,7 +345,7 @@ int PropertyName { await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); }).ConfigureAwait(false); - Assert.StartsWith("Expected diagnostic to start at column \"34\" was actually at column \"33\"", ex.Message); + Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Expected diagnostic to start at column \"34\" was actually at column \"33\"", ex.Message); } [Fact] @@ -350,7 +369,7 @@ int PropertyName { await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); }).ConfigureAwait(false); - Assert.StartsWith("Expected diagnostic to end at column \"35\" was actually at column \"34\"", ex.Message); + Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Expected diagnostic to end at column \"35\" was actually at column \"34\"", ex.Message); } [Fact] @@ -374,7 +393,7 @@ int PropertyName { await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); }).ConfigureAwait(false); - Assert.StartsWith("Expected diagnostic message to be ", ex.Message); + Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Expected diagnostic message to be ", ex.Message); } [Fact] @@ -398,7 +417,7 @@ int PropertyName { await VerifyCSharpDiagnosticAsync(testCode, expected, CancellationToken.None).ConfigureAwait(false); }).ConfigureAwait(false); - Assert.StartsWith("Expected 1 additional locations but got 0 for Diagnostic", ex.Message); + Assert.StartsWith($"Context: Diagnostics of test state{Environment.NewLine}Expected 1 additional locations but got 0 for Diagnostic", ex.Message); } private class ErrorThrowingAnalyzer : SA1002SemicolonsMustBeSpacedCorrectly @@ -408,6 +427,9 @@ private class ErrorThrowingAnalyzer : SA1002SemicolonsMustBeSpacedCorrectly /// public override void Initialize(AnalysisContext context) { + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); + context.EnableConcurrentExecution(); + context.RegisterSyntaxNodeAction(BlockAction, SyntaxKind.Block); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/EmptyAnalyzer.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/EmptyAnalyzer.cs deleted file mode 100644 index c1acec2f0..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/EmptyAnalyzer.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. - -namespace StyleCop.Analyzers.Test.Verifiers -{ - using System.Collections.Immutable; - using Microsoft.CodeAnalysis; - using Microsoft.CodeAnalysis.Diagnostics; - - [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] - public class EmptyAnalyzer : DiagnosticAnalyzer - { - public override ImmutableArray SupportedDiagnostics - => ImmutableArray.Empty; - - public override void Initialize(AnalysisContext context) - { - } - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/GenericAnalyzerTest.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/GenericAnalyzerTest.cs index 99b12a96d..c4d8416d4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/GenericAnalyzerTest.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/GenericAnalyzerTest.cs @@ -1,24 +1,68 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test.Verifiers { using System; + using System.Collections.Immutable; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; - using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Host.Mef; + using Microsoft.CodeAnalysis.Testing; using Microsoft.VisualStudio.Composition; + using StyleCop.Analyzers.Lightup; internal static class GenericAnalyzerTest { - internal static readonly MetadataReference CSharpSymbolsReference = MetadataReference.CreateFromFile(typeof(CSharpCompilation).Assembly.Location); + internal static readonly ReferenceAssemblies ReferenceAssemblies; private static readonly Lazy ExportProviderFactory; static GenericAnalyzerTest() { + string codeAnalysisTestVersion = + typeof(Compilation).Assembly.GetName().Version.Major switch + { + 1 => "1.2.1", + 2 => "2.8.2", + 3 => "3.6.0", + 4 => "4.0.1", + _ => throw new InvalidOperationException("Unknown version."), + }; + + // Use appropriate default reference assemblies per the support matrix: + // https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version + ReferenceAssemblies defaultReferenceAssemblies; + if (LightupHelpers.SupportsCSharp12) + { + defaultReferenceAssemblies = ReferenceAssemblies.Net.Net80; + } + else if (LightupHelpers.SupportsCSharp11) + { + defaultReferenceAssemblies = ReferenceAssemblies.Net.Net70; + } + else if (LightupHelpers.SupportsCSharp10) + { + defaultReferenceAssemblies = ReferenceAssemblies.Net.Net60; + } + else if (LightupHelpers.SupportsCSharp9) + { + defaultReferenceAssemblies = ReferenceAssemblies.Net.Net50; + } + else if (LightupHelpers.SupportsCSharp8) + { + defaultReferenceAssemblies = ReferenceAssemblies.NetCore.NetCoreApp30; + } + else + { + defaultReferenceAssemblies = ReferenceAssemblies.Default; + } + + ReferenceAssemblies = defaultReferenceAssemblies.AddPackages(ImmutableArray.Create( + new PackageIdentity("Microsoft.CodeAnalysis.CSharp", codeAnalysisTestVersion), + new PackageIdentity("System.ValueTuple", "4.5.0"))); + ExportProviderFactory = new Lazy( () => { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/StyleCopCodeFixVerifier`2.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/StyleCopCodeFixVerifier`2.cs index b65622e4b..3da289f01 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/StyleCopCodeFixVerifier`2.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/StyleCopCodeFixVerifier`2.cs @@ -1,23 +1,31 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Verifiers { using System; using System.Collections.Generic; + using System.IO; + using System.Linq; + using System.Net; using System.Threading; using System.Threading.Tasks; using global::LightJson; using global::LightJson.Serialization; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CodeFixes; + using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Formatting; using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Testing.Verifiers; using Microsoft.CodeAnalysis.Text; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.Settings.ObjectModel; + using StyleCop.Analyzers.Test.Helpers; using Xunit; internal static class StyleCopCodeFixVerifier @@ -39,6 +47,18 @@ internal static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult internal static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult[] expected, CancellationToken cancellationToken) => StyleCopDiagnosticVerifier.VerifyCSharpDiagnosticAsync(source, expected, cancellationToken); + internal static Task VerifyCSharpDiagnosticAsync(LanguageVersion? languageVersion, string source, DiagnosticResult expected, CancellationToken cancellationToken) + => StyleCopDiagnosticVerifier.VerifyCSharpDiagnosticAsync(languageVersion, source, expected, cancellationToken); + + internal static Task VerifyCSharpDiagnosticAsync(LanguageVersion? languageVersion, string source, DiagnosticResult[] expected, CancellationToken cancellationToken) + => StyleCopDiagnosticVerifier.VerifyCSharpDiagnosticAsync(languageVersion, source, settings: null, expected, cancellationToken); + + internal static Task VerifyCSharpDiagnosticAsync(string source, string settings, DiagnosticResult[] expected, CancellationToken cancellationToken) + => StyleCopDiagnosticVerifier.VerifyCSharpDiagnosticAsync(languageVersion: null, source, settings, expected, cancellationToken); + + internal static Task VerifyCSharpDiagnosticAsync(LanguageVersion? languageVersion, string source, string settings, DiagnosticResult[] expected, CancellationToken cancellationToken) + => StyleCopDiagnosticVerifier.VerifyCSharpDiagnosticAsync(languageVersion, source, settings, expected, cancellationToken); + internal static Task VerifyCSharpFixAsync(string source, DiagnosticResult expected, string fixedSource, CancellationToken cancellationToken) => VerifyCSharpFixAsync(source, new[] { expected }, fixedSource, cancellationToken); @@ -50,13 +70,27 @@ internal static Task VerifyCSharpFixAsync(string source, DiagnosticResult[] expe FixedCode = fixedSource, }; - if (source == fixedSource) + test.ExpectedDiagnostics.AddRange(expected); + return test.RunAsync(cancellationToken); + } + + internal static Task VerifyCSharpFixAsync(LanguageVersion? languageVersion, string source, DiagnosticResult expected, string fixedSource, CancellationToken cancellationToken) + => VerifyCSharpFixAsync(languageVersion, source, settings: null, new[] { expected }, fixedSource, cancellationToken); + + internal static Task VerifyCSharpFixAsync(LanguageVersion? languageVersion, string source, DiagnosticResult[] expected, string fixedSource, CancellationToken cancellationToken) + => VerifyCSharpFixAsync(languageVersion, source, settings: null, expected, fixedSource, cancellationToken); + + internal static Task VerifyCSharpFixAsync(string source, string settings, DiagnosticResult[] expected, string fixedSource, CancellationToken cancellationToken) + => VerifyCSharpFixAsync(languageVersion: null, source, settings, expected, fixedSource, cancellationToken); + + internal static Task VerifyCSharpFixAsync(LanguageVersion? languageVersion, string source, string settings, DiagnosticResult[] expected, string fixedSource, CancellationToken cancellationToken) + { + var test = new CSharpTest(languageVersion) { - test.FixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll; - test.FixedState.MarkupHandling = MarkupMode.Allow; - test.BatchFixedState.InheritanceMode = StateInheritanceMode.AutoInheritAll; - test.BatchFixedState.MarkupHandling = MarkupMode.Allow; - } + TestCode = source, + Settings = settings, + FixedCode = fixedSource, + }; test.ExpectedDiagnostics.AddRange(expected); return test.RunAsync(cancellationToken); @@ -68,17 +102,52 @@ internal class CSharpTest : CSharpCodeFixTest options .WithChangedOption(FormattingOptions.IndentationSize, this.Language, this.IndentationSize) .WithChangedOption(FormattingOptions.TabSize, this.Language, this.TabSize) .WithChangedOption(FormattingOptions.UseTabs, this.Language, this.UseTabs)); - this.TestState.AdditionalReferences.Add(GenericAnalyzerTest.CSharpSymbolsReference); this.TestState.AdditionalFilesFactories.Add(GenerateSettingsFile); - this.CodeFixValidationMode = CodeFixValidationMode.None; + this.CodeActionValidationMode = CodeActionValidationMode.SemanticStructure; + + this.SolutionTransforms.Add((solution, projectId) => + { + var corlib = solution.GetProject(projectId).MetadataReferences.OfType() + .Single(reference => Path.GetFileName(reference.FilePath) == "mscorlib.dll"); + var system = solution.GetProject(projectId).MetadataReferences.OfType() + .Single(reference => Path.GetFileName(reference.FilePath) == "System.dll"); + + return solution + .RemoveMetadataReference(projectId, corlib) + .RemoveMetadataReference(projectId, system) + .AddMetadataReference(projectId, corlib.WithAliases(new[] { "global", "corlib" })) + .AddMetadataReference(projectId, system.WithAliases(new[] { "global", "system" })); + }); return; @@ -112,7 +181,7 @@ public CSharpTest() { JsonObject indentationObject = JsonReader.Parse(indentationSettings).AsJsonObject; JsonObject settingsObject = JsonReader.Parse(settings).AsJsonObject; - JsonObject mergedSettings = MergeJsonObjects(settingsObject, indentationObject); + JsonObject mergedSettings = JsonTestHelper.MergeJsonObjects(settingsObject, indentationObject); using (var writer = new JsonWriter(pretty: true)) { settings = writer.Serialize(mergedSettings); @@ -127,13 +196,13 @@ public CSharpTest() } } - public SourceFileList TestSources => TestState.Sources; + public SourceFileList TestSources => this.TestState.Sources; - public SourceFileList FixedSources => FixedState.Sources; + public SourceFileList FixedSources => this.FixedState.Sources; - public SourceFileCollection FixedAdditionalFiles => FixedState.AdditionalFiles; + public SourceFileCollection FixedAdditionalFiles => this.FixedState.AdditionalFiles; - public List RemainingDiagnostics => FixedState.ExpectedDiagnostics; + public List RemainingDiagnostics => this.FixedState.ExpectedDiagnostics; /// /// Gets or sets the value of the to apply to the test @@ -142,7 +211,24 @@ public CSharpTest() /// /// The value of the to apply to the test workspace. /// - public int IndentationSize { get; set; } = DefaultIndentationSize; + public int IndentationSize + { + get + { + return this.indentationSize; + } + + set + { + if (this.indentationSize == value) + { + return; + } + + this.indentationSize = value; + this.UpdateGlobalAnalyzerConfig(); + } + } /// /// Gets or sets a value indicating whether the option is applied to the @@ -151,7 +237,24 @@ public CSharpTest() /// /// The value of the to apply to the test workspace. /// - public bool UseTabs { get; set; } = DefaultUseTabs; + public bool UseTabs + { + get + { + return this.useTabs; + } + + set + { + if (this.useTabs == value) + { + return; + } + + this.useTabs = value; + this.UpdateGlobalAnalyzerConfig(); + } + } /// /// Gets or sets the value of the to apply to the test workspace. @@ -159,7 +262,24 @@ public CSharpTest() /// /// The value of the to apply to the test workspace. /// - public int TabSize { get; set; } = DefaultTabSize; + public int TabSize + { + get + { + return this.tabSize; + } + + set + { + if (this.tabSize == value) + { + return; + } + + this.tabSize = value; + this.UpdateGlobalAnalyzerConfig(); + } + } /// /// Gets or sets the content of the settings file to use. @@ -177,6 +297,40 @@ public CSharpTest() /// public string SettingsFileName { get; set; } = SettingsHelper.SettingsFileName; + /// + /// Gets the list of diagnostic identifier that will be explicitly enabled in the compilation options. + /// + /// + /// The list of explicitly enabled diagnostic identifiers. + /// + public List ExplicitlyEnabledDiagnostics { get; } = new List(); + + private LanguageVersion? LanguageVersion { get; } + + protected override CompilationOptions CreateCompilationOptions() + { + var compilationOptions = base.CreateCompilationOptions(); + var specificDiagnosticOptions = compilationOptions.SpecificDiagnosticOptions; + + foreach (var id in this.ExplicitlyEnabledDiagnostics) + { + specificDiagnosticOptions = specificDiagnosticOptions.SetItem(id, ReportDiagnostic.Warn); + } + + return compilationOptions.WithSpecificDiagnosticOptions(specificDiagnosticOptions); + } + + protected override ParseOptions CreateParseOptions() + { + var parseOptions = base.CreateParseOptions(); + if (this.LanguageVersion is { } languageVersion) + { + parseOptions = ((CSharpParseOptions)parseOptions).WithLanguageVersion(languageVersion); + } + + return parseOptions; + } + protected override IEnumerable GetCodeFixProviders() { var codeFixProvider = new TCodeFix(); @@ -184,33 +338,38 @@ protected override IEnumerable GetCodeFixProviders() return new[] { codeFixProvider }; } - private static JsonObject MergeJsonObjects(JsonObject priority, JsonObject fallback) + private void UpdateGlobalAnalyzerConfig() { - foreach (var pair in priority) + if (!LightupHelpers.SupportsCSharp11) { - if (pair.Value.IsJsonObject) - { - switch (fallback[pair.Key].Type) - { - case JsonValueType.Null: - fallback[pair.Key] = pair.Value; - break; - - case JsonValueType.Object: - fallback[pair.Key] = MergeJsonObjects(pair.Value.AsJsonObject, fallback[pair.Key].AsJsonObject); - break; + // Options support workspace options in this version + // https://github.com/dotnet/roslyn/issues/66779 + return; + } - default: - throw new InvalidOperationException($"Cannot merge objects of type '{pair.Value.Type}' and '{fallback[pair.Key].Type}'."); - } - } - else - { - fallback[pair.Key] = pair.Value; - } + if (this.TestState.AnalyzerConfigFiles.Count == 1 + && this.TestState.AnalyzerConfigFiles[0].filename == "/.globalconfig") + { + this.TestState.AnalyzerConfigFiles.RemoveAt(0); } + else if (this.TestState.AnalyzerConfigFiles.Count > 1 + || (this.TestState.AnalyzerConfigFiles.Count > 0 && this.TestState.AnalyzerConfigFiles[0].filename != "/.globalconfig")) + { + throw new NotSupportedException("Additional configuration files are not currently supported by the test"); + } + + this.TestState.AnalyzerConfigFiles.Add(("/.globalconfig", $@"is_global = true - return fallback; +indent_size = {this.IndentationSize} +indent_style = {(this.UseTabs ? "tab" : "space")} +tab_width = {this.TabSize} +")); + } + + // NOTE: If needed, this method can be temporarily updated to default to a preview version + private LanguageVersion? GetDefaultLanguageVersion() + { + return null; } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/StyleCopDiagnosticVerifier`1.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/StyleCopDiagnosticVerifier`1.cs index 16f2681d2..b230b628e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/StyleCopDiagnosticVerifier`1.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/Verifiers/StyleCopDiagnosticVerifier`1.cs @@ -1,15 +1,19 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Test.Verifiers { using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Testing; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Testing.Verifiers; + using StyleCop.Analyzers.Lightup; internal static class StyleCopDiagnosticVerifier where TAnalyzer : DiagnosticAnalyzer, new() @@ -37,8 +41,51 @@ internal static Task VerifyCSharpDiagnosticAsync(string source, DiagnosticResult return test.RunAsync(cancellationToken); } + internal static Task VerifyCSharpDiagnosticAsync(LanguageVersion? languageVersion, string source, DiagnosticResult expected, CancellationToken cancellationToken) + => VerifyCSharpDiagnosticAsync(languageVersion, source, settings: null, new[] { expected }, cancellationToken); + + internal static Task VerifyCSharpDiagnosticAsync(LanguageVersion? languageVersion, string source, string settings, DiagnosticResult[] expected, CancellationToken cancellationToken) + { + var test = new CSharpTest(languageVersion) + { + TestCode = source, + Settings = settings, + }; + + test.ExpectedDiagnostics.AddRange(expected); + return test.RunAsync(cancellationToken); + } + internal class CSharpTest : StyleCopCodeFixVerifier.CSharpTest { + public CSharpTest() + : this(languageVersion: null) + { + } + + public CSharpTest(LanguageVersion? languageVersion) + { + this.LanguageVersion = languageVersion ?? this.GetDefaultLanguageVersion(); + } + + private LanguageVersion? LanguageVersion { get; } + + protected override ParseOptions CreateParseOptions() + { + var parseOptions = base.CreateParseOptions(); + if (this.LanguageVersion is { } languageVersion) + { + parseOptions = ((CSharpParseOptions)parseOptions).WithLanguageVersion(languageVersion); + } + + return parseOptions; + } + + // NOTE: If needed, this method can be temporarily updated to default to a preview version + private LanguageVersion? GetDefaultLanguageVersion() + { + return null; + } } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/WorkItemAttribute.cs b/StyleCop.Analyzers/StyleCop.Analyzers.Test/WorkItemAttribute.cs index bc7930190..f77b90c5d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Test/WorkItemAttribute.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/WorkItemAttribute.cs @@ -1,5 +1,5 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Test { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Test/xunit.runner.json b/StyleCop.Analyzers/StyleCop.Analyzers.Test/xunit.runner.json new file mode 100644 index 000000000..aa59e4469 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Test/xunit.runner.json @@ -0,0 +1,3 @@ +{ + "shadowCopy": false +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.Vsix/StyleCop.Analyzers.Vsix.csproj b/StyleCop.Analyzers/StyleCop.Analyzers.Vsix/StyleCop.Analyzers.Vsix.csproj index debf8b085..186d283c2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.Vsix/StyleCop.Analyzers.Vsix.csproj +++ b/StyleCop.Analyzers/StyleCop.Analyzers.Vsix/StyleCop.Analyzers.Vsix.csproj @@ -28,7 +28,7 @@ - + diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.ruleset b/StyleCop.Analyzers/StyleCop.Analyzers.ruleset index d7756937e..35d99263d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.ruleset +++ b/StyleCop.Analyzers/StyleCop.Analyzers.ruleset @@ -70,6 +70,9 @@ + + + @@ -77,6 +80,7 @@ + diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerCategory.cs b/StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerCategory.cs index f1363fc18..eda548d5a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerCategory.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerCategory.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerConstants.cs b/StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerConstants.cs index f73880535..ea1cdd6b8 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerConstants.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerConstants.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerExtensions.cs index db225e6bd..e905b2236 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerExtensions.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerExtensions.cs @@ -1,11 +1,14 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers { using System; using System.Collections.Concurrent; using System.Collections.Immutable; + using System.Diagnostics.CodeAnalysis; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Settings.ObjectModel; @@ -21,72 +24,19 @@ internal static class AnalyzerExtensions /// /// The analysis context. /// Action to be executed at completion of parsing of a document. - public static void RegisterSyntaxTreeAction(this AnalysisContext context, Action action) - { - context.RegisterSyntaxTreeAction( - c => - { - StyleCopSettings settings = context.GetStyleCopSettings(c.Options, c.CancellationToken); - action(c, settings); - }); - } - - /// - /// Register an action to be executed at completion of parsing of a code document. A syntax tree action reports - /// diagnostics about the of a document. - /// - /// The analysis context. - /// Action to be executed at completion of parsing of a document. + [SuppressMessage("MicrosoftCodeAnalysisPerformance", "RS1012:Start action has no registered actions", Justification = "This is not a start action")] public static void RegisterSyntaxTreeAction(this CompilationStartAnalysisContext context, Action action) { + var settingsFile = context.GetStyleCopSettingsFile(context.CancellationToken); + context.RegisterSyntaxTreeAction( - c => + context => { - StyleCopSettings settings = context.GetStyleCopSettings(c.Options, c.CancellationToken); - action(c, settings); + StyleCopSettings settings = context.GetStyleCopSettings(settingsFile); + action(context, settings); }); } - /// - /// Register an action to be executed at completion of semantic analysis of a with an - /// appropriate kind. A syntax node action can report diagnostics about a , and can also - /// collect state information to be used by other syntax node actions or code block end actions. - /// - /// The analysis context. - /// Action to be executed at completion of semantic analysis of a - /// . - /// The kind of syntax that should be analyzed. - /// Enum type giving the syntax node kinds of the source language for which - /// the action applies. - public static void RegisterSyntaxNodeAction(this AnalysisContext context, Action action, TLanguageKindEnum syntaxKind) - where TLanguageKindEnum : struct - { - context.RegisterSyntaxNodeAction(action, LanguageKindArrays.GetOrCreateArray(syntaxKind)); - } - - /// - /// Register an action to be executed at completion of semantic analysis of a with an - /// appropriate kind. A syntax node action can report diagnostics about a , and can also - /// collect state information to be used by other syntax node actions or code block end actions. - /// - /// The analysis context. - /// Action to be executed at completion of semantic analysis of a - /// . - /// The kinds of syntax that should be analyzed. - /// Enum type giving the syntax node kinds of the source language for which - /// the action applies. - public static void RegisterSyntaxNodeAction(this AnalysisContext context, Action action, ImmutableArray syntaxKinds) - where TLanguageKindEnum : struct - { - context.RegisterSyntaxNodeAction( - c => - { - StyleCopSettings settings = context.GetStyleCopSettings(c.Options, c.CancellationToken); - action(c, settings); - }, - syntaxKinds); - } - /// /// Register an action to be executed at completion of semantic analysis of a with an /// appropriate kind. A syntax node action can report diagnostics about a , and can also @@ -115,14 +65,17 @@ public static void RegisterSyntaxNodeAction(this CompilationS /// The kinds of syntax that should be analyzed. /// Enum type giving the syntax node kinds of the source language for which /// the action applies. + [SuppressMessage("MicrosoftCodeAnalysisPerformance", "RS1012:Start action has no registered actions", Justification = "This is not a start action")] public static void RegisterSyntaxNodeAction(this CompilationStartAnalysisContext context, Action action, ImmutableArray syntaxKinds) where TLanguageKindEnum : struct { + var settingsFile = context.GetStyleCopSettingsFile(context.CancellationToken); + context.RegisterSyntaxNodeAction( - c => + context => { - StyleCopSettings settings = context.GetStyleCopSettings(c.Options, c.CancellationToken); - action(c, settings); + StyleCopSettings settings = context.GetStyleCopSettings(settingsFile); + action(context, settings); }, syntaxKinds); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerReleases.Shipped.md b/StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerReleases.Shipped.md new file mode 100644 index 000000000..5ce6f0ad8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerReleases.Shipped.md @@ -0,0 +1,188 @@ +; Shipped analyzer releases +; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md + +## Release 1.0 + +### New Rules + +Rule ID | Category | Severity | Notes +--------|----------|----------|------- +SA0000 | StyleCop.CSharp.SpecialRules | Info | SA0000Roslyn7446Workaround +SA1000 | StyleCop.CSharp.SpacingRules | Warning | SA1000KeywordsMustBeSpacedCorrectly, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1000.md) +SA1001 | StyleCop.CSharp.SpacingRules | Warning | SA1001CommasMustBeSpacedCorrectly, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md) +SA1002 | StyleCop.CSharp.SpacingRules | Warning | SA1002SemicolonsMustBeSpacedCorrectly, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1002.md) +SA1004 | StyleCop.CSharp.SpacingRules | Warning | SA1004DocumentationLinesMustBeginWithSingleSpace +SA1005 | StyleCop.CSharp.SpacingRules | Warning | SA1005SingleLineCommentsMustBeginWithSingleSpace +SA1006 | StyleCop.CSharp.SpacingRules | Warning | SA1006PreprocessorKeywordsMustNotBePrecededBySpace +SA1007 | StyleCop.CSharp.SpacingRules | Warning | SA1007OperatorKeywordMustBeFollowedBySpace +SA1009 | StyleCop.CSharp.SpacingRules | Warning | SA1009ClosingParenthesisMustBeSpacedCorrectly, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1009.md) +SA1010 | StyleCop.CSharp.SpacingRules | Warning | SA1010OpeningSquareBracketsMustBeSpacedCorrectly, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1010.md) +SA1011 | StyleCop.CSharp.SpacingRules | Warning | SA1011ClosingSquareBracketsMustBeSpacedCorrectly, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1011.md) +SA1012 | StyleCop.CSharp.SpacingRules | Warning | SA1012OpeningBracesMustBeSpacedCorrectly, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1012.md) +SA1013 | StyleCop.CSharp.SpacingRules | Warning | SA1013ClosingBracesMustBeSpacedCorrectly, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1013.md) +SA1014 | StyleCop.CSharp.SpacingRules | Warning | SA1014OpeningGenericBracketsMustBeSpacedCorrectly, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1014.md) +SA1015 | StyleCop.CSharp.SpacingRules | Warning | SA1015ClosingGenericBracketsMustBeSpacedCorrectly, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1015.md) +SA1016 | StyleCop.CSharp.SpacingRules | Warning | SA1016OpeningAttributeBracketsMustBeSpacedCorrectly +SA1017 | StyleCop.CSharp.SpacingRules | Warning | SA1017ClosingAttributeBracketsMustBeSpacedCorrectly +SA1018 | StyleCop.CSharp.SpacingRules | Warning | SA1018NullableTypeSymbolsMustNotBePrecededBySpace +SA1019 | StyleCop.CSharp.SpacingRules | Warning | SA1019MemberAccessSymbolsMustBeSpacedCorrectly, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1019.md) +SA1020 | StyleCop.CSharp.SpacingRules | Warning | SA1020IncrementDecrementSymbolsMustBeSpacedCorrectly, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1020.md) +SA1021 | StyleCop.CSharp.SpacingRules | Warning | SA1021NegativeSignsMustBeSpacedCorrectly, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1021.md) +SA1022 | StyleCop.CSharp.SpacingRules | Warning | SA1022PositiveSignsMustBeSpacedCorrectly, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1022.md) +SA1023 | StyleCop.CSharp.SpacingRules | Warning | SA1023DereferenceAndAccessOfSymbolsMustBeSpacedCorrectly, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1023.md) +SA1024 | StyleCop.CSharp.SpacingRules | Warning | SA1024ColonsMustBeSpacedCorrectly, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1024.md) +SA1025 | StyleCop.CSharp.SpacingRules | Warning | SA1025CodeMustNotContainMultipleWhitespaceInARow +SA1026 | StyleCop.CSharp.SpacingRules | Warning | SA1026CodeMustNotContainSpaceAfterNewKeywordInImplicitlyTypedArrayAllocation +SA1027 | StyleCop.CSharp.SpacingRules | Warning | SA1027TabsMustNotBeUsed +SA1028 | StyleCop.CSharp.SpacingRules | Warning | SA1028CodeMustNotContainTrailingWhitespace +SA1100 | StyleCop.CSharp.ReadabilityRules | Warning | SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists +SA1101 | StyleCop.CSharp.ReadabilityRules | Warning | SA1101PrefixLocalCallsWithThis +SA1106 | StyleCop.CSharp.ReadabilityRules | Warning | SA1106CodeMustNotContainEmptyStatements +SA1107 | StyleCop.CSharp.ReadabilityRules | Warning | SA1107CodeMustNotContainMultipleStatementsOnOneLine +SA1108 | StyleCop.CSharp.ReadabilityRules | Warning | SA1108BlockStatementsMustNotContainEmbeddedComments +SA1110 | StyleCop.CSharp.ReadabilityRules | Warning | SA1110OpeningParenthesisMustBeOnDeclarationLine +SA1111 | StyleCop.CSharp.ReadabilityRules | Warning | SA1111ClosingParenthesisMustBeOnLineOfLastParameter +SA1112 | StyleCop.CSharp.ReadabilityRules | Warning | SA1112ClosingParenthesisMustBeOnLineOfOpeningParenthesis +SA1113 | StyleCop.CSharp.ReadabilityRules | Warning | SA1113CommaMustBeOnSameLineAsPreviousParameter +SA1114 | StyleCop.CSharp.ReadabilityRules | Warning | SA1114ParameterListMustFollowDeclaration +SA1115 | StyleCop.CSharp.ReadabilityRules | Warning | SA1115ParameterMustFollowComma +SA1116 | StyleCop.CSharp.ReadabilityRules | Warning | SA1116SplitParametersMustStartOnLineAfterDeclaration +SA1117 | StyleCop.CSharp.ReadabilityRules | Warning | SA1117ParametersMustBeOnSameLineOrSeparateLines +SA1118 | StyleCop.CSharp.ReadabilityRules | Warning | SA1118ParameterMustNotSpanMultipleLines +SA1119 | StyleCop.CSharp.MaintainabilityRules | Warning | SA1119StatementMustNotUseUnnecessaryParenthesis, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1119.md) +SA1120 | StyleCop.CSharp.ReadabilityRules | Warning | SA1120CommentsMustContainText +SA1121 | StyleCop.CSharp.ReadabilityRules | Warning | SA1121UseBuiltInTypeAlias +SA1122 | StyleCop.CSharp.ReadabilityRules | Warning | SA1122UseStringEmptyForEmptyStrings +SA1123 | StyleCop.CSharp.ReadabilityRules | Warning | SA1123DoNotPlaceRegionsWithinElements +SA1124 | StyleCop.CSharp.ReadabilityRules | Warning | SA1124DoNotUseRegions +SA1125 | StyleCop.CSharp.ReadabilityRules | Warning | SA1125UseShorthandForNullableTypes +SA1127 | StyleCop.CSharp.ReadabilityRules | Warning | SA1127GenericTypeConstraintsMustBeOnOwnLine +SA1128 | StyleCop.CSharp.ReadabilityRules | Warning | SA1128ConstructorInitializerMustBeOnOwnLine +SA1129 | StyleCop.CSharp.ReadabilityRules | Warning | SA1129DoNotUseDefaultValueTypeConstructor +SA1130 | StyleCop.CSharp.ReadabilityRules | Warning | SA1130UseLambdaSyntax +SA1131 | StyleCop.CSharp.ReadabilityRules | Warning | SA1131UseReadableConditions +SA1132 | StyleCop.CSharp.ReadabilityRules | Warning | SA1132DoNotCombineFields +SA1133 | StyleCop.CSharp.ReadabilityRules | Warning | SA1133DoNotCombineAttributes +SA1134 | StyleCop.CSharp.ReadabilityRules | Warning | SA1134AttributesMustNotShareLine +SA1200 | StyleCop.CSharp.OrderingRules | Warning | SA1200UsingDirectivesMustBePlacedCorrectly, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1200.md) +SA1201 | StyleCop.CSharp.OrderingRules | Warning | SA1201ElementsMustAppearInTheCorrectOrder +SA1202 | StyleCop.CSharp.OrderingRules | Warning | SA1202ElementsMustBeOrderedByAccess +SA1203 | StyleCop.CSharp.OrderingRules | Warning | SA1203ConstantsMustAppearBeforeFields +SA1204 | StyleCop.CSharp.OrderingRules | Warning | SA1204StaticElementsMustAppearBeforeInstanceElements +SA1205 | StyleCop.CSharp.OrderingRules | Warning | SA1205PartialElementsMustDeclareAccess, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1205.md) +SA1206 | StyleCop.CSharp.OrderingRules | Warning | SA1206DeclarationKeywordsMustFollowOrder, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1206.md) +SA1207 | StyleCop.CSharp.OrderingRules | Warning | SA1207ProtectedMustComeBeforeInternal, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1207.md) +SA1208 | StyleCop.CSharp.OrderingRules | Warning | SA1208SystemUsingDirectivesMustBePlacedBeforeOtherUsingDirectives, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1208.md) +SA1209 | StyleCop.CSharp.OrderingRules | Warning | SA1209UsingAliasDirectivesMustBePlacedAfterOtherUsingDirectives, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1209.md) +SA1210 | StyleCop.CSharp.OrderingRules | Warning | SA1210UsingDirectivesMustBeOrderedAlphabeticallyByNamespace, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1210.md) +SA1211 | StyleCop.CSharp.OrderingRules | Warning | SA1211UsingAliasDirectivesMustBeOrderedAlphabeticallyByAliasName, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1211.md) +SA1212 | StyleCop.CSharp.OrderingRules | Warning | SA1212PropertyAccessorsMustFollowOrder, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1212.md) +SA1213 | StyleCop.CSharp.OrderingRules | Warning | SA1213EventAccessorsMustFollowOrder, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1213.md) +SA1214 | StyleCop.CSharp.OrderingRules | Warning | SA1214ReadonlyElementsMustAppearBeforeNonReadonlyElements +SA1216 | StyleCop.CSharp.OrderingRules | Warning | SA1216UsingStaticDirectivesMustBePlacedAtTheCorrectLocation, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1216.md) +SA1217 | StyleCop.CSharp.OrderingRules | Warning | SA1217UsingStaticDirectivesMustBeOrderedAlphabetically, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1217.md) +SA1300 | StyleCop.CSharp.NamingRules | Warning | SA1300ElementMustBeginWithUpperCaseLetter, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1300.md) +SA1302 | StyleCop.CSharp.NamingRules | Warning | SA1302InterfaceNamesMustBeginWithI, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1302.md) +SA1303 | StyleCop.CSharp.NamingRules | Warning | SA1303ConstFieldNamesMustBeginWithUpperCaseLetter, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1303.md) +SA1304 | StyleCop.CSharp.NamingRules | Warning | SA1304NonPrivateReadonlyFieldsMustBeginWithUpperCaseLetter, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1304.md) +SA1305 | StyleCop.CSharp.NamingRules | Warning | SA1305FieldNamesMustNotUseHungarianNotation, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1305.md) +SA1306 | StyleCop.CSharp.NamingRules | Warning | SA1306FieldNamesMustBeginWithLowerCaseLetter, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1306.md) +SA1307 | StyleCop.CSharp.NamingRules | Warning | SA1307AccessibleFieldsMustBeginWithUpperCaseLetter, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1307.md) +SA1308 | StyleCop.CSharp.NamingRules | Warning | SA1308VariableNamesMustNotBePrefixed, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1308.md) +SA1309 | StyleCop.CSharp.NamingRules | Warning | SA1309FieldNamesMustNotBeginWithUnderscore, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1309.md) +SA1310 | StyleCop.CSharp.NamingRules | Warning | SA1310FieldNamesMustNotContainUnderscore, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1310.md) +SA1311 | StyleCop.CSharp.NamingRules | Warning | SA1311StaticReadonlyFieldsMustBeginWithUpperCaseLetter, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1311.md) +SA1312 | StyleCop.CSharp.NamingRules | Warning | SA1312VariableNamesMustBeginWithLowerCaseLetter +SA1313 | StyleCop.CSharp.NamingRules | Warning | SA1313ParameterNamesMustBeginWithLowerCaseLetter +SA1400 | StyleCop.CSharp.MaintainabilityRules | Warning | SA1400AccessModifierMustBeDeclared, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1400.md) +SA1401 | StyleCop.CSharp.MaintainabilityRules | Warning | SA1401FieldsMustBePrivate, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1401.md) +SA1402 | StyleCop.CSharp.MaintainabilityRules | Warning | SA1402FileMayOnlyContainASingleClass, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1402.md) +SA1403 | StyleCop.CSharp.MaintainabilityRules | Warning | SA1403FileMayOnlyContainASingleNamespace, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1403.md) +SA1404 | StyleCop.CSharp.MaintainabilityRules | Warning | SA1404CodeAnalysisSuppressionMustHaveJustification, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1404.md) +SA1405 | StyleCop.CSharp.MaintainabilityRules | Warning | SA1405DebugAssertMustProvideMessageText, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1405.md) +SA1406 | StyleCop.CSharp.MaintainabilityRules | Warning | SA1406DebugFailMustProvideMessageText, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1406.md) +SA1407 | StyleCop.CSharp.MaintainabilityRules | Warning | SA1407ArithmeticExpressionsMustDeclarePrecedence, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1407.md) +SA1408 | StyleCop.CSharp.MaintainabilityRules | Warning | SA1408ConditionalExpressionsMustDeclarePrecedence, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1408.md) +SA1410 | StyleCop.CSharp.MaintainabilityRules | Warning | SA1410RemoveDelegateParenthesisWhenPossible, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1410.md) +SA1411 | StyleCop.CSharp.MaintainabilityRules | Warning | SA1411AttributeConstructorMustNotUseUnnecessaryParenthesis, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1411.md) +SA1412 | StyleCop.CSharp.MaintainabilityRules | Warning | SA1412StoreFilesAsUtf8, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1412.md) +SA1500 | StyleCop.CSharp.LayoutRules | Warning | SA1500BracesForMultiLineStatementsMustNotShareLine, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1500.md) +SA1501 | StyleCop.CSharp.LayoutRules | Warning | SA1501StatementMustNotBeOnASingleLine, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1501.md) +SA1502 | StyleCop.CSharp.LayoutRules | Warning | SA1502ElementMustNotBeOnASingleLine +SA1503 | StyleCop.CSharp.LayoutRules | Warning | SA1503BracesMustNotBeOmitted, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1503.md) +SA1504 | StyleCop.CSharp.LayoutRules | Warning | SA1504AllAccessorsMustBeSingleLineOrMultiLine, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1504.md) +SA1505 | StyleCop.CSharp.LayoutRules | Warning | SA1505OpeningBracesMustNotBeFollowedByBlankLine, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1505.md) +SA1506 | StyleCop.CSharp.LayoutRules | Warning | SA1506ElementDocumentationHeadersMustNotBeFollowedByBlankLine, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1506.md) +SA1507 | StyleCop.CSharp.LayoutRules | Warning | SA1507CodeMustNotContainMultipleBlankLinesInARow, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md) +SA1508 | StyleCop.CSharp.LayoutRules | Warning | SA1508ClosingBracesMustNotBePrecededByBlankLine, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1508.md) +SA1509 | StyleCop.CSharp.LayoutRules | Warning | SA1509OpeningBracesMustNotBePrecededByBlankLine, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1509.md) +SA1510 | StyleCop.CSharp.LayoutRules | Warning | SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1510.md) +SA1511 | StyleCop.CSharp.LayoutRules | Warning | SA1511WhileDoFooterMustNotBePrecededByBlankLine, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1511.md) +SA1512 | StyleCop.CSharp.LayoutRules | Warning | SA1512SingleLineCommentsMustNotBeFollowedByBlankLine, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1512.md) +SA1513 | StyleCop.CSharp.LayoutRules | Warning | SA1513ClosingBraceMustBeFollowedByBlankLine, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1513.md) +SA1514 | StyleCop.CSharp.LayoutRules | Warning | SA1514ElementDocumentationHeaderMustBePrecededByBlankLine, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1514.md) +SA1515 | StyleCop.CSharp.LayoutRules | Warning | SA1515SingleLineCommentMustBePrecededByBlankLine, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1515.md) +SA1516 | StyleCop.CSharp.LayoutRules | Warning | SA1516ElementsMustBeSeparatedByBlankLine, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1516.md) +SA1517 | StyleCop.CSharp.LayoutRules | Warning | SA1517CodeMustNotContainBlankLinesAtStartOfFile, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1517.md) +SA1519 | StyleCop.CSharp.LayoutRules | Warning | SA1519BracesMustNotBeOmittedFromMultiLineChildStatement, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1519.md) +SA1520 | StyleCop.CSharp.LayoutRules | Warning | SA1520UseBracesConsistently, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1520.md) +SA1600 | StyleCop.CSharp.DocumentationRules | Warning | SA1600ElementsMustBeDocumented, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1600.md) +SA1601 | StyleCop.CSharp.DocumentationRules | Warning | SA1601PartialElementsMustBeDocumented, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1601.md) +SA1602 | StyleCop.CSharp.DocumentationRules | Warning | SA1602EnumerationItemsMustBeDocumented, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1602.md) +SA1604 | StyleCop.CSharp.DocumentationRules | Warning | SA1604ElementDocumentationMustHaveSummary, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1604.md) +SA1605 | StyleCop.CSharp.DocumentationRules | Warning | SA1605PartialElementDocumentationMustHaveSummary, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1605.md) +SA1606 | StyleCop.CSharp.DocumentationRules | Warning | SA1606ElementDocumentationMustHaveSummaryText, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1606.md) +SA1607 | StyleCop.CSharp.DocumentationRules | Warning | SA1607PartialElementDocumentationMustHaveSummaryText, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1607.md) +SA1608 | StyleCop.CSharp.DocumentationRules | Warning | SA1608ElementDocumentationMustNotHaveDefaultSummary, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1608.md) +SA1609 | StyleCop.CSharp.DocumentationRules | Warning | SA1609PropertyDocumentationMustHaveValue, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1609.md) +SA1610 | StyleCop.CSharp.DocumentationRules | Warning | SA1610PropertyDocumentationMustHaveValueText, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1610.md) +SA1611 | StyleCop.CSharp.DocumentationRules | Warning | SA1611ElementParametersMustBeDocumented +SA1612 | StyleCop.CSharp.DocumentationRules | Warning | SA1612ElementParameterDocumentationMustMatchElementParameters, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1612.md) +SA1613 | StyleCop.CSharp.DocumentationRules | Warning | SA1613ElementParameterDocumentationMustDeclareParameterName, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1613.md) +SA1614 | StyleCop.CSharp.DocumentationRules | Warning | SA1614ElementParameterDocumentationMustHaveText, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1614.md) +SA1615 | StyleCop.CSharp.DocumentationRules | Warning | SA1615ElementReturnValueMustBeDocumented, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1615.md) +SA1616 | StyleCop.CSharp.DocumentationRules | Warning | SA1616ElementReturnValueDocumentationMustHaveText, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1616.md) +SA1617 | StyleCop.CSharp.DocumentationRules | Warning | SA1617VoidReturnValueMustNotBeDocumented, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1617.md) +SA1618 | StyleCop.CSharp.DocumentationRules | Warning | SA1618GenericTypeParametersMustBeDocumented, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1618.md) +SA1619 | StyleCop.CSharp.DocumentationRules | Warning | SA1619GenericTypeParametersMustBeDocumentedPartialClass, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1619.md) +SA1620 | StyleCop.CSharp.DocumentationRules | Warning | SA1620GenericTypeParameterDocumentationMustMatchTypeParameters, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1620.md) +SA1621 | StyleCop.CSharp.DocumentationRules | Warning | SA1621GenericTypeParameterDocumentationMustDeclareParameterName, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1621.md) +SA1622 | StyleCop.CSharp.DocumentationRules | Warning | SA1622GenericTypeParameterDocumentationMustHaveText, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1622.md) +SA1625 | StyleCop.CSharp.DocumentationRules | Warning | SA1625ElementDocumentationMustNotBeCopiedAndPasted, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1625.md) +SA1626 | StyleCop.CSharp.DocumentationRules | Warning | SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1626.md) +SA1627 | StyleCop.CSharp.DocumentationRules | Warning | SA1627DocumentationTextMustNotBeEmpty +SA1642 | StyleCop.CSharp.DocumentationRules | Warning | SA1642ConstructorSummaryDocumentationMustBeginWithStandardText, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1642.md) +SA1643 | StyleCop.CSharp.DocumentationRules | Warning | SA1643DestructorSummaryDocumentationMustBeginWithStandardText, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1643.md) +SA1648 | StyleCop.CSharp.DocumentationRules | Warning | SA1648InheritDocMustBeUsedWithInheritingClass, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1648.md) +SA1649 | StyleCop.CSharp.DocumentationRules | Warning | SA1649FileNameMustMatchTypeName +SA1651 | StyleCop.CSharp.DocumentationRules | Warning | SA1651DoNotUsePlaceholderElements, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1651.md) +SA1652 | StyleCop.CSharp.DocumentationRules | Warning | SA1652EnableXmlDocumentationOutput, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1652.md) +SX1101 | StyleCop.CSharp.ReadabilityRules | Warning | SX1101DoNotPrefixLocalMembersWithThis +SX1309 | StyleCop.CSharp.NamingRules | Warning | SX1309FieldNamesMustBeginWithUnderscore, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SX1309.md) +SX1309S | StyleCop.CSharp.NamingRules | Warning | SX1309SStaticFieldNamesMustBeginWithUnderscore, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SX1309S.md) + +## Release 1.1 + +### New Rules + +Rule ID | Category | Severity | Notes +--------|----------|----------|------- +SA0001 | StyleCop.CSharp.SpecialRules | Warning | SA0001XmlCommentAnalysisDisabled, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA0001.md) +SA0002 | StyleCop.CSharp.SpecialRules | Warning | SA0002InvalidSettingsFile, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA0002.md) +SA1136 | StyleCop.CSharp.ReadabilityRules | Warning | SA1136EnumValuesShouldBeOnSeparateLines +SA1137 | StyleCop.CSharp.ReadabilityRules | Warning | SA1137ElementsShouldHaveTheSameIndentation +SA1139 | StyleCop.CSharp.ReadabilityRules | Warning | SA1139UseLiteralSuffixNotationInsteadOfCasting +SA1314 | StyleCop.CSharp.NamingRules | Warning | SA1314TypeParameterNamesMustBeginWithT +SA1413 | StyleCop.CSharp.ReadabilityRules | Warning | SA1413UseTrailingCommasInMultiLineInitializers +SA1629 | StyleCop.CSharp.DocumentationRules | Warning | SA1629DocumentationTextMustEndWithAPeriod + +### Removed Rules + +Rule ID | Category | Severity | Notes +--------|----------|----------|------- +SA0000 | StyleCop.CSharp.SpecialRules | Info | SA0000Roslyn7446Workaround +SA1516 | StyleCop.CSharp.LayoutRules | Warning | SA1516ElementsMustBeSeparatedByBlankLine, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1516.md) +SA1620 | StyleCop.CSharp.DocumentationRules | Warning | SA1620GenericTypeParameterDocumentationMustMatchTypeParameters, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1620.md) +SA1621 | StyleCop.CSharp.DocumentationRules | Warning | SA1621GenericTypeParameterDocumentationMustDeclareParameterName, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1621.md) +SA1622 | StyleCop.CSharp.DocumentationRules | Warning | SA1622GenericTypeParameterDocumentationMustHaveText, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1622.md) +SA1652 | StyleCop.CSharp.DocumentationRules | Warning | SA1652EnableXmlDocumentationOutput, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1652.md) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerReleases.Unshipped.md b/StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerReleases.Unshipped.md new file mode 100644 index 000000000..83e85e73d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerReleases.Unshipped.md @@ -0,0 +1,18 @@ +; Unshipped analyzer release +; https://github.com/dotnet/roslyn-analyzers/blob/master/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md + +### New Rules + +Rule ID | Category | Severity | Notes +--------|----------|----------|------- +SA1141 | StyleCop.CSharp.ReadabilityRules | Warning | SA1141UseTupleSyntax, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1141.md) +SA1142 | StyleCop.CSharp.ReadabilityRules | Warning | SA1142ReferToTupleElementsByName, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1142.md) +SA1316 | StyleCop.CSharp.NamingRules | Warning | SA1316TupleElementNamesShouldUseCorrectCasing, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1316.md) +SA1414 | StyleCop.CSharp.ReadabilityRules | Warning | SA1414TupleTypesInSignaturesShouldHaveElementNames, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1414.md) +SA1518 | StyleCop.CSharp.LayoutRules | Warning | SA1518UseLineEndingsCorrectlyAtEndOfFile, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1518.md) + +### Changed Rules + +Rule ID | New Category | New Severity | Old Category | Old Severity | Notes +--------|--------------|--------------|--------------|--------------|------- +SA1413 | StyleCop.CSharp.MaintainabilityRules | Warning | StyleCop.CSharp.ReadabilityRules | Warning | SA1413UseTrailingCommasInMultiLineInitializers, [Documentation](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1413.md) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/DocumentationResources.Designer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/DocumentationResources.Designer.cs deleted file mode 100644 index bf1b55c91..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/DocumentationResources.Designer.cs +++ /dev/null @@ -1,892 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace StyleCop.Analyzers.DocumentationRules { - using System; - using System.Reflection; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class DocumentationResources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal DocumentationResources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StyleCop.Analyzers.DocumentationRules.DocumentationResources", typeof(DocumentationResources).GetTypeInfo().Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Generate constructor documentation. - /// - internal static string ConstructorDocumentationCodeFix { - get { - return ResourceManager.GetString("ConstructorDocumentationCodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Generate destructor documentation. - /// - internal static string DestructorDocumentationCodeFix { - get { - return ResourceManager.GetString("DestructorDocumentationCodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Finalizes an instance of the . - /// - internal static string DestructorStandardTextFirstPart { - get { - return ResourceManager.GetString("DestructorStandardTextFirstPart", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to class.. - /// - internal static string DestructorStandardTextSecondPart { - get { - return ResourceManager.GetString("DestructorStandardTextSecondPart", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Inherit documentation. - /// - internal static string InheritdocCodeFix { - get { - return ResourceManager.GetString("InheritdocCodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Generate method documentation. - /// - internal static string MethodDocumentationCodeFix { - get { - return ResourceManager.GetString("MethodDocumentationCodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Initializes a new instance of the . - /// - internal static string NonPrivateConstructorStandardTextFirstPart { - get { - return ResourceManager.GetString("NonPrivateConstructorStandardTextFirstPart", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}. - /// - internal static string NonPrivateConstructorStandardTextSecondPart { - get { - return ResourceManager.GetString("NonPrivateConstructorStandardTextSecondPart", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The parameter is not used.. - /// - internal static string ParameterNotUsed { - get { - return ResourceManager.GetString("ParameterNotUsed", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Prevents a default instance of the . - /// - internal static string PrivateConstructorStandardTextFirstPart { - get { - return ResourceManager.GetString("PrivateConstructorStandardTextFirstPart", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0} from being created. - /// - internal static string PrivateConstructorStandardTextSecondPart { - get { - return ResourceManager.GetString("PrivateConstructorStandardTextSecondPart", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Add standard text. - /// - internal static string PropertySummaryStartTextCodeFix { - get { - return ResourceManager.GetString("PropertySummaryStartTextCodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Document value from summary. - /// - internal static string SA1609SA1610CodeFix { - get { - return ResourceManager.GetString("SA1609SA1610CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A C# method, constructor, delegate or indexer element is missing documentation for one or more of its parameters.. - /// - internal static string SA1611Description { - get { - return ResourceManager.GetString("SA1611Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The documentation for parameter '{0}' is missing. - /// - internal static string SA1611MessageFormat { - get { - return ResourceManager.GetString("SA1611MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Element parameters should be documented. - /// - internal static string SA1611Title { - get { - return ResourceManager.GetString("SA1611Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Document return value. - /// - internal static string SA1615SA1616CodeFix { - get { - return ResourceManager.GetString("SA1615SA1616CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove <returns> XML comment. - /// - internal static string SA1617CodeFix { - get { - return ResourceManager.GetString("SA1617CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The <typeparam> tags within the Xml header documentation for a generic C# element do not match the generic type parameters on the element.. - /// - internal static string SA1620Description { - get { - return ResourceManager.GetString("SA1620Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The type parameter '{0}' does not exist.. - /// - internal static string SA1620MissingMessageFormat { - get { - return ResourceManager.GetString("SA1620MissingMessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Generic type parameter documentation should match type parameters. - /// - internal static string SA1620Title { - get { - return ResourceManager.GetString("SA1620Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The type parameter documentation for '{0}' should be at position {1}.. - /// - internal static string SA1620WrongOrderMessageFormat { - get { - return ResourceManager.GetString("SA1620WrongOrderMessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A <typeparam> tag within the XML header documentation for a generic C# element is missing a name attribute, or contains an empty name attribute.. - /// - internal static string SA1621Description { - get { - return ResourceManager.GetString("SA1621Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Generic type parameter documentation should declare parameter name.. - /// - internal static string SA1621MessageFormat { - get { - return ResourceManager.GetString("SA1621MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Generic type parameter documentation should declare parameter name. - /// - internal static string SA1621Title { - get { - return ResourceManager.GetString("SA1621Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A <typeparam> tag within the Xml header documentation for a generic C# element is empty.. - /// - internal static string SA1622Description { - get { - return ResourceManager.GetString("SA1622Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Generic type parameter documentation should have text.. - /// - internal static string SA1622MessageFormat { - get { - return ResourceManager.GetString("SA1622MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Generic type parameter documentation should have text. - /// - internal static string SA1622Title { - get { - return ResourceManager.GetString("SA1622Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The documentation text within a C# property’s <summary> tag does not match the accessors within the property.. - /// - internal static string SA1623Description { - get { - return ResourceManager.GetString("SA1623Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The property's documentation summary text should begin with: '{0}'. - /// - internal static string SA1623MessageFormat { - get { - return ResourceManager.GetString("SA1623MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Property summary documentation should match accessors. - /// - internal static string SA1623Title { - get { - return ResourceManager.GetString("SA1623Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The documentation text within a C# property’s <summary> tag takes into account all of the accessors within the property, but one of the accessors has limited access.. - /// - internal static string SA1624Description { - get { - return ResourceManager.GetString("SA1624Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Because the property only contains a visible {0} accessor, the documentation summary text should begin with '{1}'.. - /// - internal static string SA1624MessageFormat { - get { - return ResourceManager.GetString("SA1624MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Property summary documentation should omit accessor with restricted access. - /// - internal static string SA1624Title { - get { - return ResourceManager.GetString("SA1624Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Convert to line comment. - /// - internal static string SA1626CodeFix { - get { - return ResourceManager.GetString("SA1626CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The XML header documentation for a C# code element contains an empty tag.. - /// - internal static string SA1627Description { - get { - return ResourceManager.GetString("SA1627Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The documentation text within the \'{0}\' tag should not be empty.. - /// - internal static string SA1627MessageFormat { - get { - return ResourceManager.GetString("SA1627MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Documentation text should not be empty. - /// - internal static string SA1627Title { - get { - return ResourceManager.GetString("SA1627Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Add period. - /// - internal static string SA1629CodeFix { - get { - return ResourceManager.GetString("SA1629CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A section of the XML header documentation for a C# element does not end with a period.. - /// - internal static string SA1629Description { - get { - return ResourceManager.GetString("SA1629Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Documentation text should end with a period. - /// - internal static string SA1629MessageFormat { - get { - return ResourceManager.GetString("SA1629MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Documentation text should end with a period. - /// - internal static string SA1629Title { - get { - return ResourceManager.GetString("SA1629Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Add file header. - /// - internal static string SA1633CodeFix { - get { - return ResourceManager.GetString("SA1633CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A C# code file is missing a standard file header.. - /// - internal static string SA1633Description { - get { - return ResourceManager.GetString("SA1633Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The file header XML is invalid.. - /// - internal static string SA1633MessageFormatMalformed { - get { - return ResourceManager.GetString("SA1633MessageFormatMalformed", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The file header is missing or not located at the top of the file.. - /// - internal static string SA1633MessageFormatMissing { - get { - return ResourceManager.GetString("SA1633MessageFormatMissing", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File should have header. - /// - internal static string SA1633Title { - get { - return ResourceManager.GetString("SA1633Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The file header at the top of a C# code file is missing a copyright tag.. - /// - internal static string SA1634Description { - get { - return ResourceManager.GetString("SA1634Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The file header should contain a copyright tag.. - /// - internal static string SA1634MessageFormat { - get { - return ResourceManager.GetString("SA1634MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File header should show copyright. - /// - internal static string SA1634Title { - get { - return ResourceManager.GetString("SA1634Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The file header at the top of a C# code file is missing copyright text.. - /// - internal static string SA1635Description { - get { - return ResourceManager.GetString("SA1635Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File header should have copyright text. - /// - internal static string SA1635MessageFormat { - get { - return ResourceManager.GetString("SA1635MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File header should have copyright text. - /// - internal static string SA1635Title { - get { - return ResourceManager.GetString("SA1635Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The file header at the top of a C# code file does not contain the appropriate copyright text.. - /// - internal static string SA1636Description { - get { - return ResourceManager.GetString("SA1636Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The file header copyright text should match the copyright text from the settings.. - /// - internal static string SA1636MessageFormat { - get { - return ResourceManager.GetString("SA1636MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File header copyright text should match. - /// - internal static string SA1636Title { - get { - return ResourceManager.GetString("SA1636Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The file header at the top of a C# code file is missing the file name.. - /// - internal static string SA1637Description { - get { - return ResourceManager.GetString("SA1637Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File header should contain file name.. - /// - internal static string SA1637MessageFormat { - get { - return ResourceManager.GetString("SA1637MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File header should contain file name. - /// - internal static string SA1637Title { - get { - return ResourceManager.GetString("SA1637Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The file attribute within copyright tag of the file header at the top of a C# code file does not contain the name of the file.. - /// - internal static string SA1638Description { - get { - return ResourceManager.GetString("SA1638Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File header file name documentation should match file name.. - /// - internal static string SA1638MessageFormat { - get { - return ResourceManager.GetString("SA1638MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File header file name documentation should match file name. - /// - internal static string SA1638Title { - get { - return ResourceManager.GetString("SA1638Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The file header at the top of a C# code file does not contain a filled-in summary tag.. - /// - internal static string SA1639Description { - get { - return ResourceManager.GetString("SA1639Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File header should have summary. - /// - internal static string SA1639MessageFormat { - get { - return ResourceManager.GetString("SA1639MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File header should have summary. - /// - internal static string SA1639Title { - get { - return ResourceManager.GetString("SA1639Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The file header at the top of a C# code file does not contain company name text.. - /// - internal static string SA1640Description { - get { - return ResourceManager.GetString("SA1640Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The copyright tag should contain a non-empty company attribute.. - /// - internal static string SA1640MessageFormat { - get { - return ResourceManager.GetString("SA1640MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File header should have valid company text. - /// - internal static string SA1640Title { - get { - return ResourceManager.GetString("SA1640Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The file header at the top of a C# code file does not contain the appropriate company name text.. - /// - internal static string SA1641Description { - get { - return ResourceManager.GetString("SA1641Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The file header company name should match the company name from the settings.. - /// - internal static string SA1641MessageFormat { - get { - return ResourceManager.GetString("SA1641MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File header company name text should match. - /// - internal static string SA1641Title { - get { - return ResourceManager.GetString("SA1641Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Add standard text. - /// - internal static string SA1642SA1643CodeFix { - get { - return ResourceManager.GetString("SA1642SA1643CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to <inheritdoc> has been used on an element that doesn't inherit from a base class or implement an interface.. - /// - internal static string SA1648Description { - get { - return ResourceManager.GetString("SA1648Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to inheritdoc should be used with inheriting class. - /// - internal static string SA1648MessageFormat { - get { - return ResourceManager.GetString("SA1648MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to inheritdoc should be used with inheriting class. - /// - internal static string SA1648Title { - get { - return ResourceManager.GetString("SA1648Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Rename file to match first type name. - /// - internal static string SA1649CodeFix { - get { - return ResourceManager.GetString("SA1649CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The file name of a C# code file does not match the first type declared in the file.. - /// - internal static string SA1649Description { - get { - return ResourceManager.GetString("SA1649Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File name should match first type name.. - /// - internal static string SA1649MessageFormat { - get { - return ResourceManager.GetString("SA1649MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File name should match first type name. - /// - internal static string SA1649Title { - get { - return ResourceManager.GetString("SA1649Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Finalize placeholder text. - /// - internal static string SA1651CodeFix { - get { - return ResourceManager.GetString("SA1651CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Gets. - /// - internal static string StartingTextGets { - get { - return ResourceManager.GetString("StartingTextGets", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Gets or sets. - /// - internal static string StartingTextGetsOrSets { - get { - return ResourceManager.GetString("StartingTextGetsOrSets", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Gets or sets a value indicating whether. - /// - internal static string StartingTextGetsOrSetsWhether { - get { - return ResourceManager.GetString("StartingTextGetsOrSetsWhether", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Gets a value indicating whether. - /// - internal static string StartingTextGetsWhether { - get { - return ResourceManager.GetString("StartingTextGetsWhether", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Sets. - /// - internal static string StartingTextSets { - get { - return ResourceManager.GetString("StartingTextSets", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Sets a value indicating whether. - /// - internal static string StartingTextSetsWhether { - get { - return ResourceManager.GetString("StartingTextSetsWhether", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Initializes static members of the . - /// - internal static string StaticConstructorStandardTextFirstPart { - get { - return ResourceManager.GetString("StaticConstructorStandardTextFirstPart", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}.. - /// - internal static string StaticConstructorStandardTextSecondPart { - get { - return ResourceManager.GetString("StaticConstructorStandardTextSecondPart", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A . - /// - internal static string TaskReturnElementFirstPart { - get { - return ResourceManager.GetString("TaskReturnElementFirstPart", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to representing the result of the asynchronous operation.. - /// - internal static string TaskReturnElementSecondPart { - get { - return ResourceManager.GetString("TaskReturnElementSecondPart", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to class. - /// - internal static string TypeTextClass { - get { - return ResourceManager.GetString("TypeTextClass", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to struct. - /// - internal static string TypeTextStruct { - get { - return ResourceManager.GetString("TypeTextStruct", resourceCulture); - } - } - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/DocumentationResources.resx b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/DocumentationResources.resx index cda8da0c1..3756dba43 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/DocumentationResources.resx +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/DocumentationResources.resx @@ -153,9 +153,108 @@ Add standard text + + A C# code element is missing a documentation header. + + + Elements should be documented + + + Elements should be documented + + + A C# partial element is missing a documentation header. + + + Partial elements should be documented + + + Partial elements should be documented + + + An item within a C# enumeration is missing an Xml documentation header. + + + Enumeration items should be documented + + + Enumeration items should be documented + + + The XML within a C# element’s document header is badly formed. + + + The documentation header is composed of invalid XML: {0} + + + Documentation should contain valid XML + + + The XML header documentation for a C# element is missing a <summary> tag. + + + Element documentation should have summary + + + Element documentation should have summary + + + The <summary> or <content> tag within the documentation header for a C# code element is missing or empty. + + + Partial element documentation should have summary + + + Partial element documentation should have summary + + + The <summary> tag within the documentation header for a C# code element is empty. + + + Element documentation should have summary text + + + Element documentation should have summary text + + + The <summary> or <content> tag within the documentation header for a C# code element is empty. + + + Partial element documentation should have summary text + + + Partial element documentation should have summary text + + + The <summary> tag within an element's XML header documentation contains the default text generated by Visual Studio during the creation of the element. + + + Element documentation should not have default summary + + + Element documentation should not have default summary + + + The XML header documentation for a C# property does not contain a <value> tag. + + + Property documentation should have value + Document value from summary + + Property documentation should have value + + + The XML header documentation for a C# property contains an empty <value> tag. + + + Property documentation should have value text + + + Property documentation should have value text + A C# method, constructor, delegate or indexer element is missing documentation for one or more of its parameters. @@ -165,12 +264,87 @@ Element parameters should be documented + + The documentation describing the parameters to a C# method, constructor, delegate or indexer element does not match the actual parameters on the element. + + + The parameter '{0}' does not exist + + + The parameter documentation for '{0}' should be at position {1} + + + Element parameter documentation should match element parameters + + + A <param> tag within a C# element's documentation header is missing a name attribute containing the name of the parameter. + + + Element parameter documentation should declare parameter name + + + Element parameter documentation should declare parameter name + + + A <param> tag within a C# element's documentation header is empty. + + + Element parameter documentation should have text + + + Element parameter documentation should have text + + + A C# element is missing documentation for its return value. + + + Element return value should be documented + Document return value + + Element return value should be documented + + + The <returns> tag within a C# element's documentation header is empty. + + + Element return value documentation should have text + + + Element return value documentation should have text + Remove <returns> XML comment + + A C# code element does not contain a return value, or returns void, but the documentation header for the element contains a <returns> tag. + + + Void return value should not be documented + + + Void return value should not be documented + + + A generic C# element is missing documentation for one or more of its generic type parameters. + + + The documentation for type parameter '{0}' is missing + + + Generic type parameters should be documented + + + A generic, partial C# element is missing documentation for one or more of its generic type parameters, and the documentation for the element contains a <summary> tag. + + + The documentation for type parameter '{0}' is missing + + + Generic type parameters should be documented partial class + The <typeparam> tags within the Xml header documentation for a generic C# element do not match the generic type parameters on the element. @@ -219,18 +393,45 @@ Property summary documentation should omit accessor with restricted access + + The Xml documentation for a C# element contains two or more identical entries, indicating that the documentation has been copied and pasted. This can sometimes indicate invalid or poorly written documentation. + + + Element documentation should not be copied and pasted + + + Element documentation should not be copied and pasted + Convert to line comment + + The C# code contains a single-line comment which begins with three forward slashes in a row. + + + Single-line comments should not use documentation style slashes + + + Single-line comments should not use documentation style slashes + The XML header documentation for a C# code element contains an empty tag. - The documentation text within the \'{0}\' tag should not be empty. + The documentation text within the '{0}' tag should not be empty Documentation text should not be empty + + A section of the XML header documentation for a C# element does not begin with a capital letter. + + + TODO: Message format + + + Documentation text should begin with a capital letter + Add period @@ -243,6 +444,33 @@ Documentation text should end with a period + + A section of the XML header documentation for a C# element does not contain any whitespace between words. + + + TODO: Message format + + + Documentation text should contain whitespace + + + A section of the Xml header documentation for a C# element does not contain enough alphabetic characters. + + + TODO: Message format + + + Documentation should meet character percentage + + + A section of the Xml header documentation for a C# element is too short. + + + TODO: Message format + + + Documentation text should meet minimum character length + Add file header @@ -330,9 +558,63 @@ File header company name text should match + + The XML documentation header for a C# constructor does not contain the appropriate summary text. + + + Constructor summary documentation should begin with standard text + Add standard text + + Constructor summary documentation should begin with standard text + + + The XML documentation header for a C# finalizer does not contain the appropriate summary text. + + + Destructor summary documentation should begin with standard text + + + Destructor summary documentation should begin with standard text + + + A section within the XML documentation header for a C# element contains blank lines. + + + TODO: Message format + + + Documentation headers should not contain blank lines + + + An included XML documentation file does not exist. + + + TODO: Message format + + + Included documentation file does not exist + + + An included XML documentation link contains an invalid path. + + + TODO: Message format + + + Included documentation XPath does not exist + + + An include tag within an XML documentation header does not contain valid file and path attribute. + + + TODO: Message format + + + Include node does not contain valid file and path + <inheritdoc> has been used on an element that doesn't inherit from a base class or implement an interface. @@ -349,14 +631,32 @@ The file name of a C# code file does not match the first type declared in the file. - File name should match first type name. + File name should match first type name File name should match first type name + + The element documentation for the element contains one or more spelling mistakes or unrecognized words. + + + TODO: Message format + + + Element documentation should be spelled correctly + Finalize placeholder text + + The element documentation contains a <placeholder> element. + + + Do not use placeholder elements + + + Do not use placeholder elements + Gets @@ -369,6 +669,12 @@ Gets a value indicating whether + + Returns + + + Returns a value indicating whether + Sets @@ -379,7 +685,7 @@ Initializes static members of the - {0}. + {0} A @@ -393,4 +699,4 @@ struct - \ No newline at end of file + diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/ElementDocumentationBase.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/ElementDocumentationBase.cs index 511473902..a597659be 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/ElementDocumentationBase.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/ElementDocumentationBase.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -31,6 +33,7 @@ internal abstract class ElementDocumentationBase : DiagnosticAnalyzer private readonly Action baseTypeDeclarationAction; private readonly Action fieldDeclarationAction; private readonly Action propertyDeclarationAction; + private readonly Action enumMemberDeclarationAction; protected ElementDocumentationBase(bool inheritDocSuppressesWarnings, string matchElementName = null) { @@ -46,6 +49,7 @@ protected ElementDocumentationBase(bool inheritDocSuppressesWarnings, string mat this.baseTypeDeclarationAction = this.HandleBaseTypeDeclaration; this.fieldDeclarationAction = this.HandleFieldDeclaration; this.propertyDeclarationAction = this.HandlePropertyDeclaration; + this.enumMemberDeclarationAction = this.HandleEnumMemberDeclaration; } /// @@ -54,15 +58,19 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(this.methodDeclarationAction, SyntaxKind.MethodDeclaration); - context.RegisterSyntaxNodeAction(this.constructorDeclarationAction, SyntaxKind.ConstructorDeclaration); - context.RegisterSyntaxNodeAction(this.delegateDeclarationAction, SyntaxKind.DelegateDeclaration); - context.RegisterSyntaxNodeAction(this.indexerDeclarationAction, SyntaxKind.IndexerDeclaration); - context.RegisterSyntaxNodeAction(this.operatorDeclarationAction, SyntaxKind.OperatorDeclaration); - context.RegisterSyntaxNodeAction(this.conversionOperatorDeclarationAction, SyntaxKind.ConversionOperatorDeclaration); - context.RegisterSyntaxNodeAction(this.baseTypeDeclarationAction, SyntaxKinds.BaseTypeDeclaration); - context.RegisterSyntaxNodeAction(this.fieldDeclarationAction, SyntaxKind.FieldDeclaration); - context.RegisterSyntaxNodeAction(this.propertyDeclarationAction, SyntaxKind.PropertyDeclaration); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(this.methodDeclarationAction, SyntaxKind.MethodDeclaration); + context.RegisterSyntaxNodeAction(this.constructorDeclarationAction, SyntaxKind.ConstructorDeclaration); + context.RegisterSyntaxNodeAction(this.delegateDeclarationAction, SyntaxKind.DelegateDeclaration); + context.RegisterSyntaxNodeAction(this.indexerDeclarationAction, SyntaxKind.IndexerDeclaration); + context.RegisterSyntaxNodeAction(this.operatorDeclarationAction, SyntaxKind.OperatorDeclaration); + context.RegisterSyntaxNodeAction(this.conversionOperatorDeclarationAction, SyntaxKind.ConversionOperatorDeclaration); + context.RegisterSyntaxNodeAction(this.baseTypeDeclarationAction, SyntaxKinds.BaseTypeDeclaration); + context.RegisterSyntaxNodeAction(this.fieldDeclarationAction, SyntaxKind.FieldDeclaration); + context.RegisterSyntaxNodeAction(this.propertyDeclarationAction, SyntaxKind.PropertyDeclaration); + context.RegisterSyntaxNodeAction(this.enumMemberDeclarationAction, SyntaxKind.EnumMemberDeclaration); + }); } /// @@ -81,6 +89,7 @@ public override void Initialize(AnalysisContext context) /// Analyzes the XML elements of a documentation comment. /// /// The current analysis context. + /// The StyleCop settings to use. /// if the current documentation settings indicate that the /// element should be documented; otherwise, . /// The complete documentation for the declared symbol, with any @@ -88,7 +97,7 @@ public override void Initialize(AnalysisContext context) /// element, this value will be , even if the XML documentation comment also included an /// <include> element. /// The location(s) where diagnostics, if any, should be reported. - protected abstract void HandleCompleteDocumentation(SyntaxNodeAnalysisContext context, bool needsComment, XElement completeDocumentation, params Location[] diagnosticLocations); + protected abstract void HandleCompleteDocumentation(SyntaxNodeAnalysisContext context, StyleCopSettings settings, bool needsComment, XElement completeDocumentation, params Location[] diagnosticLocations); private void HandleMethodDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) { @@ -200,6 +209,16 @@ private void HandlePropertyDeclaration(SyntaxNodeAnalysisContext context, StyleC this.HandleDeclaration(context, settings, needsComment, node, node.Identifier.GetLocation()); } + private void HandleEnumMemberDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) + { + var node = (EnumMemberDeclarationSyntax)context.Node; + + Accessibility declaredAccessibility = node.GetDeclaredAccessibility(); + Accessibility effectiveAccessibility = node.GetEffectiveAccessibility(context.SemanticModel, context.CancellationToken); + bool needsComment = SA1600ElementsMustBeDocumented.NeedsComment(settings.DocumentationRules, node.Kind(), node.Parent.Kind(), declaredAccessibility, effectiveAccessibility); + this.HandleDeclaration(context, settings, needsComment, node, node.Identifier.GetLocation()); + } + private void HandleDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings, bool needsComment, SyntaxNode node, params Location[] locations) { var documentation = node.GetDocumentationCommentTriviaSyntax(); @@ -216,20 +235,22 @@ private void HandleDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettin return; } - IEnumerable matchingXmlElements = string.IsNullOrEmpty(this.matchElementName) - ? documentation.Content - .Where(x => x is XmlElementSyntax || x is XmlEmptyElementSyntax) - .Where(x => !string.Equals(x.GetName()?.ToString(), XmlCommentHelper.IncludeXmlTag, StringComparison.Ordinal)) - : documentation.Content.GetXmlElements(this.matchElementName); + var hasIncludedDocumentation = + documentation.Content.GetFirstXmlElement(XmlCommentHelper.IncludeXmlTag) != null; - if (!matchingXmlElements.Any()) + if (hasIncludedDocumentation) { - var includedDocumentation = documentation.Content.GetFirstXmlElement(XmlCommentHelper.IncludeXmlTag); - if (includedDocumentation != null) + var declaration = node switch { - var declaration = context.SemanticModel.GetDeclaredSymbol(node, context.CancellationToken); - var rawDocumentation = declaration?.GetDocumentationCommentXml(expandIncludes: true, cancellationToken: context.CancellationToken); - var completeDocumentation = XElement.Parse(rawDocumentation, LoadOptions.None); + BaseFieldDeclarationSyntax baseFieldDeclaration => baseFieldDeclaration.Declaration.Variables.FirstOrDefault() ?? node, + _ => node, + }; + + var declaredSymbol = context.SemanticModel.GetDeclaredSymbol(declaration, context.CancellationToken); + if (declaredSymbol is not null) + { + var rawDocumentation = declaredSymbol?.GetDocumentationCommentXml(expandIncludes: true, cancellationToken: context.CancellationToken); + var completeDocumentation = XElement.Parse(rawDocumentation ?? "", LoadOptions.None); if (this.inheritDocSuppressesWarnings && completeDocumentation.Nodes().OfType().Any(element => element.Name == XmlCommentHelper.InheritdocXmlTag)) @@ -238,11 +259,17 @@ private void HandleDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettin return; } - this.HandleCompleteDocumentation(context, needsComment, completeDocumentation, locations); - return; // done + this.HandleCompleteDocumentation(context, settings, needsComment, completeDocumentation, locations); + return; } } + IEnumerable matchingXmlElements = string.IsNullOrEmpty(this.matchElementName) + ? documentation.Content + .Where(x => x is XmlElementSyntax || x is XmlEmptyElementSyntax) + .Where(x => !string.Equals(x.GetName()?.ToString(), XmlCommentHelper.IncludeXmlTag, StringComparison.Ordinal)) + : documentation.Content.GetXmlElements(this.matchElementName); + this.HandleXmlElement(context, settings, needsComment, matchingXmlElements, locations); } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/ElementDocumentationSummaryBase.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/ElementDocumentationSummaryBase.cs index adafc0c8e..6501a8332 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/ElementDocumentationSummaryBase.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/ElementDocumentationSummaryBase.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -47,15 +49,18 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(this.typeDeclarationAction, SyntaxKinds.BaseTypeDeclaration); - context.RegisterSyntaxNodeAction(this.methodDeclarationAction, SyntaxKind.MethodDeclaration); - context.RegisterSyntaxNodeAction(this.constructorDeclarationAction, SyntaxKind.ConstructorDeclaration); - context.RegisterSyntaxNodeAction(this.destructorDeclarationAction, SyntaxKind.DestructorDeclaration); - context.RegisterSyntaxNodeAction(this.propertyDeclarationAction, SyntaxKind.PropertyDeclaration); - context.RegisterSyntaxNodeAction(this.indexerDeclarationAction, SyntaxKind.IndexerDeclaration); - context.RegisterSyntaxNodeAction(this.fieldDeclarationAction, SyntaxKinds.BaseFieldDeclaration); - context.RegisterSyntaxNodeAction(this.delegateDeclarationAction, SyntaxKind.DelegateDeclaration); - context.RegisterSyntaxNodeAction(this.eventDeclarationAction, SyntaxKind.EventDeclaration); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(this.typeDeclarationAction, SyntaxKinds.BaseTypeDeclaration); + context.RegisterSyntaxNodeAction(this.methodDeclarationAction, SyntaxKind.MethodDeclaration); + context.RegisterSyntaxNodeAction(this.constructorDeclarationAction, SyntaxKind.ConstructorDeclaration); + context.RegisterSyntaxNodeAction(this.destructorDeclarationAction, SyntaxKind.DestructorDeclaration); + context.RegisterSyntaxNodeAction(this.propertyDeclarationAction, SyntaxKind.PropertyDeclaration); + context.RegisterSyntaxNodeAction(this.indexerDeclarationAction, SyntaxKind.IndexerDeclaration); + context.RegisterSyntaxNodeAction(this.fieldDeclarationAction, SyntaxKinds.BaseFieldDeclaration); + context.RegisterSyntaxNodeAction(this.delegateDeclarationAction, SyntaxKind.DelegateDeclaration); + context.RegisterSyntaxNodeAction(this.eventDeclarationAction, SyntaxKind.EventDeclaration); + }); } /// diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/FileHeaderAnalyzers.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/FileHeaderAnalyzers.cs index 8bca4ad88..400ddc37f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/FileHeaderAnalyzers.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/FileHeaderAnalyzers.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -182,7 +184,7 @@ private static void HandleCompilationStart(CompilationStartAnalysisContext conte var compilation = context.Compilation; // Disabling SA1633 will disable all other header related diagnostics. - if (!compilation.IsAnalyzerSuppressed(SA1633Identifier)) + if (!compilation.IsAnalyzerSuppressed(SA1633DescriptorMissing)) { context.RegisterSyntaxTreeAction((ctx, settings) => Analyzer.HandleSyntaxTree(ctx, settings, compilation)); } @@ -215,14 +217,14 @@ public static void HandleSyntaxTree(SyntaxTreeAnalysisContext context, StyleCopS return; } - if (!compilation.IsAnalyzerSuppressed(SA1634Identifier)) + if (!compilation.IsAnalyzerSuppressed(SA1634Descriptor)) { CheckCopyrightHeader(context, settings.DocumentationRules, compilation, fileHeader); } - if (!compilation.IsAnalyzerSuppressed(SA1639Identifier)) + if (!compilation.IsAnalyzerSuppressed(SA1639Descriptor)) { - CheckSummaryHeader(context, compilation, fileHeader); + CheckSummaryHeader(context, fileHeader); } } else @@ -234,7 +236,7 @@ public static void HandleSyntaxTree(SyntaxTreeAnalysisContext context, StyleCopS return; } - if (!compilation.IsAnalyzerSuppressed(SA1635Identifier)) + if (!compilation.IsAnalyzerSuppressed(SA1635Descriptor)) { if (string.IsNullOrWhiteSpace(fileHeader.CopyrightText)) { @@ -242,7 +244,7 @@ public static void HandleSyntaxTree(SyntaxTreeAnalysisContext context, StyleCopS return; } - if (compilation.IsAnalyzerSuppressed(SA1636Identifier)) + if (compilation.IsAnalyzerSuppressed(SA1636Descriptor)) { return; } @@ -265,17 +267,17 @@ private static void CheckCopyrightHeader(SyntaxTreeAnalysisContext context, Docu return; } - if (!compilation.IsAnalyzerSuppressed(SA1637Identifier)) + if (!compilation.IsAnalyzerSuppressed(SA1637Descriptor)) { CheckFile(context, compilation, fileHeader, copyrightElement); } - if (!compilation.IsAnalyzerSuppressed(SA1640Identifier)) + if (!compilation.IsAnalyzerSuppressed(SA1640Descriptor)) { CheckCompanyName(context, documentationSettings, compilation, fileHeader, copyrightElement); } - if (!compilation.IsAnalyzerSuppressed(SA1635Identifier)) + if (!compilation.IsAnalyzerSuppressed(SA1635Descriptor)) { CheckCopyrightText(context, documentationSettings, compilation, fileHeader, copyrightElement); } @@ -291,7 +293,7 @@ private static void CheckFile(SyntaxTreeAnalysisContext context, Compilation com return; } - if (compilation.IsAnalyzerSuppressed(SA1638Identifier)) + if (compilation.IsAnalyzerSuppressed(SA1638Descriptor)) { return; } @@ -314,7 +316,7 @@ private static void CheckCopyrightText(SyntaxTreeAnalysisContext context, Docume return; } - if (compilation.IsAnalyzerSuppressed(SA1636Identifier)) + if (compilation.IsAnalyzerSuppressed(SA1636Descriptor)) { return; } @@ -345,7 +347,7 @@ private static void CheckCompanyName(SyntaxTreeAnalysisContext context, Document return; } - if (compilation.IsAnalyzerSuppressed(SA1641Identifier)) + if (compilation.IsAnalyzerSuppressed(SA1641Descriptor)) { return; } @@ -363,7 +365,7 @@ private static void CheckCompanyName(SyntaxTreeAnalysisContext context, Document } } - private static void CheckSummaryHeader(SyntaxTreeAnalysisContext context, Compilation compilation, XmlFileHeader fileHeader) + private static void CheckSummaryHeader(SyntaxTreeAnalysisContext context, XmlFileHeader fileHeader) { var summaryElement = fileHeader.GetElement("summary"); if (summaryElement == null) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/GenericTypeParameterDocumentationAnalyzer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/GenericTypeParameterDocumentationAnalyzer.cs index 3d0a42c0c..f6e56cc53 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/GenericTypeParameterDocumentationAnalyzer.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/GenericTypeParameterDocumentationAnalyzer.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/PartialElementDocumentationSummaryBase.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/PartialElementDocumentationSummaryBase.cs index 554cfbbe5..897e6b0ea 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/PartialElementDocumentationSummaryBase.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/PartialElementDocumentationSummaryBase.cs @@ -1,10 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { using System; - using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Linq; @@ -21,8 +22,6 @@ namespace StyleCop.Analyzers.DocumentationRules /// internal abstract class PartialElementDocumentationSummaryBase : DiagnosticAnalyzer { - private static readonly XElement EmptyElement = new XElement("empty"); - private readonly Action typeDeclarationAction; private readonly Action methodDeclarationAction; @@ -38,8 +37,11 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(this.typeDeclarationAction, SyntaxKinds.TypeDeclaration); - context.RegisterSyntaxNodeAction(this.methodDeclarationAction, SyntaxKind.MethodDeclaration); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(this.typeDeclarationAction, SyntaxKinds.TypeDeclaration); + context.RegisterSyntaxNodeAction(this.methodDeclarationAction, SyntaxKind.MethodDeclaration); + }); } /// @@ -168,9 +170,7 @@ private string ExpandDocumentation(Compilation compilation, DocumentationComment { var sb = new StringBuilder(); - sb.AppendLine(""); - - var documentationChildren = new List(); + sb.Append("\n"); foreach (XmlNodeSyntax xmlNode in documentCommentTrivia.Content) { @@ -180,11 +180,11 @@ private string ExpandDocumentation(Compilation compilation, DocumentationComment } else { - sb.AppendLine(xmlNode.ToString()); + sb.Append(xmlNode.ToString()).Append('\n'); } } - sb.AppendLine(""); + sb.Append("\n"); return sb.ToString(); } @@ -212,7 +212,7 @@ private void ExpandIncludeTag(Compilation compilation, StringBuilder sb, XmlNode foreach (var x in expandedInclude) { - sb.AppendLine(x.ToString()); + sb.Append(x.ToString()).Append('\n'); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/PropertyDocumentationBase.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/PropertyDocumentationBase.cs index d3fbe65f2..8bc2e40a9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/PropertyDocumentationBase.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/PropertyDocumentationBase.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -42,13 +44,17 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(this.propertyDeclarationAction, SyntaxKind.PropertyDeclaration); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(this.propertyDeclarationAction, SyntaxKind.PropertyDeclaration); + }); } /// /// Analyzes the top-level <summary> element of a documentation comment. /// /// The current analysis context. + /// The StyleCop settings to use. /// if the current documentation settings indicate that the /// element should be documented; otherwise, . /// The or of the node @@ -58,7 +64,7 @@ public override void Initialize(AnalysisContext context) /// element, this value will be , even if the XML documentation comment also included an /// <include> element. /// The location where diagnostics, if any, should be reported. - protected abstract void HandleXmlElement(SyntaxNodeAnalysisContext context, bool needsComment, XmlNodeSyntax syntax, XElement completeDocumentation, Location diagnosticLocation); + protected abstract void HandleXmlElement(SyntaxNodeAnalysisContext context, StyleCopSettings settings, bool needsComment, XmlNodeSyntax syntax, XElement completeDocumentation, Location diagnosticLocation); private void HandlePropertyDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) { @@ -71,10 +77,10 @@ private void HandlePropertyDeclaration(SyntaxNodeAnalysisContext context, StyleC Accessibility declaredAccessibility = node.GetDeclaredAccessibility(context.SemanticModel, context.CancellationToken); Accessibility effectiveAccessibility = node.GetEffectiveAccessibility(context.SemanticModel, context.CancellationToken); bool needsComment = SA1600ElementsMustBeDocumented.NeedsComment(settings.DocumentationRules, node.Kind(), node.Parent.Kind(), declaredAccessibility, effectiveAccessibility); - this.HandleDeclaration(context, needsComment, node, node.Identifier.GetLocation()); + this.HandleDeclaration(context, settings, needsComment, node, node.Identifier.GetLocation()); } - private void HandleDeclaration(SyntaxNodeAnalysisContext context, bool needsComment, SyntaxNode node, Location location) + private void HandleDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings, bool needsComment, SyntaxNode node, Location location) { var documentation = node.GetDocumentationCommentTriviaSyntax(); if (documentation == null) @@ -108,7 +114,7 @@ private void HandleDeclaration(SyntaxNodeAnalysisContext context, bool needsComm } } - this.HandleXmlElement(context, needsComment, relevantXmlElement, completeDocumentation, location); + this.HandleXmlElement(context, settings, needsComment, relevantXmlElement, completeDocumentation, location); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/PropertySummaryDocumentationAnalyzer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/PropertySummaryDocumentationAnalyzer.cs index 911696012..0580c4aad 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/PropertySummaryDocumentationAnalyzer.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/PropertySummaryDocumentationAnalyzer.cs @@ -1,17 +1,19 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { using System; using System.Collections.Immutable; - using System.Globalization; using System.Xml.Linq; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Settings.ObjectModel; /// /// Analyzes the correct usage of property summary documentation. @@ -57,12 +59,11 @@ internal class PropertySummaryDocumentationAnalyzer : PropertyDocumentationBase protected override string XmlTagToHandle => XmlCommentHelper.SummaryXmlTag; /// - protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, bool needsComment, XmlNodeSyntax syntax, XElement completeDocumentation, Location diagnosticLocation) + protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, StyleCopSettings settings, bool needsComment, XmlNodeSyntax syntax, XElement completeDocumentation, Location diagnosticLocation) { var propertyDeclaration = (PropertyDeclarationSyntax)context.Node; - var propertyType = context.SemanticModel.GetTypeInfo(propertyDeclaration.Type); - var settings = context.Options.GetStyleCopSettings(context.CancellationToken); - var culture = new CultureInfo(settings.DocumentationRules.DocumentationCulture); + var propertyType = context.SemanticModel.GetTypeInfo(propertyDeclaration.Type.StripRefFromType()); + var culture = settings.DocumentationRules.DocumentationCultureInfo; var resourceManager = DocumentationResources.ResourceManager; if (propertyType.Type.SpecialType == SpecialType.System_Boolean) @@ -74,7 +75,8 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, bool propertyDeclaration, resourceManager.GetString(nameof(DocumentationResources.StartingTextGetsWhether), culture), resourceManager.GetString(nameof(DocumentationResources.StartingTextSetsWhether), culture), - resourceManager.GetString(nameof(DocumentationResources.StartingTextGetsOrSetsWhether), culture)); + resourceManager.GetString(nameof(DocumentationResources.StartingTextGetsOrSetsWhether), culture), + resourceManager.GetString(nameof(DocumentationResources.StartingTextReturnsWhether), culture)); } else { @@ -85,11 +87,12 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, bool propertyDeclaration, resourceManager.GetString(nameof(DocumentationResources.StartingTextGets), culture), resourceManager.GetString(nameof(DocumentationResources.StartingTextSets), culture), - resourceManager.GetString(nameof(DocumentationResources.StartingTextGetsOrSets), culture)); + resourceManager.GetString(nameof(DocumentationResources.StartingTextGetsOrSets), culture), + resourceManager.GetString(nameof(DocumentationResources.StartingTextReturns), culture)); } } - private static void AnalyzeSummaryElement(SyntaxNodeAnalysisContext context, XmlNodeSyntax syntax, Location diagnosticLocation, PropertyDeclarationSyntax propertyDeclaration, string startingTextGets, string startingTextSets, string startingTextGetsOrSets) + private static void AnalyzeSummaryElement(SyntaxNodeAnalysisContext context, XmlNodeSyntax syntax, Location diagnosticLocation, PropertyDeclarationSyntax propertyDeclaration, string startingTextGets, string startingTextSets, string startingTextGetsOrSets, string startingTextReturns) { var diagnosticProperties = ImmutableDictionary.CreateBuilder(); ArrowExpressionClauseSyntax expressionBody = propertyDeclaration.ExpressionBody; @@ -126,7 +129,8 @@ private static void AnalyzeSummaryElement(SyntaxNodeAnalysisContext context, Xml diagnosticProperties.Add(NoCodeFixKey, string.Empty); } - var text = !(summaryElement.Content.FirstOrDefault() is XmlTextSyntax textElement) ? string.Empty : XmlCommentHelper.GetText(textElement, true).TrimStart(); + var textElement = XmlCommentHelper.TryGetFirstTextElementWithContent(summaryElement); + string text = textElement is null ? string.Empty : XmlCommentHelper.GetText(textElement, normalizeWhitespace: true).TrimStart(); bool prefixIsGetsOrSets = text.StartsWith(startingTextGetsOrSets, StringComparison.OrdinalIgnoreCase); bool prefixIsGets = !prefixIsGetsOrSets && text.StartsWith(startingTextGets, StringComparison.OrdinalIgnoreCase); @@ -225,7 +229,7 @@ private static void AnalyzeSummaryElement(SyntaxNodeAnalysisContext context, Xml // Both getter and setter are visible. if (!prefixIsGetsOrSets) { - ReportSA1623(context, diagnosticLocation, diagnosticProperties, text, expectedStartingText: startingTextGetsOrSets, unexpectedStartingText1: startingTextGets, unexpectedStartingText2: startingTextSets); + ReportSA1623(context, diagnosticLocation, diagnosticProperties, text, expectedStartingText: startingTextGetsOrSets, unexpectedStartingText1: startingTextGets, unexpectedStartingText2: startingTextSets, unexpectedStartingText3: startingTextReturns); } } else if (setter != null) @@ -239,7 +243,7 @@ private static void AnalyzeSummaryElement(SyntaxNodeAnalysisContext context, Xml } else { - ReportSA1623(context, diagnosticLocation, diagnosticProperties, text, expectedStartingText: startingTextGets, unexpectedStartingText1: startingTextSets); + ReportSA1623(context, diagnosticLocation, diagnosticProperties, text, expectedStartingText: startingTextGets, unexpectedStartingText1: startingTextSets, unexpectedStartingText2: startingTextReturns); } } } @@ -248,7 +252,7 @@ private static void AnalyzeSummaryElement(SyntaxNodeAnalysisContext context, Xml // Getter exists and is visible. Setter does not exist. if (!prefixIsGets) { - ReportSA1623(context, diagnosticLocation, diagnosticProperties, text, expectedStartingText: startingTextGets, unexpectedStartingText1: startingTextSets, unexpectedStartingText2: startingTextGetsOrSets); + ReportSA1623(context, diagnosticLocation, diagnosticProperties, text, expectedStartingText: startingTextGets, unexpectedStartingText1: startingTextSets, unexpectedStartingText2: startingTextGetsOrSets, unexpectedStartingText3: startingTextReturns); } } } @@ -265,7 +269,7 @@ private static void AnalyzeSummaryElement(SyntaxNodeAnalysisContext context, Xml } else { - ReportSA1623(context, diagnosticLocation, diagnosticProperties, text, expectedStartingText: startingTextSets, unexpectedStartingText1: startingTextGets); + ReportSA1623(context, diagnosticLocation, diagnosticProperties, text, expectedStartingText: startingTextSets, unexpectedStartingText1: startingTextGets, unexpectedStartingText2: startingTextReturns); } } } @@ -274,13 +278,13 @@ private static void AnalyzeSummaryElement(SyntaxNodeAnalysisContext context, Xml // Setter exists and is visible. Getter does not exist. if (!prefixIsSets) { - ReportSA1623(context, diagnosticLocation, diagnosticProperties, text, expectedStartingText: startingTextSets, unexpectedStartingText1: startingTextGetsOrSets, unexpectedStartingText2: startingTextGets); + ReportSA1623(context, diagnosticLocation, diagnosticProperties, text, expectedStartingText: startingTextSets, unexpectedStartingText1: startingTextGetsOrSets, unexpectedStartingText2: startingTextGets, unexpectedStartingText3: startingTextReturns); } } } } - private static void ReportSA1623(SyntaxNodeAnalysisContext context, Location diagnosticLocation, ImmutableDictionary.Builder diagnosticProperties, string text, string expectedStartingText, string unexpectedStartingText1, string unexpectedStartingText2 = null) + private static void ReportSA1623(SyntaxNodeAnalysisContext context, Location diagnosticLocation, ImmutableDictionary.Builder diagnosticProperties, string text, string expectedStartingText, string unexpectedStartingText1, string unexpectedStartingText2 = null, string unexpectedStartingText3 = null) { diagnosticProperties.Add(ExpectedTextKey, expectedStartingText); @@ -292,6 +296,10 @@ private static void ReportSA1623(SyntaxNodeAnalysisContext context, Location dia { diagnosticProperties.Add(TextToRemoveKey, text.Substring(0, unexpectedStartingText2.Length)); } + else if ((unexpectedStartingText3 != null) && text.StartsWith(unexpectedStartingText3, StringComparison.OrdinalIgnoreCase)) + { + diagnosticProperties.Add(TextToRemoveKey, text.Substring(0, unexpectedStartingText3.Length)); + } context.ReportDiagnostic(Diagnostic.Create(SA1623Descriptor, diagnosticLocation, diagnosticProperties.ToImmutable(), expectedStartingText)); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1600ElementsMustBeDocumented.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1600ElementsMustBeDocumented.cs index 9151cd944..f64633941 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1600ElementsMustBeDocumented.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1600ElementsMustBeDocumented.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -11,6 +13,7 @@ namespace StyleCop.Analyzers.DocumentationRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.Settings.ObjectModel; /// @@ -22,7 +25,7 @@ namespace StyleCop.Analyzers.DocumentationRules /// /// A violation of this rule occurs if an element is completely missing a documentation header, or if the /// header is empty. In C# the following types of elements can have documentation headers: classes, constructors, - /// delegates, enums, events, finalizers, indexers, interfaces, methods, properties, and structs. + /// delegates, enums, events, finalizers, indexers, interfaces, methods, properties, records, and structs. /// [DiagnosticAnalyzer(LanguageNames.CSharp)] internal class SA1600ElementsMustBeDocumented : DiagnosticAnalyzer @@ -31,17 +34,14 @@ internal class SA1600ElementsMustBeDocumented : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1600"; - private const string Title = "Elements should be documented"; - private const string MessageFormat = "Elements should be documented"; - private const string Description = "A C# code element is missing a documentation header."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1600.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1600Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1600MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1600Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); - private static readonly ImmutableArray BaseTypeDeclarationKinds = - ImmutableArray.Create(SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.InterfaceDeclaration, SyntaxKind.EnumDeclaration); - private static readonly Action BaseTypeDeclarationAction = Analyzer.HandleBaseTypeDeclaration; private static readonly Action MethodDeclarationAction = Analyzer.HandleMethodDeclaration; private static readonly Action ConstructorDeclarationAction = Analyzer.HandleConstructorDeclaration; @@ -110,16 +110,19 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, BaseTypeDeclarationKinds); - context.RegisterSyntaxNodeAction(MethodDeclarationAction, SyntaxKind.MethodDeclaration); - context.RegisterSyntaxNodeAction(ConstructorDeclarationAction, SyntaxKind.ConstructorDeclaration); - context.RegisterSyntaxNodeAction(DestructorDeclarationAction, SyntaxKind.DestructorDeclaration); - context.RegisterSyntaxNodeAction(PropertyDeclarationAction, SyntaxKind.PropertyDeclaration); - context.RegisterSyntaxNodeAction(IndexerDeclarationAction, SyntaxKind.IndexerDeclaration); - context.RegisterSyntaxNodeAction(FieldDeclarationAction, SyntaxKind.FieldDeclaration); - context.RegisterSyntaxNodeAction(DelegateDeclarationAction, SyntaxKind.DelegateDeclaration); - context.RegisterSyntaxNodeAction(EventDeclarationAction, SyntaxKind.EventDeclaration); - context.RegisterSyntaxNodeAction(EventFieldDeclarationAction, SyntaxKind.EventFieldDeclaration); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKinds.BaseTypeDeclaration); + context.RegisterSyntaxNodeAction(MethodDeclarationAction, SyntaxKind.MethodDeclaration); + context.RegisterSyntaxNodeAction(ConstructorDeclarationAction, SyntaxKind.ConstructorDeclaration); + context.RegisterSyntaxNodeAction(DestructorDeclarationAction, SyntaxKind.DestructorDeclaration); + context.RegisterSyntaxNodeAction(PropertyDeclarationAction, SyntaxKind.PropertyDeclaration); + context.RegisterSyntaxNodeAction(IndexerDeclarationAction, SyntaxKind.IndexerDeclaration); + context.RegisterSyntaxNodeAction(FieldDeclarationAction, SyntaxKind.FieldDeclaration); + context.RegisterSyntaxNodeAction(DelegateDeclarationAction, SyntaxKind.DelegateDeclaration); + context.RegisterSyntaxNodeAction(EventDeclarationAction, SyntaxKind.EventDeclaration); + context.RegisterSyntaxNodeAction(EventFieldDeclarationAction, SyntaxKind.EventFieldDeclaration); + }); } private static class Analyzer diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1601PartialElementsMustBeDocumented.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1601PartialElementsMustBeDocumented.cs index 0051974e5..48cc6100f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1601PartialElementsMustBeDocumented.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1601PartialElementsMustBeDocumented.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -71,10 +73,10 @@ internal class SA1601PartialElementsMustBeDocumented : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1601"; - private const string Title = "Partial elements should be documented"; - private const string MessageFormat = "Partial elements should be documented"; - private const string Description = "A C# partial element is missing a documentation header."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1601.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1601Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1601MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1601Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -95,8 +97,11 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, BaseTypeDeclarationKinds); - context.RegisterSyntaxNodeAction(MethodDeclarationAction, SyntaxKind.MethodDeclaration); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, BaseTypeDeclarationKinds); + context.RegisterSyntaxNodeAction(MethodDeclarationAction, SyntaxKind.MethodDeclaration); + }); } private static class Analyzer diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1602EnumerationItemsMustBeDocumented.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1602EnumerationItemsMustBeDocumented.cs index fc45fc311..3e819a50a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1602EnumerationItemsMustBeDocumented.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1602EnumerationItemsMustBeDocumented.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -41,10 +43,10 @@ internal class SA1602EnumerationItemsMustBeDocumented : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1602"; - private const string Title = "Enumeration items should be documented"; - private const string MessageFormat = "Enumeration items should be documented"; - private const string Description = "An item within a C# enumeration is missing an Xml documentation header."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1602.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1602Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1602MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1602Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -61,7 +63,10 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(EnumMemberDeclarationAction, SyntaxKind.EnumMemberDeclaration); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(EnumMemberDeclarationAction, SyntaxKind.EnumMemberDeclaration); + }); } private static class Analyzer diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1603DocumentationMustContainValidXml.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1603DocumentationMustContainValidXml.cs index a51c48333..042eb0d74 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1603DocumentationMustContainValidXml.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1603DocumentationMustContainValidXml.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -26,13 +28,15 @@ internal class SA1603DocumentationMustContainValidXml : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1603"; - private const string Title = "Documentation should contain valid XML"; - private const string MessageFormat = "The documentation header is composed of invalid XML: {0}"; - private const string Description = "The XML within a C# element’s document header is badly formed."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1603.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1603Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1603MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1603Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = +#pragma warning disable RS2000 // Add analyzer diagnostic IDs to analyzer release. new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.NotConfigurable); +#pragma warning restore RS2000 // Add analyzer diagnostic IDs to analyzer release. /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -40,7 +44,11 @@ internal class SA1603DocumentationMustContainValidXml : DiagnosticAnalyzer /// [ExcludeFromCodeCoverage] +#pragma warning disable RS1025 // Configure generated code analysis +#pragma warning disable RS1026 // Enable concurrent execution public override void Initialize(AnalysisContext context) +#pragma warning restore RS1026 // Enable concurrent execution +#pragma warning restore RS1025 // Configure generated code analysis { // This diagnostic is not implemented (by design) in StyleCopAnalyzers. } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1604ElementDocumentationMustHaveSummary.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1604ElementDocumentationMustHaveSummary.cs index f86bf90a0..0ceb22f08 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1604ElementDocumentationMustHaveSummary.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1604ElementDocumentationMustHaveSummary.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -10,7 +12,6 @@ namespace StyleCop.Analyzers.DocumentationRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; - using StyleCop.Analyzers.Settings.ObjectModel; /// /// The XML header documentation for a C# element is missing a <summary> tag. @@ -29,10 +30,10 @@ internal class SA1604ElementDocumentationMustHaveSummary : ElementDocumentationS /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1604"; - private const string Title = "Element documentation should have summary"; - private const string MessageFormat = "Element documentation should have summary"; - private const string Description = "The XML header documentation for a C# element is missing a tag."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1604.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1604Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1604MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1604Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1605PartialElementDocumentationMustHaveSummary.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1605PartialElementDocumentationMustHaveSummary.cs index ff8acaafb..5722feabb 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1605PartialElementDocumentationMustHaveSummary.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1605PartialElementDocumentationMustHaveSummary.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -72,10 +74,10 @@ internal class SA1605PartialElementDocumentationMustHaveSummary : PartialElement /// analyzer. /// public const string DiagnosticId = "SA1605"; - private const string Title = "Partial element documentation should have summary"; - private const string MessageFormat = "Partial element documentation should have summary"; - private const string Description = "The or tag within the documentation header for a C# code element is missing or empty."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1605.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1605Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1605MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1605Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1606ElementDocumentationMustHaveSummaryText.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1606ElementDocumentationMustHaveSummaryText.cs index f314fb531..41609ceb7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1606ElementDocumentationMustHaveSummaryText.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1606ElementDocumentationMustHaveSummaryText.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -29,10 +31,10 @@ internal class SA1606ElementDocumentationMustHaveSummaryText : ElementDocumentat /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1606"; - private const string Title = "Element documentation should have summary text"; - private const string MessageFormat = "Element documentation should have summary text"; - private const string Description = "The tag within the documentation header for a C# code element is empty."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1606.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1606Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1606MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1606Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1607PartialElementDocumentationMustHaveSummaryText.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1607PartialElementDocumentationMustHaveSummaryText.cs index d47271083..aca48da32 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1607PartialElementDocumentationMustHaveSummaryText.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1607PartialElementDocumentationMustHaveSummaryText.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -73,10 +75,10 @@ internal class SA1607PartialElementDocumentationMustHaveSummaryText : PartialEle /// analyzer. /// public const string DiagnosticId = "SA1607"; - private const string Title = "Partial element documentation should have summary text"; - private const string MessageFormat = "Partial element documentation should have summary text"; - private const string Description = "The or tag within the documentation header for a C# code element is empty."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1607.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1607Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1607MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1607Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1608ElementDocumentationMustNotHaveDefaultSummary.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1608ElementDocumentationMustNotHaveDefaultSummary.cs index d74f20ab5..2a52d84b6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1608ElementDocumentationMustNotHaveDefaultSummary.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1608ElementDocumentationMustNotHaveDefaultSummary.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -37,13 +39,14 @@ internal class SA1608ElementDocumentationMustNotHaveDefaultSummary : ElementDocu /// analyzer. /// public const string DiagnosticId = "SA1608"; - private const string Title = "Element documentation should not have default summary"; - private const string MessageFormat = "Element documentation should not have default summary"; - private const string Description = "The tag within an element's XML header documentation contains the default text generated by Visual Studio during the creation of the element."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1608.md"; private const string DefaultText = "Summary description for"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1608Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1608MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1608Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -76,7 +79,7 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, Styl } /// - protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext context, bool needsComment, XElement completeDocumentation, params Location[] diagnosticLocations) + protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext context, StyleCopSettings settings, bool needsComment, XElement completeDocumentation, params Location[] diagnosticLocations) { // We are working with an element var includedSummaryElement = completeDocumentation.Nodes().OfType().FirstOrDefault(element => element.Name == XmlCommentHelper.SummaryXmlTag); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1609PropertyDocumentationMustHaveValue.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1609PropertyDocumentationMustHaveValue.cs index d85dde471..ca06e1dae 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1609PropertyDocumentationMustHaveValue.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1609PropertyDocumentationMustHaveValue.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -10,6 +12,7 @@ namespace StyleCop.Analyzers.DocumentationRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Settings.ObjectModel; /// /// The XML header documentation for a C# property does not contain a <value> tag. @@ -30,10 +33,10 @@ internal class SA1609PropertyDocumentationMustHaveValue : PropertyDocumentationB /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1609"; - private const string Title = "Property documentation should have value"; - private const string MessageFormat = "Property documentation should have value"; - private const string Description = "The XML header documentation for a C# property does not contain a tag."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1609.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1609Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1609MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1609Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink); @@ -46,7 +49,7 @@ internal class SA1609PropertyDocumentationMustHaveValue : PropertyDocumentationB protected override string XmlTagToHandle => XmlCommentHelper.ValueXmlTag; /// - protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, bool needsComment, XmlNodeSyntax syntax, XElement completeDocumentation, Location diagnosticLocation) + protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, StyleCopSettings settings, bool needsComment, XmlNodeSyntax syntax, XElement completeDocumentation, Location diagnosticLocation) { if (!needsComment) { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1610PropertyDocumentationMustHaveValueText.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1610PropertyDocumentationMustHaveValueText.cs index b1e333433..d0b733ff1 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1610PropertyDocumentationMustHaveValueText.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1610PropertyDocumentationMustHaveValueText.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -10,6 +12,7 @@ namespace StyleCop.Analyzers.DocumentationRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Settings.ObjectModel; /// /// The XML header documentation for a C# property contains an empty <value> tag. @@ -30,10 +33,10 @@ internal class SA1610PropertyDocumentationMustHaveValueText : PropertyDocumentat /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1610"; - private const string Title = "Property documentation should have value text"; - private const string MessageFormat = "Property documentation should have value text"; - private const string Description = "The XML header documentation for a C# property contains an empty tag."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1610.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1610Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1610MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1610Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -46,7 +49,7 @@ internal class SA1610PropertyDocumentationMustHaveValueText : PropertyDocumentat protected override string XmlTagToHandle => XmlCommentHelper.ValueXmlTag; /// - protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, bool needsComment, XmlNodeSyntax syntax, XElement completeDocumentation, Location diagnosticLocation) + protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, StyleCopSettings settings, bool needsComment, XmlNodeSyntax syntax, XElement completeDocumentation, Location diagnosticLocation) { var properties = ImmutableDictionary.Create(); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1611ElementParametersMustBeDocumented.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1611ElementParametersMustBeDocumented.cs index d3c542f99..13ec45241 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1611ElementParametersMustBeDocumented.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1611ElementParametersMustBeDocumented.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -31,10 +33,10 @@ internal class SA1611ElementParametersMustBeDocumented : ElementDocumentationBas /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1611"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1611.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1611Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1611MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1611Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1611.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -73,7 +75,7 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, Styl } /// - protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext context, bool needsComment, XElement completeDocumentation, params Location[] diagnosticLocations) + protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext context, StyleCopSettings settings, bool needsComment, XElement completeDocumentation, params Location[] diagnosticLocations) { if (!needsComment) { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1612ElementParameterDocumentationMustMatchElementParameters.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1612ElementParameterDocumentationMustMatchElementParameters.cs index 6acff0b33..6990202bb 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1612ElementParameterDocumentationMustMatchElementParameters.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1612ElementParameterDocumentationMustMatchElementParameters.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -32,12 +34,12 @@ internal class SA1612ElementParameterDocumentationMustMatchElementParameters : E /// analyzer. /// public const string DiagnosticId = "SA1612"; - private const string Title = "Element parameter documentation should match element parameters"; - private const string Description = "The documentation describing the parameters to a C# method, constructor, delegate or indexer element does not match the actual parameters on the element."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1612.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1612Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1612Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); - private const string MissingParamForDocumentationMessageFormat = "The parameter '{0}' does not exist."; - private const string ParamWrongOrderMessageFormat = "The parameter documentation for '{0}' should be at position {1}."; + private static readonly LocalizableString MissingParamForDocumentationMessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1612MissingParamForDocumentationMessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString ParamWrongOrderMessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1612ParamWrongOrderMessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor MissingParameterDescriptor = new DiagnosticDescriptor(DiagnosticId, Title, MissingParamForDocumentationMessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -109,12 +111,14 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, Styl if (parentParameters.Length <= index || parentParameters[index] != parentParameter) { +#pragma warning disable RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor (https://github.com/dotnet/roslyn-analyzers/issues/4103) context.ReportDiagnostic( Diagnostic.Create( OrderDescriptor, location, nameAttributeText, parentParameters.IndexOf(parentParameter) + 1)); +#pragma warning restore RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor } } @@ -123,7 +127,7 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, Styl } /// - protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext context, bool needsComment, XElement completeDocumentation, params Location[] diagnosticLocations) + protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext context, StyleCopSettings settings, bool needsComment, XElement completeDocumentation, params Location[] diagnosticLocations) { var node = context.Node; var identifier = GetIdentifier(node); @@ -180,12 +184,14 @@ protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext co if (parentParameters.Length <= index || parentParameters[index] != parentParameter) { +#pragma warning disable RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor (https://github.com/dotnet/roslyn-analyzers/issues/4103) context.ReportDiagnostic( Diagnostic.Create( OrderDescriptor, identifierLocation, nameAttributeText, parentParameters.IndexOf(parentParameter) + 1)); +#pragma warning restore RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1613ElementParameterDocumentationMustDeclareParameterName.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1613ElementParameterDocumentationMustDeclareParameterName.cs index 12910e9c1..e3828e01b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1613ElementParameterDocumentationMustDeclareParameterName.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1613ElementParameterDocumentationMustDeclareParameterName.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -32,10 +34,10 @@ internal class SA1613ElementParameterDocumentationMustDeclareParameterName : Ele /// analyzer. /// public const string DiagnosticId = "SA1613"; - private const string Title = "Element parameter documentation should declare parameter name"; - private const string MessageFormat = "Element parameter documentation should declare parameter name"; - private const string Description = "A tag within a C# element's documentation header is missing a name attribute containing the name of the parameter."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1613.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1613Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1613MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1613Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -70,7 +72,7 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, Styl } /// - protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext context, bool needsComment, XElement completeDocumentation, params Location[] diagnosticLocations) + protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext context, StyleCopSettings settings, bool needsComment, XElement completeDocumentation, params Location[] diagnosticLocations) { var xmlParamTags = completeDocumentation.Nodes() .OfType() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1614ElementParameterDocumentationMustHaveText.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1614ElementParameterDocumentationMustHaveText.cs index 8786914e7..29196f26d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1614ElementParameterDocumentationMustHaveText.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1614ElementParameterDocumentationMustHaveText.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -32,10 +34,10 @@ internal class SA1614ElementParameterDocumentationMustHaveText : ElementDocument /// analyzer. /// public const string DiagnosticId = "SA1614"; - private const string Title = "Element parameter documentation should have text"; - private const string MessageFormat = "Element parameter documentation should have text"; - private const string Description = "A tag within a C# element's documentation header is empty."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1614.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1614Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1614MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1614Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -64,7 +66,7 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, Styl } /// - protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext context, bool needsComment, XElement completeDocumentation, params Location[] diagnosticLocations) + protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext context, StyleCopSettings settings, bool needsComment, XElement completeDocumentation, params Location[] diagnosticLocations) { var xmlParamTags = completeDocumentation.Nodes() .OfType() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1615ElementReturnValueMustBeDocumented.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1615ElementReturnValueMustBeDocumented.cs index df3fc2be0..c826d7635 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1615ElementReturnValueMustBeDocumented.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1615ElementReturnValueMustBeDocumented.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -31,10 +33,10 @@ internal class SA1615ElementReturnValueMustBeDocumented : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1615"; - private const string Title = "Element return value should be documented"; - private const string MessageFormat = "Element return value should be documented"; - private const string Description = "A C# element is missing documentation for its return value."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1615.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1615Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1615MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1615Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -52,8 +54,11 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(MethodDeclarationAction, SyntaxKind.MethodDeclaration); - context.RegisterSyntaxNodeAction(DelegateDeclarationAction, SyntaxKind.DelegateDeclaration); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(MethodDeclarationAction, SyntaxKind.MethodDeclaration); + context.RegisterSyntaxNodeAction(DelegateDeclarationAction, SyntaxKind.DelegateDeclaration); + }); } private static void HandleMethodDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1616ElementReturnValueDocumentationMustHaveText.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1616ElementReturnValueDocumentationMustHaveText.cs index e5a155075..062d1e315 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1616ElementReturnValueDocumentationMustHaveText.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1616ElementReturnValueDocumentationMustHaveText.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -31,10 +33,10 @@ internal class SA1616ElementReturnValueDocumentationMustHaveText : ElementDocume /// analyzer. /// public const string DiagnosticId = "SA1616"; - private const string Title = "Element return value documentation should have text"; - private const string MessageFormat = "Element return value documentation should have text"; - private const string Description = "The tag within a C# element's documentation header is empty."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1616.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1616Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1616MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1616Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -62,7 +64,7 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, Styl } /// - protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext context, bool needsComment, XElement completeDocumentation, params Location[] diagnosticLocations) + protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext context, StyleCopSettings settings, bool needsComment, XElement completeDocumentation, params Location[] diagnosticLocations) { var returnsNodes = completeDocumentation.Nodes() .OfType() diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1617VoidReturnValueMustNotBeDocumented.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1617VoidReturnValueMustNotBeDocumented.cs index fb0abb6b6..235a1de64 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1617VoidReturnValueMustNotBeDocumented.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1617VoidReturnValueMustNotBeDocumented.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -37,10 +39,10 @@ internal class SA1617VoidReturnValueMustNotBeDocumented : DiagnosticAnalyzer /// internal const string NoCodeFixKey = "NoCodeFix"; - private const string Title = "Void return value should not be documented"; - private const string MessageFormat = "Void return value should not be documented"; - private const string Description = "A C# code element does not contain a return value, or returns void, but the documentation header for the element contains a tag."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1617.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1617Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1617MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1617Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1618GenericTypeParametersMustBeDocumented.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1618GenericTypeParametersMustBeDocumented.cs index 0aa25feb0..5ca9f22d4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1618GenericTypeParametersMustBeDocumented.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1618GenericTypeParametersMustBeDocumented.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -31,10 +33,10 @@ internal class SA1618GenericTypeParametersMustBeDocumented : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1618"; - private const string Title = "Generic type parameters should be documented"; - private const string MessageFormat = "The documentation for type parameter '{0}' is missing"; - private const string Description = "A generic C# element is missing documentation for one or more of its generic type parameters."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1618.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1618Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1618MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1618Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -53,9 +55,12 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKinds.TypeDeclaration); - context.RegisterSyntaxNodeAction(MethodDeclarationAction, SyntaxKind.MethodDeclaration); - context.RegisterSyntaxNodeAction(DelegateDeclarationAction, SyntaxKind.DelegateDeclaration); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKinds.TypeDeclaration); + context.RegisterSyntaxNodeAction(MethodDeclarationAction, SyntaxKind.MethodDeclaration); + context.RegisterSyntaxNodeAction(DelegateDeclarationAction, SyntaxKind.DelegateDeclaration); + }); } private static void HandleTypeDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1619GenericTypeParametersMustBeDocumentedPartialClass.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1619GenericTypeParametersMustBeDocumentedPartialClass.cs index fcf85e655..5757f5f3d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1619GenericTypeParametersMustBeDocumentedPartialClass.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1619GenericTypeParametersMustBeDocumentedPartialClass.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -81,10 +83,10 @@ internal class SA1619GenericTypeParametersMustBeDocumentedPartialClass : Diagnos /// analyzer. /// public const string DiagnosticId = "SA1619"; - private const string Title = "Generic type parameters should be documented partial class"; - private const string MessageFormat = "The documentation for type parameter '{0}' is missing"; - private const string Description = "A generic, partial C# element is missing documentation for one or more of its generic type parameters, and the documentation for the element contains a tag."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1619.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1619Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1619MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1619Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -101,7 +103,10 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKinds.TypeDeclaration); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKinds.TypeDeclaration); + }); } private static void HandleTypeDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1625ElementDocumentationMustNotBeCopiedAndPasted.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1625ElementDocumentationMustNotBeCopiedAndPasted.cs index 1ffcad916..1d2b230c3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1625ElementDocumentationMustNotBeCopiedAndPasted.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1625ElementDocumentationMustNotBeCopiedAndPasted.cs @@ -1,14 +1,14 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { using System; using System.Collections.Generic; using System.Collections.Immutable; - using System.Globalization; using System.Linq; - using System.Resources; using System.Xml.Linq; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -67,10 +67,10 @@ internal class SA1625ElementDocumentationMustNotBeCopiedAndPasted : ElementDocum /// analyzer. /// public const string DiagnosticId = "SA1625"; - private const string Title = "Element documentation should not be copied and pasted"; - private const string MessageFormat = "Element documentation should not be copied and pasted"; - private const string Description = "The Xml documentation for a C# element contains two or more identical entries, indicating that the documentation has been copied and pasted. This can sometimes indicate invalid or poorly written documentation."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1625.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1625Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1625MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1625Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -89,7 +89,7 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, Styl { var objectPool = SharedPools.Default>(); HashSet documentationTexts = objectPool.Allocate(); - var culture = new CultureInfo(settings.DocumentationRules.DocumentationCulture); + var culture = settings.DocumentationRules.DocumentationCultureInfo; var resourceManager = DocumentationResources.ResourceManager; foreach (var documentationSyntax in syntaxList) @@ -101,27 +101,22 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, Styl continue; } - if (documentationTexts.Contains(documentation)) + if (!documentationTexts.Add(documentation)) { // Add violation context.ReportDiagnostic(Diagnostic.Create(Descriptor, documentationSyntax.GetLocation())); } - else - { - documentationTexts.Add(documentation); - } } objectPool.ClearAndFree(documentationTexts); } /// - protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext context, bool needsComment, XElement completeDocumentation, params Location[] diagnosticLocations) + protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext context, StyleCopSettings settings, bool needsComment, XElement completeDocumentation, params Location[] diagnosticLocations) { var objectPool = SharedPools.Default>(); HashSet documentationTexts = objectPool.Allocate(); - var settings = context.Options.GetStyleCopSettings(context.CancellationToken); - var culture = new CultureInfo(settings.DocumentationRules.DocumentationCulture); + var culture = settings.DocumentationRules.DocumentationCultureInfo; var resourceManager = DocumentationResources.ResourceManager; // Concatenate all XML node values @@ -149,15 +144,11 @@ protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext co continue; } - if (documentationTexts.Contains(documentation)) + if (!documentationTexts.Add(documentation)) { // Add violation context.ReportDiagnostic(Diagnostic.Create(Descriptor, diagnosticLocations.First())); } - else - { - documentationTexts.Add(documentation); - } } objectPool.ClearAndFree(documentationTexts); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes.cs index 0aceff5db..5575434ca 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -53,10 +55,10 @@ internal class SA1626SingleLineCommentsMustNotUseDocumentationStyleSlashes : Dia /// analyzer. /// public const string DiagnosticId = "SA1626"; - private const string Title = "Single-line comments should not use documentation style slashes"; - private const string MessageFormat = "Single-line comments should not use documentation style slashes"; - private const string Description = "The C# code contains a single-line comment which begins with three forward slashes in a row."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1626.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1626Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1626MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1626Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1627DocumentationTextMustNotBeEmpty.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1627DocumentationTextMustNotBeEmpty.cs index 7a872b0f1..5ee6e0f74 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1627DocumentationTextMustNotBeEmpty.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1627DocumentationTextMustNotBeEmpty.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -45,10 +47,10 @@ internal class SA1627DocumentationTextMustNotBeEmpty : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1627"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1627.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1627Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1627MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1627Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1627.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1628DocumentationTextMustBeginWithACapitalLetter.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1628DocumentationTextMustBeginWithACapitalLetter.cs index fed41c1d1..e9407379c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1628DocumentationTextMustBeginWithACapitalLetter.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1628DocumentationTextMustBeginWithACapitalLetter.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -42,13 +44,15 @@ internal class SA1628DocumentationTextMustBeginWithACapitalLetter : DiagnosticAn /// analyzer. /// public const string DiagnosticId = "SA1628"; - private const string Title = "Documentation text should begin with a capital letter"; - private const string MessageFormat = "TODO: Message format"; - private const string Description = "A section of the XML header documentation for a C# element does not begin with a capital letter."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1628.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1628Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1628MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1628Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = +#pragma warning disable RS2000 // Add analyzer diagnostic IDs to analyzer release. new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.NotConfigurable); +#pragma warning restore RS2000 // Add analyzer diagnostic IDs to analyzer release. /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -56,7 +60,11 @@ internal class SA1628DocumentationTextMustBeginWithACapitalLetter : DiagnosticAn /// [ExcludeFromCodeCoverage] +#pragma warning disable RS1025 // Configure generated code analysis +#pragma warning disable RS1026 // Enable concurrent execution public override void Initialize(AnalysisContext context) +#pragma warning restore RS1026 // Enable concurrent execution +#pragma warning restore RS1025 // Configure generated code analysis { // This diagnostic is not implemented (by design) in StyleCopAnalyzers. } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1629DocumentationTextMustEndWithAPeriod.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1629DocumentationTextMustEndWithAPeriod.cs index c0bd39820..6f16360cf 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1629DocumentationTextMustEndWithAPeriod.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1629DocumentationTextMustEndWithAPeriod.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -52,10 +54,12 @@ internal class SA1629DocumentationTextMustEndWithAPeriod : ElementDocumentationB /// internal const string NoCodeFixKey = "NoCodeFix"; + internal const string ReplaceCharKey = "CharToReplace"; + + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1629.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1629Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1629MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1629Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1629.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -84,7 +88,7 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, Styl } /// - protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext context, bool needsComment, XElement completeDocumentation, params Location[] diagnosticLocations) + protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext context, StyleCopSettings settings, bool needsComment, XElement completeDocumentation, params Location[] diagnosticLocations) { foreach (var node in completeDocumentation.Nodes().OfType()) { @@ -123,13 +127,32 @@ private static void HandleSectionOrBlockXmlElement(SyntaxNodeAnalysisContext con if (!string.IsNullOrEmpty(textWithoutTrailingWhitespace)) { - if (!textWithoutTrailingWhitespace.EndsWith(".", StringComparison.Ordinal) - && !textWithoutTrailingWhitespace.EndsWith(".)", StringComparison.Ordinal) - && (startingWithFinalParagraph || !textWithoutTrailingWhitespace.EndsWith(":", StringComparison.Ordinal)) - && !textWithoutTrailingWhitespace.EndsWith("-or-", StringComparison.Ordinal)) + if (IsMissingRequiredPeriod(textWithoutTrailingWhitespace, startingWithFinalParagraph)) { - var location = Location.Create(xmlElement.SyntaxTree, new TextSpan(textToken.SpanStart + textWithoutTrailingWhitespace.Length, 1)); - context.ReportDiagnostic(Diagnostic.Create(Descriptor, location)); + int spanStart = textToken.SpanStart + textWithoutTrailingWhitespace.Length; + ImmutableDictionary properties = null; + if (textWithoutTrailingWhitespace.EndsWith(",", StringComparison.Ordinal) + || textWithoutTrailingWhitespace.EndsWith(";", StringComparison.Ordinal)) + { + spanStart -= 1; + SetReplaceChar(); + } + else if (textWithoutTrailingWhitespace.EndsWith(",)", StringComparison.Ordinal) + || textWithoutTrailingWhitespace.EndsWith(";)", StringComparison.Ordinal)) + { + spanStart -= 2; + SetReplaceChar(); + } + + var location = Location.Create(xmlElement.SyntaxTree, new TextSpan(spanStart, 1)); + context.ReportDiagnostic(Diagnostic.Create(Descriptor, location, properties)); + + void SetReplaceChar() + { + var propertiesBuilder = ImmutableDictionary.CreateBuilder(); + propertiesBuilder.Add(ReplaceCharKey, string.Empty); + properties = propertiesBuilder.ToImmutable(); + } } currentParagraphDone = true; @@ -138,10 +161,15 @@ private static void HandleSectionOrBlockXmlElement(SyntaxNodeAnalysisContext con } else if (xmlElement.Content[i].IsInlineElement() && !currentParagraphDone) { - // Treat empty XML elements as a "word not ending with a period" - var location = Location.Create(xmlElement.SyntaxTree, new TextSpan(xmlElement.Content[i].Span.End, 1)); - context.ReportDiagnostic(Diagnostic.Create(Descriptor, location)); - currentParagraphDone = true; + var lastTextElement = XmlCommentHelper.TryGetLastTextElementWithContent(xmlElement.Content[i]); + + if (lastTextElement is null // Treat empty XML elements as a "word not ending with a period" + || IsMissingRequiredPeriod(lastTextElement.TextTokens.Last().Text.TrimEnd(' ', '\r', '\n'), startingWithFinalParagraph)) + { + var location = Location.Create(xmlElement.SyntaxTree, new TextSpan(xmlElement.Content[i].Span.End, 1)); + context.ReportDiagnostic(Diagnostic.Create(Descriptor, location)); + currentParagraphDone = true; + } } else if (xmlElement.Content[i] is XmlElementSyntax childXmlElement) { @@ -174,5 +202,13 @@ private static void HandleSectionOrBlockXmlElement(SyntaxNodeAnalysisContext con } } } + + private static bool IsMissingRequiredPeriod(string textWithoutTrailingWhitespace, bool startingWithFinalParagraph) + { + return !textWithoutTrailingWhitespace.EndsWith(".", StringComparison.Ordinal) + && !textWithoutTrailingWhitespace.EndsWith(".)", StringComparison.Ordinal) + && (startingWithFinalParagraph || !textWithoutTrailingWhitespace.EndsWith(":", StringComparison.Ordinal)) + && !textWithoutTrailingWhitespace.EndsWith("-or-", StringComparison.Ordinal); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1630DocumentationTextMustContainWhitespace.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1630DocumentationTextMustContainWhitespace.cs index 5a9aa6ec8..9b89035c0 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1630DocumentationTextMustContainWhitespace.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1630DocumentationTextMustContainWhitespace.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -42,13 +44,15 @@ internal class SA1630DocumentationTextMustContainWhitespace : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1630"; - private const string Title = "Documentation text should contain whitespace"; - private const string MessageFormat = "TODO: Message format"; - private const string Description = "A section of the XML header documentation for a C# element does not contain any whitespace between words."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1630.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1630Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1630MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1630Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = +#pragma warning disable RS2000 // Add analyzer diagnostic IDs to analyzer release. new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.NotConfigurable); +#pragma warning restore RS2000 // Add analyzer diagnostic IDs to analyzer release. /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -56,7 +60,11 @@ internal class SA1630DocumentationTextMustContainWhitespace : DiagnosticAnalyzer /// [ExcludeFromCodeCoverage] +#pragma warning disable RS1025 // Configure generated code analysis +#pragma warning disable RS1026 // Enable concurrent execution public override void Initialize(AnalysisContext context) +#pragma warning restore RS1026 // Enable concurrent execution +#pragma warning restore RS1025 // Configure generated code analysis { // This diagnostic is not implemented (by design) in StyleCopAnalyzers. } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1631DocumentationMustMeetCharacterPercentage.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1631DocumentationMustMeetCharacterPercentage.cs index 8cfdf86b4..961bef910 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1631DocumentationMustMeetCharacterPercentage.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1631DocumentationMustMeetCharacterPercentage.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -43,13 +45,15 @@ internal class SA1631DocumentationMustMeetCharacterPercentage : DiagnosticAnalyz /// analyzer. /// public const string DiagnosticId = "SA1631"; - private const string Title = "Documentation should meet character percentage"; - private const string MessageFormat = "TODO: Message format"; - private const string Description = "A section of the Xml header documentation for a C# element does not contain enough alphabetic characters."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1631.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1631Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1631MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1631Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = +#pragma warning disable RS2000 // Add analyzer diagnostic IDs to analyzer release. new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.NotConfigurable); +#pragma warning restore RS2000 // Add analyzer diagnostic IDs to analyzer release. /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -57,7 +61,11 @@ internal class SA1631DocumentationMustMeetCharacterPercentage : DiagnosticAnalyz /// [ExcludeFromCodeCoverage] +#pragma warning disable RS1025 // Configure generated code analysis +#pragma warning disable RS1026 // Enable concurrent execution public override void Initialize(AnalysisContext context) +#pragma warning restore RS1026 // Enable concurrent execution +#pragma warning restore RS1025 // Configure generated code analysis { // This diagnostic is not implemented (by design) in StyleCopAnalyzers. } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1632DocumentationTextMustMeetMinimumCharacterLength.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1632DocumentationTextMustMeetMinimumCharacterLength.cs index 2538d0972..4a9a0cced 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1632DocumentationTextMustMeetMinimumCharacterLength.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1632DocumentationTextMustMeetMinimumCharacterLength.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -41,13 +43,15 @@ internal class SA1632DocumentationTextMustMeetMinimumCharacterLength : Diagnosti /// analyzer. /// public const string DiagnosticId = "SA1632"; - private const string Title = "Documentation text should meet minimum character length"; - private const string MessageFormat = "TODO: Message format"; - private const string Description = "A section of the Xml header documentation for a C# element is too short."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1632.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1632Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1632MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1632Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = +#pragma warning disable RS2000 // Add analyzer diagnostic IDs to analyzer release. new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.NotConfigurable); +#pragma warning restore RS2000 // Add analyzer diagnostic IDs to analyzer release. /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -55,7 +59,11 @@ internal class SA1632DocumentationTextMustMeetMinimumCharacterLength : Diagnosti /// [ExcludeFromCodeCoverage] +#pragma warning disable RS1025 // Configure generated code analysis +#pragma warning disable RS1026 // Enable concurrent execution public override void Initialize(AnalysisContext context) +#pragma warning restore RS1026 // Enable concurrent execution +#pragma warning restore RS1025 // Configure generated code analysis { // This diagnostic is not implemented (by design) in StyleCopAnalyzers. } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1642ConstructorSummaryDocumentationMustBeginWithStandardText.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1642ConstructorSummaryDocumentationMustBeginWithStandardText.cs index 0f8ea0902..9b49d92a1 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1642ConstructorSummaryDocumentationMustBeginWithStandardText.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1642ConstructorSummaryDocumentationMustBeginWithStandardText.cs @@ -1,16 +1,19 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { using System; using System.Collections.Immutable; - using System.Globalization; using System.Linq; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; + using StyleCop.Analyzers.Lightup; + using StyleCop.Analyzers.Settings.ObjectModel; /// /// The XML documentation header for a C# constructor does not contain the appropriate summary text. @@ -97,15 +100,15 @@ internal class SA1642ConstructorSummaryDocumentationMustBeginWithStandardText : /// analyzer. /// public const string DiagnosticId = "SA1642"; - private const string Title = "Constructor summary documentation should begin with standard text"; - private const string MessageFormat = "Constructor summary documentation should begin with standard text"; - private const string Description = "The XML documentation header for a C# constructor does not contain the appropriate summary text."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1642.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1642Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1642MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1642Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); - private static readonly Action ConstructorDeclarationAction = HandleConstructorDeclaration; + private static readonly Action ConstructorDeclarationAction = HandleConstructorDeclaration; /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -117,18 +120,22 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(ConstructorDeclarationAction, SyntaxKind.ConstructorDeclaration); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(ConstructorDeclarationAction, SyntaxKind.ConstructorDeclaration); + }); } - private static void HandleConstructorDeclaration(SyntaxNodeAnalysisContext context) + private static void HandleConstructorDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) { var constructorDeclarationSyntax = (ConstructorDeclarationSyntax)context.Node; - var settings = context.Options.GetStyleCopSettings(context.CancellationToken); - var culture = new CultureInfo(settings.DocumentationRules.DocumentationCulture); + var culture = settings.DocumentationRules.DocumentationCultureInfo; var resourceManager = DocumentationResources.ResourceManager; - bool isStruct = constructorDeclarationSyntax.Parent?.IsKind(SyntaxKind.StructDeclaration) ?? false; + var parent = constructorDeclarationSyntax.Parent; + bool isStruct = parent != null && + (parent.IsKind(SyntaxKind.StructDeclaration) || parent.IsKind(SyntaxKindEx.RecordStructDeclaration)); var typeKindText = resourceManager.GetString(isStruct ? nameof(DocumentationResources.TypeTextStruct) : nameof(DocumentationResources.TypeTextClass), culture); if (constructorDeclarationSyntax.Modifiers.Any(SyntaxKind.StaticKeyword)) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1643DestructorSummaryDocumentationMustBeginWithStandardText.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1643DestructorSummaryDocumentationMustBeginWithStandardText.cs index 9e02662b5..44d035260 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1643DestructorSummaryDocumentationMustBeginWithStandardText.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1643DestructorSummaryDocumentationMustBeginWithStandardText.cs @@ -1,15 +1,16 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { using System; using System.Collections.Immutable; - using System.Globalization; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; - using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; + using StyleCop.Analyzers.Settings.ObjectModel; /// /// The XML documentation header for a C# finalizer does not contain the appropriate summary text. @@ -53,15 +54,15 @@ internal class SA1643DestructorSummaryDocumentationMustBeginWithStandardText : S /// analyzer. /// public const string DiagnosticId = "SA1643"; - private const string Title = "Destructor summary documentation should begin with standard text"; - private const string MessageFormat = "Destructor summary documentation should begin with standard text"; - private const string Description = "The XML documentation header for a C# finalizer does not contain the appropriate summary text."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1643.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1643Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1643MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1643Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); - private static readonly Action DestructorDeclarationAction = HandleDestructor; + private static readonly Action DestructorDeclarationAction = HandleDestructor; /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -73,14 +74,15 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(DestructorDeclarationAction, SyntaxKind.DestructorDeclaration); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(DestructorDeclarationAction, SyntaxKind.DestructorDeclaration); + }); } - private static void HandleDestructor(SyntaxNodeAnalysisContext context) + private static void HandleDestructor(SyntaxNodeAnalysisContext context, StyleCopSettings settings) { - var destructorDeclaration = (DestructorDeclarationSyntax)context.Node; - var settings = context.Options.GetStyleCopSettings(context.CancellationToken); - var culture = new CultureInfo(settings.DocumentationRules.DocumentationCulture); + var culture = settings.DocumentationRules.DocumentationCultureInfo; var resourceManager = DocumentationResources.ResourceManager; HandleDeclaration( diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1644DocumentationHeadersMustNotContainBlankLines.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1644DocumentationHeadersMustNotContainBlankLines.cs index 4c06f4fb0..fc868c4d0 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1644DocumentationHeadersMustNotContainBlankLines.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1644DocumentationHeadersMustNotContainBlankLines.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -60,22 +62,28 @@ internal class SA1644DocumentationHeadersMustNotContainBlankLines : DiagnosticAn /// analyzer. /// public const string DiagnosticId = "SA1644"; - private const string Title = "Documentation headers should not contain blank lines"; - private const string MessageFormat = "TODO: Message format"; - private const string Description = "A section within the XML documentation header for a C# element contains blank lines."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1644.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1644Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1644MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1644Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = - new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledNoTests, Description, HelpLink, WellKnownDiagnosticTags.NotConfigurable); +#pragma warning disable RS2000 // Add analyzer diagnostic IDs to analyzer release. + new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.NotConfigurable); +#pragma warning restore RS2000 // Add analyzer diagnostic IDs to analyzer release. /// public override ImmutableArray SupportedDiagnostics { get; } = ImmutableArray.Create(Descriptor); /// +#pragma warning disable RS1025 // Configure generated code analysis +#pragma warning disable RS1026 // Enable concurrent execution public override void Initialize(AnalysisContext context) +#pragma warning restore RS1026 // Enable concurrent execution +#pragma warning restore RS1025 // Configure generated code analysis { - // TODO: Implement analysis + // This diagnostic is not implemented (by design) in StyleCopAnalyzers. } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1645IncludedDocumentationFileDoesNotExist.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1645IncludedDocumentationFileDoesNotExist.cs index 82dd46559..e8cb6c66c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1645IncludedDocumentationFileDoesNotExist.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1645IncludedDocumentationFileDoesNotExist.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -38,13 +40,15 @@ internal class SA1645IncludedDocumentationFileDoesNotExist : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1645"; - private const string Title = "Included documentation file does not exist"; - private const string MessageFormat = "TODO: Message format"; - private const string Description = "An included XML documentation file does not exist."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1645.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1645Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1645MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1645Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = +#pragma warning disable RS2000 // Add analyzer diagnostic IDs to analyzer release. new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.NotConfigurable); +#pragma warning restore RS2000 // Add analyzer diagnostic IDs to analyzer release. /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -52,7 +56,11 @@ internal class SA1645IncludedDocumentationFileDoesNotExist : DiagnosticAnalyzer /// [ExcludeFromCodeCoverage] +#pragma warning disable RS1025 // Configure generated code analysis +#pragma warning disable RS1026 // Enable concurrent execution public override void Initialize(AnalysisContext context) +#pragma warning restore RS1026 // Enable concurrent execution +#pragma warning restore RS1025 // Configure generated code analysis { // This diagnostic is not implemented (by design) in StyleCopAnalyzers. } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1646IncludedDocumentationXPathDoesNotExist.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1646IncludedDocumentationXPathDoesNotExist.cs index dae33f6c9..0605fc7e5 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1646IncludedDocumentationXPathDoesNotExist.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1646IncludedDocumentationXPathDoesNotExist.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -39,13 +41,15 @@ internal class SA1646IncludedDocumentationXPathDoesNotExist : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1646"; - private const string Title = "Included documentation XPath does not exist"; - private const string MessageFormat = "TODO: Message format"; - private const string Description = "An included XML documentation link contains an invalid path."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1646.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1646Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1646MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1646Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = +#pragma warning disable RS2000 // Add analyzer diagnostic IDs to analyzer release. new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.NotConfigurable); +#pragma warning restore RS2000 // Add analyzer diagnostic IDs to analyzer release. /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -53,7 +57,11 @@ internal class SA1646IncludedDocumentationXPathDoesNotExist : DiagnosticAnalyzer /// [ExcludeFromCodeCoverage] +#pragma warning disable RS1025 // Configure generated code analysis +#pragma warning disable RS1026 // Enable concurrent execution public override void Initialize(AnalysisContext context) +#pragma warning restore RS1026 // Enable concurrent execution +#pragma warning restore RS1025 // Configure generated code analysis { // This diagnostic is not implemented (by design) in StyleCopAnalyzers. } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1647IncludeNodeDoesNotContainValidFileAndPath.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1647IncludeNodeDoesNotContainValidFileAndPath.cs index 294441862..dd22c90ad 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1647IncludeNodeDoesNotContainValidFileAndPath.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1647IncludeNodeDoesNotContainValidFileAndPath.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -40,13 +42,15 @@ internal class SA1647IncludeNodeDoesNotContainValidFileAndPath : DiagnosticAnaly /// analyzer. /// public const string DiagnosticId = "SA1647"; - private const string Title = "Include node does not contain valid file and path"; - private const string MessageFormat = "TODO: Message format"; - private const string Description = "An include tag within an XML documentation header does not contain valid file and path attribute."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1647.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1647Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1647MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1647Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = +#pragma warning disable RS2000 // Add analyzer diagnostic IDs to analyzer release. new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.NotConfigurable); +#pragma warning restore RS2000 // Add analyzer diagnostic IDs to analyzer release. /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -54,7 +58,11 @@ internal class SA1647IncludeNodeDoesNotContainValidFileAndPath : DiagnosticAnaly /// [ExcludeFromCodeCoverage] +#pragma warning disable RS1025 // Configure generated code analysis +#pragma warning disable RS1026 // Enable concurrent execution public override void Initialize(AnalysisContext context) +#pragma warning restore RS1026 // Enable concurrent execution +#pragma warning restore RS1025 // Configure generated code analysis { // This diagnostic is not implemented (by design) in StyleCopAnalyzers. } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1648InheritDocMustBeUsedWithInheritingClass.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1648InheritDocMustBeUsedWithInheritingClass.cs index b6c5568e8..339508867 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1648InheritDocMustBeUsedWithInheritingClass.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1648InheritDocMustBeUsedWithInheritingClass.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -25,10 +27,10 @@ internal class SA1648InheritDocMustBeUsedWithInheritingClass : DiagnosticAnalyze /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1648"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1648.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1648Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1648MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1648Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1648.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -86,7 +88,7 @@ private static void HandleBaseTypeLikeDeclaration(SyntaxNodeAnalysisContext cont if (documentation.Content.GetFirstXmlElement(XmlCommentHelper.IncludeXmlTag) is XmlEmptyElementSyntax includeElement) { - var declaration = context.SemanticModel.GetDeclaredSymbol(baseType, context.CancellationToken); + var declaration = context.SemanticModel.GetDeclaredSymbol(context.Node, context.CancellationToken); if (declaration == null) { return; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1649FileNameMustMatchTypeName.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1649FileNameMustMatchTypeName.cs index dfb6840e3..09371ee7e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1649FileNameMustMatchTypeName.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1649FileNameMustMatchTypeName.cs @@ -1,17 +1,19 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { using System; using System.Collections.Immutable; - using System.IO; using System.Linq; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.Settings.ObjectModel; /// @@ -33,10 +35,10 @@ internal class SA1649FileNameMustMatchTypeName : DiagnosticAnalyzer /// internal const string ExpectedFileNameKey = "ExpectedFileName"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1649.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1649Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1649MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1649Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1649.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -53,7 +55,10 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxTreeAction(SyntaxTreeAction); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxTreeAction(SyntaxTreeAction); + }); } private static class Analyzer @@ -68,7 +73,8 @@ public static void HandleSyntaxTree(SyntaxTreeAnalysisContext context, StyleCopS return; } - if (firstTypeDeclaration.Modifiers.Any(SyntaxKind.PartialKeyword)) + var modifiers = (firstTypeDeclaration as BaseTypeDeclarationSyntax)?.Modifiers ?? SyntaxFactory.TokenList(); + if (modifiers.Any(SyntaxKind.PartialKeyword)) { return; } @@ -88,15 +94,31 @@ public static void HandleSyntaxTree(SyntaxTreeAnalysisContext context, StyleCopS var properties = ImmutableDictionary.Create() .Add(ExpectedFileNameKey, expectedFileName + suffix); - context.ReportDiagnostic(Diagnostic.Create(Descriptor, firstTypeDeclaration.Identifier.GetLocation(), properties)); + var identifier = (firstTypeDeclaration as BaseTypeDeclarationSyntax)?.Identifier + ?? ((DelegateDeclarationSyntax)firstTypeDeclaration).Identifier; + context.ReportDiagnostic(Diagnostic.Create(Descriptor, identifier.GetLocation(), properties)); } } - private static TypeDeclarationSyntax GetFirstTypeDeclaration(SyntaxNode root) + private static MemberDeclarationSyntax GetFirstTypeDeclaration(SyntaxNode root) { - return root.DescendantNodes(descendIntoChildren: node => node.IsKind(SyntaxKind.CompilationUnit) || node.IsKind(SyntaxKind.NamespaceDeclaration)) + // Prefer to find the first type which is a true TypeDeclarationSyntax + MemberDeclarationSyntax firstTypeDeclaration = root.DescendantNodes(descendIntoChildren: node => node.IsKind(SyntaxKind.CompilationUnit) || node.IsKind(SyntaxKind.NamespaceDeclaration) || node.IsKind(SyntaxKindEx.FileScopedNamespaceDeclaration)) .OfType() .FirstOrDefault(); + + // If no TypeDeclarationSyntax is found, expand the search to any type declaration as long as only one + // is present + var expandedTypeDeclarations = root.DescendantNodes(descendIntoChildren: node => node.IsKind(SyntaxKind.CompilationUnit) || node.IsKind(SyntaxKind.NamespaceDeclaration) || node.IsKind(SyntaxKindEx.FileScopedNamespaceDeclaration)) + .OfType() + .Where(node => node is BaseTypeDeclarationSyntax || node.IsKind(SyntaxKind.DelegateDeclaration)) + .ToList(); + if (expandedTypeDeclarations.Count == 1) + { + firstTypeDeclaration = expandedTypeDeclarations[0]; + } + + return firstTypeDeclaration; } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1650ElementDocumentationMustBeSpelledCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1650ElementDocumentationMustBeSpelledCorrectly.cs index b7bf942a4..e2c66405e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1650ElementDocumentationMustBeSpelledCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1650ElementDocumentationMustBeSpelledCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -65,13 +67,15 @@ internal class SA1650ElementDocumentationMustBeSpelledCorrectly : DiagnosticAnal /// analyzer. /// public const string DiagnosticId = "SA1650"; - private const string Title = "Element documentation should be spelled correctly"; - private const string MessageFormat = "TODO: Message format"; - private const string Description = "The element documentation for the element contains one or more spelling mistakes or unrecognized words."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1650.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1650Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1650MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1650Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = +#pragma warning disable RS2000 // Add analyzer diagnostic IDs to analyzer release. new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.NotConfigurable); +#pragma warning restore RS2000 // Add analyzer diagnostic IDs to analyzer release. /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -79,7 +83,11 @@ internal class SA1650ElementDocumentationMustBeSpelledCorrectly : DiagnosticAnal /// [ExcludeFromCodeCoverage] +#pragma warning disable RS1025 // Configure generated code analysis +#pragma warning disable RS1026 // Enable concurrent execution public override void Initialize(AnalysisContext context) +#pragma warning restore RS1026 // Enable concurrent execution +#pragma warning restore RS1025 // Configure generated code analysis { // This diagnostic is not implemented (by design) in StyleCopAnalyzers. } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1651DoNotUsePlaceholderElements.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1651DoNotUsePlaceholderElements.cs index 8580021c1..7ff3f125d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1651DoNotUsePlaceholderElements.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/SA1651DoNotUsePlaceholderElements.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { @@ -46,10 +48,10 @@ internal class SA1651DoNotUsePlaceholderElements : DiagnosticAnalyzer /// internal const string NoCodeFixKey = "NoCodeFix"; - private const string Title = "Do not use placeholder elements"; - private const string MessageFormat = "Do not use placeholder elements"; - private const string Description = "The element documentation contains a element."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1651.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(DocumentationResources.SA1651Title), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(DocumentationResources.SA1651MessageFormat), DocumentationResources.ResourceManager, typeof(DocumentationResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1651Description), DocumentationResources.ResourceManager, typeof(DocumentationResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/StandardTextDiagnosticBase.cs b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/StandardTextDiagnosticBase.cs index 54e6e90f9..2b6c7263e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/StandardTextDiagnosticBase.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/DocumentationRules/StandardTextDiagnosticBase.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.DocumentationRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ExcludeFromCodeCoverageAttribute.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ExcludeFromCodeCoverageAttribute.cs index 14c3d8181..72d7172cb 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ExcludeFromCodeCoverageAttribute.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ExcludeFromCodeCoverageAttribute.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable #if NETSTANDARD1_1 diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/AccessLevel.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/AccessLevel.cs index da0fe193e..6699c9c7c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/AccessLevel.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/AccessLevel.cs @@ -1,5 +1,5 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Helpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/AccessLevelHelper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/AccessLevelHelper.cs index 1737cc53a..bcc1bcd69 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/AccessLevelHelper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/AccessLevelHelper.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { @@ -294,11 +296,17 @@ internal static Accessibility GetDeclaredAccessibility(this BaseFieldDeclaration internal static Accessibility GetDeclaredAccessibility(this EnumMemberDeclarationSyntax syntax) { + // Intentionally unused + _ = syntax; + return Accessibility.Public; } internal static Accessibility GetDeclaredAccessibility(this DelegateDeclarationSyntax syntax, SemanticModel semanticModel, CancellationToken cancellationToken) { + // Currently unused + _ = cancellationToken; + Requires.NotNull(syntax, nameof(syntax)); Requires.NotNull(semanticModel, nameof(semanticModel)); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/DeclarationModifiersHelper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/DeclarationModifiersHelper.cs index 90801515e..cdda0397d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/DeclarationModifiersHelper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/DeclarationModifiersHelper.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { @@ -122,7 +124,7 @@ internal static SyntaxTokenList GetModifiers(this MemberDeclarationSyntax syntax return ((IncompleteMemberSyntax)syntax).Modifiers; } - return default(SyntaxTokenList); + return default; } internal static SyntaxNode WithModifiers(this SyntaxNode node, SyntaxTokenList modifiers) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/DiagnosticOptionsHelper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/DiagnosticOptionsHelper.cs index a8a21c9e3..5c97de2bd 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/DiagnosticOptionsHelper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/DiagnosticOptionsHelper.cs @@ -1,12 +1,14 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable // There are no start actions in this file. This warning should not be reported. #pragma warning disable RS1012 // Start action has no registered actions. namespace StyleCop.Analyzers.Helpers { - using System.Collections.Immutable; + using System; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; @@ -19,44 +21,52 @@ internal static class DiagnosticOptionsHelper /// Determines if the diagnostic identified by the given identifier is currently suppressed. /// /// The context that will be used to determine if the diagnostic is currently suppressed. - /// The diagnostic identifier to check. + /// The diagnostic descriptor to check. /// True if the diagnostic is currently suppressed. - internal static bool IsAnalyzerSuppressed(this SyntaxNodeAnalysisContext context, string diagnosticId) + internal static bool IsAnalyzerSuppressed(this SyntaxNodeAnalysisContext context, DiagnosticDescriptor descriptor) { - return context.SemanticModel.Compilation.IsAnalyzerSuppressed(diagnosticId); + return context.SemanticModel.Compilation.IsAnalyzerSuppressed(descriptor); } /// /// Determines if the diagnostic identified by the given identifier is currently suppressed. /// /// The context that will be used to determine if the diagnostic is currently suppressed. - /// The diagnostic identifier to check. + /// The diagnostic descriptor to check. /// True if the diagnostic is currently suppressed. - internal static bool IsAnalyzerSuppressed(this CompilationStartAnalysisContext context, string diagnosticId) + internal static bool IsAnalyzerSuppressed(this CompilationStartAnalysisContext context, DiagnosticDescriptor descriptor) { - return context.Compilation.IsAnalyzerSuppressed(diagnosticId); + return context.Compilation.IsAnalyzerSuppressed(descriptor); } /// /// Determines if the diagnostic identified by the given identifier is currently suppressed. /// /// The compilation that will be used to determine if the diagnostic is currently suppressed. - /// The diagnostic identifier to check. + /// The diagnostic descriptor to check. /// True if the diagnostic is currently suppressed. - internal static bool IsAnalyzerSuppressed(this Compilation compilation, string diagnosticId) + internal static bool IsAnalyzerSuppressed(this Compilation compilation, DiagnosticDescriptor descriptor) { - return compilation.Options.IsAnalyzerSuppressed(diagnosticId); + return compilation.Options.IsAnalyzerSuppressed(descriptor); } /// /// Determines if the diagnostic identified by the given identifier is currently suppressed. /// /// The compilation options that will be used to determine if the diagnostic is currently suppressed. - /// The diagnostic identifier to check. + /// The diagnostic descriptor to check. /// True if the diagnostic is currently suppressed. - internal static bool IsAnalyzerSuppressed(this CompilationOptions compilationOptions, string diagnosticId) + internal static bool IsAnalyzerSuppressed(this CompilationOptions compilationOptions, DiagnosticDescriptor descriptor) { - return compilationOptions.SpecificDiagnosticOptions.GetValueOrDefault(diagnosticId, ReportDiagnostic.Default) == ReportDiagnostic.Suppress; + switch (descriptor.GetEffectiveSeverity(compilationOptions)) + { + case ReportDiagnostic.Suppress: + return true; + case ReportDiagnostic.Default: + throw new InvalidOperationException("This should be unreachable."); + default: + return false; + } } /// diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/DictionaryExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/DictionaryExtensions.cs new file mode 100644 index 000000000..19d43d7c7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/DictionaryExtensions.cs @@ -0,0 +1,23 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Helpers +{ + using System.Collections.Generic; + + internal static class DictionaryExtensions + { + public static TValue GetValueOrDefault(this Dictionary dictionary, TKey key, TValue defaultValue) + where TKey : notnull + { + if (!dictionary.TryGetValue(key, out var value)) + { + value = defaultValue; + } + + return value; + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/DocumentationCommentExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/DocumentationCommentExtensions.cs index 851b58168..bb1220f38 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/DocumentationCommentExtensions.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/DocumentationCommentExtensions.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ExpressionSyntaxHelpers.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ExpressionSyntaxHelpers.cs index 4a85074bb..a37b30637 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ExpressionSyntaxHelpers.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ExpressionSyntaxHelpers.cs @@ -1,5 +1,5 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Helpers { @@ -17,5 +17,16 @@ public static ExpressionSyntax WalkDownParentheses(this ExpressionSyntax express return result; } + + public static ExpressionSyntax WalkUpParentheses(this ExpressionSyntax expression) + { + var result = expression; + while (result.Parent is ParenthesizedExpressionSyntax parenthesizedExpression) + { + result = parenthesizedExpression; + } + + return result; + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/FileHeader.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/FileHeader.cs index 143844493..42ae25b6b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/FileHeader.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/FileHeader.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { @@ -12,7 +14,6 @@ namespace StyleCop.Analyzers.Helpers internal class FileHeader { private readonly int fileHeaderStart; - private readonly int fileHeaderEnd; /// /// Initializes a new instance of the class. @@ -22,9 +23,11 @@ internal class FileHeader /// The offset within the file at which the header ended. internal FileHeader(string copyrightText, int fileHeaderStart, int fileHeaderEnd) { + // Currently unused + _ = fileHeaderEnd; + this.CopyrightText = copyrightText; this.fileHeaderStart = fileHeaderStart; - this.fileHeaderEnd = fileHeaderEnd; } /// diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/FileHeaderHelpers.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/FileHeaderHelpers.cs index 03e87545c..5296de96c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/FileHeaderHelpers.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/FileHeaderHelpers.cs @@ -1,11 +1,12 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { using System; using System.Linq; - using System.Text; using System.Xml; using System.Xml.Linq; using Microsoft.CodeAnalysis; @@ -55,7 +56,7 @@ internal static FileHeader ParseFileHeader(SyntaxNode root) fileHeaderStart = Math.Min(trivia.FullSpan.Start, fileHeaderStart); fileHeaderEnd = trivia.FullSpan.End; - sb.AppendLine(commentString.Substring(2).Trim()); + sb.Append(commentString.Substring(2).Trim()).Append('\n'); break; case SyntaxKind.MultiLineCommentTrivia: // only process a MultiLineCommentTrivia if no SingleLineCommentTrivia have been processed @@ -78,7 +79,7 @@ internal static FileHeader ParseFileHeader(SyntaxNode root) foreach (var part in triviaStringParts) { var trimmedPart = part.TrimStart(' ', '*'); - sb.AppendLine(trimmedPart); + sb.Append(trimmedPart).Append('\n'); } fileHeaderStart = trivia.FullSpan.Start; @@ -105,9 +106,9 @@ internal static FileHeader ParseFileHeader(SyntaxNode root) if (sb.Length > 0) { - // remove the final newline - var eolLength = Environment.NewLine.Length; - sb.Remove(sb.Length - eolLength, eolLength); + // remove the final newline, which is always in '\n' form + const int EolLength = 1; + sb.Remove(sb.Length - EolLength, EolLength); } return new FileHeader(StringBuilderPool.ReturnAndFree(sb), fileHeaderStart, fileHeaderEnd); @@ -178,7 +179,7 @@ private static string ProcessSingleLineCommentsHeader(SyntaxTriviaList triviaLis fileHeaderEnd = int.MinValue; // wrap the XML from the file header in a single root element to make XML parsing work. - sb.AppendLine(""); + sb.Append("\n"); int i; for (i = startIndex; !done && (i < triviaList.Count); i++) @@ -205,7 +206,7 @@ private static string ProcessSingleLineCommentsHeader(SyntaxTriviaList triviaLis fileHeaderStart = Math.Min(trivia.FullSpan.Start, fileHeaderStart); fileHeaderEnd = trivia.FullSpan.End; - sb.AppendLine(commentString.Substring(2)); + sb.Append(commentString.Substring(2)).Append('\n'); break; case SyntaxKind.EndOfLineTrivia: @@ -219,7 +220,7 @@ private static string ProcessSingleLineCommentsHeader(SyntaxTriviaList triviaLis } } - sb.AppendLine(""); + sb.Append("\n"); return StringBuilderPool.ReturnAndFree(sb); } @@ -228,7 +229,7 @@ private static string ProcessMultiLineCommentsHeader(SyntaxTrivia multiLineComme var sb = StringBuilderPool.Allocate(); // wrap the XML from the file header in a single root element to make XML parsing work. - sb.AppendLine(""); + sb.Append("\n"); fileHeaderStart = multiLineComment.FullSpan.Start; fileHeaderEnd = multiLineComment.FullSpan.End; @@ -241,10 +242,10 @@ private static string ProcessMultiLineCommentsHeader(SyntaxTrivia multiLineComme foreach (var commentLine in commentLines) { - sb.AppendLine(commentLine.TrimStart(' ', '*')); + sb.Append(commentLine.TrimStart(' ', '*')).Append('\n'); } - sb.AppendLine(""); + sb.Append("\n"); return StringBuilderPool.ReturnAndFree(sb); } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/FileNameHelpers.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/FileNameHelpers.cs index 3277fa993..089b5cdde 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/FileNameHelpers.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/FileNameHelpers.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { @@ -45,6 +47,22 @@ internal static string GetConventionalFileName(MemberDeclarationSyntax declarati return GetStyleCopFileName(typeDeclaration); } } + else if (declaration is DelegateDeclarationSyntax delegateDeclaration) + { + if (delegateDeclaration.TypeParameterList == null) + { + return GetSimpleFileName(delegateDeclaration); + } + + switch (convention) + { + case FileNamingConvention.Metadata: + return GetMetadataFileName(delegateDeclaration); + + default: + return GetStyleCopFileName(delegateDeclaration); + } + } return GetSimpleFileName(declaration); } @@ -60,10 +78,21 @@ private static string GetMetadataFileName(TypeDeclarationSyntax typeDeclaration) return $"{typeDeclaration.Identifier.ValueText}`{typeDeclaration.Arity}"; } + private static string GetMetadataFileName(DelegateDeclarationSyntax delegateDeclaration) + { + return $"{delegateDeclaration.Identifier.ValueText}`{delegateDeclaration.Arity}"; + } + private static string GetStyleCopFileName(TypeDeclarationSyntax typeDeclaration) { var typeParameterList = string.Join(",", typeDeclaration.TypeParameterList.Parameters.Select(p => p.Identifier.ValueText)); return $"{typeDeclaration.Identifier.ValueText}{{{typeParameterList}}}"; } + + private static string GetStyleCopFileName(DelegateDeclarationSyntax delegateDeclaration) + { + var typeParameterList = string.Join(",", delegateDeclaration.TypeParameterList.Parameters.Select(p => p.Identifier.ValueText)); + return $"{delegateDeclaration.Identifier.ValueText}{{{typeParameterList}}}"; + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/HelpersResources.Designer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/HelpersResources.Designer.cs deleted file mode 100644 index b9dd7db1e..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/HelpersResources.Designer.cs +++ /dev/null @@ -1,91 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace StyleCop.Analyzers.Helpers { - using System; - using System.Reflection; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class HelpersResources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal HelpersResources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StyleCop.Analyzers.Helpers.HelpersResources", typeof(HelpersResources).GetTypeInfo().Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Fix all '{0}'. - /// - internal static string FixAllOccurrencesOfDiagnostic { - get { - return ResourceManager.GetString("FixAllOccurrencesOfDiagnostic", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Fix all '{0}' in '{1}'. - /// - internal static string FixAllOccurrencesOfDiagnosticInScope { - get { - return ResourceManager.GetString("FixAllOccurrencesOfDiagnosticInScope", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Fix all '{0}' in Solution. - /// - internal static string FixAllOccurrencesOfDiagnosticInSolution { - get { - return ResourceManager.GetString("FixAllOccurrencesOfDiagnosticInSolution", resourceCulture); - } - } - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/KeyValuePairExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/KeyValuePairExtensions.cs new file mode 100644 index 000000000..af27eb6f6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/KeyValuePairExtensions.cs @@ -0,0 +1,18 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Helpers +{ + using System.Collections.Generic; + + internal static class KeyValuePairExtensions + { + public static void Deconstruct(this KeyValuePair pair, out TKey key, out TValue value) + { + key = pair.Key; + value = pair.Value; + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/LanguageFeatureHelpers.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/LanguageFeatureHelpers.cs new file mode 100644 index 000000000..893461c1f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/LanguageFeatureHelpers.cs @@ -0,0 +1,50 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Helpers +{ + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.Diagnostics; + using StyleCop.Analyzers.Lightup; + + /// + /// Helper methods for checking specific language versions. + /// + internal static class LanguageFeatureHelpers + { + /// + /// Checks if the tuple language feature is supported. + /// + /// The analysis context that will be checked. + /// True if tuples are supported by the compiler. + internal static bool SupportsTuples(this SyntaxNodeAnalysisContext context) + { + var csharpParseOptions = context.Node.SyntaxTree.Options as CSharpParseOptions; + return (csharpParseOptions != null) && (csharpParseOptions.LanguageVersion >= LanguageVersionEx.CSharp7); + } + + /// + /// Checks if the tuple language feature is supported. + /// + /// The analysis context that will be checked. + /// True if tuples are supported by the compiler. + internal static bool SupportsTuples(this OperationAnalysisContext context) + { + var csharpParseOptions = context.Operation.Syntax.SyntaxTree.Options as CSharpParseOptions; + return (csharpParseOptions != null) && (csharpParseOptions.LanguageVersion >= LanguageVersionEx.CSharp7); + } + + /// + /// Checks if the inferred tuple element names language feature is supported. + /// + /// The analysis context that will be checked. + /// True if inferred tuple names are supported by the compiler. + internal static bool SupportsInferredTupleElementNames(this SyntaxNodeAnalysisContext context) + { + var csharpParseOptions = context.Node.SyntaxTree.Options as CSharpParseOptions; + return (csharpParseOptions != null) && (csharpParseOptions.LanguageVersion >= LanguageVersionEx.CSharp7_1); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/LiteralExpressionHelpers.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/LiteralExpressionHelpers.cs index adbe5be89..3bca66576 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/LiteralExpressionHelpers.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/LiteralExpressionHelpers.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/LocationHelpers.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/LocationHelpers.cs index 74857f8f6..553537954 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/LocationHelpers.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/LocationHelpers.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/MemberOrderHelper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/MemberOrderHelper.cs index 8381d567d..049c1ca10 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/MemberOrderHelper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/MemberOrderHelper.cs @@ -1,5 +1,5 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Helpers { @@ -8,12 +8,13 @@ namespace StyleCop.Analyzers.Helpers using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.Settings.ObjectModel; /// /// Helper for dealing with member priority. /// - internal struct MemberOrderHelper + internal readonly struct MemberOrderHelper { private static readonly ImmutableArray TypeMemberOrder = ImmutableArray.Create( SyntaxKind.ClassDeclaration, @@ -41,8 +42,13 @@ internal MemberOrderHelper(MemberDeclarationSyntax member, ImmutableArray SyntaxKind.EventDeclaration, + SyntaxKindEx.RecordDeclaration => SyntaxKind.ClassDeclaration, + SyntaxKindEx.RecordStructDeclaration => SyntaxKind.StructDeclaration, + var kind => kind, + }; this.Priority = 0; foreach (OrderingTrait trait in elementOrder) @@ -98,22 +104,22 @@ internal MemberOrderHelper(MemberDeclarationSyntax member, ImmutableArray - /// No modifiers + /// No modifiers. /// None = 0, /// - /// Readonly modifier + /// modifier. /// Readonly = 1, /// - /// Static modifier + /// modifier. /// Static = 1 << 2, /// - /// Const modifier + /// modifier. /// Const = 1 << 3, } @@ -151,10 +157,14 @@ internal static AccessLevel GetAccessLevelForOrdering(SyntaxNode member, SyntaxT accessibility = AccessLevelHelper.GetAccessLevel(modifiers); if (accessibility == AccessLevel.NotSpecified) { - if (member.Parent.IsKind(SyntaxKind.CompilationUnit) || member.Parent.IsKind(SyntaxKind.NamespaceDeclaration)) + if (member.Parent.IsKind(SyntaxKind.CompilationUnit) || member.Parent.IsKind(SyntaxKind.NamespaceDeclaration) || member.Parent.IsKind(SyntaxKindEx.FileScopedNamespaceDeclaration)) { accessibility = AccessLevel.Internal; } + else if (member.Parent.IsKind(SyntaxKind.InterfaceDeclaration)) + { + accessibility = AccessLevel.Public; + } else { accessibility = AccessLevel.Private; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ModifierOrderHelper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ModifierOrderHelper.cs index 788c66a7d..d4f3f39a4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ModifierOrderHelper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ModifierOrderHelper.cs @@ -1,10 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; + using StyleCop.Analyzers.Lightup; internal static class ModifierOrderHelper { @@ -14,22 +17,22 @@ internal static class ModifierOrderHelper internal enum ModifierType { /// - /// Represents default value + /// Represents default value. /// None, /// - /// Represents any of access modifiers i.e public, protected, internal, private + /// Represents any of access modifiers, i.e , , , , . /// Access, /// - /// Represents static modifier + /// Represents modifier. /// Static, /// - /// Represents other modifiers i.e partial, virtual, abstract, override, extern, unsafe, new, async, const, sealed, readonly, volatile, fixed, ref + /// Represents other modifiers, i.e , , , , , , , , , , , , , . /// Other, } @@ -44,6 +47,7 @@ internal static ModifierType GetModifierType(SyntaxToken modifier) case SyntaxKind.ProtectedKeyword: case SyntaxKind.InternalKeyword: case SyntaxKind.PrivateKeyword: + case SyntaxKindEx.FileKeyword: result = ModifierType.Access; break; @@ -65,6 +69,7 @@ internal static ModifierType GetModifierType(SyntaxToken modifier) case SyntaxKind.AsyncKeyword: case SyntaxKind.PartialKeyword: case SyntaxKind.RefKeyword: + case SyntaxKindEx.RequiredKeyword: result = ModifierType.Other; break; } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/NameSyntaxHelpers.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/NameSyntaxHelpers.cs index a3ca60482..4c5734fa6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/NameSyntaxHelpers.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/NameSyntaxHelpers.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/NamedTypeHelpers.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/NamedTypeHelpers.cs index d299d89d7..685bc2e5e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/NamedTypeHelpers.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/NamedTypeHelpers.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { @@ -9,6 +11,8 @@ namespace StyleCop.Analyzers.Helpers using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; + using StyleCop.Analyzers.Lightup; + internal static class NamedTypeHelpers { internal static bool IsNativeMethodsClass(INamedTypeSymbol type) @@ -84,6 +88,8 @@ internal static string GetNameOrIdentifier(MemberDeclarationSyntax member) case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.StructDeclaration: + case SyntaxKindEx.RecordDeclaration: + case SyntaxKindEx.RecordStructDeclaration: return ((TypeDeclarationSyntax)member).Identifier.Text; case SyntaxKind.EnumDeclaration: @@ -139,11 +145,6 @@ internal static bool IsPartialDeclaration(MemberDeclarationSyntax declaration) /// true if the member is implementing an interface member, otherwise false. internal static bool IsImplementingAnInterfaceMember(ISymbol memberSymbol) { - if (memberSymbol.IsStatic) - { - return false; - } - bool isImplementingExplicitly; // Only methods, properties and events can implement an interface member @@ -179,5 +180,8 @@ internal static bool IsImplementingAnInterfaceMember(ISymbol memberSymbol) .Select(typeSymbol.FindImplementationForInterfaceMember) .Any(x => memberSymbol.Equals(x)); } + + internal static INamedTypeSymbol TupleUnderlyingTypeOrSelf(this INamedTypeSymbol tupleSymbol) + => tupleSymbol.TupleUnderlyingType() ?? tupleSymbol; } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ObjectPools/ObjectPool`1.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ObjectPools/ObjectPool`1.cs index b415b8b8c..54f373c0f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ObjectPools/ObjectPool`1.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ObjectPools/ObjectPool`1.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers.ObjectPools { @@ -41,7 +43,9 @@ internal class ObjectPool private T firstItem; internal ObjectPool(Func factory) +#pragma warning disable RS1035 // Do not use APIs banned for analyzers (false positive: https://github.com/dotnet/roslyn-analyzers/issues/6571) : this(factory, Environment.ProcessorCount * 2) +#pragma warning restore RS1035 // Do not use APIs banned for analyzers { } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ObjectPools/PooledObject`1.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ObjectPools/PooledObject`1.cs index aa9bb6f8d..3bc8b0822 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ObjectPools/PooledObject`1.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ObjectPools/PooledObject`1.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers.ObjectPools { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ObjectPools/SharedPoolExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ObjectPools/SharedPoolExtensions.cs index 5afd9dfc3..47dcd6be8 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ObjectPools/SharedPoolExtensions.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ObjectPools/SharedPoolExtensions.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers.ObjectPools { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ObjectPools/SharedPools.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ObjectPools/SharedPools.cs index 928fd4739..5b6e51cb5 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ObjectPools/SharedPools.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ObjectPools/SharedPools.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers.ObjectPools { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ObjectPools/StringBuilderPool.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ObjectPools/StringBuilderPool.cs index 21cfd5e86..9deabc35f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ObjectPools/StringBuilderPool.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/ObjectPools/StringBuilderPool.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers.ObjectPools { @@ -20,8 +22,11 @@ public static void Free(StringBuilder builder) public static string ReturnAndFree(StringBuilder builder) { - SharedPools.Default(); - return builder.ToString(); + string result = builder.ToString(); + + StringBuilderPool.Free(builder); + + return result; } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/Requires.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/Requires.cs index efa9f876d..6a64e1f3f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/Requires.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/Requires.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SpacingExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SpacingExtensions.cs index 4f94bbdcf..edc9371b2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SpacingExtensions.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SpacingExtensions.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/SpecialTypeHelper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SpecialTypeHelper.cs similarity index 96% rename from StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/SpecialTypeHelper.cs rename to StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SpecialTypeHelper.cs index 99c793374..7248057b3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/Helpers/SpecialTypeHelper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SpecialTypeHelper.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SpecializedTasks.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SpecializedTasks.cs index 127775b06..4253b4768 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SpecializedTasks.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SpecializedTasks.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SymbolNameHelpers.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SymbolNameHelpers.cs new file mode 100644 index 000000000..983138beb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SymbolNameHelpers.cs @@ -0,0 +1,242 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Helpers +{ + using System.Text; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + using StyleCop.Analyzers.Lightup; + + /// + /// Contains helper methods to work with symbol names consistently over different C# versions. + /// + internal static class SymbolNameHelpers + { + private const string GenericTypeParametersOpen = "<"; + private const string GenericTypeParametersClose = ">"; + private const string GenericSeparator = ", "; + + private const string TupleTypeOpen = "("; + private const string TupleTypeClose = ")"; + private const string TupleElementSeparator = ", "; + + /// + /// Generates the qualified name for the given symbol. + /// + /// The symbol to use. + /// The syntax node which resolves to the symbol. + /// The generated qualified name. + public static string ToQualifiedString(this ISymbol symbol, NameSyntax name) + { + var builder = ObjectPools.StringBuilderPool.Allocate(); + AppendQualifiedSymbolName(builder, symbol, name); + return ObjectPools.StringBuilderPool.ReturnAndFree(builder); + } + + /// + /// Generates the fully qualified System.ValueTuple based name for the given tuple type. + /// + /// The tuple symbol. + /// The generated fully qualified display string. + public static string ToFullyQualifiedValueTupleDisplayString(this INamedTypeSymbol tupleSymbol) + { + var tupleElements = tupleSymbol.TupleElements(); + if (tupleElements.IsDefault) + { + // If the tuple elements API is not available, the default formatting will produce System.ValueTuple and not the C# tuple format. + return tupleSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); + } + else + { + // workaround for SymbolDisplayCompilerInternalOptions.UseValueTuple not being available to us. + var builder = ObjectPools.StringBuilderPool.Allocate(); + + builder.Append("global::System.ValueTuple<"); + + for (var i = 0; i < tupleElements.Length; i++) + { + if (i > 0) + { + builder.Append(", "); + } + + builder.Append(tupleElements[i].Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + } + + builder.Append(">"); + + return ObjectPools.StringBuilderPool.ReturnAndFree(builder); + } + } + + private static bool AppendQualifiedSymbolName(StringBuilder builder, ISymbol symbol, TypeSyntax type) + { + switch (symbol.Kind) + { + case SymbolKind.ArrayType: + var arraySymbol = (IArrayTypeSymbol)symbol; + AppendQualifiedSymbolName(builder, arraySymbol.ElementType, GetElementSyntax(type)); + builder + .Append("[") + .Append(',', arraySymbol.Rank - 1) + .Append("]"); + + AppendNullableSuffixIfNeeded(builder, type); + return true; + + case SymbolKind.Namespace: + var namespaceSymbol = (INamespaceSymbol)symbol; + if (namespaceSymbol.IsGlobalNamespace) + { + return false; + } + + builder.Append(namespaceSymbol.ToDisplayString()); + return true; + + case SymbolKind.NamedType: + var namedTypeSymbol = (INamedTypeSymbol)symbol; + + if (SpecialTypeHelper.TryGetPredefinedType(namedTypeSymbol.SpecialType, out var specialTypeSyntax) && + (type?.IsKind(SyntaxKind.PredefinedType) == true + || (type is NullableTypeSyntax nullable && nullable.ElementType.IsKind(SyntaxKind.PredefinedType)))) + { + // This handles these cases: int, int?, object, object? + // But not these cases: System.Int32, System.Int32?, System.Object, System.Object? + builder.Append(specialTypeSyntax.ToFullString()); + AppendNullableSuffixIfNeeded(builder, type); + return true; + } + else if (namedTypeSymbol.IsTupleType()) + { + return AppendTupleType(builder, namedTypeSymbol, type); + } + else if (namedTypeSymbol.OriginalDefinition.SpecialType == SpecialType.System_Nullable_T && + type?.IsKind(SyntaxKind.NullableType) == true) + { + // This handles the case '(int, int)?' but not 'System.Nullable<(int, int)>' + AppendQualifiedSymbolName(builder, namedTypeSymbol.TypeArguments[0], GetElementSyntax(type)); + builder.Append("?"); + return true; + } + else + { + return AppendNamedType(builder, namedTypeSymbol, type); + } + + default: + if (symbol != null) + { + builder.Append(symbol.Name); + return true; + } + + return false; + } + } + + private static bool AppendNamedType(StringBuilder builder, INamedTypeSymbol namedTypeSymbol, TypeSyntax type) + { + if (AppendQualifiedSymbolName(builder, namedTypeSymbol.ContainingSymbol, (type as QualifiedNameSyntax)?.Left)) + { + builder.Append("."); + } + + builder.Append(namedTypeSymbol.Name); + if (namedTypeSymbol.IsGenericType && !namedTypeSymbol.TypeArguments.IsEmpty) + { + builder.Append(GenericTypeParametersOpen); + var arguments = namedTypeSymbol.TypeArguments; + var argumentTypes = type is QualifiedNameSyntax qualifiedName + ? (qualifiedName.Right as GenericNameSyntax)?.TypeArgumentList + : (type as GenericNameSyntax)?.TypeArgumentList; + + for (int i = 0; i < arguments.Length; i++) + { + var argument = arguments[i]; + var argumentType = argumentTypes != null && argumentTypes.Arguments.Count > i ? argumentTypes.Arguments[i] : null; + + if (i > 0) + { + builder.Append(GenericSeparator); + } + + if (!argumentType.IsKind(SyntaxKind.OmittedTypeArgument)) + { + AppendQualifiedSymbolName(builder, argument, argumentType); + } + } + + builder.Append(GenericTypeParametersClose); + } + + AppendNullableSuffixIfNeeded(builder, type); + return true; + } + + private static bool AppendTupleType(StringBuilder builder, INamedTypeSymbol namedTypeSymbol, TypeSyntax type) + { + if (TupleTypeSyntaxWrapper.IsInstance(type)) + { + var tupleType = (TupleTypeSyntaxWrapper)type; + + builder.Append(TupleTypeOpen); + var elements = namedTypeSymbol.TupleElements(); + for (int i = 0; i < elements.Length; i++) + { + var field = elements[i]; + var fieldType = tupleType.Elements.Count > i ? tupleType.Elements[i] : default; + + if (i > 0) + { + builder.Append(TupleElementSeparator); + } + + AppendQualifiedSymbolName(builder, field.Type, fieldType.Type); + if (!Equals(field, field.CorrespondingTupleField())) + { + builder.Append(" ").Append(field.Name); + } + } + + builder.Append(TupleTypeClose); + AppendNullableSuffixIfNeeded(builder, type); + return true; + } + else + { + return AppendNamedType(builder, namedTypeSymbol.TupleUnderlyingTypeOrSelf(), type); + } + } + + private static TypeSyntax GetElementSyntax(TypeSyntax typeSyntax) + { + return typeSyntax switch + { + ArrayTypeSyntax array => array.ElementType, + + NullableTypeSyntax nullable => + nullable.ElementType switch + { + ArrayTypeSyntax array => array.ElementType, + _ => nullable.ElementType, + }, + + _ => null, + }; + } + + private static void AppendNullableSuffixIfNeeded(StringBuilder builder, TypeSyntax type) + { + if (type?.IsKind(SyntaxKind.NullableType) == true) + { + builder.Append("?"); + } + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SyntaxKinds.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SyntaxKinds.cs index f2738a8c1..221b34bf3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SyntaxKinds.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SyntaxKinds.cs @@ -1,14 +1,30 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { using System.Collections.Immutable; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; + using StyleCop.Analyzers.Lightup; internal static class SyntaxKinds { + /// + /// Gets a collection of values which appear in the syntax tree as a + /// . + /// + /// + /// A collection of values which appear in the syntax tree as a + /// . + /// + public static ImmutableArray BaseNamespaceDeclaration { get; } = + ImmutableArray.Create( + SyntaxKind.NamespaceDeclaration, + SyntaxKindEx.FileScopedNamespaceDeclaration); + /// /// Gets a collection of values which appear in the syntax tree as a /// . @@ -22,7 +38,9 @@ internal static class SyntaxKinds SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.InterfaceDeclaration, - SyntaxKind.EnumDeclaration); + SyntaxKind.EnumDeclaration, + SyntaxKindEx.RecordDeclaration, + SyntaxKindEx.RecordStructDeclaration); /// /// Gets a collection of values which appear in the syntax tree as a @@ -36,7 +54,9 @@ internal static class SyntaxKinds ImmutableArray.Create( SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, - SyntaxKind.InterfaceDeclaration); + SyntaxKind.InterfaceDeclaration, + SyntaxKindEx.RecordDeclaration, + SyntaxKindEx.RecordStructDeclaration); /// /// Gets a collection of values which appear in the syntax tree as a diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SyntaxNodeExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SyntaxNodeExtensions.cs new file mode 100644 index 000000000..85006923a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SyntaxNodeExtensions.cs @@ -0,0 +1,90 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Helpers +{ + using System.Threading; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal static class SyntaxNodeExtensions + { + public static bool IsInExpressionTree( + this SyntaxNode? node, + SemanticModel semanticModel, + INamedTypeSymbol? expressionType, + CancellationToken cancellationToken) + { + if (expressionType != null) + { + for (var current = node; current != null; current = current.Parent) + { + if (current.IsAnyLambda()) + { + var typeInfo = semanticModel.GetTypeInfo(current, cancellationToken); + if (expressionType.Equals(typeInfo.ConvertedType?.OriginalDefinition)) + { + return true; + } + } + else if (current is SelectOrGroupClauseSyntax or OrderingSyntax) + { + var info = semanticModel.GetSymbolInfo(current, cancellationToken); + if (AnyTakesExpressionTree(info, expressionType)) + { + return true; + } + } + else if (current is QueryClauseSyntax queryClause) + { + var info = semanticModel.GetQueryClauseInfo(queryClause, cancellationToken); + if (AnyTakesExpressionTree(info.CastInfo, expressionType) + || AnyTakesExpressionTree(info.OperationInfo, expressionType)) + { + return true; + } + } + } + } + + return false; + + static bool AnyTakesExpressionTree(SymbolInfo info, INamedTypeSymbol expressionType) + { + if (TakesExpressionTree(info.Symbol, expressionType)) + { + return true; + } + + foreach (var symbol in info.CandidateSymbols) + { + if (TakesExpressionTree(symbol, expressionType)) + { + return true; + } + } + + return false; + } + + static bool TakesExpressionTree(ISymbol symbol, INamedTypeSymbol expressionType) + { + if (symbol is IMethodSymbol method + && method.Parameters.Length > 0 + && expressionType.Equals(method.Parameters[0].Type?.OriginalDefinition)) + { + return true; + } + + return false; + } + } + + public static bool IsAnyLambda(this SyntaxNode? node) + { + return node.IsKind(SyntaxKind.ParenthesizedLambdaExpression) + || node.IsKind(SyntaxKind.SimpleLambdaExpression); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SyntaxTreeHelpers.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SyntaxTreeHelpers.cs index 91f666406..c917df7a5 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SyntaxTreeHelpers.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/SyntaxTreeHelpers.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { @@ -10,6 +12,7 @@ namespace StyleCop.Analyzers.Helpers using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; + using StyleCop.Analyzers.Lightup; internal static class SyntaxTreeHelpers { @@ -89,7 +92,7 @@ internal static bool ContainsUsingAlias(this SyntaxTree tree, ConcurrentDictiona private static bool ContainsUsingAliasNoCache(SyntaxTree tree) { - var nodes = tree.GetRoot().DescendantNodes(node => node.IsKind(SyntaxKind.CompilationUnit) || node.IsKind(SyntaxKind.NamespaceDeclaration)); + var nodes = tree.GetRoot().DescendantNodes(node => node.IsKind(SyntaxKind.CompilationUnit) || node.IsKind(SyntaxKind.NamespaceDeclaration) || node.IsKind(SyntaxKindEx.FileScopedNamespaceDeclaration)); return nodes.OfType().Any(x => x.Alias != null); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/TokenHelper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/TokenHelper.cs index 897a57681..9df1e5739 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/TokenHelper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/TokenHelper.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { @@ -173,5 +175,35 @@ internal static bool IsFollowedByWhitespace(this SyntaxToken token) triviaList = token.GetNextToken().LeadingTrivia; return triviaList.Count > 0 && triviaList.First().IsKind(SyntaxKind.WhitespaceTrivia); } + + /// + /// Returns the closest end of line trivia preceding the . + /// This currently only looks immediately before the specified token. + /// + /// The token to process. + /// The closest preceding end of line trivia, or if none is found. + internal static SyntaxTrivia GetPrecedingEndOfLineTrivia(this SyntaxToken token) + { + var leadingTrivia = token.LeadingTrivia; + for (var i = leadingTrivia.Count - 1; i >= 0; i--) + { + if (leadingTrivia[i].IsKind(SyntaxKind.EndOfLineTrivia)) + { + return leadingTrivia[i]; + } + } + + var prevToken = token.GetPreviousToken(); + var prevTrailingTrivia = prevToken.TrailingTrivia; + for (var i = prevTrailingTrivia.Count - 1; i >= 0; i--) + { + if (prevTrailingTrivia[i].IsKind(SyntaxKind.EndOfLineTrivia)) + { + return prevTrailingTrivia[i]; + } + } + + return SyntaxFactory.CarriageReturnLineFeed; + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/TriviaHelper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/TriviaHelper.cs index 09e1b6796..5563cd920 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/TriviaHelper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/TriviaHelper.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/TypeSyntaxHelper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/TypeSyntaxHelper.cs index 36675716d..54ebaade2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/TypeSyntaxHelper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/TypeSyntaxHelper.cs @@ -1,8 +1,11 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using StyleCop.Analyzers.Lightup; @@ -55,5 +58,15 @@ public static bool IsReturnType(this TypeSyntax syntax) return false; } } + + public static TypeSyntax StripRefFromType(this TypeSyntax syntax) + { + if (syntax.IsKind(SyntaxKindEx.RefType)) + { + syntax = ((RefTypeSyntaxWrapper)syntax).Type; + } + + return syntax; + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/UsingDirectiveSyntaxHelpers.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/UsingDirectiveSyntaxHelpers.cs index 497911203..7a35d4a38 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/UsingDirectiveSyntaxHelpers.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/UsingDirectiveSyntaxHelpers.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/UsingGroup.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/UsingGroup.cs index 215e9e82a..0e5219a32 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/UsingGroup.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/UsingGroup.cs @@ -1,5 +1,5 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Helpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/XPathExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/XPathExtensions.cs index 2b5bc720f..2c1fc6772 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/XPathExtensions.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/XPathExtensions.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/XmlCommentHelper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/XmlCommentHelper.cs index 2c1b3535e..24d2728d1 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/XmlCommentHelper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/XmlCommentHelper.cs @@ -1,11 +1,12 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { using System.Linq; using System.Text; - using System.Text.RegularExpressions; using System.Xml.Linq; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -122,18 +123,13 @@ internal static bool IsConsideredEmpty(XmlNodeSyntax xmlSyntax, bool considerEmp return true; } - if (xmlSyntax is XmlEmptyElementSyntax emptyElement) + if (xmlSyntax is XmlEmptyElementSyntax) { // This includes return considerEmptyElements; } - if (xmlSyntax is XmlProcessingInstructionSyntax processingElement) - { - return false; - } - - return true; + return !(xmlSyntax is XmlProcessingInstructionSyntax); } /// @@ -162,12 +158,69 @@ internal static bool IsConsideredEmpty(XNode node) return true; } - if (node is XProcessingInstruction processingElement) + return !(node is XProcessingInstruction); + } + + /// + /// Returns the first which is not simply empty or whitespace. + /// + /// The XML content to search. + /// The first which is not simply empty or whitespace, or + /// if no such element exists. + internal static XmlTextSyntax TryGetFirstTextElementWithContent(XmlNodeSyntax node) + { + if (node is XmlEmptyElementSyntax) { - return false; + return null; + } + else if (node is XmlTextSyntax xmlText) + { + return !IsConsideredEmpty(node) ? xmlText : null; + } + else if (node is XmlElementSyntax xmlElement) + { + foreach (var child in xmlElement.Content) + { + var nestedContent = TryGetFirstTextElementWithContent(child); + if (nestedContent != null) + { + return nestedContent; + } + } } - return true; + return null; + } + + /// + /// Returns the last which is not simply empty or whitespace. + /// + /// The XML content to search. + /// The last which is not simply empty or whitespace, or + /// if no such element exists. + internal static XmlTextSyntax TryGetLastTextElementWithContent(XmlNodeSyntax node) + { + if (node is XmlEmptyElementSyntax) + { + return null; + } + else if (node is XmlTextSyntax xmlText) + { + return !IsConsideredEmpty(node) ? xmlText : null; + } + else if (node is XmlElementSyntax xmlElement) + { + for (var i = xmlElement.Content.Count - 1; i >= 0; i--) + { + var nestedContent = TryGetFirstTextElementWithContent(xmlElement.Content[i]); + if (nestedContent != null) + { + return nestedContent; + } + } + } + + return null; } /// @@ -245,20 +298,101 @@ internal static string GetText(XmlTextSyntax textElement, bool normalizeWhitespa return null; } - StringBuilder stringBuilder = StringBuilderPool.Allocate(); + bool lastWhitespace = false; + + string single = string.Empty; + + StringBuilder stringBuilder = null; foreach (var item in textElement.TextTokens) { - stringBuilder.Append(item); + if (single.Length == 0) + { + single = item.ToString(); + } + else + { + if (stringBuilder == null) + { + stringBuilder = StringBuilderPool.Allocate(); + stringBuilder.AppendNormalize(single, normalizeWhitespace, ref lastWhitespace); + } + + stringBuilder.AppendNormalize(item.ToString(), normalizeWhitespace, ref lastWhitespace); + } + } + + if (stringBuilder == null) + { + if (normalizeWhitespace) + { + stringBuilder = StringBuilderPool.Allocate(); + + if (!stringBuilder.AppendNormalize(single, normalizeWhitespace, ref lastWhitespace)) + { + StringBuilderPool.Free(stringBuilder); + + // No change is needed, return original string. + return single; + } + } + else + { + return single; + } } - string result = StringBuilderPool.ReturnAndFree(stringBuilder); + return StringBuilderPool.ReturnAndFree(stringBuilder); + } + + /// + /// Append to StringBuilder and perform white space normalization. + /// + /// StringBuilder to append to. + /// String to append. + /// Normalize flag. + /// last char is white space flag. + /// True if output is different. + internal static bool AppendNormalize(this StringBuilder builder, string text, bool normalizeWhitespace, ref bool lastWhitespace) + { + bool diff = false; + if (normalizeWhitespace) { - result = Regex.Replace(result, @"\s+", " "); + foreach (char ch in text) + { + if (char.IsWhiteSpace(ch)) + { + if (lastWhitespace) + { + diff = true; + } + else + { + if (ch != ' ') + { + diff = true; + } + + builder.Append(' '); + } + + lastWhitespace = true; + } + else + { + builder.Append(ch); + + lastWhitespace = false; + } + } + } + else + { + builder.Append(text); } - return result; + return diff; } internal static T GetFirstAttributeOrDefault(XmlNodeSyntax nodeSyntax) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/XmlFileHeader.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/XmlFileHeader.cs index da2300f24..d805d31bd 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/XmlFileHeader.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/XmlFileHeader.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/XmlSyntaxFactory.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/XmlSyntaxFactory.cs index 0fb3aac53..cf0b228e7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/XmlSyntaxFactory.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Helpers/XmlSyntaxFactory.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Helpers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/LayoutResources.Designer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/LayoutResources.Designer.cs deleted file mode 100644 index 33430040c..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/LayoutResources.Designer.cs +++ /dev/null @@ -1,424 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace StyleCop.Analyzers.LayoutRules { - using System; - using System.Reflection; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class LayoutResources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal LayoutResources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StyleCop.Analyzers.LayoutRules.LayoutResources", typeof(LayoutResources).GetTypeInfo().Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Align braces. - /// - internal static string SA1500CodeFix { - get { - return ResourceManager.GetString("SA1500CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expand single line block. - /// - internal static string SA1501CodeFix { - get { - return ResourceManager.GetString("SA1501CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expand all single line blocks. - /// - internal static string SA1501CodeFixAll { - get { - return ResourceManager.GetString("SA1501CodeFixAll", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Expand element. - /// - internal static string SA1502CodeFix { - get { - return ResourceManager.GetString("SA1502CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A C# element containing opening and closing braces is written completely on a single line.. - /// - internal static string SA1502Description { - get { - return ResourceManager.GetString("SA1502Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Element should not be on a single line. - /// - internal static string SA1502MessageFormat { - get { - return ResourceManager.GetString("SA1502MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Element should not be on a single line. - /// - internal static string SA1502Title { - get { - return ResourceManager.GetString("SA1502Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Wrap with braces. - /// - internal static string SA1503CodeFix { - get { - return ResourceManager.GetString("SA1503CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Reformat accessors to multiple lines style. - /// - internal static string SA1504CodeFixMultipleLines { - get { - return ResourceManager.GetString("SA1504CodeFixMultipleLines", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Reformat accessors to single line style. - /// - internal static string SA1504CodeFixSingleLine { - get { - return ResourceManager.GetString("SA1504CodeFixSingleLine", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove blank lines following this brace. - /// - internal static string SA1505CodeFix { - get { - return ResourceManager.GetString("SA1505CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove blank line(s) after documentation header. - /// - internal static string SA1506CodeFix { - get { - return ResourceManager.GetString("SA1506CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove multiple blank lines. - /// - internal static string SA1507CodeFix { - get { - return ResourceManager.GetString("SA1507CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove blank lines preceding this brace. - /// - internal static string SA1508CodeFix { - get { - return ResourceManager.GetString("SA1508CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove blank lines preceding this brace. - /// - internal static string SA1509CodeFix { - get { - return ResourceManager.GetString("SA1509CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove blank line before chained statement. - /// - internal static string SA1510CodeFix { - get { - return ResourceManager.GetString("SA1510CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove blank line before while. - /// - internal static string SA1511CodeFix { - get { - return ResourceManager.GetString("SA1511CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove blank line after comment. - /// - internal static string SA1512CodeFix { - get { - return ResourceManager.GetString("SA1512CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Insert blank line after brace. - /// - internal static string SA1513CodeFix { - get { - return ResourceManager.GetString("SA1513CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Insert blank line before documentation header. - /// - internal static string SA1514CodeFix { - get { - return ResourceManager.GetString("SA1514CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Insert blank line before comment. - /// - internal static string SA1515CodeFix { - get { - return ResourceManager.GetString("SA1515CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Fix blank lines. - /// - internal static string SA1516CodeFixAll { - get { - return ResourceManager.GetString("SA1516CodeFixAll", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Insert new line. - /// - internal static string SA1516CodeFixInsert { - get { - return ResourceManager.GetString("SA1516CodeFixInsert", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove blank line. - /// - internal static string SA1516CodeFixRemove { - get { - return ResourceManager.GetString("SA1516CodeFixRemove", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Adjacent C# elements are not separated by a blank line.. - /// - internal static string SA1516Description { - get { - return ResourceManager.GetString("SA1516Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Adjacent using directives should not be separated by a blank line.. - /// - internal static string SA1516DescriptionOmit { - get { - return ResourceManager.GetString("SA1516DescriptionOmit", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Adjacent using directives should be separated by a blank line.. - /// - internal static string SA1516DescriptionRequire { - get { - return ResourceManager.GetString("SA1516DescriptionRequire", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Elements should be separated by blank line. - /// - internal static string SA1516MessageFormat { - get { - return ResourceManager.GetString("SA1516MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Using directives should not be separated by blank line. - /// - internal static string SA1516MessageFormatOmit { - get { - return ResourceManager.GetString("SA1516MessageFormatOmit", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Using directives should be separated by blank line. - /// - internal static string SA1516MessageFormatRequire { - get { - return ResourceManager.GetString("SA1516MessageFormatRequire", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Elements should be separated by blank line. - /// - internal static string SA1516Title { - get { - return ResourceManager.GetString("SA1516Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove blank lines at the start of the file. - /// - internal static string SA1517CodeFix { - get { - return ResourceManager.GetString("SA1517CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Fix whitespace at the end of the file. - /// - internal static string SA1518CodeFix { - get { - return ResourceManager.GetString("SA1518CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Code should not contain blank lines at the end of the file. - /// - internal static string SA1518DescriptionAllow { - get { - return ResourceManager.GetString("SA1518DescriptionAllow", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File may not end with a newline character. - /// - internal static string SA1518DescriptionOmit { - get { - return ResourceManager.GetString("SA1518DescriptionOmit", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File is required to end with a single newline character. - /// - internal static string SA1518DescriptionRequire { - get { - return ResourceManager.GetString("SA1518DescriptionRequire", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Code should not contain blank lines at the end of the file. - /// - internal static string SA1518MessageFormatAllow { - get { - return ResourceManager.GetString("SA1518MessageFormatAllow", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File may not end with a newline character. - /// - internal static string SA1518MessageFormatOmit { - get { - return ResourceManager.GetString("SA1518MessageFormatOmit", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to File is required to end with a single newline character. - /// - internal static string SA1518MessageFormatRequire { - get { - return ResourceManager.GetString("SA1518MessageFormatRequire", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use line endings correctly at end of file. - /// - internal static string SA1518Title { - get { - return ResourceManager.GetString("SA1518Title", resourceCulture); - } - } - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/LayoutResources.resx b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/LayoutResources.resx index e0387537b..a3c0124a9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/LayoutResources.resx +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/LayoutResources.resx @@ -120,12 +120,30 @@ Align braces + + The opening or closing brace within a C# statement, element, or expression is not placed on its own line. + + + Braces for multi-line statements should not share line + + + Braces for multi-line statements should not share line + Expand single line block Expand all single line blocks + + A C# statement containing opening and closing braces is written completely on a single line. + + + Statement should not be on a single line + + + Statement should not be on a single line + Expand element @@ -141,45 +159,162 @@ Wrap with braces + + The opening and closing braces for a C# statement have been omitted. + + + Braces should not be omitted + + + Braces should not be omitted + Reformat accessors to multiple lines style Reformat accessors to single line style + + Within a C# property, indexer or event, at least one of the child accessors is written on a single line, and at least one of the child accessors is written across multiple lines. + + + All accessors should be single-line or multi-line + + + All accessors should be single-line or multi-line + Remove blank lines following this brace + + An opening brace within a C# element, statement, or expression is followed by a blank line. + + + An opening brace should not be followed by a blank line + + + Opening braces should not be followed by blank line + Remove blank line(s) after documentation header + + An element documentation header above a C# element is followed by a blank line. + + + Element documentation headers should not be followed by blank line + + + Element documentation headers should not be followed by blank line + Remove multiple blank lines + + The C# code contains multiple blank lines in a row. + + + Code should not contain multiple blank lines in a row + + + Code should not contain multiple blank lines in a row + Remove blank lines preceding this brace + + A closing brace within a C# element, statement, or expression is preceded by a blank line. + + + A closing brace should not be preceded by a blank line + + + Closing braces should not be preceded by blank line + Remove blank lines preceding this brace + + An opening brace within a C# element, statement, or expression is preceded by a blank line. + + + Opening braces should not be preceded by blank line + + + Opening braces should not be preceded by blank line + Remove blank line before chained statement + + Chained C# statements are separated by a blank line. + + + '{0}' statement should not be preceded by a blank line + + + Chained statement blocks should not be preceded by blank line + Remove blank line before while + + The while footer at the bottom of a do-while statement is separated from the statement by a blank line. + + + While-do footer should not be preceded by blank line + + + While-do footer should not be preceded by blank line + Remove blank line after comment + + A single-line comment within C# code is followed by a blank line. + + + Single-line comments should not be followed by blank line + + + Single-line comments should not be followed by blank line + Insert blank line after brace + + A closing brace within a C# element, statement, or expression is not followed by a blank line. + + + Closing brace should be followed by blank line + + + Closing brace should be followed by blank line + Insert blank line before documentation header + + An element documentation header above a C# element is not preceded by a blank line. + + + Element documentation header should be preceded by blank line + + + Element documentation header should be preceded by blank line + Insert blank line before comment + + A single-line comment within C# code is not preceded by a blank line. + + + Single-line comment should be preceded by blank line + + + Single-line comment should be preceded by blank line + Fix blank lines @@ -213,17 +348,26 @@ Remove blank lines at the start of the file + + The code file has blank lines at the start. + + + Code should not contain blank lines at start of file + + + Code should not contain blank lines at start of file + Fix whitespace at the end of the file - Code should not contain blank lines at the end of the file + Code should not contain blank lines at the end of the file. - File may not end with a newline character + File may not end with a newline character. - File is required to end with a single newline character + File is required to end with a single newline character. Code should not contain blank lines at the end of the file @@ -237,4 +381,22 @@ Use line endings correctly at end of file + + The opening and closing braces for a multi-line C# statement have been omitted. + + + Braces should not be omitted from multi-line child statement + + + Braces should not be omitted from multi-line child statement + + + The opening and closing braces of a chained if/else if/else construct were included for some clauses, but omitted for others. + + + Use braces consistently + + + Use braces consistently + \ No newline at end of file diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1500BracesForMultiLineStatementsMustNotShareLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1500BracesForMultiLineStatementsMustNotShareLine.cs index 85238cc89..dee2b8846 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1500BracesForMultiLineStatementsMustNotShareLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1500BracesForMultiLineStatementsMustNotShareLine.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -10,6 +12,8 @@ namespace StyleCop.Analyzers.LayoutRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; + using StyleCop.Analyzers.Settings.ObjectModel; /// /// The opening or closing brace within a C# statement, element, or expression is not placed on its own line. @@ -60,21 +64,21 @@ internal class SA1500BracesForMultiLineStatementsMustNotShareLine : DiagnosticAn /// analyzer. /// public const string DiagnosticId = "SA1500"; - private const string Title = "Braces for multi-line statements should not share line"; - private const string MessageFormat = "Braces for multi-line statements should not share line"; - private const string Description = "The opening or closing brace within a C# statement, element, or expression is not placed on its own line."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1500.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(LayoutResources.SA1500Title), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(LayoutResources.SA1500MessageFormat), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(LayoutResources.SA1500Description), LayoutResources.ResourceManager, typeof(LayoutResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.LayoutRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); - private static readonly Action NamespaceDeclarationAction = HandleNamespaceDeclaration; - private static readonly Action BaseTypeDeclarationAction = HandleBaseTypeDeclaration; - private static readonly Action AccessorListAction = HandleAccessorList; - private static readonly Action BlockAction = HandleBlock; - private static readonly Action SwitchStatementAction = HandleSwitchStatement; - private static readonly Action InitializerExpressionAction = HandleInitializerExpression; - private static readonly Action AnonymousObjectCreationExpressionAction = HandleAnonymousObjectCreationExpression; + private static readonly Action NamespaceDeclarationAction = HandleNamespaceDeclaration; + private static readonly Action BaseTypeDeclarationAction = HandleBaseTypeDeclaration; + private static readonly Action AccessorListAction = HandleAccessorList; + private static readonly Action BlockAction = HandleBlock; + private static readonly Action SwitchStatementAction = HandleSwitchStatement; + private static readonly Action InitializerExpressionAction = HandleInitializerExpression; + private static readonly Action AnonymousObjectCreationExpressionAction = HandleAnonymousObjectCreationExpression; /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -86,59 +90,67 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(NamespaceDeclarationAction, SyntaxKind.NamespaceDeclaration); - context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKinds.BaseTypeDeclaration); - context.RegisterSyntaxNodeAction(AccessorListAction, SyntaxKind.AccessorList); - context.RegisterSyntaxNodeAction(BlockAction, SyntaxKind.Block); - context.RegisterSyntaxNodeAction(SwitchStatementAction, SyntaxKind.SwitchStatement); - context.RegisterSyntaxNodeAction(InitializerExpressionAction, SyntaxKinds.InitializerExpression); - context.RegisterSyntaxNodeAction(AnonymousObjectCreationExpressionAction, SyntaxKind.AnonymousObjectCreationExpression); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(NamespaceDeclarationAction, SyntaxKind.NamespaceDeclaration); + context.RegisterSyntaxNodeAction(BaseTypeDeclarationAction, SyntaxKinds.BaseTypeDeclaration); + context.RegisterSyntaxNodeAction(AccessorListAction, SyntaxKind.AccessorList); + context.RegisterSyntaxNodeAction(BlockAction, SyntaxKind.Block); + context.RegisterSyntaxNodeAction(SwitchStatementAction, SyntaxKind.SwitchStatement); + context.RegisterSyntaxNodeAction(InitializerExpressionAction, SyntaxKinds.InitializerExpression); + context.RegisterSyntaxNodeAction(AnonymousObjectCreationExpressionAction, SyntaxKind.AnonymousObjectCreationExpression); + }); } - private static void HandleNamespaceDeclaration(SyntaxNodeAnalysisContext context) + private static void HandleNamespaceDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) { var syntax = (NamespaceDeclarationSyntax)context.Node; - CheckBraces(context, syntax.OpenBraceToken, syntax.CloseBraceToken); + CheckBraces(context, settings, syntax.OpenBraceToken, syntax.CloseBraceToken); } - private static void HandleBaseTypeDeclaration(SyntaxNodeAnalysisContext context) + private static void HandleBaseTypeDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) { var syntax = (BaseTypeDeclarationSyntax)context.Node; - CheckBraces(context, syntax.OpenBraceToken, syntax.CloseBraceToken); + CheckBraces(context, settings, syntax.OpenBraceToken, syntax.CloseBraceToken); } - private static void HandleAccessorList(SyntaxNodeAnalysisContext context) + private static void HandleAccessorList(SyntaxNodeAnalysisContext context, StyleCopSettings settings) { var syntax = (AccessorListSyntax)context.Node; - CheckBraces(context, syntax.OpenBraceToken, syntax.CloseBraceToken); + CheckBraces(context, settings, syntax.OpenBraceToken, syntax.CloseBraceToken); } - private static void HandleBlock(SyntaxNodeAnalysisContext context) + private static void HandleBlock(SyntaxNodeAnalysisContext context, StyleCopSettings settings) { var syntax = (BlockSyntax)context.Node; - CheckBraces(context, syntax.OpenBraceToken, syntax.CloseBraceToken); + CheckBraces(context, settings, syntax.OpenBraceToken, syntax.CloseBraceToken); } - private static void HandleSwitchStatement(SyntaxNodeAnalysisContext context) + private static void HandleSwitchStatement(SyntaxNodeAnalysisContext context, StyleCopSettings settings) { var syntax = (SwitchStatementSyntax)context.Node; - CheckBraces(context, syntax.OpenBraceToken, syntax.CloseBraceToken); + CheckBraces(context, settings, syntax.OpenBraceToken, syntax.CloseBraceToken); } - private static void HandleInitializerExpression(SyntaxNodeAnalysisContext context) + private static void HandleInitializerExpression(SyntaxNodeAnalysisContext context, StyleCopSettings settings) { var syntax = (InitializerExpressionSyntax)context.Node; - CheckBraces(context, syntax.OpenBraceToken, syntax.CloseBraceToken); + CheckBraces(context, settings, syntax.OpenBraceToken, syntax.CloseBraceToken); } - private static void HandleAnonymousObjectCreationExpression(SyntaxNodeAnalysisContext context) + private static void HandleAnonymousObjectCreationExpression(SyntaxNodeAnalysisContext context, StyleCopSettings settings) { var syntax = (AnonymousObjectCreationExpressionSyntax)context.Node; - CheckBraces(context, syntax.OpenBraceToken, syntax.CloseBraceToken); + CheckBraces(context, settings, syntax.OpenBraceToken, syntax.CloseBraceToken); } - private static void CheckBraces(SyntaxNodeAnalysisContext context, SyntaxToken openBraceToken, SyntaxToken closeBraceToken) + private static void CheckBraces(SyntaxNodeAnalysisContext context, StyleCopSettings settings, SyntaxToken openBraceToken, SyntaxToken closeBraceToken) { + if (openBraceToken.IsKind(SyntaxKind.None) || closeBraceToken.IsKind(SyntaxKind.None)) + { + return; + } + bool checkCloseBrace = true; int openBraceTokenLine = openBraceToken.GetLine(); @@ -172,6 +184,22 @@ private static void CheckBraces(SyntaxNodeAnalysisContext context, SyntaxToken o break; + case SyntaxKind.StackAllocArrayCreationExpression: + if (((StackAllocArrayCreationExpressionSyntax)context.Node.Parent).StackAllocKeyword.GetLine() == openBraceTokenLine) + { + return; + } + + break; + + case SyntaxKindEx.ImplicitStackAllocArrayCreationExpression: + if (((ImplicitStackAllocArrayCreationExpressionSyntaxWrapper)context.Node.Parent).StackAllocKeyword.GetLine() == openBraceTokenLine) + { + return; + } + + break; + case SyntaxKind.ArrayInitializerExpression: if (!InitializerExpressionSharesLine((InitializerExpressionSyntax)context.Node)) { @@ -191,6 +219,7 @@ private static void CheckBraces(SyntaxNodeAnalysisContext context, SyntaxToken o { case SyntaxKind.GetAccessorDeclaration: case SyntaxKind.SetAccessorDeclaration: + case SyntaxKindEx.InitAccessorDeclaration: case SyntaxKind.AddAccessorDeclaration: case SyntaxKind.RemoveAccessorDeclaration: case SyntaxKind.UnknownAccessorDeclaration: @@ -210,10 +239,10 @@ private static void CheckBraces(SyntaxNodeAnalysisContext context, SyntaxToken o } } - CheckBraceToken(context, openBraceToken); + CheckBraceToken(context, settings, openBraceToken); if (checkCloseBrace) { - CheckBraceToken(context, closeBraceToken); + CheckBraceToken(context, settings, closeBraceToken, openBraceToken); } } @@ -225,7 +254,7 @@ private static bool InitializerExpressionSharesLine(InitializerExpressionSyntax return (index > 0) && (parent.Expressions[index - 1].GetEndLine() == parent.Expressions[index].GetLine()); } - private static void CheckBraceToken(SyntaxNodeAnalysisContext context, SyntaxToken token) + private static void CheckBraceToken(SyntaxNodeAnalysisContext context, StyleCopSettings settings, SyntaxToken token, SyntaxToken openBraceToken = default) { if (token.IsMissing) { @@ -262,6 +291,21 @@ private static void CheckBraceToken(SyntaxNodeAnalysisContext context, SyntaxTok // last token of this file return; + case SyntaxKind.WhileKeyword: + // Because the default Visual Studio code completion snippet for a do-while loop + // places the while expression on the same line as the closing brace, some users + // may want to allow that and not have SA1500 report it as a style error. + if (settings.LayoutRules.AllowDoWhileOnClosingBrace) + { + if (openBraceToken.Parent.IsKind(SyntaxKind.Block) + && openBraceToken.Parent.Parent.IsKind(SyntaxKind.DoStatement)) + { + return; + } + } + + break; + default: break; } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1501StatementMustNotBeOnASingleLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1501StatementMustNotBeOnASingleLine.cs index cd50da3a1..9fc629067 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1501StatementMustNotBeOnASingleLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1501StatementMustNotBeOnASingleLine.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -52,10 +54,10 @@ internal class SA1501StatementMustNotBeOnASingleLine : DiagnosticAnalyzer internal const string SuppressCodeFixKey = "SuppressCodeFix"; internal const string SuppressCodeFixValue = "true"; - private const string Title = "Statement should not be on a single line"; - private const string MessageFormat = "Statement should not be on a single line"; - private const string Description = "A C# statement containing opening and closing braces is written completely on a single line."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1501.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(LayoutResources.SA1501Title), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(LayoutResources.SA1501MessageFormat), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(LayoutResources.SA1501Description), LayoutResources.ResourceManager, typeof(LayoutResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.LayoutRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -82,16 +84,16 @@ public override void Initialize(AnalysisContext context) private static void HandleCompilationStart(CompilationStartAnalysisContext context) { // If SA1503 is suppressed, we need to handle compound blocks as well. - if (context.IsAnalyzerSuppressed(SA1503BracesMustNotBeOmitted.DiagnosticId)) + if (context.IsAnalyzerSuppressed(SA1503BracesMustNotBeOmitted.Descriptor)) { context.RegisterSyntaxNodeAction(HandleIfStatement, SyntaxKind.IfStatement); - context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ctx.Node, ((DoStatementSyntax)ctx.Node).Statement), SyntaxKind.DoStatement); - context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ctx.Node, ((WhileStatementSyntax)ctx.Node).Statement), SyntaxKind.WhileStatement); - context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ctx.Node, ((ForStatementSyntax)ctx.Node).Statement), SyntaxKind.ForStatement); - context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ctx.Node, ((ForEachStatementSyntax)ctx.Node).Statement), SyntaxKind.ForEachStatement); - context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ctx.Node, ((LockStatementSyntax)ctx.Node).Statement), SyntaxKind.LockStatement); - context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ctx.Node, ((UsingStatementSyntax)ctx.Node).Statement), SyntaxKind.UsingStatement); - context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ctx.Node, ((FixedStatementSyntax)ctx.Node).Statement), SyntaxKind.FixedStatement); + context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ((DoStatementSyntax)ctx.Node).Statement), SyntaxKind.DoStatement); + context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ((WhileStatementSyntax)ctx.Node).Statement), SyntaxKind.WhileStatement); + context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ((ForStatementSyntax)ctx.Node).Statement), SyntaxKind.ForStatement); + context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ((ForEachStatementSyntax)ctx.Node).Statement), SyntaxKind.ForEachStatement); + context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ((LockStatementSyntax)ctx.Node).Statement), SyntaxKind.LockStatement); + context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ((UsingStatementSyntax)ctx.Node).Statement), SyntaxKind.UsingStatement); + context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ((FixedStatementSyntax)ctx.Node).Statement), SyntaxKind.FixedStatement); } } @@ -146,7 +148,7 @@ private static void HandleIfStatement(SyntaxNodeAnalysisContext context) } } - if (!context.IsAnalyzerSuppressed(SA1520UseBracesConsistently.DiagnosticId)) + if (!context.IsAnalyzerSuppressed(SA1520UseBracesConsistently.Descriptor)) { // inconsistencies will be reported as SA1520, as long as it's not suppressed if (clauses.OfType().Any()) @@ -157,17 +159,11 @@ private static void HandleIfStatement(SyntaxNodeAnalysisContext context) foreach (StatementSyntax clause in clauses) { - SyntaxNode node = clause.Parent; - if (node.IsKind(SyntaxKind.IfStatement) && node.Parent.IsKind(SyntaxKind.ElseClause)) - { - node = node.Parent; - } - - CheckChildStatement(context, node, clause); + CheckChildStatement(context, clause); } } - private static void CheckChildStatement(SyntaxNodeAnalysisContext context, SyntaxNode node, StatementSyntax childStatement) + private static void CheckChildStatement(SyntaxNodeAnalysisContext context, StatementSyntax childStatement) { bool reportAsHidden = false; @@ -190,7 +186,7 @@ private static void CheckChildStatement(SyntaxNodeAnalysisContext context, Synta return; } - if (!context.IsAnalyzerSuppressed(SA1519BracesMustNotBeOmittedFromMultiLineChildStatement.DiagnosticId)) + if (!context.IsAnalyzerSuppressed(SA1519BracesMustNotBeOmittedFromMultiLineChildStatement.Descriptor)) { // diagnostics for multi-line statements is handled by SA1519, as long as it's not suppressed FileLinePositionSpan lineSpan = childStatement.GetLineSpan(); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1502ElementMustNotBeOnASingleLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1502ElementMustNotBeOnASingleLine.cs index d734212c2..5d25d2ebd 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1502ElementMustNotBeOnASingleLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1502ElementMustNotBeOnASingleLine.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -44,10 +46,10 @@ internal class SA1502ElementMustNotBeOnASingleLine : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1502"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1502.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(LayoutResources.SA1502Title), LayoutResources.ResourceManager, typeof(LayoutResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(LayoutResources.SA1502MessageFormat), LayoutResources.ResourceManager, typeof(LayoutResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(LayoutResources.SA1502Description), LayoutResources.ResourceManager, typeof(LayoutResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1502.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.LayoutRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -126,6 +128,11 @@ private static void HandleNamespaceDeclaration(SyntaxNodeAnalysisContext context private static void CheckViolation(SyntaxNodeAnalysisContext context, SyntaxToken openBraceToken, SyntaxToken closeBraceToken) { + if (openBraceToken.IsKind(SyntaxKind.None) || closeBraceToken.IsKind(SyntaxKind.None)) + { + return; + } + var openingBraceLineSpan = openBraceToken.GetLineSpan(); var closingBraceLineSpan = closeBraceToken.GetLineSpan(); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1503BracesMustNotBeOmitted.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1503BracesMustNotBeOmitted.cs index c43fa27cc..d74285bcc 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1503BracesMustNotBeOmitted.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1503BracesMustNotBeOmitted.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -61,13 +63,16 @@ internal class SA1503BracesMustNotBeOmitted : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1503"; - private const string Title = "Braces should not be omitted"; - private const string MessageFormat = "Braces should not be omitted"; - private const string Description = "The opening and closing braces for a C# statement have been omitted."; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1503.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(LayoutResources.SA1503Title), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(LayoutResources.SA1503MessageFormat), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(LayoutResources.SA1503Description), LayoutResources.ResourceManager, typeof(LayoutResources)); - private static readonly DiagnosticDescriptor Descriptor = +#pragma warning disable SA1202 // Elements should be ordered by access + internal static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.LayoutRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); +#pragma warning restore SA1202 // Elements should be ordered by access private static readonly Action IfStatementAction = HandleIfStatement; private static readonly Action UsingStatementAction = HandleUsingStatement; @@ -82,14 +87,17 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(IfStatementAction, SyntaxKind.IfStatement); - context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ((DoStatementSyntax)ctx.Node).Statement), SyntaxKind.DoStatement); - context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ((WhileStatementSyntax)ctx.Node).Statement), SyntaxKind.WhileStatement); - context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ((ForStatementSyntax)ctx.Node).Statement), SyntaxKind.ForStatement); - context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ((ForEachStatementSyntax)ctx.Node).Statement), SyntaxKind.ForEachStatement); - context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ((FixedStatementSyntax)ctx.Node).Statement), SyntaxKind.FixedStatement); - context.RegisterSyntaxNodeAction(UsingStatementAction, SyntaxKind.UsingStatement); - context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ((LockStatementSyntax)ctx.Node).Statement), SyntaxKind.LockStatement); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(IfStatementAction, SyntaxKind.IfStatement); + context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ((DoStatementSyntax)ctx.Node).Statement), SyntaxKind.DoStatement); + context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ((WhileStatementSyntax)ctx.Node).Statement), SyntaxKind.WhileStatement); + context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ((ForStatementSyntax)ctx.Node).Statement), SyntaxKind.ForStatement); + context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ((ForEachStatementSyntax)ctx.Node).Statement), SyntaxKind.ForEachStatement); + context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ((FixedStatementSyntax)ctx.Node).Statement), SyntaxKind.FixedStatement); + context.RegisterSyntaxNodeAction(UsingStatementAction, SyntaxKind.UsingStatement); + context.RegisterSyntaxNodeAction(ctx => CheckChildStatement(ctx, ((LockStatementSyntax)ctx.Node).Statement), SyntaxKind.LockStatement); + }); } private static void HandleIfStatement(SyntaxNodeAnalysisContext context) @@ -111,7 +119,7 @@ private static void HandleIfStatement(SyntaxNodeAnalysisContext context) } } - if (context.SemanticModel.Compilation.Options.SpecificDiagnosticOptions.GetValueOrDefault(SA1520UseBracesConsistently.DiagnosticId, ReportDiagnostic.Default) != ReportDiagnostic.Suppress) + if (!context.IsAnalyzerSuppressed(SA1520UseBracesConsistently.Descriptor)) { // inconsistencies will be reported as SA1520, as long as it's not suppressed if (clauses.OfType().Any()) @@ -144,7 +152,7 @@ private static void CheckChildStatement(SyntaxNodeAnalysisContext context, State return; } - if (context.SemanticModel.Compilation.Options.SpecificDiagnosticOptions.GetValueOrDefault(SA1519BracesMustNotBeOmittedFromMultiLineChildStatement.DiagnosticId, ReportDiagnostic.Default) != ReportDiagnostic.Suppress) + if (!context.IsAnalyzerSuppressed(SA1519BracesMustNotBeOmittedFromMultiLineChildStatement.Descriptor)) { // diagnostics for multi-line statements is handled by SA1519, as long as it's not suppressed FileLinePositionSpan lineSpan = childStatement.GetLineSpan(); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1504AllAccessorsMustBeSingleLineOrMultiLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1504AllAccessorsMustBeSingleLineOrMultiLine.cs index 829823a87..aac92093c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1504AllAccessorsMustBeSingleLineOrMultiLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1504AllAccessorsMustBeSingleLineOrMultiLine.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -67,10 +69,10 @@ internal class SA1504AllAccessorsMustBeSingleLineOrMultiLine : DiagnosticAnalyze /// public const string DiagnosticId = "SA1504"; - private const string Title = "All accessors should be single-line or multi-line"; - private const string MessageFormat = "All accessors should be single-line or multi-line"; - private const string Description = "Within a C# property, indexer or event, at least one of the child accessors is written on a single line, and at least one of the child accessors is written across multiple lines."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1504.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(LayoutResources.SA1504Title), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(LayoutResources.SA1504MessageFormat), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(LayoutResources.SA1504Description), LayoutResources.ResourceManager, typeof(LayoutResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.LayoutRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1505OpeningBracesMustNotBeFollowedByBlankLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1505OpeningBracesMustNotBeFollowedByBlankLine.cs index 7cce8763c..0c912e48c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1505OpeningBracesMustNotBeFollowedByBlankLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1505OpeningBracesMustNotBeFollowedByBlankLine.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -10,7 +12,6 @@ namespace StyleCop.Analyzers.LayoutRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; - using StyleCop.Analyzers.SpacingRules; /// /// An opening brace within a C# element, statement, or expression is followed by a blank line. @@ -45,10 +46,10 @@ internal class SA1505OpeningBracesMustNotBeFollowedByBlankLine : DiagnosticAnaly /// analyzer. /// public const string DiagnosticId = "SA1505"; - private const string Title = "Opening braces should not be followed by blank line"; - private const string MessageFormat = "An opening brace should not be followed by a blank line."; - private const string Description = "An opening brace within a C# element, statement, or expression is followed by a blank line."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1505.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(LayoutResources.SA1505Title), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(LayoutResources.SA1505MessageFormat), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(LayoutResources.SA1505Description), LayoutResources.ResourceManager, typeof(LayoutResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.LayoutRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1506ElementDocumentationHeadersMustNotBeFollowedByBlankLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1506ElementDocumentationHeadersMustNotBeFollowedByBlankLine.cs index 12684be0d..a73f734c1 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1506ElementDocumentationHeadersMustNotBeFollowedByBlankLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1506ElementDocumentationHeadersMustNotBeFollowedByBlankLine.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -42,10 +44,10 @@ internal class SA1506ElementDocumentationHeadersMustNotBeFollowedByBlankLine : D /// analyzer. /// public const string DiagnosticId = "SA1506"; - private const string Title = "Element documentation headers should not be followed by blank line"; - private const string MessageFormat = "Element documentation headers should not be followed by blank line"; - private const string Description = "An element documentation header above a C# element is followed by a blank line."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1506.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(LayoutResources.SA1506Title), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(LayoutResources.SA1506MessageFormat), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(LayoutResources.SA1506Description), LayoutResources.ResourceManager, typeof(LayoutResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.LayoutRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1507CodeMustNotContainMultipleBlankLinesInARow.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1507CodeMustNotContainMultipleBlankLinesInARow.cs index 937989026..aed19a0bb 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1507CodeMustNotContainMultipleBlankLinesInARow.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1507CodeMustNotContainMultipleBlankLinesInARow.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -46,13 +48,16 @@ internal class SA1507CodeMustNotContainMultipleBlankLinesInARow : DiagnosticAnal /// analyzer. /// public const string DiagnosticId = "SA1507"; - private const string Title = "Code should not contain multiple blank lines in a row"; - private const string MessageFormat = "Code should not contain multiple blank lines in a row"; - private const string Description = "The C# code contains multiple blank lines in a row."; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1507.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(LayoutResources.SA1507Title), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(LayoutResources.SA1507MessageFormat), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(LayoutResources.SA1507Description), LayoutResources.ResourceManager, typeof(LayoutResources)); - private static readonly DiagnosticDescriptor Descriptor = +#pragma warning disable SA1202 // Elements should be ordered by access + internal static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.LayoutRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); +#pragma warning restore SA1202 // Elements should be ordered by access private static readonly Action SyntaxTreeAction = HandleSyntaxTree; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1508ClosingBracesMustNotBePrecededByBlankLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1508ClosingBracesMustNotBePrecededByBlankLine.cs index 820c8aa22..5214321d3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1508ClosingBracesMustNotBePrecededByBlankLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1508ClosingBracesMustNotBePrecededByBlankLine.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -44,10 +46,10 @@ internal class SA1508ClosingBracesMustNotBePrecededByBlankLine : DiagnosticAnaly /// analyzer. /// public const string DiagnosticId = "SA1508"; - private const string Title = "Closing braces should not be preceded by blank line"; - private const string MessageFormat = "A closing brace should not be preceded by a blank line."; - private const string Description = "A closing brace within a C# element, statement, or expression is preceded by a blank line."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1508.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(LayoutResources.SA1508Title), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(LayoutResources.SA1508MessageFormat), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(LayoutResources.SA1508Description), LayoutResources.ResourceManager, typeof(LayoutResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.LayoutRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -123,6 +125,11 @@ private static void HandleAccessorList(SyntaxNodeAnalysisContext context) private static void AnalyzeCloseBrace(SyntaxNodeAnalysisContext context, SyntaxToken closeBraceToken) { + if (closeBraceToken.IsKind(SyntaxKind.None)) + { + return; + } + var previousToken = closeBraceToken.GetPreviousToken(); if ((closeBraceToken.GetLineSpan().StartLinePosition.Line - previousToken.GetLineSpan().EndLinePosition.Line) < 2) { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1509OpeningBracesMustNotBePrecededByBlankLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1509OpeningBracesMustNotBePrecededByBlankLine.cs index a2c20aa50..399d85199 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1509OpeningBracesMustNotBePrecededByBlankLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1509OpeningBracesMustNotBePrecededByBlankLine.cs @@ -1,14 +1,14 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { using System; using System.Collections.Immutable; - using System.Linq; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; - using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; @@ -45,10 +45,10 @@ internal class SA1509OpeningBracesMustNotBePrecededByBlankLine : DiagnosticAnaly /// analyzer. /// public const string DiagnosticId = "SA1509"; - private const string Title = "Opening braces should not be preceded by blank line"; - private const string MessageFormat = "Opening braces should not be preceded by blank line."; - private const string Description = "An opening brace within a C# element, statement, or expression is preceded by a blank line."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1509.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(LayoutResources.SA1509Title), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(LayoutResources.SA1509MessageFormat), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(LayoutResources.SA1509Description), LayoutResources.ResourceManager, typeof(LayoutResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.LayoutRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -72,7 +72,7 @@ private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context) { var syntaxRoot = context.Tree.GetRoot(context.CancellationToken); - SyntaxToken previousToken = default(SyntaxToken); + SyntaxToken previousToken = default; foreach (var token in syntaxRoot.DescendantTokens()) { if (token.IsKind(SyntaxKind.OpenBraceToken) && !previousToken.IsKind(SyntaxKind.CloseBraceToken)) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine.cs index 11a623d71..a7bea8627 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -44,10 +46,10 @@ internal class SA1510ChainedStatementBlocksMustNotBePrecededByBlankLine : Diagno /// analyzer. /// public const string DiagnosticId = "SA1510"; - private const string Title = "Chained statement blocks should not be preceded by blank line"; - private const string MessageFormat = "'{0}' statement should not be preceded by a blank line"; - private const string Description = "Chained C# statements are separated by a blank line."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1510.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(LayoutResources.SA1510Title), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(LayoutResources.SA1510MessageFormat), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(LayoutResources.SA1510Description), LayoutResources.ResourceManager, typeof(LayoutResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.LayoutRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1511WhileDoFooterMustNotBePrecededByBlankLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1511WhileDoFooterMustNotBePrecededByBlankLine.cs index bebe9b6aa..56b2d93bf 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1511WhileDoFooterMustNotBePrecededByBlankLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1511WhileDoFooterMustNotBePrecededByBlankLine.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -39,10 +41,10 @@ internal class SA1511WhileDoFooterMustNotBePrecededByBlankLine : DiagnosticAnaly /// analyzer. /// public const string DiagnosticId = "SA1511"; - private const string Title = "While-do footer should not be preceded by blank line"; - private const string MessageFormat = "While-do footer should not be preceded by blank line"; - private const string Description = "The while footer at the bottom of a do-while statement is separated from the statement by a blank line."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1511.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(LayoutResources.SA1511Title), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(LayoutResources.SA1511MessageFormat), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(LayoutResources.SA1511Description), LayoutResources.ResourceManager, typeof(LayoutResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.LayoutRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1512SingleLineCommentsMustNotBeFollowedByBlankLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1512SingleLineCommentsMustNotBeFollowedByBlankLine.cs index a6975d22f..7da75ca5c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1512SingleLineCommentsMustNotBeFollowedByBlankLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1512SingleLineCommentsMustNotBeFollowedByBlankLine.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -78,10 +80,10 @@ internal class SA1512SingleLineCommentsMustNotBeFollowedByBlankLine : Diagnostic /// analyzer. /// public const string DiagnosticId = "SA1512"; - private const string Title = "Single-line comments should not be followed by blank line"; - private const string MessageFormat = "Single-line comments should not be followed by blank line"; - private const string Description = "A single-line comment within C# code is followed by a blank line."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1512.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(LayoutResources.SA1512Title), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(LayoutResources.SA1512MessageFormat), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(LayoutResources.SA1512Description), LayoutResources.ResourceManager, typeof(LayoutResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.LayoutRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -103,11 +105,10 @@ public override void Initialize(AnalysisContext context) private static void HandleCompilationStart(CompilationStartAnalysisContext context) { - var diagnosticOptions = context.Compilation.Options.SpecificDiagnosticOptions; - context.RegisterSyntaxTreeAction(c => HandleSyntaxTreeAnalysis(c, diagnosticOptions)); + context.RegisterSyntaxTreeAction(c => HandleSyntaxTreeAnalysis(c, context.Compilation)); } - private static void HandleSyntaxTreeAnalysis(SyntaxTreeAnalysisContext context, ImmutableDictionary specificDiagnosticOptions) + private static void HandleSyntaxTreeAnalysis(SyntaxTreeAnalysisContext context, Compilation compilation) { var syntaxRoot = context.Tree.GetRoot(context.CancellationToken); @@ -144,7 +145,7 @@ private static void HandleSyntaxTreeAnalysis(SyntaxTreeAnalysisContext context, } else if (trailingBlankLineCount > 1) { - if (specificDiagnosticOptions.GetValueOrDefault(SA1507CodeMustNotContainMultipleBlankLinesInARow.DiagnosticId, ReportDiagnostic.Default) != ReportDiagnostic.Suppress) + if (!compilation.IsAnalyzerSuppressed(SA1507CodeMustNotContainMultipleBlankLinesInARow.Descriptor)) { // ignore comments that are followed by multiple blank lines -> the multiple blank lines will be reported by SA1507 continue; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1513ClosingBraceMustBeFollowedByBlankLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1513ClosingBraceMustBeFollowedByBlankLine.cs index f8943f373..97dd481f1 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1513ClosingBraceMustBeFollowedByBlankLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1513ClosingBraceMustBeFollowedByBlankLine.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -13,6 +15,7 @@ namespace StyleCop.Analyzers.LayoutRules using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Text; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; /// /// A closing brace within a C# element, statement, or expression is not followed by a blank line. @@ -44,10 +47,10 @@ internal class SA1513ClosingBraceMustBeFollowedByBlankLine : DiagnosticAnalyzer /// analyzer. /// public const string DiagnosticId = "SA1513"; - private const string Title = "Closing brace should be followed by blank line"; - private const string MessageFormat = "Closing brace should be followed by blank line"; - private const string Description = "A closing brace within a C# element, statement, or expression is not followed by a blank line."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1513.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(LayoutResources.SA1513Title), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(LayoutResources.SA1513MessageFormat), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(LayoutResources.SA1513Description), LayoutResources.ResourceManager, typeof(LayoutResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.LayoutRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -176,6 +179,13 @@ private static bool IsPartOf(SyntaxToken token) private void AnalyzeCloseBrace(SyntaxToken token) { + if (token.Parent.IsKind(SyntaxKind.Interpolation)) + { + // The text after an interpolation is part of a string literal, and therefore does not require a + // blank line in source. + return; + } + var nextToken = token.GetNextToken(true, true); if (nextToken.HasLeadingTrivia @@ -242,9 +252,10 @@ private void AnalyzeCloseBrace(SyntaxToken token) IsPartOf(token) || IsPartOf(token) || IsPartOf(token) || + IsPartOf(token) || IsPartOf(token))) { - // the close brace is part of a variable initialization statement or a return statement + // the close brace is part of a variable initialization statement or a return/throw statement return; } @@ -261,10 +272,17 @@ private void AnalyzeCloseBrace(SyntaxToken token) return; } + if (nextToken.IsKind(SyntaxKind.CloseBracketToken)) + { + // the close brace is for example in an object initializer at the end of a collection expression. + return; + } + if (nextToken.IsKind(SyntaxKind.AddKeyword) || nextToken.IsKind(SyntaxKind.RemoveKeyword) || nextToken.IsKind(SyntaxKind.GetKeyword) - || nextToken.IsKind(SyntaxKind.SetKeyword)) + || nextToken.IsKind(SyntaxKind.SetKeyword) + || nextToken.IsKind(SyntaxKindEx.InitKeyword)) { // the close brace is followed by an accessor (SA1516 will handle that) return; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1514ElementDocumentationHeaderMustBePrecededByBlankLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1514ElementDocumentationHeaderMustBePrecededByBlankLine.cs index 691683822..377dfe327 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1514ElementDocumentationHeaderMustBePrecededByBlankLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1514ElementDocumentationHeaderMustBePrecededByBlankLine.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -66,10 +68,10 @@ internal class SA1514ElementDocumentationHeaderMustBePrecededByBlankLine : Diagn /// analyzer. /// public const string DiagnosticId = "SA1514"; - private const string Title = "Element documentation header should be preceded by blank line"; - private const string MessageFormat = "Element documentation header should be preceded by blank line"; - private const string Description = "An element documentation header above a C# element is not preceded by a blank line."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1514.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(LayoutResources.SA1514Title), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(LayoutResources.SA1514MessageFormat), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(LayoutResources.SA1514Description), LayoutResources.ResourceManager, typeof(LayoutResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.LayoutRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1515SingleLineCommentMustBePrecededByBlankLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1515SingleLineCommentMustBePrecededByBlankLine.cs index 9fbf4df2e..c8a31adf6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1515SingleLineCommentMustBePrecededByBlankLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1515SingleLineCommentMustBePrecededByBlankLine.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -80,10 +82,10 @@ internal class SA1515SingleLineCommentMustBePrecededByBlankLine : DiagnosticAnal /// analyzer. /// public const string DiagnosticId = "SA1515"; - private const string Title = "Single-line comment should be preceded by blank line"; - private const string MessageFormat = "Single-line comment should be preceded by blank line"; - private const string Description = "A single-line comment within C# code is not preceded by a blank line."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1515.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(LayoutResources.SA1515Title), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(LayoutResources.SA1515MessageFormat), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(LayoutResources.SA1515Description), LayoutResources.ResourceManager, typeof(LayoutResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.LayoutRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -106,21 +108,18 @@ public override void Initialize(AnalysisContext context) private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context) { var syntaxRoot = context.Tree.GetRoot(context.CancellationToken); - var previousCommentNotOnOwnLine = false; foreach (var trivia in syntaxRoot.DescendantTrivia().Where(trivia => trivia.IsKind(SyntaxKind.SingleLineCommentTrivia))) { if (trivia.FullSpan.Start == 0) { // skip the trivia if it is at the start of the file - previousCommentNotOnOwnLine = false; continue; } if (trivia.ToString().StartsWith("////", StringComparison.Ordinal)) { // ignore commented out code - previousCommentNotOnOwnLine = false; continue; } @@ -130,26 +129,21 @@ private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context) if (!IsOnOwnLine(triviaList, triviaIndex)) { // ignore comments after other code elements. - previousCommentNotOnOwnLine = true; continue; } if (IsPrecededByBlankLine(triviaList, triviaIndex)) { // allow properly formatted blank line comments. - previousCommentNotOnOwnLine = false; continue; } - if (!previousCommentNotOnOwnLine && IsPrecededBySingleLineCommentOrDocumentation(triviaList, triviaIndex)) + if (IsPrecededBySingleLineCommentOnOwnLineOrDocumentation(triviaList, triviaIndex)) { // allow consecutive single line comments. - previousCommentNotOnOwnLine = false; continue; } - previousCommentNotOnOwnLine = false; - if (IsAtStartOfScope(trivia)) { // allow single line comment at scope start. @@ -170,8 +164,19 @@ private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context) private static bool IsOnOwnLine(T triviaList, int triviaIndex) where T : IReadOnlyList { + if (triviaList[triviaIndex].Span.Start == 0) + { + return true; + } + while (triviaIndex >= 0) { + if (triviaList[triviaIndex].IsDirective) + { + // directive trivia are special, as they have a 'built-in' end-of-line. + return true; + } + if (triviaList[triviaIndex].IsKind(SyntaxKind.EndOfLineTrivia)) { return true; @@ -183,7 +188,7 @@ private static bool IsOnOwnLine(T triviaList, int triviaIndex) return false; } - private static bool IsPrecededBySingleLineCommentOrDocumentation(T triviaList, int triviaIndex) + private static bool IsPrecededBySingleLineCommentOnOwnLineOrDocumentation(T triviaList, int triviaIndex) where T : IReadOnlyList { var eolCount = 0; @@ -204,6 +209,8 @@ private static bool IsPrecededBySingleLineCommentOrDocumentation(T triviaList break; case SyntaxKind.SingleLineCommentTrivia: + return IsOnOwnLine(triviaList, triviaIndex); + case SyntaxKind.SingleLineDocumentationCommentTrivia: return true; @@ -279,6 +286,7 @@ private static bool IsPrecededByDirectiveTrivia(T triviaList, int triviaIndex case SyntaxKind.IfDirectiveTrivia: case SyntaxKind.ElifDirectiveTrivia: case SyntaxKind.ElseDirectiveTrivia: + case SyntaxKind.PragmaWarningDirectiveTrivia: return true; default: diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1516ElementsMustBeSeparatedByBlankLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1516ElementsMustBeSeparatedByBlankLine.cs index f1be2548c..2ac731989 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1516ElementsMustBeSeparatedByBlankLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1516ElementsMustBeSeparatedByBlankLine.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -13,6 +15,7 @@ namespace StyleCop.Analyzers.LayoutRules using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Text; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.Settings.ObjectModel; /// @@ -71,6 +74,8 @@ internal class SA1516ElementsMustBeSeparatedByBlankLine : DiagnosticAnalyzer internal const string RemoveBlankLinesValue = "RemoveBlankLines"; internal const string InsertBlankLineValue = "InsertBlankLine"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1516.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(LayoutResources.SA1516Title), LayoutResources.ResourceManager, typeof(LayoutResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(LayoutResources.SA1516MessageFormat), LayoutResources.ResourceManager, typeof(LayoutResources)); @@ -80,11 +85,10 @@ internal class SA1516ElementsMustBeSeparatedByBlankLine : DiagnosticAnalyzer private static readonly LocalizableString MessageFormatOmit = new LocalizableResourceString(nameof(LayoutResources.SA1516MessageFormatOmit), LayoutResources.ResourceManager, typeof(LayoutResources)); private static readonly LocalizableString DescriptionOmit = new LocalizableResourceString(nameof(LayoutResources.SA1516DescriptionOmit), LayoutResources.ResourceManager, typeof(LayoutResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1516.md"; - private static readonly Action TypeDeclarationAction = HandleTypeDeclaration; private static readonly Action CompilationUnitAction = HandleCompilationUnit; private static readonly Action NamespaceDeclarationAction = HandleNamespaceDeclaration; + private static readonly Action FileScopedNamespaceDeclarationAction = HandleFileScopedNamespaceDeclaration; private static readonly Action BasePropertyDeclarationAction = HandleBasePropertyDeclaration; private static readonly ImmutableDictionary DiagnosticProperties = ImmutableDictionary.Empty.Add(CodeFixActionKey, InsertBlankLineValue); @@ -122,10 +126,14 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKinds.TypeDeclaration); - context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); - context.RegisterSyntaxNodeAction(NamespaceDeclarationAction, SyntaxKind.NamespaceDeclaration); - context.RegisterSyntaxNodeAction(BasePropertyDeclarationAction, SyntaxKinds.BasePropertyDeclaration); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKinds.TypeDeclaration); + context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); + context.RegisterSyntaxNodeAction(NamespaceDeclarationAction, SyntaxKind.NamespaceDeclaration); + context.RegisterSyntaxNodeAction(FileScopedNamespaceDeclarationAction, SyntaxKindEx.FileScopedNamespaceDeclaration); + context.RegisterSyntaxNodeAction(BasePropertyDeclarationAction, SyntaxKinds.BasePropertyDeclaration); + }); } private static void HandleBasePropertyDeclaration(SyntaxNodeAnalysisContext context) @@ -169,20 +177,77 @@ private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context, Sty { var compilationUnit = (CompilationUnitSyntax)context.Node; + var externs = compilationUnit.Externs; var usings = compilationUnit.Usings; + var attributeLists = compilationUnit.AttributeLists; var members = compilationUnit.Members; HandleUsings(context, usings, settings); HandleMemberList(context, members); - if (members.Count > 0 && compilationUnit.Usings.Count > 0) + SyntaxNode previousItem = externs.LastOrDefault(); + if (usings.Any()) { - ReportIfThereIsNoBlankLine(context, usings[usings.Count - 1], members[0]); + if (previousItem != null) + { + ReportIfThereIsNoBlankLine(context, previousItem, usings[0]); + } + + previousItem = usings.Last(); + } + + if (attributeLists.Any()) + { + if (previousItem != null) + { + ReportIfThereIsNoBlankLine(context, previousItem, attributeLists[0]); + } + + previousItem = attributeLists.Last(); } - if (compilationUnit.Usings.Count > 0 && compilationUnit.Externs.Count > 0) + if (members.Any()) { - ReportIfThereIsNoBlankLine(context, compilationUnit.Externs[compilationUnit.Externs.Count - 1], compilationUnit.Usings[0]); + if (previousItem != null) + { + ReportIfThereIsNoBlankLine(context, previousItem, members[0]); + } + } + } + + private static void HandleFileScopedNamespaceDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) + { + var namespaceDeclaration = (BaseNamespaceDeclarationSyntaxWrapper)context.Node; + + var usings = namespaceDeclaration.Usings; + var members = namespaceDeclaration.Members; + + HandleUsings(context, usings, settings); + HandleMemberList(context, members); + + if (namespaceDeclaration.Externs.Count > 0) + { + ReportIfThereIsNoBlankLine(context, namespaceDeclaration.Name, namespaceDeclaration.Externs[0]); + } + + if (namespaceDeclaration.Usings.Count > 0) + { + ReportIfThereIsNoBlankLine(context, namespaceDeclaration.Name, namespaceDeclaration.Usings[0]); + + if (namespaceDeclaration.Externs.Count > 0) + { + ReportIfThereIsNoBlankLine(context, namespaceDeclaration.Externs[namespaceDeclaration.Externs.Count - 1], namespaceDeclaration.Usings[0]); + } + } + + if (members.Count > 0) + { + ReportIfThereIsNoBlankLine(context, namespaceDeclaration.Name, members[0]); + + if (namespaceDeclaration.Usings.Count > 0) + { + ReportIfThereIsNoBlankLine(context, usings[usings.Count - 1], members[0]); + } } } @@ -272,6 +337,12 @@ private static void HandleMemberList(SyntaxNodeAnalysisContext context, SyntaxLi { for (int i = 1; i < members.Count; i++) { + // Don't report between global statements + if (members[i - 1].IsKind(SyntaxKind.GlobalStatement) && members[i].IsKind(SyntaxKind.GlobalStatement)) + { + continue; + } + if (!members[i - 1].ContainsDiagnostics && !members[i].ContainsDiagnostics) { // Report if @@ -345,10 +416,16 @@ private static Location GetDiagnosticLocation(SyntaxNode node) return node.GetLeadingTrivia()[0].GetLocation(); } + // Prefer the first token which is a direct child, but fall back to the first descendant token var firstToken = node.ChildTokens().FirstOrDefault(); - if (firstToken != default(SyntaxToken)) + if (firstToken.IsKind(SyntaxKind.None)) + { + firstToken = node.GetFirstToken(); + } + + if (firstToken != default) { - return node.ChildTokens().First().GetLocation(); + return firstToken.GetLocation(); } return Location.None; @@ -358,7 +435,7 @@ private static bool HasEmptyLine(IEnumerable allTrivia) { allTrivia = allTrivia.Where(x => !x.IsKind(SyntaxKind.WhitespaceTrivia)); - SyntaxTrivia previousTrivia = default(SyntaxTrivia); + SyntaxTrivia previousTrivia = default; foreach (var trivia in allTrivia) { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1517CodeMustNotContainBlankLinesAtStartOfFile.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1517CodeMustNotContainBlankLinesAtStartOfFile.cs index afd638f48..41b434ef4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1517CodeMustNotContainBlankLinesAtStartOfFile.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1517CodeMustNotContainBlankLinesAtStartOfFile.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -26,10 +28,10 @@ internal class SA1517CodeMustNotContainBlankLinesAtStartOfFile : DiagnosticAnaly /// analyzer. /// public const string DiagnosticId = "SA1517"; - private const string Title = "Code should not contain blank lines at start of file"; - private const string MessageFormat = "Code should not contain blank lines at start of file"; - private const string Description = "The code file has blank lines at the start."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1517.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(LayoutResources.SA1517Title), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(LayoutResources.SA1517MessageFormat), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(LayoutResources.SA1517Description), LayoutResources.ResourceManager, typeof(LayoutResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.LayoutRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1518UseLineEndingsCorrectlyAtEndOfFile.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1518UseLineEndingsCorrectlyAtEndOfFile.cs index 897a9d27b..90e697efa 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1518UseLineEndingsCorrectlyAtEndOfFile.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1518UseLineEndingsCorrectlyAtEndOfFile.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -28,6 +30,8 @@ internal class SA1518UseLineEndingsCorrectlyAtEndOfFile : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1518"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1518.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(LayoutResources.SA1518Title), LayoutResources.ResourceManager, typeof(LayoutResources)); private static readonly LocalizableString MessageFormatAllow = new LocalizableResourceString(nameof(LayoutResources.SA1518MessageFormatAllow), LayoutResources.ResourceManager, typeof(LayoutResources)); @@ -37,18 +41,18 @@ internal class SA1518UseLineEndingsCorrectlyAtEndOfFile : DiagnosticAnalyzer private static readonly LocalizableString MessageFormatOmit = new LocalizableResourceString(nameof(LayoutResources.SA1518MessageFormatOmit), LayoutResources.ResourceManager, typeof(LayoutResources)); private static readonly LocalizableString DescriptionOmit = new LocalizableResourceString(nameof(LayoutResources.SA1518DescriptionOmit), LayoutResources.ResourceManager, typeof(LayoutResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1518.md"; - - private static readonly Action SyntaxTreeAction = HandleSyntaxTree; - - public static DiagnosticDescriptor DescriptorAllow { get; } = +#pragma warning disable SA1202 // Elements should be ordered by access + internal static readonly DiagnosticDescriptor DescriptorAllow = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormatAllow, AnalyzerCategory.LayoutRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, DescriptionAllow, HelpLink); - public static DiagnosticDescriptor DescriptorRequire { get; } = + internal static readonly DiagnosticDescriptor DescriptorRequire = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormatRequire, AnalyzerCategory.LayoutRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, DescriptionRequire, HelpLink); - public static DiagnosticDescriptor DescriptorOmit { get; } = + internal static readonly DiagnosticDescriptor DescriptorOmit = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormatOmit, AnalyzerCategory.LayoutRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, DescriptionOmit, HelpLink); +#pragma warning restore SA1202 // Elements should be ordered by access + + private static readonly Action SyntaxTreeAction = HandleSyntaxTree; /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -60,7 +64,10 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxTreeAction(SyntaxTreeAction); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxTreeAction(SyntaxTreeAction); + }); } private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context, StyleCopSettings settings) @@ -68,7 +75,7 @@ private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context, StyleCop var endOfFileToken = context.Tree.GetRoot().GetLastToken(includeZeroWidth: true); TextSpan reportedSpan = new TextSpan(endOfFileToken.SpanStart, 0); - SyntaxTrivia precedingTrivia = default(SyntaxTrivia); + SyntaxTrivia precedingTrivia = default; bool checkPrecedingToken; if (endOfFileToken.HasLeadingTrivia) { @@ -108,7 +115,7 @@ private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context, StyleCop else if (trailingWhitespaceIndex == 0) { reportedSpan = TextSpan.FromBounds(previousToken.TrailingTrivia[trailingWhitespaceIndex].SpanStart, reportedSpan.End); - precedingTrivia = default(SyntaxTrivia); + precedingTrivia = default; } else { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1519BracesMustNotBeOmittedFromMultiLineChildStatement.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1519BracesMustNotBeOmittedFromMultiLineChildStatement.cs index 0ada44196..b5bfc1443 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1519BracesMustNotBeOmittedFromMultiLineChildStatement.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1519BracesMustNotBeOmittedFromMultiLineChildStatement.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -36,19 +38,24 @@ internal class SA1519BracesMustNotBeOmittedFromMultiLineChildStatement : Diagnos /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1519"; - private const string Title = "Braces should not be omitted from multi-line child statement"; - private const string MessageFormat = "Braces should not be omitted from multi-line child statement"; - private const string Description = "The opening and closing braces for a multi-line C# statement have been omitted."; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1519.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(LayoutResources.SA1519Title), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(LayoutResources.SA1519MessageFormat), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(LayoutResources.SA1519Description), LayoutResources.ResourceManager, typeof(LayoutResources)); - private static readonly DiagnosticDescriptor Descriptor = +#pragma warning disable SA1202 // Elements should be ordered by access + internal static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.LayoutRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); +#pragma warning restore SA1202 // Elements should be ordered by access private static readonly Action IfStatementAction = HandleIfStatement; private static readonly Action DoStatementAction = HandleDoStatement; private static readonly Action WhileStatementAction = HandleWhileStatement; private static readonly Action ForStatementAction = HandleForStatement; private static readonly Action ForEachStatementAction = HandleForEachStatement; + private static readonly Action LockStatementAction = HandleLockStatement; + private static readonly Action FixedStatementAction = HandleFixedStatement; private static readonly Action UsingStatementAction = HandleUsingStatement; /// @@ -61,12 +68,17 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(IfStatementAction, SyntaxKind.IfStatement); - context.RegisterSyntaxNodeAction(DoStatementAction, SyntaxKind.DoStatement); - context.RegisterSyntaxNodeAction(WhileStatementAction, SyntaxKind.WhileStatement); - context.RegisterSyntaxNodeAction(ForStatementAction, SyntaxKind.ForStatement); - context.RegisterSyntaxNodeAction(ForEachStatementAction, SyntaxKind.ForEachStatement); - context.RegisterSyntaxNodeAction(UsingStatementAction, SyntaxKind.UsingStatement); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(IfStatementAction, SyntaxKind.IfStatement); + context.RegisterSyntaxNodeAction(DoStatementAction, SyntaxKind.DoStatement); + context.RegisterSyntaxNodeAction(WhileStatementAction, SyntaxKind.WhileStatement); + context.RegisterSyntaxNodeAction(ForStatementAction, SyntaxKind.ForStatement); + context.RegisterSyntaxNodeAction(ForEachStatementAction, SyntaxKind.ForEachStatement); + context.RegisterSyntaxNodeAction(LockStatementAction, SyntaxKind.LockStatement); + context.RegisterSyntaxNodeAction(FixedStatementAction, SyntaxKind.FixedStatement); + context.RegisterSyntaxNodeAction(UsingStatementAction, SyntaxKind.UsingStatement); + }); } private static void HandleIfStatement(SyntaxNodeAnalysisContext context) @@ -109,6 +121,18 @@ private static void HandleForEachStatement(SyntaxNodeAnalysisContext context) CheckChildStatement(context, forEachStatement.Statement); } + private static void HandleLockStatement(SyntaxNodeAnalysisContext context) + { + var lockStatement = (LockStatementSyntax)context.Node; + CheckChildStatement(context, lockStatement.Statement); + } + + private static void HandleFixedStatement(SyntaxNodeAnalysisContext context) + { + var fixedStatement = (FixedStatementSyntax)context.Node; + CheckChildStatement(context, fixedStatement.Statement); + } + private static void HandleUsingStatement(SyntaxNodeAnalysisContext context, StyleCopSettings settings) { var usingStatement = (UsingStatementSyntax)context.Node; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1520UseBracesConsistently.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1520UseBracesConsistently.cs index 1f5a0612a..21305e654 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1520UseBracesConsistently.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1520UseBracesConsistently.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.LayoutRules { @@ -42,13 +44,16 @@ internal class SA1520UseBracesConsistently : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1520"; - private const string Title = "Use braces consistently"; - private const string MessageFormat = "Use braces consistently"; - private const string Description = "The opening and closing braces of a chained if/else if/else construct were included for some clauses, but omitted for others."; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1520.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(LayoutResources.SA1520Title), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(LayoutResources.SA1520MessageFormat), LayoutResources.ResourceManager, typeof(LayoutResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(LayoutResources.SA1520Description), LayoutResources.ResourceManager, typeof(LayoutResources)); - private static readonly DiagnosticDescriptor Descriptor = +#pragma warning disable SA1202 // Elements should be ordered by access + internal static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.LayoutRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); +#pragma warning restore SA1202 // Elements should be ordered by access private static readonly Action IfStatementAction = HandleIfStatement; @@ -109,7 +114,7 @@ private static void CheckChildStatement(SyntaxNodeAnalysisContext context, State return; } - if (context.SemanticModel.Compilation.Options.SpecificDiagnosticOptions.GetValueOrDefault(SA1519BracesMustNotBeOmittedFromMultiLineChildStatement.DiagnosticId, ReportDiagnostic.Default) != ReportDiagnostic.Suppress) + if (!context.IsAnalyzerSuppressed(SA1519BracesMustNotBeOmittedFromMultiLineChildStatement.Descriptor)) { // diagnostics for multi-line statements is handled by SA1519, as long as it's not suppressed FileLinePositionSpan lineSpan = childStatement.GetLineSpan(); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/JsonArray.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/JsonArray.cs index 5b04fe74d..bd8965164 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/JsonArray.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/JsonArray.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace LightJson { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/JsonObject.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/JsonObject.cs index c41a97ce7..3bd026c83 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/JsonObject.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/JsonObject.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace LightJson { @@ -217,8 +219,10 @@ public KeyValuePair[] Keys [DebuggerDisplay("{value.ToString(),nq}", Name = "{key}", Type = "JsonValue({Type})")] public class KeyValuePair { +#pragma warning disable IDE0052 // Remove unread private members [DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly string key; +#pragma warning restore IDE0052 // Remove unread private members [DebuggerBrowsable(DebuggerBrowsableState.Never)] private readonly JsonValue value; @@ -248,15 +252,6 @@ public object View } } } - - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - private JsonValueType Type - { - get - { - return this.value.Type; - } - } } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/JsonValue.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/JsonValue.cs index 429dacd47..abfeac41f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/JsonValue.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/JsonValue.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace LightJson { @@ -20,7 +22,7 @@ internal struct JsonValue /// /// Represents a null JsonValue. /// - public static readonly JsonValue Null = new JsonValue(JsonValueType.Null, default(double), null); + public static readonly JsonValue Null = new JsonValue(JsonValueType.Null, default, null); private readonly JsonValueType type; private readonly object reference; @@ -74,7 +76,7 @@ public JsonValue(string value) { if (value != null) { - this.value = default(double); + this.value = default; this.type = JsonValueType.String; @@ -94,7 +96,7 @@ public JsonValue(JsonObject value) { if (value != null) { - this.value = default(double); + this.value = default; this.type = JsonValueType.Object; @@ -114,7 +116,7 @@ public JsonValue(JsonArray value) { if (value != null) { - this.value = default(double); + this.value = default; this.type = JsonValueType.Array; @@ -604,7 +606,9 @@ public static explicit operator int(JsonValue jsonValue) /// Throws System.InvalidCastException when the inner value type of the /// JsonValue is not the desired type of the conversion. /// +#pragma warning disable IDE0055 // Fix formatting public static explicit operator int?(JsonValue jsonValue) +#pragma warning restore IDE0055 // Fix formatting { if (jsonValue.IsNull) { @@ -640,7 +644,9 @@ public static explicit operator bool(JsonValue jsonValue) /// Throws System.InvalidCastException when the inner value type of the /// JsonValue is not the desired type of the conversion. /// +#pragma warning disable IDE0055 // Fix formatting public static explicit operator bool?(JsonValue jsonValue) +#pragma warning restore IDE0055 // Fix formatting { if (jsonValue.IsNull) { @@ -676,7 +682,9 @@ public static explicit operator double(JsonValue jsonValue) /// Throws System.InvalidCastException when the inner value type of the /// JsonValue is not the desired type of the conversion. /// +#pragma warning disable IDE0055 // Fix formatting public static explicit operator double?(JsonValue jsonValue) +#pragma warning restore IDE0055 // Fix formatting { if (jsonValue.IsNull) { @@ -758,7 +766,9 @@ public static explicit operator DateTime(JsonValue jsonValue) /// Converts the given JsonValue into a nullable DateTime. /// /// The JsonValue to be converted. +#pragma warning disable IDE0055 // Fix formatting public static explicit operator DateTime?(JsonValue jsonValue) +#pragma warning restore IDE0055 // Fix formatting { if (jsonValue.IsDateTime || jsonValue.IsNull) { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/JsonValueType.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/JsonValueType.cs index a0e959b41..778619a52 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/JsonValueType.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/JsonValueType.cs @@ -1,5 +1,5 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace LightJson { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/JsonParseException.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/JsonParseException.cs index cde555cd1..9f4c53c28 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/JsonParseException.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/JsonParseException.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace LightJson.Serialization { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/JsonReader.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/JsonReader.cs index d77ebc080..5c5c9509a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/JsonReader.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/JsonReader.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace LightJson.Serialization { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/JsonSerializationException.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/JsonSerializationException.cs index 2d4be3b8d..f2c3af7b1 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/JsonSerializationException.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/JsonSerializationException.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace LightJson.Serialization { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/JsonWriter.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/JsonWriter.cs index 0b6c47dac..fb29e866e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/JsonWriter.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/JsonWriter.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace LightJson.Serialization { @@ -107,11 +109,6 @@ public void Dispose() } } - private static bool IsValidNumber(double number) - { - return !(double.IsNaN(number) || double.IsInfinity(number)); - } - private void Initialize() { this.indent = 0; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/TextPosition.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/TextPosition.cs index a0c70afcb..215003e71 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/TextPosition.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/TextPosition.cs @@ -1,5 +1,5 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace LightJson.Serialization { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/TextScanner.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/TextScanner.cs index 48236a062..3e195e3ee 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/TextScanner.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LightJson/Serialization/TextScanner.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace LightJson.Serialization { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/DocumentationResources.Designer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/DocumentationResources.Designer.cs new file mode 100644 index 000000000..78415df23 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/DocumentationResources.Designer.cs @@ -0,0 +1,407 @@ +// + +#nullable enable +using System.Reflection; + + +namespace StyleCop.Analyzers.DocumentationRules +{ + internal static partial class DocumentationResources + { + private static global::System.Resources.ResourceManager? s_resourceManager; + public static global::System.Resources.ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new global::System.Resources.ResourceManager(typeof(DocumentationResources))); + public static global::System.Globalization.CultureInfo? Culture { get; set; } + [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + [return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("defaultValue")] + internal static string? GetResourceString(string resourceKey, string? defaultValue = null) => ResourceManager.GetString(resourceKey, Culture) ?? defaultValue; + /// Generate constructor documentation + public static string @ConstructorDocumentationCodeFix => GetResourceString("ConstructorDocumentationCodeFix")!; + /// Generate destructor documentation + public static string @DestructorDocumentationCodeFix => GetResourceString("DestructorDocumentationCodeFix")!; + /// Finalizes an instance of the + public static string @DestructorStandardTextFirstPart => GetResourceString("DestructorStandardTextFirstPart")!; + /// class. + public static string @DestructorStandardTextSecondPart => GetResourceString("DestructorStandardTextSecondPart")!; + /// Inherit documentation + public static string @InheritdocCodeFix => GetResourceString("InheritdocCodeFix")!; + /// Generate method documentation + public static string @MethodDocumentationCodeFix => GetResourceString("MethodDocumentationCodeFix")!; + /// Initializes a new instance of the + public static string @NonPrivateConstructorStandardTextFirstPart => GetResourceString("NonPrivateConstructorStandardTextFirstPart")!; + /// {0} + public static string @NonPrivateConstructorStandardTextSecondPart => GetResourceString("NonPrivateConstructorStandardTextSecondPart")!; + /// The parameter is not used. + public static string @ParameterNotUsed => GetResourceString("ParameterNotUsed")!; + /// Prevents a default instance of the + public static string @PrivateConstructorStandardTextFirstPart => GetResourceString("PrivateConstructorStandardTextFirstPart")!; + /// {0} from being created + public static string @PrivateConstructorStandardTextSecondPart => GetResourceString("PrivateConstructorStandardTextSecondPart")!; + /// Add standard text + public static string @PropertySummaryStartTextCodeFix => GetResourceString("PropertySummaryStartTextCodeFix")!; + /// A C# code element is missing a documentation header. + public static string @SA1600Description => GetResourceString("SA1600Description")!; + /// Elements should be documented + public static string @SA1600MessageFormat => GetResourceString("SA1600MessageFormat")!; + /// Elements should be documented + public static string @SA1600Title => GetResourceString("SA1600Title")!; + /// A C# partial element is missing a documentation header. + public static string @SA1601Description => GetResourceString("SA1601Description")!; + /// Partial elements should be documented + public static string @SA1601MessageFormat => GetResourceString("SA1601MessageFormat")!; + /// Partial elements should be documented + public static string @SA1601Title => GetResourceString("SA1601Title")!; + /// An item within a C# enumeration is missing an Xml documentation header. + public static string @SA1602Description => GetResourceString("SA1602Description")!; + /// Enumeration items should be documented + public static string @SA1602MessageFormat => GetResourceString("SA1602MessageFormat")!; + /// Enumeration items should be documented + public static string @SA1602Title => GetResourceString("SA1602Title")!; + /// The XML within a C# element’s document header is badly formed. + public static string @SA1603Description => GetResourceString("SA1603Description")!; + /// The documentation header is composed of invalid XML: {0} + public static string @SA1603MessageFormat => GetResourceString("SA1603MessageFormat")!; + /// Documentation should contain valid XML + public static string @SA1603Title => GetResourceString("SA1603Title")!; + /// The XML header documentation for a C# element is missing a <summary> tag. + public static string @SA1604Description => GetResourceString("SA1604Description")!; + /// Element documentation should have summary + public static string @SA1604MessageFormat => GetResourceString("SA1604MessageFormat")!; + /// Element documentation should have summary + public static string @SA1604Title => GetResourceString("SA1604Title")!; + /// The <summary> or <content> tag within the documentation header for a C# code element is missing or empty. + public static string @SA1605Description => GetResourceString("SA1605Description")!; + /// Partial element documentation should have summary + public static string @SA1605MessageFormat => GetResourceString("SA1605MessageFormat")!; + /// Partial element documentation should have summary + public static string @SA1605Title => GetResourceString("SA1605Title")!; + /// The <summary> tag within the documentation header for a C# code element is empty. + public static string @SA1606Description => GetResourceString("SA1606Description")!; + /// Element documentation should have summary text + public static string @SA1606MessageFormat => GetResourceString("SA1606MessageFormat")!; + /// Element documentation should have summary text + public static string @SA1606Title => GetResourceString("SA1606Title")!; + /// The <summary> or <content> tag within the documentation header for a C# code element is empty. + public static string @SA1607Description => GetResourceString("SA1607Description")!; + /// Partial element documentation should have summary text + public static string @SA1607MessageFormat => GetResourceString("SA1607MessageFormat")!; + /// Partial element documentation should have summary text + public static string @SA1607Title => GetResourceString("SA1607Title")!; + /// The <summary> tag within an element's XML header documentation contains the default text generated by Visual Studio during the creation of the element. + public static string @SA1608Description => GetResourceString("SA1608Description")!; + /// Element documentation should not have default summary + public static string @SA1608MessageFormat => GetResourceString("SA1608MessageFormat")!; + /// Element documentation should not have default summary + public static string @SA1608Title => GetResourceString("SA1608Title")!; + /// The XML header documentation for a C# property does not contain a <value> tag. + public static string @SA1609Description => GetResourceString("SA1609Description")!; + /// Property documentation should have value + public static string @SA1609MessageFormat => GetResourceString("SA1609MessageFormat")!; + /// Document value from summary + public static string @SA1609SA1610CodeFix => GetResourceString("SA1609SA1610CodeFix")!; + /// Property documentation should have value + public static string @SA1609Title => GetResourceString("SA1609Title")!; + /// The XML header documentation for a C# property contains an empty <value> tag. + public static string @SA1610Description => GetResourceString("SA1610Description")!; + /// Property documentation should have value text + public static string @SA1610MessageFormat => GetResourceString("SA1610MessageFormat")!; + /// Property documentation should have value text + public static string @SA1610Title => GetResourceString("SA1610Title")!; + /// A C# method, constructor, delegate or indexer element is missing documentation for one or more of its parameters. + public static string @SA1611Description => GetResourceString("SA1611Description")!; + /// The documentation for parameter '{0}' is missing + public static string @SA1611MessageFormat => GetResourceString("SA1611MessageFormat")!; + /// Element parameters should be documented + public static string @SA1611Title => GetResourceString("SA1611Title")!; + /// The documentation describing the parameters to a C# method, constructor, delegate or indexer element does not match the actual parameters on the element. + public static string @SA1612Description => GetResourceString("SA1612Description")!; + /// The parameter '{0}' does not exist + public static string @SA1612MissingParamForDocumentationMessageFormat => GetResourceString("SA1612MissingParamForDocumentationMessageFormat")!; + /// The parameter documentation for '{0}' should be at position {1} + public static string @SA1612ParamWrongOrderMessageFormat => GetResourceString("SA1612ParamWrongOrderMessageFormat")!; + /// Element parameter documentation should match element parameters + public static string @SA1612Title => GetResourceString("SA1612Title")!; + /// A <param> tag within a C# element's documentation header is missing a name attribute containing the name of the parameter. + public static string @SA1613Description => GetResourceString("SA1613Description")!; + /// Element parameter documentation should declare parameter name + public static string @SA1613MessageFormat => GetResourceString("SA1613MessageFormat")!; + /// Element parameter documentation should declare parameter name + public static string @SA1613Title => GetResourceString("SA1613Title")!; + /// A <param> tag within a C# element's documentation header is empty. + public static string @SA1614Description => GetResourceString("SA1614Description")!; + /// Element parameter documentation should have text + public static string @SA1614MessageFormat => GetResourceString("SA1614MessageFormat")!; + /// Element parameter documentation should have text + public static string @SA1614Title => GetResourceString("SA1614Title")!; + /// A C# element is missing documentation for its return value. + public static string @SA1615Description => GetResourceString("SA1615Description")!; + /// Element return value should be documented + public static string @SA1615MessageFormat => GetResourceString("SA1615MessageFormat")!; + /// Document return value + public static string @SA1615SA1616CodeFix => GetResourceString("SA1615SA1616CodeFix")!; + /// Element return value should be documented + public static string @SA1615Title => GetResourceString("SA1615Title")!; + /// The <returns> tag within a C# element's documentation header is empty. + public static string @SA1616Description => GetResourceString("SA1616Description")!; + /// Element return value documentation should have text + public static string @SA1616MessageFormat => GetResourceString("SA1616MessageFormat")!; + /// Element return value documentation should have text + public static string @SA1616Title => GetResourceString("SA1616Title")!; + /// Remove <returns> XML comment + public static string @SA1617CodeFix => GetResourceString("SA1617CodeFix")!; + /// A C# code element does not contain a return value, or returns void, but the documentation header for the element contains a <returns> tag. + public static string @SA1617Description => GetResourceString("SA1617Description")!; + /// Void return value should not be documented + public static string @SA1617MessageFormat => GetResourceString("SA1617MessageFormat")!; + /// Void return value should not be documented + public static string @SA1617Title => GetResourceString("SA1617Title")!; + /// A generic C# element is missing documentation for one or more of its generic type parameters. + public static string @SA1618Description => GetResourceString("SA1618Description")!; + /// The documentation for type parameter '{0}' is missing + public static string @SA1618MessageFormat => GetResourceString("SA1618MessageFormat")!; + /// Generic type parameters should be documented + public static string @SA1618Title => GetResourceString("SA1618Title")!; + /// A generic, partial C# element is missing documentation for one or more of its generic type parameters, and the documentation for the element contains a <summary> tag. + public static string @SA1619Description => GetResourceString("SA1619Description")!; + /// The documentation for type parameter '{0}' is missing + public static string @SA1619MessageFormat => GetResourceString("SA1619MessageFormat")!; + /// Generic type parameters should be documented partial class + public static string @SA1619Title => GetResourceString("SA1619Title")!; + /// The <typeparam> tags within the Xml header documentation for a generic C# element do not match the generic type parameters on the element. + public static string @SA1620Description => GetResourceString("SA1620Description")!; + /// The type parameter '{0}' does not exist. + public static string @SA1620MissingMessageFormat => GetResourceString("SA1620MissingMessageFormat")!; + /// Generic type parameter documentation should match type parameters + public static string @SA1620Title => GetResourceString("SA1620Title")!; + /// The type parameter documentation for '{0}' should be at position {1}. + public static string @SA1620WrongOrderMessageFormat => GetResourceString("SA1620WrongOrderMessageFormat")!; + /// A <typeparam> tag within the XML header documentation for a generic C# element is missing a name attribute, or contains an empty name attribute. + public static string @SA1621Description => GetResourceString("SA1621Description")!; + /// Generic type parameter documentation should declare parameter name. + public static string @SA1621MessageFormat => GetResourceString("SA1621MessageFormat")!; + /// Generic type parameter documentation should declare parameter name + public static string @SA1621Title => GetResourceString("SA1621Title")!; + /// A <typeparam> tag within the Xml header documentation for a generic C# element is empty. + public static string @SA1622Description => GetResourceString("SA1622Description")!; + /// Generic type parameter documentation should have text. + public static string @SA1622MessageFormat => GetResourceString("SA1622MessageFormat")!; + /// Generic type parameter documentation should have text + public static string @SA1622Title => GetResourceString("SA1622Title")!; + /// The documentation text within a C# property’s <summary> tag does not match the accessors within the property. + public static string @SA1623Description => GetResourceString("SA1623Description")!; + /// The property's documentation summary text should begin with: '{0}' + public static string @SA1623MessageFormat => GetResourceString("SA1623MessageFormat")!; + /// Property summary documentation should match accessors + public static string @SA1623Title => GetResourceString("SA1623Title")!; + /// The documentation text within a C# property’s <summary> tag takes into account all of the accessors within the property, but one of the accessors has limited access. + public static string @SA1624Description => GetResourceString("SA1624Description")!; + /// Because the property only contains a visible {0} accessor, the documentation summary text should begin with '{1}'. + public static string @SA1624MessageFormat => GetResourceString("SA1624MessageFormat")!; + /// Property summary documentation should omit accessor with restricted access + public static string @SA1624Title => GetResourceString("SA1624Title")!; + /// The Xml documentation for a C# element contains two or more identical entries, indicating that the documentation has been copied and pasted. This can sometimes indicate invalid or poorly written documentation. + public static string @SA1625Description => GetResourceString("SA1625Description")!; + /// Element documentation should not be copied and pasted + public static string @SA1625MessageFormat => GetResourceString("SA1625MessageFormat")!; + /// Element documentation should not be copied and pasted + public static string @SA1625Title => GetResourceString("SA1625Title")!; + /// Convert to line comment + public static string @SA1626CodeFix => GetResourceString("SA1626CodeFix")!; + /// The C# code contains a single-line comment which begins with three forward slashes in a row. + public static string @SA1626Description => GetResourceString("SA1626Description")!; + /// Single-line comments should not use documentation style slashes + public static string @SA1626MessageFormat => GetResourceString("SA1626MessageFormat")!; + /// Single-line comments should not use documentation style slashes + public static string @SA1626Title => GetResourceString("SA1626Title")!; + /// The XML header documentation for a C# code element contains an empty tag. + public static string @SA1627Description => GetResourceString("SA1627Description")!; + /// The documentation text within the '{0}' tag should not be empty + public static string @SA1627MessageFormat => GetResourceString("SA1627MessageFormat")!; + /// Documentation text should not be empty + public static string @SA1627Title => GetResourceString("SA1627Title")!; + /// A section of the XML header documentation for a C# element does not begin with a capital letter. + public static string @SA1628Description => GetResourceString("SA1628Description")!; + /// TODO: Message format + public static string @SA1628MessageFormat => GetResourceString("SA1628MessageFormat")!; + /// Documentation text should begin with a capital letter + public static string @SA1628Title => GetResourceString("SA1628Title")!; + /// Add period + public static string @SA1629CodeFix => GetResourceString("SA1629CodeFix")!; + /// A section of the XML header documentation for a C# element does not end with a period. + public static string @SA1629Description => GetResourceString("SA1629Description")!; + /// Documentation text should end with a period + public static string @SA1629MessageFormat => GetResourceString("SA1629MessageFormat")!; + /// Documentation text should end with a period + public static string @SA1629Title => GetResourceString("SA1629Title")!; + /// A section of the XML header documentation for a C# element does not contain any whitespace between words. + public static string @SA1630Description => GetResourceString("SA1630Description")!; + /// TODO: Message format + public static string @SA1630MessageFormat => GetResourceString("SA1630MessageFormat")!; + /// Documentation text should contain whitespace + public static string @SA1630Title => GetResourceString("SA1630Title")!; + /// A section of the Xml header documentation for a C# element does not contain enough alphabetic characters. + public static string @SA1631Description => GetResourceString("SA1631Description")!; + /// TODO: Message format + public static string @SA1631MessageFormat => GetResourceString("SA1631MessageFormat")!; + /// Documentation should meet character percentage + public static string @SA1631Title => GetResourceString("SA1631Title")!; + /// A section of the Xml header documentation for a C# element is too short. + public static string @SA1632Description => GetResourceString("SA1632Description")!; + /// TODO: Message format + public static string @SA1632MessageFormat => GetResourceString("SA1632MessageFormat")!; + /// Documentation text should meet minimum character length + public static string @SA1632Title => GetResourceString("SA1632Title")!; + /// Add file header + public static string @SA1633CodeFix => GetResourceString("SA1633CodeFix")!; + /// A C# code file is missing a standard file header. + public static string @SA1633Description => GetResourceString("SA1633Description")!; + /// The file header XML is invalid. + public static string @SA1633MessageFormatMalformed => GetResourceString("SA1633MessageFormatMalformed")!; + /// The file header is missing or not located at the top of the file. + public static string @SA1633MessageFormatMissing => GetResourceString("SA1633MessageFormatMissing")!; + /// File should have header + public static string @SA1633Title => GetResourceString("SA1633Title")!; + /// The file header at the top of a C# code file is missing a copyright tag. + public static string @SA1634Description => GetResourceString("SA1634Description")!; + /// The file header should contain a copyright tag. + public static string @SA1634MessageFormat => GetResourceString("SA1634MessageFormat")!; + /// File header should show copyright + public static string @SA1634Title => GetResourceString("SA1634Title")!; + /// The file header at the top of a C# code file is missing copyright text. + public static string @SA1635Description => GetResourceString("SA1635Description")!; + /// File header should have copyright text + public static string @SA1635MessageFormat => GetResourceString("SA1635MessageFormat")!; + /// File header should have copyright text + public static string @SA1635Title => GetResourceString("SA1635Title")!; + /// The file header at the top of a C# code file does not contain the appropriate copyright text. + public static string @SA1636Description => GetResourceString("SA1636Description")!; + /// The file header copyright text should match the copyright text from the settings. + public static string @SA1636MessageFormat => GetResourceString("SA1636MessageFormat")!; + /// File header copyright text should match + public static string @SA1636Title => GetResourceString("SA1636Title")!; + /// The file header at the top of a C# code file is missing the file name. + public static string @SA1637Description => GetResourceString("SA1637Description")!; + /// File header should contain file name. + public static string @SA1637MessageFormat => GetResourceString("SA1637MessageFormat")!; + /// File header should contain file name + public static string @SA1637Title => GetResourceString("SA1637Title")!; + /// The file attribute within copyright tag of the file header at the top of a C# code file does not contain the name of the file. + public static string @SA1638Description => GetResourceString("SA1638Description")!; + /// File header file name documentation should match file name. + public static string @SA1638MessageFormat => GetResourceString("SA1638MessageFormat")!; + /// File header file name documentation should match file name + public static string @SA1638Title => GetResourceString("SA1638Title")!; + /// The file header at the top of a C# code file does not contain a filled-in summary tag. + public static string @SA1639Description => GetResourceString("SA1639Description")!; + /// File header should have summary + public static string @SA1639MessageFormat => GetResourceString("SA1639MessageFormat")!; + /// File header should have summary + public static string @SA1639Title => GetResourceString("SA1639Title")!; + /// The file header at the top of a C# code file does not contain company name text. + public static string @SA1640Description => GetResourceString("SA1640Description")!; + /// The copyright tag should contain a non-empty company attribute. + public static string @SA1640MessageFormat => GetResourceString("SA1640MessageFormat")!; + /// File header should have valid company text + public static string @SA1640Title => GetResourceString("SA1640Title")!; + /// The file header at the top of a C# code file does not contain the appropriate company name text. + public static string @SA1641Description => GetResourceString("SA1641Description")!; + /// The file header company name should match the company name from the settings. + public static string @SA1641MessageFormat => GetResourceString("SA1641MessageFormat")!; + /// File header company name text should match + public static string @SA1641Title => GetResourceString("SA1641Title")!; + /// The XML documentation header for a C# constructor does not contain the appropriate summary text. + public static string @SA1642Description => GetResourceString("SA1642Description")!; + /// Constructor summary documentation should begin with standard text + public static string @SA1642MessageFormat => GetResourceString("SA1642MessageFormat")!; + /// Add standard text + public static string @SA1642SA1643CodeFix => GetResourceString("SA1642SA1643CodeFix")!; + /// Constructor summary documentation should begin with standard text + public static string @SA1642Title => GetResourceString("SA1642Title")!; + /// The XML documentation header for a C# finalizer does not contain the appropriate summary text. + public static string @SA1643Description => GetResourceString("SA1643Description")!; + /// Destructor summary documentation should begin with standard text + public static string @SA1643MessageFormat => GetResourceString("SA1643MessageFormat")!; + /// Destructor summary documentation should begin with standard text + public static string @SA1643Title => GetResourceString("SA1643Title")!; + /// A section within the XML documentation header for a C# element contains blank lines. + public static string @SA1644Description => GetResourceString("SA1644Description")!; + /// TODO: Message format + public static string @SA1644MessageFormat => GetResourceString("SA1644MessageFormat")!; + /// Documentation headers should not contain blank lines + public static string @SA1644Title => GetResourceString("SA1644Title")!; + /// An included XML documentation file does not exist. + public static string @SA1645Description => GetResourceString("SA1645Description")!; + /// TODO: Message format + public static string @SA1645MessageFormat => GetResourceString("SA1645MessageFormat")!; + /// Included documentation file does not exist + public static string @SA1645Title => GetResourceString("SA1645Title")!; + /// An included XML documentation link contains an invalid path. + public static string @SA1646Description => GetResourceString("SA1646Description")!; + /// TODO: Message format + public static string @SA1646MessageFormat => GetResourceString("SA1646MessageFormat")!; + /// Included documentation XPath does not exist + public static string @SA1646Title => GetResourceString("SA1646Title")!; + /// An include tag within an XML documentation header does not contain valid file and path attribute. + public static string @SA1647Description => GetResourceString("SA1647Description")!; + /// TODO: Message format + public static string @SA1647MessageFormat => GetResourceString("SA1647MessageFormat")!; + /// Include node does not contain valid file and path + public static string @SA1647Title => GetResourceString("SA1647Title")!; + /// <inheritdoc> has been used on an element that doesn't inherit from a base class or implement an interface. + public static string @SA1648Description => GetResourceString("SA1648Description")!; + /// inheritdoc should be used with inheriting class + public static string @SA1648MessageFormat => GetResourceString("SA1648MessageFormat")!; + /// inheritdoc should be used with inheriting class + public static string @SA1648Title => GetResourceString("SA1648Title")!; + /// Rename file to match first type name + public static string @SA1649CodeFix => GetResourceString("SA1649CodeFix")!; + /// The file name of a C# code file does not match the first type declared in the file. + public static string @SA1649Description => GetResourceString("SA1649Description")!; + /// File name should match first type name + public static string @SA1649MessageFormat => GetResourceString("SA1649MessageFormat")!; + /// File name should match first type name + public static string @SA1649Title => GetResourceString("SA1649Title")!; + /// The element documentation for the element contains one or more spelling mistakes or unrecognized words. + public static string @SA1650Description => GetResourceString("SA1650Description")!; + /// TODO: Message format + public static string @SA1650MessageFormat => GetResourceString("SA1650MessageFormat")!; + /// Element documentation should be spelled correctly + public static string @SA1650Title => GetResourceString("SA1650Title")!; + /// Finalize placeholder text + public static string @SA1651CodeFix => GetResourceString("SA1651CodeFix")!; + /// The element documentation contains a <placeholder> element. + public static string @SA1651Description => GetResourceString("SA1651Description")!; + /// Do not use placeholder elements + public static string @SA1651MessageFormat => GetResourceString("SA1651MessageFormat")!; + /// Do not use placeholder elements + public static string @SA1651Title => GetResourceString("SA1651Title")!; + /// Gets + public static string @StartingTextGets => GetResourceString("StartingTextGets")!; + /// Gets or sets + public static string @StartingTextGetsOrSets => GetResourceString("StartingTextGetsOrSets")!; + /// Gets or sets a value indicating whether + public static string @StartingTextGetsOrSetsWhether => GetResourceString("StartingTextGetsOrSetsWhether")!; + /// Gets a value indicating whether + public static string @StartingTextGetsWhether => GetResourceString("StartingTextGetsWhether")!; + /// Returns + public static string @StartingTextReturns => GetResourceString("StartingTextReturns")!; + /// Returns a value indicating whether + public static string @StartingTextReturnsWhether => GetResourceString("StartingTextReturnsWhether")!; + /// Sets + public static string @StartingTextSets => GetResourceString("StartingTextSets")!; + /// Sets a value indicating whether + public static string @StartingTextSetsWhether => GetResourceString("StartingTextSetsWhether")!; + /// Initializes static members of the + public static string @StaticConstructorStandardTextFirstPart => GetResourceString("StaticConstructorStandardTextFirstPart")!; + /// {0} + public static string @StaticConstructorStandardTextSecondPart => GetResourceString("StaticConstructorStandardTextSecondPart")!; + /// A + public static string @TaskReturnElementFirstPart => GetResourceString("TaskReturnElementFirstPart")!; + /// representing the result of the asynchronous operation. + public static string @TaskReturnElementSecondPart => GetResourceString("TaskReturnElementSecondPart")!; + /// class + public static string @TypeTextClass => GetResourceString("TypeTextClass")!; + /// struct + public static string @TypeTextStruct => GetResourceString("TypeTextStruct")!; + + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/HelpersResources.Designer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/HelpersResources.Designer.cs new file mode 100644 index 000000000..126525ea1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/HelpersResources.Designer.cs @@ -0,0 +1,25 @@ +// + +#nullable enable +using System.Reflection; + + +namespace StyleCop.Analyzers.Helpers +{ + internal static partial class HelpersResources + { + private static global::System.Resources.ResourceManager? s_resourceManager; + public static global::System.Resources.ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new global::System.Resources.ResourceManager(typeof(HelpersResources))); + public static global::System.Globalization.CultureInfo? Culture { get; set; } + [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + [return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("defaultValue")] + internal static string? GetResourceString(string resourceKey, string? defaultValue = null) => ResourceManager.GetString(resourceKey, Culture) ?? defaultValue; + /// Fix all '{0}' + public static string @FixAllOccurrencesOfDiagnostic => GetResourceString("FixAllOccurrencesOfDiagnostic")!; + /// Fix all '{0}' in '{1}' + public static string @FixAllOccurrencesOfDiagnosticInScope => GetResourceString("FixAllOccurrencesOfDiagnosticInScope")!; + /// Fix all '{0}' in Solution + public static string @FixAllOccurrencesOfDiagnosticInSolution => GetResourceString("FixAllOccurrencesOfDiagnosticInSolution")!; + + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/LayoutResources.Designer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/LayoutResources.Designer.cs new file mode 100644 index 000000000..b261b244e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/LayoutResources.Designer.cs @@ -0,0 +1,207 @@ +// + +#nullable enable +using System.Reflection; + + +namespace StyleCop.Analyzers.LayoutRules +{ + internal static partial class LayoutResources + { + private static global::System.Resources.ResourceManager? s_resourceManager; + public static global::System.Resources.ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new global::System.Resources.ResourceManager(typeof(LayoutResources))); + public static global::System.Globalization.CultureInfo? Culture { get; set; } + [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + [return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("defaultValue")] + internal static string? GetResourceString(string resourceKey, string? defaultValue = null) => ResourceManager.GetString(resourceKey, Culture) ?? defaultValue; + /// Align braces + public static string @SA1500CodeFix => GetResourceString("SA1500CodeFix")!; + /// The opening or closing brace within a C# statement, element, or expression is not placed on its own line. + public static string @SA1500Description => GetResourceString("SA1500Description")!; + /// Braces for multi-line statements should not share line + public static string @SA1500MessageFormat => GetResourceString("SA1500MessageFormat")!; + /// Braces for multi-line statements should not share line + public static string @SA1500Title => GetResourceString("SA1500Title")!; + /// Expand single line block + public static string @SA1501CodeFix => GetResourceString("SA1501CodeFix")!; + /// Expand all single line blocks + public static string @SA1501CodeFixAll => GetResourceString("SA1501CodeFixAll")!; + /// A C# statement containing opening and closing braces is written completely on a single line. + public static string @SA1501Description => GetResourceString("SA1501Description")!; + /// Statement should not be on a single line + public static string @SA1501MessageFormat => GetResourceString("SA1501MessageFormat")!; + /// Statement should not be on a single line + public static string @SA1501Title => GetResourceString("SA1501Title")!; + /// Expand element + public static string @SA1502CodeFix => GetResourceString("SA1502CodeFix")!; + /// A C# element containing opening and closing braces is written completely on a single line. + public static string @SA1502Description => GetResourceString("SA1502Description")!; + /// Element should not be on a single line + public static string @SA1502MessageFormat => GetResourceString("SA1502MessageFormat")!; + /// Element should not be on a single line + public static string @SA1502Title => GetResourceString("SA1502Title")!; + /// Wrap with braces + public static string @SA1503CodeFix => GetResourceString("SA1503CodeFix")!; + /// The opening and closing braces for a C# statement have been omitted. + public static string @SA1503Description => GetResourceString("SA1503Description")!; + /// Braces should not be omitted + public static string @SA1503MessageFormat => GetResourceString("SA1503MessageFormat")!; + /// Braces should not be omitted + public static string @SA1503Title => GetResourceString("SA1503Title")!; + /// Reformat accessors to multiple lines style + public static string @SA1504CodeFixMultipleLines => GetResourceString("SA1504CodeFixMultipleLines")!; + /// Reformat accessors to single line style + public static string @SA1504CodeFixSingleLine => GetResourceString("SA1504CodeFixSingleLine")!; + /// Within a C# property, indexer or event, at least one of the child accessors is written on a single line, and at least one of the child accessors is written across multiple lines. + public static string @SA1504Description => GetResourceString("SA1504Description")!; + /// All accessors should be single-line or multi-line + public static string @SA1504MessageFormat => GetResourceString("SA1504MessageFormat")!; + /// All accessors should be single-line or multi-line + public static string @SA1504Title => GetResourceString("SA1504Title")!; + /// Remove blank lines following this brace + public static string @SA1505CodeFix => GetResourceString("SA1505CodeFix")!; + /// An opening brace within a C# element, statement, or expression is followed by a blank line. + public static string @SA1505Description => GetResourceString("SA1505Description")!; + /// An opening brace should not be followed by a blank line + public static string @SA1505MessageFormat => GetResourceString("SA1505MessageFormat")!; + /// Opening braces should not be followed by blank line + public static string @SA1505Title => GetResourceString("SA1505Title")!; + /// Remove blank line(s) after documentation header + public static string @SA1506CodeFix => GetResourceString("SA1506CodeFix")!; + /// An element documentation header above a C# element is followed by a blank line. + public static string @SA1506Description => GetResourceString("SA1506Description")!; + /// Element documentation headers should not be followed by blank line + public static string @SA1506MessageFormat => GetResourceString("SA1506MessageFormat")!; + /// Element documentation headers should not be followed by blank line + public static string @SA1506Title => GetResourceString("SA1506Title")!; + /// Remove multiple blank lines + public static string @SA1507CodeFix => GetResourceString("SA1507CodeFix")!; + /// The C# code contains multiple blank lines in a row. + public static string @SA1507Description => GetResourceString("SA1507Description")!; + /// Code should not contain multiple blank lines in a row + public static string @SA1507MessageFormat => GetResourceString("SA1507MessageFormat")!; + /// Code should not contain multiple blank lines in a row + public static string @SA1507Title => GetResourceString("SA1507Title")!; + /// Remove blank lines preceding this brace + public static string @SA1508CodeFix => GetResourceString("SA1508CodeFix")!; + /// A closing brace within a C# element, statement, or expression is preceded by a blank line. + public static string @SA1508Description => GetResourceString("SA1508Description")!; + /// A closing brace should not be preceded by a blank line + public static string @SA1508MessageFormat => GetResourceString("SA1508MessageFormat")!; + /// Closing braces should not be preceded by blank line + public static string @SA1508Title => GetResourceString("SA1508Title")!; + /// Remove blank lines preceding this brace + public static string @SA1509CodeFix => GetResourceString("SA1509CodeFix")!; + /// An opening brace within a C# element, statement, or expression is preceded by a blank line. + public static string @SA1509Description => GetResourceString("SA1509Description")!; + /// Opening braces should not be preceded by blank line + public static string @SA1509MessageFormat => GetResourceString("SA1509MessageFormat")!; + /// Opening braces should not be preceded by blank line + public static string @SA1509Title => GetResourceString("SA1509Title")!; + /// Remove blank line before chained statement + public static string @SA1510CodeFix => GetResourceString("SA1510CodeFix")!; + /// Chained C# statements are separated by a blank line. + public static string @SA1510Description => GetResourceString("SA1510Description")!; + /// '{0}' statement should not be preceded by a blank line + public static string @SA1510MessageFormat => GetResourceString("SA1510MessageFormat")!; + /// Chained statement blocks should not be preceded by blank line + public static string @SA1510Title => GetResourceString("SA1510Title")!; + /// Remove blank line before while + public static string @SA1511CodeFix => GetResourceString("SA1511CodeFix")!; + /// The while footer at the bottom of a do-while statement is separated from the statement by a blank line. + public static string @SA1511Description => GetResourceString("SA1511Description")!; + /// While-do footer should not be preceded by blank line + public static string @SA1511MessageFormat => GetResourceString("SA1511MessageFormat")!; + /// While-do footer should not be preceded by blank line + public static string @SA1511Title => GetResourceString("SA1511Title")!; + /// Remove blank line after comment + public static string @SA1512CodeFix => GetResourceString("SA1512CodeFix")!; + /// A single-line comment within C# code is followed by a blank line. + public static string @SA1512Description => GetResourceString("SA1512Description")!; + /// Single-line comments should not be followed by blank line + public static string @SA1512MessageFormat => GetResourceString("SA1512MessageFormat")!; + /// Single-line comments should not be followed by blank line + public static string @SA1512Title => GetResourceString("SA1512Title")!; + /// Insert blank line after brace + public static string @SA1513CodeFix => GetResourceString("SA1513CodeFix")!; + /// A closing brace within a C# element, statement, or expression is not followed by a blank line. + public static string @SA1513Description => GetResourceString("SA1513Description")!; + /// Closing brace should be followed by blank line + public static string @SA1513MessageFormat => GetResourceString("SA1513MessageFormat")!; + /// Closing brace should be followed by blank line + public static string @SA1513Title => GetResourceString("SA1513Title")!; + /// Insert blank line before documentation header + public static string @SA1514CodeFix => GetResourceString("SA1514CodeFix")!; + /// An element documentation header above a C# element is not preceded by a blank line. + public static string @SA1514Description => GetResourceString("SA1514Description")!; + /// Element documentation header should be preceded by blank line + public static string @SA1514MessageFormat => GetResourceString("SA1514MessageFormat")!; + /// Element documentation header should be preceded by blank line + public static string @SA1514Title => GetResourceString("SA1514Title")!; + /// Insert blank line before comment + public static string @SA1515CodeFix => GetResourceString("SA1515CodeFix")!; + /// A single-line comment within C# code is not preceded by a blank line. + public static string @SA1515Description => GetResourceString("SA1515Description")!; + /// Single-line comment should be preceded by blank line + public static string @SA1515MessageFormat => GetResourceString("SA1515MessageFormat")!; + /// Single-line comment should be preceded by blank line + public static string @SA1515Title => GetResourceString("SA1515Title")!; + /// Fix blank lines + public static string @SA1516CodeFixAll => GetResourceString("SA1516CodeFixAll")!; + /// Insert new line + public static string @SA1516CodeFixInsert => GetResourceString("SA1516CodeFixInsert")!; + /// Remove blank line + public static string @SA1516CodeFixRemove => GetResourceString("SA1516CodeFixRemove")!; + /// Adjacent C# elements are not separated by a blank line. + public static string @SA1516Description => GetResourceString("SA1516Description")!; + /// Adjacent using directives should not be separated by a blank line. + public static string @SA1516DescriptionOmit => GetResourceString("SA1516DescriptionOmit")!; + /// Adjacent using directives should be separated by a blank line. + public static string @SA1516DescriptionRequire => GetResourceString("SA1516DescriptionRequire")!; + /// Elements should be separated by blank line + public static string @SA1516MessageFormat => GetResourceString("SA1516MessageFormat")!; + /// Using directives should not be separated by blank line + public static string @SA1516MessageFormatOmit => GetResourceString("SA1516MessageFormatOmit")!; + /// Using directives should be separated by blank line + public static string @SA1516MessageFormatRequire => GetResourceString("SA1516MessageFormatRequire")!; + /// Elements should be separated by blank line + public static string @SA1516Title => GetResourceString("SA1516Title")!; + /// Remove blank lines at the start of the file + public static string @SA1517CodeFix => GetResourceString("SA1517CodeFix")!; + /// The code file has blank lines at the start. + public static string @SA1517Description => GetResourceString("SA1517Description")!; + /// Code should not contain blank lines at start of file + public static string @SA1517MessageFormat => GetResourceString("SA1517MessageFormat")!; + /// Code should not contain blank lines at start of file + public static string @SA1517Title => GetResourceString("SA1517Title")!; + /// Fix whitespace at the end of the file + public static string @SA1518CodeFix => GetResourceString("SA1518CodeFix")!; + /// Code should not contain blank lines at the end of the file. + public static string @SA1518DescriptionAllow => GetResourceString("SA1518DescriptionAllow")!; + /// File may not end with a newline character. + public static string @SA1518DescriptionOmit => GetResourceString("SA1518DescriptionOmit")!; + /// File is required to end with a single newline character. + public static string @SA1518DescriptionRequire => GetResourceString("SA1518DescriptionRequire")!; + /// Code should not contain blank lines at the end of the file + public static string @SA1518MessageFormatAllow => GetResourceString("SA1518MessageFormatAllow")!; + /// File may not end with a newline character + public static string @SA1518MessageFormatOmit => GetResourceString("SA1518MessageFormatOmit")!; + /// File is required to end with a single newline character + public static string @SA1518MessageFormatRequire => GetResourceString("SA1518MessageFormatRequire")!; + /// Use line endings correctly at end of file + public static string @SA1518Title => GetResourceString("SA1518Title")!; + /// The opening and closing braces for a multi-line C# statement have been omitted. + public static string @SA1519Description => GetResourceString("SA1519Description")!; + /// Braces should not be omitted from multi-line child statement + public static string @SA1519MessageFormat => GetResourceString("SA1519MessageFormat")!; + /// Braces should not be omitted from multi-line child statement + public static string @SA1519Title => GetResourceString("SA1519Title")!; + /// The opening and closing braces of a chained if/else if/else construct were included for some clauses, but omitted for others. + public static string @SA1520Description => GetResourceString("SA1520Description")!; + /// Use braces consistently + public static string @SA1520MessageFormat => GetResourceString("SA1520MessageFormat")!; + /// Use braces consistently + public static string @SA1520Title => GetResourceString("SA1520Title")!; + + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/MaintainabilityResources.Designer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/MaintainabilityResources.Designer.cs new file mode 100644 index 000000000..c704b6b44 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/MaintainabilityResources.Designer.cs @@ -0,0 +1,131 @@ +// + +#nullable enable +using System.Reflection; + + +namespace StyleCop.Analyzers.MaintainabilityRules +{ + internal static partial class MaintainabilityResources + { + private static global::System.Resources.ResourceManager? s_resourceManager; + public static global::System.Resources.ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new global::System.Resources.ResourceManager(typeof(MaintainabilityResources))); + public static global::System.Globalization.CultureInfo? Culture { get; set; } + [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + [return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("defaultValue")] + internal static string? GetResourceString(string resourceKey, string? defaultValue = null) => ResourceManager.GetString(resourceKey, Culture) ?? defaultValue; + /// Remove parentheses + public static string @SA1119CodeFix => GetResourceString("SA1119CodeFix")!; + /// A C# statement contains parenthesis which are unnecessary and should be removed. + public static string @SA1119Description => GetResourceString("SA1119Description")!; + /// Statement should not use unnecessary parenthesis + public static string @SA1119MessageFormat => GetResourceString("SA1119MessageFormat")!; + /// Statement should not use unnecessary parenthesis + public static string @SA1119Title => GetResourceString("SA1119Title")!; + /// Declare accessibility + public static string @SA1400CodeFix => GetResourceString("SA1400CodeFix")!; + /// The access modifier for a C# element has not been explicitly defined. + public static string @SA1400Description => GetResourceString("SA1400Description")!; + /// Element '{0}' should declare an access modifier + public static string @SA1400MessageFormat => GetResourceString("SA1400MessageFormat")!; + /// Access modifier should be declared + public static string @SA1400Title => GetResourceString("SA1400Title")!; + /// A field within a C# class has an access modifier other than private. + public static string @SA1401Description => GetResourceString("SA1401Description")!; + /// Field should be private + public static string @SA1401MessageFormat => GetResourceString("SA1401MessageFormat")!; + /// Fields should be private + public static string @SA1401Title => GetResourceString("SA1401Title")!; + /// Move type to new file + public static string @SA1402CodeFix => GetResourceString("SA1402CodeFix")!; + /// A C# code file contains more than one unique type. + public static string @SA1402Description => GetResourceString("SA1402Description")!; + /// File may only contain a single type + public static string @SA1402MessageFormat => GetResourceString("SA1402MessageFormat")!; + /// File may only contain a single type + public static string @SA1402Title => GetResourceString("SA1402Title")!; + /// A C# code file contains more than one namespace. + public static string @SA1403Description => GetResourceString("SA1403Description")!; + /// File may only contain a single namespace + public static string @SA1403MessageFormat => GetResourceString("SA1403MessageFormat")!; + /// File may only contain a single namespace + public static string @SA1403Title => GetResourceString("SA1403Title")!; + /// Fix justification + public static string @SA1404CodeFix => GetResourceString("SA1404CodeFix")!; + /// A Code Analysis SuppressMessage attribute does not include a justification. + public static string @SA1404Description => GetResourceString("SA1404Description")!; + /// Code analysis suppression should have justification + public static string @SA1404MessageFormat => GetResourceString("SA1404MessageFormat")!; + /// Code analysis suppression should have justification + public static string @SA1404Title => GetResourceString("SA1404Title")!; + /// A call to Debug.Assert in C# code does not include a descriptive message. + public static string @SA1405Description => GetResourceString("SA1405Description")!; + /// Debug.Assert should provide message text + public static string @SA1405MessageFormat => GetResourceString("SA1405MessageFormat")!; + /// Debug.Assert should provide message text + public static string @SA1405Title => GetResourceString("SA1405Title")!; + /// A call to Debug.Fail in C# code does not include a descriptive message. + public static string @SA1406Description => GetResourceString("SA1406Description")!; + /// Debug.Fail should provide message text + public static string @SA1406MessageFormat => GetResourceString("SA1406MessageFormat")!; + /// Debug.Fail should provide message text + public static string @SA1406Title => GetResourceString("SA1406Title")!; + /// A C# statement contains a complex arithmetic expression which omits parenthesis around operators. + public static string @SA1407Description => GetResourceString("SA1407Description")!; + /// Arithmetic expressions should declare precedence + public static string @SA1407MessageFormat => GetResourceString("SA1407MessageFormat")!; + /// Add parentheses + public static string @SA1407SA1408CodeFix => GetResourceString("SA1407SA1408CodeFix")!; + /// Arithmetic expressions should declare precedence + public static string @SA1407Title => GetResourceString("SA1407Title")!; + /// A C# statement contains a complex conditional expression which omits parenthesis around operators. + public static string @SA1408Description => GetResourceString("SA1408Description")!; + /// Conditional expressions should declare precedence + public static string @SA1408MessageFormat => GetResourceString("SA1408MessageFormat")!; + /// Conditional expressions should declare precedence + public static string @SA1408Title => GetResourceString("SA1408Title")!; + /// A C# file contains code which is unnecessary and can be removed without changing the overall logic of the code. + public static string @SA1409Description => GetResourceString("SA1409Description")!; + /// TODO: Message format + public static string @SA1409MessageFormat => GetResourceString("SA1409MessageFormat")!; + /// Remove unnecessary code + public static string @SA1409Title => GetResourceString("SA1409Title")!; + /// A call to a C# anonymous method does not contain any method parameters, yet the statement still includes parenthesis. + public static string @SA1410Description => GetResourceString("SA1410Description")!; + /// Remove delegate parenthesis when possible + public static string @SA1410MessageFormat => GetResourceString("SA1410MessageFormat")!; + /// Remove parentheses + public static string @SA1410SA1411CodeFix => GetResourceString("SA1410SA1411CodeFix")!; + /// Remove delegate parenthesis when possible + public static string @SA1410Title => GetResourceString("SA1410Title")!; + /// TODO. + public static string @SA1411Description => GetResourceString("SA1411Description")!; + /// Attribute constructor should not use unnecessary parenthesis + public static string @SA1411MessageFormat => GetResourceString("SA1411MessageFormat")!; + /// Attribute constructor should not use unnecessary parenthesis + public static string @SA1411Title => GetResourceString("SA1411Title")!; + /// Change encoding from '{0}' to UTF-8 with byte order mark + public static string @SA1412CodeFix => GetResourceString("SA1412CodeFix")!; + /// Source files should be saved using the UTF-8 encoding with a byte order mark. + public static string @SA1412Description => GetResourceString("SA1412Description")!; + /// Store files as UTF-8 with byte order mark + public static string @SA1412MessageFormat => GetResourceString("SA1412MessageFormat")!; + /// Store files as UTF-8 with byte order mark + public static string @SA1412Title => GetResourceString("SA1412Title")!; + /// Add trailing comma + public static string @SA1413CodeFix => GetResourceString("SA1413CodeFix")!; + /// A multi-line initializer in a C# code file should use a comma on the last line. + public static string @SA1413Description => GetResourceString("SA1413Description")!; + /// Use trailing comma in multi-line initializers + public static string @SA1413MessageFormat => GetResourceString("SA1413MessageFormat")!; + /// Use trailing comma in multi-line initializers + public static string @SA1413Title => GetResourceString("SA1413Title")!; + /// Tuple types appearing in member declarations should have explicitly named tuple elements. + public static string @SA1414Description => GetResourceString("SA1414Description")!; + /// Tuple types in signatures should have element names + public static string @SA1414MessageFormat => GetResourceString("SA1414MessageFormat")!; + /// Tuple types in signatures should have element names + public static string @SA1414Title => GetResourceString("SA1414Title")!; + + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/NamingResources.Designer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/NamingResources.Designer.cs new file mode 100644 index 000000000..6393d2d1b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/NamingResources.Designer.cs @@ -0,0 +1,135 @@ +// + +#nullable enable +using System.Reflection; + + +namespace StyleCop.Analyzers.NamingRules +{ + internal static partial class NamingResources + { + private static global::System.Resources.ResourceManager? s_resourceManager; + public static global::System.Resources.ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new global::System.Resources.ResourceManager(typeof(NamingResources))); + public static global::System.Globalization.CultureInfo? Culture { get; set; } + [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + [return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("defaultValue")] + internal static string? GetResourceString(string resourceKey, string? defaultValue = null) => ResourceManager.GetString(resourceKey, Culture) ?? defaultValue; + /// Rename To '{0}' + public static string @RenameToCodeFix => GetResourceString("RenameToCodeFix")!; + /// The name of a C# element does not begin with an upper-case letter. + public static string @SA1300Description => GetResourceString("SA1300Description")!; + /// Element '{0}' should begin with an uppercase letter + public static string @SA1300MessageFormat => GetResourceString("SA1300MessageFormat")!; + /// Element should begin with upper-case letter + public static string @SA1300Title => GetResourceString("SA1300Title")!; + /// There are currently no situations in which this rule will fire. + public static string @SA1301Description => GetResourceString("SA1301Description")!; + /// Element should begin with lower-case letter + public static string @SA1301MessageFormat => GetResourceString("SA1301MessageFormat")!; + /// Element should begin with lower-case letter + public static string @SA1301Title => GetResourceString("SA1301Title")!; + /// Prefix interface name with 'I' + public static string @SA1302CodeFix => GetResourceString("SA1302CodeFix")!; + /// The name of a C# interface does not begin with the capital letter I. + public static string @SA1302Description => GetResourceString("SA1302Description")!; + /// Interface names should begin with I + public static string @SA1302MessageFormat => GetResourceString("SA1302MessageFormat")!; + /// Interface names should begin with I + public static string @SA1302Title => GetResourceString("SA1302Title")!; + /// The name of a constant C# field should begin with an upper-case letter. + public static string @SA1303Description => GetResourceString("SA1303Description")!; + /// Const field names should begin with upper-case letter + public static string @SA1303MessageFormat => GetResourceString("SA1303MessageFormat")!; + /// Const field names should begin with upper-case letter + public static string @SA1303Title => GetResourceString("SA1303Title")!; + /// The name of a non-private readonly C# field should being with an upper-case letter. + public static string @SA1304Description => GetResourceString("SA1304Description")!; + /// Non-private readonly fields should begin with upper-case letter + public static string @SA1304MessageFormat => GetResourceString("SA1304MessageFormat")!; + /// Non-private readonly fields should begin with upper-case letter + public static string @SA1304Title => GetResourceString("SA1304Title")!; + /// The name of a field or variable in C# uses Hungarian notation. + public static string @SA1305Description => GetResourceString("SA1305Description")!; + /// {0} '{1}' should not use Hungarian notation + public static string @SA1305MessageFormat => GetResourceString("SA1305MessageFormat")!; + /// Field names should not use Hungarian notation + public static string @SA1305Title => GetResourceString("SA1305Title")!; + /// The name of a field in C# does not begin with a lower-case letter. + public static string @SA1306Description => GetResourceString("SA1306Description")!; + /// Field '{0}' should begin with lower-case letter + public static string @SA1306MessageFormat => GetResourceString("SA1306MessageFormat")!; + /// Field names should begin with lower-case letter + public static string @SA1306Title => GetResourceString("SA1306Title")!; + /// The name of a public or internal field in C# does not begin with an upper-case letter. + public static string @SA1307Description => GetResourceString("SA1307Description")!; + /// Field '{0}' should begin with upper-case letter + public static string @SA1307MessageFormat => GetResourceString("SA1307MessageFormat")!; + /// Accessible fields should begin with upper-case letter + public static string @SA1307Title => GetResourceString("SA1307Title")!; + /// A field name in C# is prefixed with 'm_', 's_', or 't_'. + public static string @SA1308Description => GetResourceString("SA1308Description")!; + /// Field '{0}' should not begin with the prefix '{1}' + public static string @SA1308MessageFormat => GetResourceString("SA1308MessageFormat")!; + /// Variable names should not be prefixed + public static string @SA1308Title => GetResourceString("SA1308Title")!; + /// A field name in C# begins with an underscore. + public static string @SA1309Description => GetResourceString("SA1309Description")!; + /// Field '{0}' should not begin with an underscore + public static string @SA1309MessageFormat => GetResourceString("SA1309MessageFormat")!; + /// Field names should not begin with underscore + public static string @SA1309Title => GetResourceString("SA1309Title")!; + /// A field name in C# contains an underscore. + public static string @SA1310Description => GetResourceString("SA1310Description")!; + /// Field '{0}' should not contain an underscore + public static string @SA1310MessageFormat => GetResourceString("SA1310MessageFormat")!; + /// Field names should not contain underscore + public static string @SA1310Title => GetResourceString("SA1310Title")!; + /// The name of a static readonly field does not begin with an upper-case letter. + public static string @SA1311Description => GetResourceString("SA1311Description")!; + /// Static readonly fields should begin with upper-case letter + public static string @SA1311MessageFormat => GetResourceString("SA1311MessageFormat")!; + /// Static readonly fields should begin with upper-case letter + public static string @SA1311Title => GetResourceString("SA1311Title")!; + /// The name of a variable in C# does not begin with a lower-case letter. + public static string @SA1312Description => GetResourceString("SA1312Description")!; + /// Variable '{0}' should begin with lower-case letter + public static string @SA1312MessageFormat => GetResourceString("SA1312MessageFormat")!; + /// Variable names should begin with lower-case letter + public static string @SA1312Title => GetResourceString("SA1312Title")!; + /// The name of a parameter in C# does not begin with a lower-case letter. + public static string @SA1313Description => GetResourceString("SA1313Description")!; + /// Parameter '{0}' should begin with lower-case letter + public static string @SA1313MessageFormat => GetResourceString("SA1313MessageFormat")!; + /// Parameter names should begin with lower-case letter + public static string @SA1313Title => GetResourceString("SA1313Title")!; + /// Prefix type parameter name with 'T' + public static string @SA1314CodeFix => GetResourceString("SA1314CodeFix")!; + /// The name of a C# type parameter does not begin with the capital letter T. + public static string @SA1314Description => GetResourceString("SA1314Description")!; + /// Type parameter names should begin with T + public static string @SA1314MessageFormat => GetResourceString("SA1314MessageFormat")!; + /// Type parameter names should begin with T + public static string @SA1314Title => GetResourceString("SA1314Title")!; + /// Correct tuple element name casing + public static string @SA1316CodeFix => GetResourceString("SA1316CodeFix")!; + /// Element names within a tuple type should have the correct casing. + public static string @SA1316Description => GetResourceString("SA1316Description")!; + /// Tuple element names should use correct casing + public static string @SA1316MessageFormat => GetResourceString("SA1316MessageFormat")!; + /// Tuple element names should use correct casing + public static string @SA1316Title => GetResourceString("SA1316Title")!; + /// A field name in C# does not begin with an underscore. + public static string @SX1309Description => GetResourceString("SX1309Description")!; + /// Field '{0}' should begin with an underscore + public static string @SX1309MessageFormat => GetResourceString("SX1309MessageFormat")!; + /// A static field name in C# does not begin with an underscore. + public static string @SX1309SDescription => GetResourceString("SX1309SDescription")!; + /// Static field '{0}' should begin with an underscore + public static string @SX1309SMessageFormat => GetResourceString("SX1309SMessageFormat")!; + /// Static field names should begin with underscore + public static string @SX1309STitle => GetResourceString("SX1309STitle")!; + /// Field names should begin with underscore + public static string @SX1309Title => GetResourceString("SX1309Title")!; + + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/OrderingResources.Designer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/OrderingResources.Designer.cs new file mode 100644 index 000000000..85eafd3e6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/OrderingResources.Designer.cs @@ -0,0 +1,137 @@ +// + +#nullable enable +using System.Reflection; + + +namespace StyleCop.Analyzers.OrderingRules +{ + internal static partial class OrderingResources + { + private static global::System.Resources.ResourceManager? s_resourceManager; + public static global::System.Resources.ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new global::System.Resources.ResourceManager(typeof(OrderingResources))); + public static global::System.Globalization.CultureInfo? Culture { get; set; } + [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + [return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("defaultValue")] + internal static string? GetResourceString(string resourceKey, string? defaultValue = null) => ResourceManager.GetString(resourceKey, Culture) ?? defaultValue; + /// Fix element order + public static string @ElementOrderCodeFix => GetResourceString("ElementOrderCodeFix")!; + /// Fix modifier order + public static string @ModifierOrderCodeFix => GetResourceString("ModifierOrderCodeFix")!; + /// A C# using directive is placed outside of a namespace element. + public static string @SA1200DescriptionInside => GetResourceString("SA1200DescriptionInside")!; + /// A C# using directive is placed inside of a namespace declaration. + public static string @SA1200DescriptionOutside => GetResourceString("SA1200DescriptionOutside")!; + /// Using directive should appear within a namespace declaration + public static string @SA1200MessageFormatInside => GetResourceString("SA1200MessageFormatInside")!; + /// Using directive should appear outside a namespace declaration + public static string @SA1200MessageFormatOutside => GetResourceString("SA1200MessageFormatOutside")!; + /// Using directives should be placed correctly + public static string @SA1200Title => GetResourceString("SA1200Title")!; + /// An element within a C# code file is out of order in relation to the other elements in the code. + public static string @SA1201Description => GetResourceString("SA1201Description")!; + /// A {0} should not follow a {1} + public static string @SA1201MessageFormat => GetResourceString("SA1201MessageFormat")!; + /// Elements should appear in the correct order + public static string @SA1201Title => GetResourceString("SA1201Title")!; + /// An element within a C# code file is out of order in relation to other elements in the code. + public static string @SA1202Description => GetResourceString("SA1202Description")!; + /// '{0}' members should come before '{1}' members + public static string @SA1202MessageFormat => GetResourceString("SA1202MessageFormat")!; + /// Elements should be ordered by access + public static string @SA1202Title => GetResourceString("SA1202Title")!; + /// A constant field is placed beneath a non-constant field. + public static string @SA1203Description => GetResourceString("SA1203Description")!; + /// Constant fields should appear before non-constant fields + public static string @SA1203MessageFormat => GetResourceString("SA1203MessageFormat")!; + /// Constants should appear before fields + public static string @SA1203Title => GetResourceString("SA1203Title")!; + /// A static element is positioned beneath an instance element. + public static string @SA1204Description => GetResourceString("SA1204Description")!; + /// Static members should appear before non-static members + public static string @SA1204MessageFormat => GetResourceString("SA1204MessageFormat")!; + /// Static elements should appear before instance elements + public static string @SA1204Title => GetResourceString("SA1204Title")!; + /// Add access modifier + public static string @SA1205CodeFix => GetResourceString("SA1205CodeFix")!; + /// The partial element does not have an access modifier defined. + public static string @SA1205Description => GetResourceString("SA1205Description")!; + /// Partial elements should declare an access modifier + public static string @SA1205MessageFormat => GetResourceString("SA1205MessageFormat")!; + /// Partial elements should declare access + public static string @SA1205Title => GetResourceString("SA1205Title")!; + /// The keywords within the declaration of an element do not follow a standard ordering scheme. + public static string @SA1206Description => GetResourceString("SA1206Description")!; + /// The '{0}' modifier should appear before '{1}' + public static string @SA1206MessageFormat => GetResourceString("SA1206MessageFormat")!; + /// Declaration keywords should follow order + public static string @SA1206Title => GetResourceString("SA1206Title")!; + /// Place keyword 'protected' before keyword 'internal' + public static string @SA1207CodeFix => GetResourceString("SA1207CodeFix")!; + /// The keyword '{0}' is positioned after the keyword '{1}' within the declaration of a {0} {1} C# element. + public static string @SA1207Description => GetResourceString("SA1207Description")!; + /// The keyword '{0}' should come before '{1}' + public static string @SA1207MessageFormat => GetResourceString("SA1207MessageFormat")!; + /// Protected should come before internal + public static string @SA1207Title => GetResourceString("SA1207Title")!; + /// A using directive which declares a member of the 'System' namespace appears after a using directive which declares a member of a different namespace, within a C# code file. + public static string @SA1208Description => GetResourceString("SA1208Description")!; + /// Using directive for '{0}' should appear before directive for '{1}' + public static string @SA1208MessageFormat => GetResourceString("SA1208MessageFormat")!; + /// System using directives should be placed before other using directives + public static string @SA1208Title => GetResourceString("SA1208Title")!; + /// A using-alias directive is positioned before a regular using directive. + public static string @SA1209Description => GetResourceString("SA1209Description")!; + /// Using alias directives should be placed after all using namespace directives + public static string @SA1209MessageFormat => GetResourceString("SA1209MessageFormat")!; + /// Using alias directives should be placed after other using directives + public static string @SA1209Title => GetResourceString("SA1209Title")!; + /// The using directives within a C# code file are not sorted alphabetically by namespace. + public static string @SA1210Description => GetResourceString("SA1210Description")!; + /// Using directives should be ordered alphabetically by the namespaces + public static string @SA1210MessageFormat => GetResourceString("SA1210MessageFormat")!; + /// Using directives should be ordered alphabetically by namespace + public static string @SA1210Title => GetResourceString("SA1210Title")!; + /// The using-alias directives within a C# code file are not sorted alphabetically by alias name. + public static string @SA1211Description => GetResourceString("SA1211Description")!; + /// Using alias directive for '{0}' should appear before using alias directive for '{1}' + public static string @SA1211MessageFormat => GetResourceString("SA1211MessageFormat")!; + /// Using alias directives should be ordered alphabetically by alias name + public static string @SA1211Title => GetResourceString("SA1211Title")!; + /// A get accessor appears after a set accessor within a property or indexer. + public static string @SA1212Description => GetResourceString("SA1212Description")!; + /// A get accessor appears after a set accessor within a property or indexer + public static string @SA1212MessageFormat => GetResourceString("SA1212MessageFormat")!; + /// Property accessors should follow order + public static string @SA1212Title => GetResourceString("SA1212Title")!; + /// Fix accessor order + public static string @SA1213CodeFix => GetResourceString("SA1213CodeFix")!; + /// An add accessor appears after a remove accessor within an event. + public static string @SA1213Description => GetResourceString("SA1213Description")!; + /// Event accessors should follow order + public static string @SA1213MessageFormat => GetResourceString("SA1213MessageFormat")!; + /// Event accessors should follow order + public static string @SA1213Title => GetResourceString("SA1213Title")!; + /// A readonly field is positioned beneath a non-readonly field. + public static string @SA1214Description => GetResourceString("SA1214Description")!; + /// Readonly fields should appear before non-readonly fields + public static string @SA1214MessageFormat => GetResourceString("SA1214MessageFormat")!; + /// Readonly fields should appear before non-readonly fields + public static string @SA1214Title => GetResourceString("SA1214Title")!; + /// A using static directive is positioned before a regular or after an alias using directive. + public static string @SA1216Description => GetResourceString("SA1216Description")!; + /// Using static directives should be placed at the correct location + public static string @SA1216MessageFormat => GetResourceString("SA1216MessageFormat")!; + /// Using static directives should be placed at the correct location + public static string @SA1216Title => GetResourceString("SA1216Title")!; + /// All using static directives should be ordered alphabetically. + public static string @SA1217Description => GetResourceString("SA1217Description")!; + /// The using static directive for '{0}' should appear after the using static directive for '{1}' + public static string @SA1217MessageFormat => GetResourceString("SA1217MessageFormat")!; + /// Using static directives should be ordered alphabetically + public static string @SA1217Title => GetResourceString("SA1217Title")!; + /// Reorder using statements + public static string @UsingCodeFix => GetResourceString("UsingCodeFix")!; + + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/ReadabilityResources.Designer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/ReadabilityResources.Designer.cs new file mode 100644 index 000000000..abcfec0b9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/ReadabilityResources.Designer.cs @@ -0,0 +1,323 @@ +// + +#nullable enable +using System.Reflection; + + +namespace StyleCop.Analyzers.ReadabilityRules +{ + internal static partial class ReadabilityResources + { + private static global::System.Resources.ResourceManager? s_resourceManager; + public static global::System.Resources.ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new global::System.Resources.ResourceManager(typeof(ReadabilityResources))); + public static global::System.Globalization.CultureInfo? Culture { get; set; } + [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + [return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("defaultValue")] + internal static string? GetResourceString(string resourceKey, string? defaultValue = null) => ResourceManager.GetString(resourceKey, Culture) ?? defaultValue; + /// Fix indentation + public static string @IndentationCodeFix => GetResourceString("IndentationCodeFix")!; + /// Remove region + public static string @RemoveRegionCodeFix => GetResourceString("RemoveRegionCodeFix")!; + /// Replace 'base.' with 'this.' + public static string @SA1100CodeFix => GetResourceString("SA1100CodeFix")!; + /// A call to a member from an inherited class begins with 'base.', and the local class does not contain an override or implementation of the member. + public static string @SA1100Description => GetResourceString("SA1100Description")!; + /// Do not prefix calls with base unless local implementation exists + public static string @SA1100MessageFormat => GetResourceString("SA1100MessageFormat")!; + /// Do not prefix calls with base unless local implementation exists + public static string @SA1100Title => GetResourceString("SA1100Title")!; + /// Prefix reference with 'this.' + public static string @SA1101CodeFix => GetResourceString("SA1101CodeFix")!; + /// A call to an instance member of the local class or a base class is not prefixed with 'this.', within a C# code file. + public static string @SA1101Description => GetResourceString("SA1101Description")!; + /// Prefix local calls with this + public static string @SA1101MessageFormat => GetResourceString("SA1101MessageFormat")!; + /// Prefix local calls with this + public static string @SA1101Title => GetResourceString("SA1101Title")!; + /// Remove separating lines + public static string @SA1102CodeFix => GetResourceString("SA1102CodeFix")!; + /// A C# query clause does not begin on the same line as the previous clause, or on the next line. + public static string @SA1102Description => GetResourceString("SA1102Description")!; + /// Query clause should follow previous clause. + public static string @SA1102MessageFormat => GetResourceString("SA1102MessageFormat")!; + /// Query clause should follow previous clause + public static string @SA1102Title => GetResourceString("SA1102Title")!; + /// Place on multiple lines + public static string @SA1103CodeFixMultipleLines => GetResourceString("SA1103CodeFixMultipleLines")!; + /// Place on single line + public static string @SA1103CodeFixSingleLine => GetResourceString("SA1103CodeFixSingleLine")!; + /// The clauses within a C# query expression are not all placed on the same line, and each clause is not placed on its own line. + public static string @SA1103Description => GetResourceString("SA1103Description")!; + /// Query clauses should be on separate lines or all on one line + public static string @SA1103MessageFormat => GetResourceString("SA1103MessageFormat")!; + /// Query clauses should be on separate lines or all on one line + public static string @SA1103Title => GetResourceString("SA1103Title")!; + /// A clause within a C# query expression begins on the same line as the previous clause, when the previous clause spans across multiple lines. + public static string @SA1104Description => GetResourceString("SA1104Description")!; + /// Query clause should begin on new line when previous clause spans multiple lines + public static string @SA1104MessageFormat => GetResourceString("SA1104MessageFormat")!; + /// Insert new line + public static string @SA1104SA1105CodeFix => GetResourceString("SA1104SA1105CodeFix")!; + /// Query clause should begin on new line when previous clause spans multiple lines + public static string @SA1104Title => GetResourceString("SA1104Title")!; + /// A clause within a C# query expression spans across multiple lines, and does not begin on its own line. + public static string @SA1105Description => GetResourceString("SA1105Description")!; + /// Query clauses spanning multiple lines should begin on own line + public static string @SA1105MessageFormat => GetResourceString("SA1105MessageFormat")!; + /// Query clauses spanning multiple lines should begin on own line + public static string @SA1105Title => GetResourceString("SA1105Title")!; + /// Remove empty statement + public static string @SA1106CodeFix => GetResourceString("SA1106CodeFix")!; + /// The C# code contains an extra semicolon. + public static string @SA1106Description => GetResourceString("SA1106Description")!; + /// Code should not contain empty statements + public static string @SA1106MessageFormat => GetResourceString("SA1106MessageFormat")!; + /// Code should not contain empty statements + public static string @SA1106Title => GetResourceString("SA1106Title")!; + /// Enter new line + public static string @SA1107CodeFix => GetResourceString("SA1107CodeFix")!; + /// The C# code contains more than one statement on a single line. + public static string @SA1107Description => GetResourceString("SA1107Description")!; + /// Code should not contain multiple statements on one line + public static string @SA1107MessageFormat => GetResourceString("SA1107MessageFormat")!; + /// Code should not contain multiple statements on one line + public static string @SA1107Title => GetResourceString("SA1107Title")!; + /// A C# statement contains a comment between the declaration of the statement and the opening brace of the statement. + public static string @SA1108Description => GetResourceString("SA1108Description")!; + /// Block statements should not contain embedded comments + public static string @SA1108MessageFormat => GetResourceString("SA1108MessageFormat")!; + /// Block statements should not contain embedded comments + public static string @SA1108Title => GetResourceString("SA1108Title")!; + /// A C# statement contains a region tag between the declaration of the statement and the opening brace of the statement. + public static string @SA1109Description => GetResourceString("SA1109Description")!; + /// + public static string @SA1109MessageFormat => GetResourceString("SA1109MessageFormat")!; + /// Block statements should not contain embedded regions + public static string @SA1109Title => GetResourceString("SA1109Title")!; + /// The opening parenthesis or bracket is not placed on the same line as the method/indexer/attribute/array name. + public static string @SA1110Description => GetResourceString("SA1110Description")!; + /// Opening parenthesis or bracket should be on declaration line + public static string @SA1110MessageFormat => GetResourceString("SA1110MessageFormat")!; + /// Opening parenthesis or bracket should be on declaration line + public static string @SA1110Title => GetResourceString("SA1110Title")!; + /// The closing parenthesis or bracket in a call to or declaration of a C# method/indexer/attribute/array/constructor/delegate is not placed on the same line as the last parameter. + public static string @SA1111Description => GetResourceString("SA1111Description")!; + /// Closing parenthesis should be on line of last parameter + public static string @SA1111MessageFormat => GetResourceString("SA1111MessageFormat")!; + /// Closing parenthesis should be on line of last parameter + public static string @SA1111Title => GetResourceString("SA1111Title")!; + /// The closing parenthesis or bracket in a call to a C# method or indexer, or the declaration of a method or indexer, is not placed on the same line as the opening bracket when the element does not take any parameters. + public static string @SA1112Description => GetResourceString("SA1112Description")!; + /// Closing parenthesis should be on line of opening parenthesis + public static string @SA1112MessageFormat => GetResourceString("SA1112MessageFormat")!; + /// Closing parenthesis should be on line of opening parenthesis + public static string @SA1112Title => GetResourceString("SA1112Title")!; + /// A comma between two parameters in a call to a C# method or indexer, or in the declaration of a method or indexer, is not placed on the same line as the previous parameter. + public static string @SA1113Description => GetResourceString("SA1113Description")!; + /// Comma should be on the same line as previous parameter + public static string @SA1113MessageFormat => GetResourceString("SA1113MessageFormat")!; + /// Comma should be on the same line as previous parameter + public static string @SA1113Title => GetResourceString("SA1113Title")!; + /// The start of the parameter list for a method/constructor/indexer/array/operator call or declaration does not begin on the same line as the opening bracket, or on the line after the opening bracket. + public static string @SA1114Description => GetResourceString("SA1114Description")!; + /// Parameter list should follow declaration + public static string @SA1114MessageFormat => GetResourceString("SA1114MessageFormat")!; + /// Parameter list should follow declaration + public static string @SA1114Title => GetResourceString("SA1114Title")!; + /// A parameter within a C# method or indexer call or declaration does not begin on the same line as the previous parameter, or on the next line. + public static string @SA1115Description => GetResourceString("SA1115Description")!; + /// The parameter should begin on the line after the previous parameter + public static string @SA1115MessageFormat => GetResourceString("SA1115MessageFormat")!; + /// Parameter should follow comma + public static string @SA1115Title => GetResourceString("SA1115Title")!; + /// Move first argument to next line + public static string @SA1116CodeFix => GetResourceString("SA1116CodeFix")!; + /// The parameters to a C# method or indexer call or declaration span across multiple lines, but the first parameter does not start on the line after the opening bracket. + public static string @SA1116Description => GetResourceString("SA1116Description")!; + /// The parameters should begin on the line after the declaration, whenever the parameter span across multiple lines + public static string @SA1116MessageFormat => GetResourceString("SA1116MessageFormat")!; + /// Split parameters should start on line after declaration + public static string @SA1116Title => GetResourceString("SA1116Title")!; + /// The parameters to a C# method or indexer call or declaration are not all on the same line or each on a separate line. + public static string @SA1117Description => GetResourceString("SA1117Description")!; + /// The parameters should all be placed on the same line or each parameter should be placed on its own line + public static string @SA1117MessageFormat => GetResourceString("SA1117MessageFormat")!; + /// Parameters should be on same line or separate lines + public static string @SA1117Title => GetResourceString("SA1117Title")!; + /// A parameter to a C# method/indexer/attribute/array, other than the first parameter, spans across multiple lines. If the parameter is short, place the entire parameter on a single line. Otherwise, save the contents of the parameter in a temporary variable a ... + public static string @SA1118Description => GetResourceString("SA1118Description")!; + /// The parameter spans multiple lines + public static string @SA1118MessageFormat => GetResourceString("SA1118MessageFormat")!; + /// Parameter should not span multiple lines + public static string @SA1118Title => GetResourceString("SA1118Title")!; + /// Remove empty comment + public static string @SA1120CodeFix => GetResourceString("SA1120CodeFix")!; + /// The C# comment does not contain any comment text. + public static string @SA1120Description => GetResourceString("SA1120Description")!; + /// Comments should contain text + public static string @SA1120MessageFormat => GetResourceString("SA1120MessageFormat")!; + /// Comments should contain text + public static string @SA1120Title => GetResourceString("SA1120Title")!; + /// Replace with built-in type + public static string @SA1121CodeFix => GetResourceString("SA1121CodeFix")!; + /// The code uses one of the basic C# types, but does not use the built-in alias for the type. + public static string @SA1121Description => GetResourceString("SA1121Description")!; + /// Use built-in type alias + public static string @SA1121MessageFormat => GetResourceString("SA1121MessageFormat")!; + /// Use built-in type alias + public static string @SA1121Title => GetResourceString("SA1121Title")!; + /// Replace with string.Empty + public static string @SA1122CodeFix => GetResourceString("SA1122CodeFix")!; + /// The C# code includes an empty string, written as "". + public static string @SA1122Description => GetResourceString("SA1122Description")!; + /// Use string.Empty for empty strings + public static string @SA1122MessageFormat => GetResourceString("SA1122MessageFormat")!; + /// Use string.Empty for empty strings + public static string @SA1122Title => GetResourceString("SA1122Title")!; + /// The C# code contains a region within the body of a code element. + public static string @SA1123Description => GetResourceString("SA1123Description")!; + /// Region should not be located within a code element + public static string @SA1123MessageFormat => GetResourceString("SA1123MessageFormat")!; + /// Do not place regions within elements + public static string @SA1123Title => GetResourceString("SA1123Title")!; + /// The C# code contains a region. + public static string @SA1124Description => GetResourceString("SA1124Description")!; + /// Do not use regions + public static string @SA1124MessageFormat => GetResourceString("SA1124MessageFormat")!; + /// Do not use regions + public static string @SA1124Title => GetResourceString("SA1124Title")!; + /// The Nullable<T> type has been defined not using the C# shorthand. For example, Nullable<DateTime> has been used instead of the preferred DateTime? + public static string @SA1125Description => GetResourceString("SA1125Description")!; + /// Use shorthand for nullable types + public static string @SA1125MessageFormat => GetResourceString("SA1125MessageFormat")!; + /// Use shorthand for nullable types + public static string @SA1125Title => GetResourceString("SA1125Title")!; + /// A call to a member is not prefixed with the 'this.', 'base.', 'object.' or 'typename.' prefix to indicate the intended method call, within a C# code file. + public static string @SA1126Description => GetResourceString("SA1126Description")!; + /// + public static string @SA1126MessageFormat => GetResourceString("SA1126MessageFormat")!; + /// Prefix calls correctly + public static string @SA1126Title => GetResourceString("SA1126Title")!; + /// Place each type constraint on a new line + public static string @SA1127CodeFix => GetResourceString("SA1127CodeFix")!; + /// Each type constraint clause for a generic type parameter should be listed on a line of code by itself. + public static string @SA1127Description => GetResourceString("SA1127Description")!; + /// Generic type constraints should be on their own line + public static string @SA1127MessageFormat => GetResourceString("SA1127MessageFormat")!; + /// Generic type constraints should be on their own line + public static string @SA1127Title => GetResourceString("SA1127Title")!; + /// Place constructor initializer on own line + public static string @SA1128CodeFix => GetResourceString("SA1128CodeFix")!; + /// A constructor initializer, including the colon character, should be on its own line. + public static string @SA1128Description => GetResourceString("SA1128Description")!; + /// Put constructor initializers on their own line + public static string @SA1128MessageFormat => GetResourceString("SA1128MessageFormat")!; + /// Put constructor initializers on their own line + public static string @SA1128Title => GetResourceString("SA1128Title")!; + /// Replace with default(T) + public static string @SA1129CodeFix => GetResourceString("SA1129CodeFix")!; + /// When creating a new instance of a value type T, the syntax 'default(T)' is functionally equivalent to the syntax 'new T()'. To avoid confusion regarding the behavior of the resulting instance, the first form is preferred. + public static string @SA1129Description => GetResourceString("SA1129Description")!; + /// Do not use default value type constructor + public static string @SA1129MessageFormat => GetResourceString("SA1129MessageFormat")!; + /// Do not use default value type constructor + public static string @SA1129Title => GetResourceString("SA1129Title")!; + /// Replace with lambda. + public static string @SA1130CodeFix => GetResourceString("SA1130CodeFix")!; + /// Lambda expressions are more succinct and easier to read than anonymous methods, so they should are preferred whenever the two are functionally equivalent. + public static string @SA1130Description => GetResourceString("SA1130Description")!; + /// Use lambda syntax + public static string @SA1130MessageFormat => GetResourceString("SA1130MessageFormat")!; + /// Use lambda syntax + public static string @SA1130Title => GetResourceString("SA1130Title")!; + /// Swap operands + public static string @SA1131CodeFix => GetResourceString("SA1131CodeFix")!; + /// When a comparison is made between a variable and a literal, the variable should be placed on the left-hand-side to maximize readability. + public static string @SA1131Description => GetResourceString("SA1131Description")!; + /// Constant values should appear on the right-hand side of comparisons + public static string @SA1131MessageFormat => GetResourceString("SA1131MessageFormat")!; + /// Use readable conditions + public static string @SA1131Title => GetResourceString("SA1131Title")!; + /// Place each field on a new line + public static string @SA1132CodeFix => GetResourceString("SA1132CodeFix")!; + /// Each field should be declared on its own line, in order to clearly see each field of a type and allow for proper documentation of the behavior of each field. + public static string @SA1132Description => GetResourceString("SA1132Description")!; + /// Each field should be declared on its own line + public static string @SA1132MessageFormat => GetResourceString("SA1132MessageFormat")!; + /// Do not combine fields + public static string @SA1132Title => GetResourceString("SA1132Title")!; + /// Give each attribute its own square brackets + public static string @SA1133CodeFix => GetResourceString("SA1133CodeFix")!; + /// Each attribute usage should be placed in its own set of square brackets for maximum readability. + public static string @SA1133Description => GetResourceString("SA1133Description")!; + /// Each attribute should be placed in its own set of square brackets + public static string @SA1133MessageFormat => GetResourceString("SA1133MessageFormat")!; + /// Do not combine attributes + public static string @SA1133Title => GetResourceString("SA1133Title")!; + /// Place attribute on own line. + public static string @SA1134CodeFix => GetResourceString("SA1134CodeFix")!; + /// Each attribute should be placed on its own line of code. + public static string @SA1134Description => GetResourceString("SA1134Description")!; + /// Each attribute should be placed on its own line of code + public static string @SA1134MessageFormat => GetResourceString("SA1134MessageFormat")!; + /// Attributes should not share line + public static string @SA1134Title => GetResourceString("SA1134Title")!; + /// Qualify using directive + public static string @SA1135CodeFix => GetResourceString("SA1135CodeFix")!; + /// All using directives should be qualified. + public static string @SA1135Description => GetResourceString("SA1135Description")!; + /// Using directive for namespace '{0}' should be qualified + public static string @SA1135MessageFormatNamespace => GetResourceString("SA1135MessageFormatNamespace")!; + /// Using directive for type '{0}' should be qualified + public static string @SA1135MessageFormatType => GetResourceString("SA1135MessageFormatType")!; + /// Using directives should be qualified + public static string @SA1135Title => GetResourceString("SA1135Title")!; + /// Place enum values own their own lines + public static string @SA1136CodeFix => GetResourceString("SA1136CodeFix")!; + /// Enum values should be placed on their own lines for maximum readability. + public static string @SA1136Description => GetResourceString("SA1136Description")!; + /// Enum values should be on separate lines + public static string @SA1136MessageFormat => GetResourceString("SA1136MessageFormat")!; + /// Enum values should be on separate lines + public static string @SA1136Title => GetResourceString("SA1136Title")!; + /// Elements at the same level in the syntax tree should have the same indentation. + public static string @SA1137Description => GetResourceString("SA1137Description")!; + /// Elements should have the same indentation + public static string @SA1137MessageFormat => GetResourceString("SA1137MessageFormat")!; + /// Elements should have the same indentation + public static string @SA1137Title => GetResourceString("SA1137Title")!; + /// Use literal suffix notation instead of casting + public static string @SA1139CodeFix => GetResourceString("SA1139CodeFix")!; + /// Use literal suffix notation instead of casting, in order to improve readability, avoid bugs related to illegal casts and ensure that optimal IL is produced. + public static string @SA1139Description => GetResourceString("SA1139Description")!; + /// Use literal suffix notation instead of casting + public static string @SA1139MessageFormat => GetResourceString("SA1139MessageFormat")!; + /// Use literal suffix notation instead of casting + public static string @SA1139Title => GetResourceString("SA1139Title")!; + /// Replace with tuple syntax + public static string @SA1141CodeFix => GetResourceString("SA1141CodeFix")!; + /// Use tuple syntax instead of the underlying ValueTuple implementation type. + public static string @SA1141Description => GetResourceString("SA1141Description")!; + /// Use tuple syntax + public static string @SA1141MessageFormat => GetResourceString("SA1141MessageFormat")!; + /// Use tuple syntax + public static string @SA1141Title => GetResourceString("SA1141Title")!; + /// Use tuple field name + public static string @SA1142CodeFix => GetResourceString("SA1142CodeFix")!; + /// A field of a tuple was referenced by its metadata name when a field name is available. + public static string @SA1142Description => GetResourceString("SA1142Description")!; + /// Refer to tuple fields by name + public static string @SA1142MessageFormat => GetResourceString("SA1142MessageFormat")!; + /// Refer to tuple fields by name + public static string @SA1142Title => GetResourceString("SA1142Title")!; + /// Remove 'this.' prefix + public static string @SX1101CodeFix => GetResourceString("SX1101CodeFix")!; + /// A call to an instance member of the local class or a base class is prefixed with `this.`. + public static string @SX1101Description => GetResourceString("SX1101Description")!; + /// Do not prefix local calls with 'this.' + public static string @SX1101MessageFormat => GetResourceString("SX1101MessageFormat")!; + /// Do not prefix local calls with 'this.' + public static string @SX1101Title => GetResourceString("SX1101Title")!; + + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/SettingsResources.Designer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/SettingsResources.Designer.cs new file mode 100644 index 000000000..978888fdb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/SettingsResources.Designer.cs @@ -0,0 +1,21 @@ +// + +#nullable enable +using System.Reflection; + + +namespace StyleCop.Analyzers.Settings +{ + internal static partial class SettingsResources + { + private static global::System.Resources.ResourceManager? s_resourceManager; + public static global::System.Resources.ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new global::System.Resources.ResourceManager(typeof(SettingsResources))); + public static global::System.Globalization.CultureInfo? Culture { get; set; } + [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + [return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("defaultValue")] + internal static string? GetResourceString(string resourceKey, string? defaultValue = null) => ResourceManager.GetString(resourceKey, Culture) ?? defaultValue; + /// Add StyleCop settings file to the project + public static string @SettingsFileCodeFix => GetResourceString("SettingsFileCodeFix")!; + + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/SpacingResources.Designer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/SpacingResources.Designer.cs new file mode 100644 index 000000000..7d47c696a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/SpacingResources.Designer.cs @@ -0,0 +1,249 @@ +// + +#nullable enable +using System.Reflection; + + +namespace StyleCop.Analyzers.SpacingRules +{ + internal static partial class SpacingResources + { + private static global::System.Resources.ResourceManager? s_resourceManager; + public static global::System.Resources.ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new global::System.Resources.ResourceManager(typeof(SpacingResources))); + public static global::System.Globalization.CultureInfo? Culture { get; set; } + [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + [return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("defaultValue")] + internal static string? GetResourceString(string resourceKey, string? defaultValue = null) => ResourceManager.GetString(resourceKey, Culture) ?? defaultValue; + /// The spacing around a C# keyword is incorrect. + public static string @SA1000Description => GetResourceString("SA1000Description")!; + /// The keyword '{0}' should{1} be followed by a space + public static string @SA1000MessageFormat => GetResourceString("SA1000MessageFormat")!; + /// Keywords should be spaced correctly + public static string @SA1000Title => GetResourceString("SA1000Title")!; + /// The spacing around a comma is incorrect, within a C# code file. + public static string @SA1001Description => GetResourceString("SA1001Description")!; + /// Commas should{0} be {1} by whitespace + public static string @SA1001MessageFormat => GetResourceString("SA1001MessageFormat")!; + /// Commas should be spaced correctly + public static string @SA1001Title => GetResourceString("SA1001Title")!; + /// The spacing around a semicolon is incorrect, within a C# code file. + public static string @SA1002Description => GetResourceString("SA1002Description")!; + /// Semicolons should{0} be {1} by a space + public static string @SA1002MessageFormat => GetResourceString("SA1002MessageFormat")!; + /// Semicolons should be spaced correctly + public static string @SA1002Title => GetResourceString("SA1002Title")!; + /// Fix spacing + public static string @SA1003CodeFix => GetResourceString("SA1003CodeFix")!; + /// The spacing around an operator symbol is incorrect, within a C# code file. + public static string @SA1003Description => GetResourceString("SA1003Description")!; + /// Operator '{0}' should be followed by whitespace. + public static string @SA1003MessageFormatFollowedByWhitespace => GetResourceString("SA1003MessageFormatFollowedByWhitespace")!; + /// Operator '{0}' should not appear at the end of a line. + public static string @SA1003MessageFormatNotAtEndOfLine => GetResourceString("SA1003MessageFormatNotAtEndOfLine")!; + /// Operator '{0}' should not be followed by a comment. + public static string @SA1003MessageFormatNotFollowedByComment => GetResourceString("SA1003MessageFormatNotFollowedByComment")!; + /// Operator '{0}' should not be followed by whitespace. + public static string @SA1003MessageFormatNotFollowedByWhitespace => GetResourceString("SA1003MessageFormatNotFollowedByWhitespace")!; + /// Operator '{0}' should not be preceded by whitespace. + public static string @SA1003MessageFormatNotPrecededByWhitespace => GetResourceString("SA1003MessageFormatNotPrecededByWhitespace")!; + /// Operator '{0}' should be preceded by whitespace. + public static string @SA1003MessageFormatPrecededByWhitespace => GetResourceString("SA1003MessageFormatPrecededByWhitespace")!; + /// Symbols should be spaced correctly + public static string @SA1003Title => GetResourceString("SA1003Title")!; + /// Fix spacing + public static string @SA1004CodeFix => GetResourceString("SA1004CodeFix")!; + /// A line within a documentation header above a C# element does not begin with a single space. + public static string @SA1004Description => GetResourceString("SA1004Description")!; + /// Documentation line should begin with a space + public static string @SA1004MessageFormat => GetResourceString("SA1004MessageFormat")!; + /// Documentation lines should begin with single space + public static string @SA1004Title => GetResourceString("SA1004Title")!; + /// Fix spacing + public static string @SA1005CodeFix => GetResourceString("SA1005CodeFix")!; + /// A single-line comment within a C# code file does not begin with a single space. + public static string @SA1005Description => GetResourceString("SA1005Description")!; + /// Single line comment should begin with a space + public static string @SA1005MessageFormat => GetResourceString("SA1005MessageFormat")!; + /// Single line comments should begin with single space + public static string @SA1005Title => GetResourceString("SA1005Title")!; + /// A C# preprocessor-type keyword is preceded by space. + public static string @SA1006Description => GetResourceString("SA1006Description")!; + /// Preprocessor keyword '{0}' should not be preceded by a space + public static string @SA1006MessageFormat => GetResourceString("SA1006MessageFormat")!; + /// Preprocessor keywords should not be preceded by space + public static string @SA1006Title => GetResourceString("SA1006Title")!; + /// The operator keyword within a C# operator overload method is not followed by any whitespace. + public static string @SA1007Description => GetResourceString("SA1007Description")!; + /// Operator keyword should be followed by a space + public static string @SA1007MessageFormat => GetResourceString("SA1007MessageFormat")!; + /// Operator keyword should be followed by space + public static string @SA1007Title => GetResourceString("SA1007Title")!; + /// Fix spacing + public static string @SA1008CodeFix => GetResourceString("SA1008CodeFix")!; + /// An opening parenthesis within a C# statement is not spaced correctly. + public static string @SA1008Description => GetResourceString("SA1008Description")!; + /// Opening parenthesis should not be followed by a space. + public static string @SA1008MessageNotFollowed => GetResourceString("SA1008MessageNotFollowed")!; + /// Opening parenthesis should not be preceded by a space. + public static string @SA1008MessageNotPreceded => GetResourceString("SA1008MessageNotPreceded")!; + /// Opening parenthesis should be preceded by a space. + public static string @SA1008MessagePreceded => GetResourceString("SA1008MessagePreceded")!; + /// Opening parenthesis should be spaced correctly + public static string @SA1008Title => GetResourceString("SA1008Title")!; + /// A closing parenthesis within a C# statement is not spaced correctly. + public static string @SA1009Description => GetResourceString("SA1009Description")!; + /// Closing parenthesis should be followed by a space + public static string @SA1009MessageFollowed => GetResourceString("SA1009MessageFollowed")!; + /// Closing parenthesis should not be followed by a space + public static string @SA1009MessageNotFollowed => GetResourceString("SA1009MessageNotFollowed")!; + /// Closing parenthesis should not be preceded by a space + public static string @SA1009MessageNotPreceded => GetResourceString("SA1009MessageNotPreceded")!; + /// Closing parenthesis should be spaced correctly + public static string @SA1009Title => GetResourceString("SA1009Title")!; + /// An opening square bracket within a C# statement is not spaced correctly. + public static string @SA1010Description => GetResourceString("SA1010Description")!; + /// Opening square brackets should not be followed by a space + public static string @SA1010MessageNotFollowed => GetResourceString("SA1010MessageNotFollowed")!; + /// Opening square brackets should not be preceded by a space + public static string @SA1010MessageNotPreceded => GetResourceString("SA1010MessageNotPreceded")!; + /// Opening square brackets should be spaced correctly + public static string @SA1010Title => GetResourceString("SA1010Title")!; + /// A closing square bracket within a C# statement is not spaced correctly. + public static string @SA1011Description => GetResourceString("SA1011Description")!; + /// Closing square bracket should{0} be {1} by a space + public static string @SA1011MessageFormat => GetResourceString("SA1011MessageFormat")!; + /// Closing square brackets should be spaced correctly + public static string @SA1011Title => GetResourceString("SA1011Title")!; + /// An opening brace within a C# element is not spaced correctly. + public static string @SA1012Description => GetResourceString("SA1012Description")!; + /// Opening brace should{0} be {1} by a space + public static string @SA1012MessageFormat => GetResourceString("SA1012MessageFormat")!; + /// Opening braces should be spaced correctly + public static string @SA1012Title => GetResourceString("SA1012Title")!; + /// A closing brace within a C# element is not spaced correctly. + public static string @SA1013Description => GetResourceString("SA1013Description")!; + /// Closing brace should{0} be {1} by a space + public static string @SA1013MessageFormat => GetResourceString("SA1013MessageFormat")!; + /// Closing braces should be spaced correctly + public static string @SA1013Title => GetResourceString("SA1013Title")!; + /// An opening generic bracket within a C# element is not spaced correctly. + public static string @SA1014Description => GetResourceString("SA1014Description")!; + /// Opening generic brackets should not be {0} by a space + public static string @SA1014MessageFormat => GetResourceString("SA1014MessageFormat")!; + /// Opening generic brackets should be spaced correctly + public static string @SA1014Title => GetResourceString("SA1014Title")!; + /// A closing generic bracket within a C# element is not spaced correctly. + public static string @SA1015Description => GetResourceString("SA1015Description")!; + /// Closing generic bracket should be followed by a space + public static string @SA1015MessageFollowed => GetResourceString("SA1015MessageFollowed")!; + /// Closing generic bracket should not be followed by a space + public static string @SA1015MessageNotFollowed => GetResourceString("SA1015MessageNotFollowed")!; + /// Closing generic bracket should not be preceded by a space + public static string @SA1015MessageNotPreceded => GetResourceString("SA1015MessageNotPreceded")!; + /// Closing generic brackets should be spaced correctly + public static string @SA1015Title => GetResourceString("SA1015Title")!; + /// An opening attribute bracket within a C# element is not spaced correctly. + public static string @SA1016Description => GetResourceString("SA1016Description")!; + /// Opening attribute brackets should not be followed by a space + public static string @SA1016MessageFormat => GetResourceString("SA1016MessageFormat")!; + /// Opening attribute brackets should be spaced correctly + public static string @SA1016Title => GetResourceString("SA1016Title")!; + /// A closing attribute bracket within a C# element is not spaced correctly. + public static string @SA1017Description => GetResourceString("SA1017Description")!; + /// Closing attribute brackets should not be preceded by a space + public static string @SA1017MessageFormat => GetResourceString("SA1017MessageFormat")!; + /// Closing attribute brackets should be spaced correctly + public static string @SA1017Title => GetResourceString("SA1017Title")!; + /// Fix spacing + public static string @SA1018CodeFix => GetResourceString("SA1018CodeFix")!; + /// A nullable type symbol within a C# element is not spaced correctly. + public static string @SA1018Description => GetResourceString("SA1018Description")!; + /// Nullable type symbol should not be preceded by a space + public static string @SA1018MessageFormat => GetResourceString("SA1018MessageFormat")!; + /// Nullable type symbols should be spaced correctly + public static string @SA1018Title => GetResourceString("SA1018Title")!; + /// The spacing around a member access symbol is incorrect, within a C# code file. + public static string @SA1019Description => GetResourceString("SA1019Description")!; + /// Member access symbol '{0}' should not be followed by a space + public static string @SA1019MessageNotFollowed => GetResourceString("SA1019MessageNotFollowed")!; + /// Member access symbol '{0}' should not be preceded by a space + public static string @SA1019MessageNotPreceded => GetResourceString("SA1019MessageNotPreceded")!; + /// Member access symbols should be spaced correctly + public static string @SA1019Title => GetResourceString("SA1019Title")!; + /// An increment or decrement symbol within a C# element is not spaced correctly. + public static string @SA1020Description => GetResourceString("SA1020Description")!; + /// {0} symbol '{1}' should not be {2} by a space + public static string @SA1020MessageFormat => GetResourceString("SA1020MessageFormat")!; + /// Increment decrement symbols should be spaced correctly + public static string @SA1020Title => GetResourceString("SA1020Title")!; + /// A negative sign within a C# element is not spaced correctly. + public static string @SA1021Description => GetResourceString("SA1021Description")!; + /// Negative sign should{0} be {1} by a space + public static string @SA1021MessageFormat => GetResourceString("SA1021MessageFormat")!; + /// Negative signs should be spaced correctly + public static string @SA1021Title => GetResourceString("SA1021Title")!; + /// A positive sign within a C# element is not spaced correctly. + public static string @SA1022Description => GetResourceString("SA1022Description")!; + /// Positive sign should{0} be {1} by a space + public static string @SA1022MessageFormat => GetResourceString("SA1022MessageFormat")!; + /// Positive signs should be spaced correctly + public static string @SA1022Title => GetResourceString("SA1022Title")!; + /// A dereference symbol or an access-of symbol within a C# element is not spaced correctly. + public static string @SA1023Description => GetResourceString("SA1023Description")!; + /// Dereference symbol '*' should be followed by a space + public static string @SA1023MessageFollowed => GetResourceString("SA1023MessageFollowed")!; + /// Dereference symbol '*' should not appear at the beginning of a line + public static string @SA1023MessageNotAtBeginningOfLine => GetResourceString("SA1023MessageNotAtBeginningOfLine")!; + /// Dereference symbol '*' should not appear at the end of a line + public static string @SA1023MessageNotAtEndOfLine => GetResourceString("SA1023MessageNotAtEndOfLine")!; + /// Dereference symbol '*' should not be followed by a space + public static string @SA1023MessageNotFollowed => GetResourceString("SA1023MessageNotFollowed")!; + /// Dereference symbol '*' should not be preceded by a space + public static string @SA1023MessageNotPreceded => GetResourceString("SA1023MessageNotPreceded")!; + /// Dereference and access of symbols should be spaced correctly + public static string @SA1023Title => GetResourceString("SA1023Title")!; + /// A colon within a C# element is not spaced correctly. + public static string @SA1024Description => GetResourceString("SA1024Description")!; + /// Colon should be followed by a space + public static string @SA1024MessageFollowed => GetResourceString("SA1024MessageFollowed")!; + /// Colon should not be preceded by a space + public static string @SA1024MessageNotPreceded => GetResourceString("SA1024MessageNotPreceded")!; + /// Colon should be preceded by a space + public static string @SA1024MessagePreceded => GetResourceString("SA1024MessagePreceded")!; + /// Colons Should Be Spaced Correctly + public static string @SA1024Title => GetResourceString("SA1024Title")!; + /// Fix spacing + public static string @SA1025CodeFix => GetResourceString("SA1025CodeFix")!; + /// The code contains multiple whitespace characters in a row. + public static string @SA1025Description => GetResourceString("SA1025Description")!; + /// Code should not contain multiple whitespace characters in a row + public static string @SA1025MessageFormat => GetResourceString("SA1025MessageFormat")!; + /// Code should not contain multiple whitespace in a row + public static string @SA1025Title => GetResourceString("SA1025Title")!; + /// An implicitly typed array allocation within a C# code file is not spaced correctly. + public static string @SA1026Description => GetResourceString("SA1026Description")!; + /// The keyword '{0}' should not be followed by a space or a blank line + public static string @SA1026MessageFormat => GetResourceString("SA1026MessageFormat")!; + /// Code should not contain space after new or stackalloc keyword in implicitly typed array allocation + public static string @SA1026Title => GetResourceString("SA1026Title")!; + /// Fix tabs + public static string @SA1027CodeFix => GetResourceString("SA1027CodeFix")!; + /// The code contains a tab or space character which is not consistent with the current project settings. + public static string @SA1027Description => GetResourceString("SA1027Description")!; + /// Tabs and spaces should be used correctly + public static string @SA1027MessageFormat => GetResourceString("SA1027MessageFormat")!; + /// Use tabs correctly + public static string @SA1027Title => GetResourceString("SA1027Title")!; + /// Remove trailing whitespace + public static string @SA1028CodeFix => GetResourceString("SA1028CodeFix")!; + /// There should not be any whitespace at the end of a line of code. + public static string @SA1028Description => GetResourceString("SA1028Description")!; + /// Code should not contain trailing whitespace + public static string @SA1028MessageFormat => GetResourceString("SA1028MessageFormat")!; + /// Code should not contain trailing whitespace + public static string @SA1028Title => GetResourceString("SA1028Title")!; + /// Fix spacing + public static string @TokenSpacingCodeFix => GetResourceString("TokenSpacingCodeFix")!; + + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/SpecialResources.Designer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/SpecialResources.Designer.cs new file mode 100644 index 000000000..35f2ba7a9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp/Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.CSharpResxGenerator/SpecialResources.Designer.cs @@ -0,0 +1,33 @@ +// + +#nullable enable +using System.Reflection; + + +namespace StyleCop.Analyzers.SpecialRules +{ + internal static partial class SpecialResources + { + private static global::System.Resources.ResourceManager? s_resourceManager; + public static global::System.Resources.ResourceManager ResourceManager => s_resourceManager ?? (s_resourceManager = new global::System.Resources.ResourceManager(typeof(SpecialResources))); + public static global::System.Globalization.CultureInfo? Culture { get; set; } + [global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + [return: global::System.Diagnostics.CodeAnalysis.NotNullIfNotNull("defaultValue")] + internal static string? GetResourceString(string resourceKey, string? defaultValue = null) => ResourceManager.GetString(resourceKey, Culture) ?? defaultValue; + /// XML comment analysis can only be performed when the project is configured to parse documentation comments. To enable this functionality, update the project to produce an XML documentation file as part of the build. + public static string @SA0001Description => GetResourceString("SA0001Description")!; + /// XML comment analysis is disabled due to project configuration + public static string @SA0001MessageFormat => GetResourceString("SA0001MessageFormat")!; + /// XML comment analysis disabled + public static string @SA0001Title => GetResourceString("SA0001Title")!; + /// Various errors in the stylecop.json file can prevent the file from being loaded by the analyzers. In this case, the default settings are used instead. + /// + /// {0} + public static string @SA0002Description => GetResourceString("SA0002Description")!; + /// The stylecop.json settings file could not be loaded + public static string @SA0002MessageFormat => GetResourceString("SA0002MessageFormat")!; + /// Invalid settings file + public static string @SA0002Title => GetResourceString("SA0002Title")!; + + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IAddressOfOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IAddressOfOperationWrapper.g.cs new file mode 100644 index 000000000..c15464308 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IAddressOfOperationWrapper.g.cs @@ -0,0 +1,52 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IAddressOfOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IAddressOfOperation"; + private static readonly Type WrappedType; + private static readonly Func ReferenceAccessor; + private readonly IOperation operation; + static IAddressOfOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IAddressOfOperationWrapper)); + ReferenceAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Reference)); + } + + private IAddressOfOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Reference => ReferenceAccessor(this.WrappedOperation); + public static explicit operator IAddressOfOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IAddressOfOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IAddressOfOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IAddressOfOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IAnonymousFunctionOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IAnonymousFunctionOperationWrapper.g.cs new file mode 100644 index 000000000..b2b8f85a3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IAnonymousFunctionOperationWrapper.g.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IAnonymousFunctionOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IAnonymousFunctionOperation"; + private static readonly Type WrappedType; + private static readonly Func SymbolAccessor; + private static readonly Func BodyAccessor; + private readonly IOperation operation; + static IAnonymousFunctionOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IAnonymousFunctionOperationWrapper)); + SymbolAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Symbol)); + BodyAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Body)); + } + + private IAnonymousFunctionOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IMethodSymbol Symbol => SymbolAccessor(this.WrappedOperation); + public IBlockOperationWrapper Body => IBlockOperationWrapper.FromOperation(BodyAccessor(this.WrappedOperation)); + public static explicit operator IAnonymousFunctionOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IAnonymousFunctionOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IAnonymousFunctionOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IAnonymousFunctionOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IAnonymousObjectCreationOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IAnonymousObjectCreationOperationWrapper.g.cs new file mode 100644 index 000000000..80fb2cbd8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IAnonymousObjectCreationOperationWrapper.g.cs @@ -0,0 +1,52 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IAnonymousObjectCreationOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IAnonymousObjectCreationOperation"; + private static readonly Type WrappedType; + private static readonly Func> InitializersAccessor; + private readonly IOperation operation; + static IAnonymousObjectCreationOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IAnonymousObjectCreationOperationWrapper)); + InitializersAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(Initializers)); + } + + private IAnonymousObjectCreationOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ImmutableArray Initializers => InitializersAccessor(this.WrappedOperation); + public static explicit operator IAnonymousObjectCreationOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IAnonymousObjectCreationOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IAnonymousObjectCreationOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IAnonymousObjectCreationOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IArgumentOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IArgumentOperationWrapper.g.cs new file mode 100644 index 000000000..ee7fb731c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IArgumentOperationWrapper.g.cs @@ -0,0 +1,58 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IArgumentOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IArgumentOperation"; + private static readonly Type WrappedType; + private static readonly Func ParameterAccessor; + private static readonly Func ValueAccessor; + private readonly IOperation operation; + static IArgumentOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IArgumentOperationWrapper)); + ParameterAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Parameter)); + ValueAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Value)); + } + + private IArgumentOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public object ArgumentKind => throw new NotImplementedException("Property 'IArgumentOperation.ArgumentKind' has unsupported type 'ArgumentKind'"); + public IParameterSymbol Parameter => ParameterAccessor(this.WrappedOperation); + public IOperation Value => ValueAccessor(this.WrappedOperation); + public object InConversion => throw new NotImplementedException("Property 'IArgumentOperation.InConversion' has unsupported type 'CommonConversion'"); + public object OutConversion => throw new NotImplementedException("Property 'IArgumentOperation.OutConversion' has unsupported type 'CommonConversion'"); + public static explicit operator IArgumentOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IArgumentOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IArgumentOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IArgumentOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IArrayCreationOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IArrayCreationOperationWrapper.g.cs new file mode 100644 index 000000000..9772d16fb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IArrayCreationOperationWrapper.g.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IArrayCreationOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IArrayCreationOperation"; + private static readonly Type WrappedType; + private static readonly Func> DimensionSizesAccessor; + private static readonly Func InitializerAccessor; + private readonly IOperation operation; + static IArrayCreationOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IArrayCreationOperationWrapper)); + DimensionSizesAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(DimensionSizes)); + InitializerAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Initializer)); + } + + private IArrayCreationOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ImmutableArray DimensionSizes => DimensionSizesAccessor(this.WrappedOperation); + public IArrayInitializerOperationWrapper Initializer => IArrayInitializerOperationWrapper.FromOperation(InitializerAccessor(this.WrappedOperation)); + public static explicit operator IArrayCreationOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IArrayCreationOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IArrayCreationOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IArrayCreationOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IArrayElementReferenceOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IArrayElementReferenceOperationWrapper.g.cs new file mode 100644 index 000000000..546a020d8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IArrayElementReferenceOperationWrapper.g.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IArrayElementReferenceOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IArrayElementReferenceOperation"; + private static readonly Type WrappedType; + private static readonly Func ArrayReferenceAccessor; + private static readonly Func> IndicesAccessor; + private readonly IOperation operation; + static IArrayElementReferenceOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IArrayElementReferenceOperationWrapper)); + ArrayReferenceAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(ArrayReference)); + IndicesAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(Indices)); + } + + private IArrayElementReferenceOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation ArrayReference => ArrayReferenceAccessor(this.WrappedOperation); + public ImmutableArray Indices => IndicesAccessor(this.WrappedOperation); + public static explicit operator IArrayElementReferenceOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IArrayElementReferenceOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IArrayElementReferenceOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IArrayElementReferenceOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IArrayInitializerOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IArrayInitializerOperationWrapper.g.cs new file mode 100644 index 000000000..60eeb5485 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IArrayInitializerOperationWrapper.g.cs @@ -0,0 +1,52 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IArrayInitializerOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IArrayInitializerOperation"; + private static readonly Type WrappedType; + private static readonly Func> ElementValuesAccessor; + private readonly IOperation operation; + static IArrayInitializerOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IArrayInitializerOperationWrapper)); + ElementValuesAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(ElementValues)); + } + + private IArrayInitializerOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ImmutableArray ElementValues => ElementValuesAccessor(this.WrappedOperation); + public static explicit operator IArrayInitializerOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IArrayInitializerOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IArrayInitializerOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IArrayInitializerOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IAssignmentOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IAssignmentOperationWrapper.g.cs new file mode 100644 index 000000000..d1cd9cb3e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IAssignmentOperationWrapper.g.cs @@ -0,0 +1,60 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IAssignmentOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IAssignmentOperation"; + private static readonly Type WrappedType; + private static readonly Func TargetAccessor; + private static readonly Func ValueAccessor; + private readonly IOperation operation; + static IAssignmentOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IAssignmentOperationWrapper)); + TargetAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Target)); + ValueAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Value)); + } + + private IAssignmentOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Target => TargetAccessor(this.WrappedOperation); + public IOperation Value => ValueAccessor(this.WrappedOperation); + public static explicit operator IAssignmentOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IAssignmentOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IAssignmentOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IAssignmentOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + + internal static IAssignmentOperationWrapper FromUpcast(IOperation operation) + { + return new IAssignmentOperationWrapper(operation); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IAwaitOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IAwaitOperationWrapper.g.cs new file mode 100644 index 000000000..75b1e8934 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IAwaitOperationWrapper.g.cs @@ -0,0 +1,52 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IAwaitOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IAwaitOperation"; + private static readonly Type WrappedType; + private static readonly Func OperationAccessor; + private readonly IOperation operation; + static IAwaitOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IAwaitOperationWrapper)); + OperationAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Operation)); + } + + private IAwaitOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Operation => OperationAccessor(this.WrappedOperation); + public static explicit operator IAwaitOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IAwaitOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IAwaitOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IAwaitOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IBinaryOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IBinaryOperationWrapper.g.cs new file mode 100644 index 000000000..5ca2c247f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IBinaryOperationWrapper.g.cs @@ -0,0 +1,68 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IBinaryOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IBinaryOperation"; + private static readonly Type WrappedType; + private static readonly Func LeftOperandAccessor; + private static readonly Func RightOperandAccessor; + private static readonly Func IsLiftedAccessor; + private static readonly Func IsCheckedAccessor; + private static readonly Func IsCompareTextAccessor; + private static readonly Func OperatorMethodAccessor; + private readonly IOperation operation; + static IBinaryOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IBinaryOperationWrapper)); + LeftOperandAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(LeftOperand)); + RightOperandAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(RightOperand)); + IsLiftedAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsLifted)); + IsCheckedAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsChecked)); + IsCompareTextAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsCompareText)); + OperatorMethodAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(OperatorMethod)); + } + + private IBinaryOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public object OperatorKind => throw new NotImplementedException("Property 'IBinaryOperation.OperatorKind' has unsupported type 'BinaryOperatorKind'"); + public IOperation LeftOperand => LeftOperandAccessor(this.WrappedOperation); + public IOperation RightOperand => RightOperandAccessor(this.WrappedOperation); + public bool IsLifted => IsLiftedAccessor(this.WrappedOperation); + public bool IsChecked => IsCheckedAccessor(this.WrappedOperation); + public bool IsCompareText => IsCompareTextAccessor(this.WrappedOperation); + public IMethodSymbol OperatorMethod => OperatorMethodAccessor(this.WrappedOperation); + public static explicit operator IBinaryOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IBinaryOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IBinaryOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IBinaryOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IBinaryPatternOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IBinaryPatternOperationWrapper.g.cs new file mode 100644 index 000000000..2ee77ab8c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IBinaryPatternOperationWrapper.g.cs @@ -0,0 +1,60 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IBinaryPatternOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IBinaryPatternOperation"; + private static readonly Type WrappedType; + private static readonly Func LeftPatternAccessor; + private static readonly Func RightPatternAccessor; + private readonly IOperation operation; + static IBinaryPatternOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IBinaryPatternOperationWrapper)); + LeftPatternAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(LeftPattern)); + RightPatternAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(RightPattern)); + } + + private IBinaryPatternOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public object OperatorKind => throw new NotImplementedException("Property 'IBinaryPatternOperation.OperatorKind' has unsupported type 'BinaryOperatorKind'"); + public IPatternOperationWrapper LeftPattern => IPatternOperationWrapper.FromOperation(LeftPatternAccessor(this.WrappedOperation)); + public IPatternOperationWrapper RightPattern => IPatternOperationWrapper.FromOperation(RightPatternAccessor(this.WrappedOperation)); + public static explicit operator IBinaryPatternOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IBinaryPatternOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public ITypeSymbol InputType => ((IPatternOperationWrapper)this).InputType; + public ITypeSymbol NarrowedType => ((IPatternOperationWrapper)this).NarrowedType; + public static explicit operator IBinaryPatternOperationWrapper(IPatternOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IPatternOperationWrapper(IBinaryPatternOperationWrapper wrapper) => IPatternOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IBinaryPatternOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IBinaryPatternOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IBlockOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IBlockOperationWrapper.g.cs new file mode 100644 index 000000000..f92318d04 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IBlockOperationWrapper.g.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IBlockOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IBlockOperation"; + private static readonly Type WrappedType; + private static readonly Func> OperationsAccessor; + private static readonly Func> LocalsAccessor; + private readonly IOperation operation; + static IBlockOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IBlockOperationWrapper)); + OperationsAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(Operations)); + LocalsAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(Locals)); + } + + private IBlockOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ImmutableArray Operations => OperationsAccessor(this.WrappedOperation); + public ImmutableArray Locals => LocalsAccessor(this.WrappedOperation); + public static explicit operator IBlockOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IBlockOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IBlockOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IBlockOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IBranchOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IBranchOperationWrapper.g.cs new file mode 100644 index 000000000..0f3b2431d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IBranchOperationWrapper.g.cs @@ -0,0 +1,53 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IBranchOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IBranchOperation"; + private static readonly Type WrappedType; + private static readonly Func TargetAccessor; + private readonly IOperation operation; + static IBranchOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IBranchOperationWrapper)); + TargetAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Target)); + } + + private IBranchOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ILabelSymbol Target => TargetAccessor(this.WrappedOperation); + public object BranchKind => throw new NotImplementedException("Property 'IBranchOperation.BranchKind' has unsupported type 'BranchKind'"); + public static explicit operator IBranchOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IBranchOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IBranchOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IBranchOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ICaseClauseOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ICaseClauseOperationWrapper.g.cs new file mode 100644 index 000000000..5af08b36c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ICaseClauseOperationWrapper.g.cs @@ -0,0 +1,58 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ICaseClauseOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ICaseClauseOperation"; + private static readonly Type WrappedType; + private static readonly Func LabelAccessor; + private readonly IOperation operation; + static ICaseClauseOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ICaseClauseOperationWrapper)); + LabelAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Label)); + } + + private ICaseClauseOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public object CaseKind => throw new NotImplementedException("Property 'ICaseClauseOperation.CaseKind' has unsupported type 'CaseKind'"); + public ILabelSymbol Label => LabelAccessor(this.WrappedOperation); + public static explicit operator ICaseClauseOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ICaseClauseOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ICaseClauseOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ICaseClauseOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + + internal static ICaseClauseOperationWrapper FromUpcast(IOperation operation) + { + return new ICaseClauseOperationWrapper(operation); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ICatchClauseOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ICatchClauseOperationWrapper.g.cs new file mode 100644 index 000000000..a94af5284 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ICatchClauseOperationWrapper.g.cs @@ -0,0 +1,64 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ICatchClauseOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ICatchClauseOperation"; + private static readonly Type WrappedType; + private static readonly Func ExceptionDeclarationOrExpressionAccessor; + private static readonly Func ExceptionTypeAccessor; + private static readonly Func> LocalsAccessor; + private static readonly Func FilterAccessor; + private static readonly Func HandlerAccessor; + private readonly IOperation operation; + static ICatchClauseOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ICatchClauseOperationWrapper)); + ExceptionDeclarationOrExpressionAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(ExceptionDeclarationOrExpression)); + ExceptionTypeAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(ExceptionType)); + LocalsAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(Locals)); + FilterAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Filter)); + HandlerAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Handler)); + } + + private ICatchClauseOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation ExceptionDeclarationOrExpression => ExceptionDeclarationOrExpressionAccessor(this.WrappedOperation); + public ITypeSymbol ExceptionType => ExceptionTypeAccessor(this.WrappedOperation); + public ImmutableArray Locals => LocalsAccessor(this.WrappedOperation); + public IOperation Filter => FilterAccessor(this.WrappedOperation); + public IBlockOperationWrapper Handler => IBlockOperationWrapper.FromOperation(HandlerAccessor(this.WrappedOperation)); + public static explicit operator ICatchClauseOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ICatchClauseOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ICatchClauseOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ICatchClauseOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ICaughtExceptionOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ICaughtExceptionOperationWrapper.g.cs new file mode 100644 index 000000000..fa5ae1ac2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ICaughtExceptionOperationWrapper.g.cs @@ -0,0 +1,49 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ICaughtExceptionOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.FlowAnalysis.ICaughtExceptionOperation"; + private static readonly Type WrappedType; + private readonly IOperation operation; + static ICaughtExceptionOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ICaughtExceptionOperationWrapper)); + } + + private ICaughtExceptionOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public static explicit operator ICaughtExceptionOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ICaughtExceptionOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ICaughtExceptionOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ICaughtExceptionOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ICoalesceAssignmentOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ICoalesceAssignmentOperationWrapper.g.cs new file mode 100644 index 000000000..421c5ca5a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ICoalesceAssignmentOperationWrapper.g.cs @@ -0,0 +1,53 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ICoalesceAssignmentOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ICoalesceAssignmentOperation"; + private static readonly Type WrappedType; + private readonly IOperation operation; + static ICoalesceAssignmentOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ICoalesceAssignmentOperationWrapper)); + } + + private ICoalesceAssignmentOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public static explicit operator ICoalesceAssignmentOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ICoalesceAssignmentOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public IOperation Target => ((IAssignmentOperationWrapper)this).Target; + public IOperation Value => ((IAssignmentOperationWrapper)this).Value; + public static explicit operator ICoalesceAssignmentOperationWrapper(IAssignmentOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IAssignmentOperationWrapper(ICoalesceAssignmentOperationWrapper wrapper) => IAssignmentOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ICoalesceAssignmentOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ICoalesceAssignmentOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ICoalesceOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ICoalesceOperationWrapper.g.cs new file mode 100644 index 000000000..f487fe9b5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ICoalesceOperationWrapper.g.cs @@ -0,0 +1,56 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ICoalesceOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ICoalesceOperation"; + private static readonly Type WrappedType; + private static readonly Func ValueAccessor; + private static readonly Func WhenNullAccessor; + private readonly IOperation operation; + static ICoalesceOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ICoalesceOperationWrapper)); + ValueAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Value)); + WhenNullAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(WhenNull)); + } + + private ICoalesceOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Value => ValueAccessor(this.WrappedOperation); + public IOperation WhenNull => WhenNullAccessor(this.WrappedOperation); + public object ValueConversion => throw new NotImplementedException("Property 'ICoalesceOperation.ValueConversion' has unsupported type 'CommonConversion'"); + public static explicit operator ICoalesceOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ICoalesceOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ICoalesceOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ICoalesceOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ICollectionElementInitializerOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ICollectionElementInitializerOperationWrapper.g.cs new file mode 100644 index 000000000..e5cfe4546 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ICollectionElementInitializerOperationWrapper.g.cs @@ -0,0 +1,58 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ICollectionElementInitializerOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ICollectionElementInitializerOperation"; + private static readonly Type WrappedType; + private static readonly Func AddMethodAccessor; + private static readonly Func> ArgumentsAccessor; + private static readonly Func IsDynamicAccessor; + private readonly IOperation operation; + static ICollectionElementInitializerOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ICollectionElementInitializerOperationWrapper)); + AddMethodAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(AddMethod)); + ArgumentsAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(Arguments)); + IsDynamicAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsDynamic)); + } + + private ICollectionElementInitializerOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IMethodSymbol AddMethod => AddMethodAccessor(this.WrappedOperation); + public ImmutableArray Arguments => ArgumentsAccessor(this.WrappedOperation); + public bool IsDynamic => IsDynamicAccessor(this.WrappedOperation); + public static explicit operator ICollectionElementInitializerOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ICollectionElementInitializerOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ICollectionElementInitializerOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ICollectionElementInitializerOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ICompoundAssignmentOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ICompoundAssignmentOperationWrapper.g.cs new file mode 100644 index 000000000..ab80b1866 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ICompoundAssignmentOperationWrapper.g.cs @@ -0,0 +1,65 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ICompoundAssignmentOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ICompoundAssignmentOperation"; + private static readonly Type WrappedType; + private static readonly Func IsLiftedAccessor; + private static readonly Func IsCheckedAccessor; + private static readonly Func OperatorMethodAccessor; + private readonly IOperation operation; + static ICompoundAssignmentOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ICompoundAssignmentOperationWrapper)); + IsLiftedAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsLifted)); + IsCheckedAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsChecked)); + OperatorMethodAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(OperatorMethod)); + } + + private ICompoundAssignmentOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public object InConversion => throw new NotImplementedException("Property 'ICompoundAssignmentOperation.InConversion' has unsupported type 'CommonConversion'"); + public object OutConversion => throw new NotImplementedException("Property 'ICompoundAssignmentOperation.OutConversion' has unsupported type 'CommonConversion'"); + public object OperatorKind => throw new NotImplementedException("Property 'ICompoundAssignmentOperation.OperatorKind' has unsupported type 'BinaryOperatorKind'"); + public bool IsLifted => IsLiftedAccessor(this.WrappedOperation); + public bool IsChecked => IsCheckedAccessor(this.WrappedOperation); + public IMethodSymbol OperatorMethod => OperatorMethodAccessor(this.WrappedOperation); + public static explicit operator ICompoundAssignmentOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ICompoundAssignmentOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public IOperation Target => ((IAssignmentOperationWrapper)this).Target; + public IOperation Value => ((IAssignmentOperationWrapper)this).Value; + public static explicit operator ICompoundAssignmentOperationWrapper(IAssignmentOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IAssignmentOperationWrapper(ICompoundAssignmentOperationWrapper wrapper) => IAssignmentOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ICompoundAssignmentOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ICompoundAssignmentOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IConditionalAccessInstanceOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IConditionalAccessInstanceOperationWrapper.g.cs new file mode 100644 index 000000000..699a9b01a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IConditionalAccessInstanceOperationWrapper.g.cs @@ -0,0 +1,49 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IConditionalAccessInstanceOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IConditionalAccessInstanceOperation"; + private static readonly Type WrappedType; + private readonly IOperation operation; + static IConditionalAccessInstanceOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IConditionalAccessInstanceOperationWrapper)); + } + + private IConditionalAccessInstanceOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public static explicit operator IConditionalAccessInstanceOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IConditionalAccessInstanceOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IConditionalAccessInstanceOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IConditionalAccessInstanceOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IConditionalAccessOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IConditionalAccessOperationWrapper.g.cs new file mode 100644 index 000000000..1228ba488 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IConditionalAccessOperationWrapper.g.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IConditionalAccessOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IConditionalAccessOperation"; + private static readonly Type WrappedType; + private static readonly Func OperationAccessor; + private static readonly Func WhenNotNullAccessor; + private readonly IOperation operation; + static IConditionalAccessOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IConditionalAccessOperationWrapper)); + OperationAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Operation)); + WhenNotNullAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(WhenNotNull)); + } + + private IConditionalAccessOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Operation => OperationAccessor(this.WrappedOperation); + public IOperation WhenNotNull => WhenNotNullAccessor(this.WrappedOperation); + public static explicit operator IConditionalAccessOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IConditionalAccessOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IConditionalAccessOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IConditionalAccessOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IConditionalOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IConditionalOperationWrapper.g.cs new file mode 100644 index 000000000..07aea6579 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IConditionalOperationWrapper.g.cs @@ -0,0 +1,61 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IConditionalOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IConditionalOperation"; + private static readonly Type WrappedType; + private static readonly Func ConditionAccessor; + private static readonly Func WhenTrueAccessor; + private static readonly Func WhenFalseAccessor; + private static readonly Func IsRefAccessor; + private readonly IOperation operation; + static IConditionalOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IConditionalOperationWrapper)); + ConditionAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Condition)); + WhenTrueAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(WhenTrue)); + WhenFalseAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(WhenFalse)); + IsRefAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsRef)); + } + + private IConditionalOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Condition => ConditionAccessor(this.WrappedOperation); + public IOperation WhenTrue => WhenTrueAccessor(this.WrappedOperation); + public IOperation WhenFalse => WhenFalseAccessor(this.WrappedOperation); + public bool IsRef => IsRefAccessor(this.WrappedOperation); + public static explicit operator IConditionalOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IConditionalOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IConditionalOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IConditionalOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IConstantPatternOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IConstantPatternOperationWrapper.g.cs new file mode 100644 index 000000000..cfe474883 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IConstantPatternOperationWrapper.g.cs @@ -0,0 +1,56 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IConstantPatternOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IConstantPatternOperation"; + private static readonly Type WrappedType; + private static readonly Func ValueAccessor; + private readonly IOperation operation; + static IConstantPatternOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IConstantPatternOperationWrapper)); + ValueAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Value)); + } + + private IConstantPatternOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Value => ValueAccessor(this.WrappedOperation); + public static explicit operator IConstantPatternOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IConstantPatternOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public ITypeSymbol InputType => ((IPatternOperationWrapper)this).InputType; + public ITypeSymbol NarrowedType => ((IPatternOperationWrapper)this).NarrowedType; + public static explicit operator IConstantPatternOperationWrapper(IPatternOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IPatternOperationWrapper(IConstantPatternOperationWrapper wrapper) => IPatternOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IConstantPatternOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IConstantPatternOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IConstructorBodyOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IConstructorBodyOperationWrapper.g.cs new file mode 100644 index 000000000..de028075e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IConstructorBodyOperationWrapper.g.cs @@ -0,0 +1,59 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IConstructorBodyOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IConstructorBodyOperation"; + private static readonly Type WrappedType; + private static readonly Func> LocalsAccessor; + private static readonly Func InitializerAccessor; + private readonly IOperation operation; + static IConstructorBodyOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IConstructorBodyOperationWrapper)); + LocalsAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(Locals)); + InitializerAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Initializer)); + } + + private IConstructorBodyOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ImmutableArray Locals => LocalsAccessor(this.WrappedOperation); + public IOperation Initializer => InitializerAccessor(this.WrappedOperation); + public static explicit operator IConstructorBodyOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IConstructorBodyOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public IBlockOperationWrapper BlockBody => ((IMethodBodyBaseOperationWrapper)this).BlockBody; + public IBlockOperationWrapper ExpressionBody => ((IMethodBodyBaseOperationWrapper)this).ExpressionBody; + public static explicit operator IConstructorBodyOperationWrapper(IMethodBodyBaseOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IMethodBodyBaseOperationWrapper(IConstructorBodyOperationWrapper wrapper) => IMethodBodyBaseOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IConstructorBodyOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IConstructorBodyOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IConversionOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IConversionOperationWrapper.g.cs new file mode 100644 index 000000000..94c59a7d3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IConversionOperationWrapper.g.cs @@ -0,0 +1,62 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IConversionOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IConversionOperation"; + private static readonly Type WrappedType; + private static readonly Func OperandAccessor; + private static readonly Func OperatorMethodAccessor; + private static readonly Func IsTryCastAccessor; + private static readonly Func IsCheckedAccessor; + private readonly IOperation operation; + static IConversionOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IConversionOperationWrapper)); + OperandAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Operand)); + OperatorMethodAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(OperatorMethod)); + IsTryCastAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsTryCast)); + IsCheckedAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsChecked)); + } + + private IConversionOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Operand => OperandAccessor(this.WrappedOperation); + public IMethodSymbol OperatorMethod => OperatorMethodAccessor(this.WrappedOperation); + public object Conversion => throw new NotImplementedException("Property 'IConversionOperation.Conversion' has unsupported type 'CommonConversion'"); + public bool IsTryCast => IsTryCastAccessor(this.WrappedOperation); + public bool IsChecked => IsCheckedAccessor(this.WrappedOperation); + public static explicit operator IConversionOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IConversionOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IConversionOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IConversionOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDeclarationExpressionOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDeclarationExpressionOperationWrapper.g.cs new file mode 100644 index 000000000..8d4595b24 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDeclarationExpressionOperationWrapper.g.cs @@ -0,0 +1,52 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IDeclarationExpressionOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IDeclarationExpressionOperation"; + private static readonly Type WrappedType; + private static readonly Func ExpressionAccessor; + private readonly IOperation operation; + static IDeclarationExpressionOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IDeclarationExpressionOperationWrapper)); + ExpressionAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Expression)); + } + + private IDeclarationExpressionOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Expression => ExpressionAccessor(this.WrappedOperation); + public static explicit operator IDeclarationExpressionOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IDeclarationExpressionOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IDeclarationExpressionOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IDeclarationExpressionOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDeclarationPatternOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDeclarationPatternOperationWrapper.g.cs new file mode 100644 index 000000000..74ee4e6c4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDeclarationPatternOperationWrapper.g.cs @@ -0,0 +1,62 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IDeclarationPatternOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IDeclarationPatternOperation"; + private static readonly Type WrappedType; + private static readonly Func MatchedTypeAccessor; + private static readonly Func MatchesNullAccessor; + private static readonly Func DeclaredSymbolAccessor; + private readonly IOperation operation; + static IDeclarationPatternOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IDeclarationPatternOperationWrapper)); + MatchedTypeAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(MatchedType)); + MatchesNullAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(MatchesNull)); + DeclaredSymbolAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(DeclaredSymbol)); + } + + private IDeclarationPatternOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ITypeSymbol MatchedType => MatchedTypeAccessor(this.WrappedOperation); + public bool MatchesNull => MatchesNullAccessor(this.WrappedOperation); + public ISymbol DeclaredSymbol => DeclaredSymbolAccessor(this.WrappedOperation); + public static explicit operator IDeclarationPatternOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IDeclarationPatternOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public ITypeSymbol InputType => ((IPatternOperationWrapper)this).InputType; + public ITypeSymbol NarrowedType => ((IPatternOperationWrapper)this).NarrowedType; + public static explicit operator IDeclarationPatternOperationWrapper(IPatternOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IPatternOperationWrapper(IDeclarationPatternOperationWrapper wrapper) => IPatternOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IDeclarationPatternOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IDeclarationPatternOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDeconstructionAssignmentOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDeconstructionAssignmentOperationWrapper.g.cs new file mode 100644 index 000000000..21a53890b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDeconstructionAssignmentOperationWrapper.g.cs @@ -0,0 +1,53 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IDeconstructionAssignmentOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IDeconstructionAssignmentOperation"; + private static readonly Type WrappedType; + private readonly IOperation operation; + static IDeconstructionAssignmentOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IDeconstructionAssignmentOperationWrapper)); + } + + private IDeconstructionAssignmentOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public static explicit operator IDeconstructionAssignmentOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IDeconstructionAssignmentOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public IOperation Target => ((IAssignmentOperationWrapper)this).Target; + public IOperation Value => ((IAssignmentOperationWrapper)this).Value; + public static explicit operator IDeconstructionAssignmentOperationWrapper(IAssignmentOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IAssignmentOperationWrapper(IDeconstructionAssignmentOperationWrapper wrapper) => IAssignmentOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IDeconstructionAssignmentOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IDeconstructionAssignmentOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDefaultCaseClauseOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDefaultCaseClauseOperationWrapper.g.cs new file mode 100644 index 000000000..a88f01da3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDefaultCaseClauseOperationWrapper.g.cs @@ -0,0 +1,53 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IDefaultCaseClauseOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IDefaultCaseClauseOperation"; + private static readonly Type WrappedType; + private readonly IOperation operation; + static IDefaultCaseClauseOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IDefaultCaseClauseOperationWrapper)); + } + + private IDefaultCaseClauseOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public static explicit operator IDefaultCaseClauseOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IDefaultCaseClauseOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public object CaseKind => ((ICaseClauseOperationWrapper)this).CaseKind; + public ILabelSymbol Label => ((ICaseClauseOperationWrapper)this).Label; + public static explicit operator IDefaultCaseClauseOperationWrapper(ICaseClauseOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator ICaseClauseOperationWrapper(IDefaultCaseClauseOperationWrapper wrapper) => ICaseClauseOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IDefaultCaseClauseOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IDefaultCaseClauseOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDefaultValueOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDefaultValueOperationWrapper.g.cs new file mode 100644 index 000000000..93fe593c6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDefaultValueOperationWrapper.g.cs @@ -0,0 +1,49 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IDefaultValueOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IDefaultValueOperation"; + private static readonly Type WrappedType; + private readonly IOperation operation; + static IDefaultValueOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IDefaultValueOperationWrapper)); + } + + private IDefaultValueOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public static explicit operator IDefaultValueOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IDefaultValueOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IDefaultValueOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IDefaultValueOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDelegateCreationOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDelegateCreationOperationWrapper.g.cs new file mode 100644 index 000000000..998be0e94 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDelegateCreationOperationWrapper.g.cs @@ -0,0 +1,52 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IDelegateCreationOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IDelegateCreationOperation"; + private static readonly Type WrappedType; + private static readonly Func TargetAccessor; + private readonly IOperation operation; + static IDelegateCreationOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IDelegateCreationOperationWrapper)); + TargetAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Target)); + } + + private IDelegateCreationOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Target => TargetAccessor(this.WrappedOperation); + public static explicit operator IDelegateCreationOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IDelegateCreationOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IDelegateCreationOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IDelegateCreationOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDiscardOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDiscardOperationWrapper.g.cs new file mode 100644 index 000000000..af53508b6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDiscardOperationWrapper.g.cs @@ -0,0 +1,50 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IDiscardOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IDiscardOperation"; + private static readonly Type WrappedType; + private readonly IOperation operation; + static IDiscardOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IDiscardOperationWrapper)); + } + + private IDiscardOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public object DiscardSymbol => throw new NotImplementedException("Property 'IDiscardOperation.DiscardSymbol' has unsupported type 'IDiscardSymbol'"); + public static explicit operator IDiscardOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IDiscardOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IDiscardOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IDiscardOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDiscardPatternOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDiscardPatternOperationWrapper.g.cs new file mode 100644 index 000000000..ebcfc587d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDiscardPatternOperationWrapper.g.cs @@ -0,0 +1,53 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IDiscardPatternOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IDiscardPatternOperation"; + private static readonly Type WrappedType; + private readonly IOperation operation; + static IDiscardPatternOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IDiscardPatternOperationWrapper)); + } + + private IDiscardPatternOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public static explicit operator IDiscardPatternOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IDiscardPatternOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public ITypeSymbol InputType => ((IPatternOperationWrapper)this).InputType; + public ITypeSymbol NarrowedType => ((IPatternOperationWrapper)this).NarrowedType; + public static explicit operator IDiscardPatternOperationWrapper(IPatternOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IPatternOperationWrapper(IDiscardPatternOperationWrapper wrapper) => IPatternOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IDiscardPatternOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IDiscardPatternOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDynamicIndexerAccessOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDynamicIndexerAccessOperationWrapper.g.cs new file mode 100644 index 000000000..e28bf9458 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDynamicIndexerAccessOperationWrapper.g.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IDynamicIndexerAccessOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IDynamicIndexerAccessOperation"; + private static readonly Type WrappedType; + private static readonly Func OperationAccessor; + private static readonly Func> ArgumentsAccessor; + private readonly IOperation operation; + static IDynamicIndexerAccessOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IDynamicIndexerAccessOperationWrapper)); + OperationAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Operation)); + ArgumentsAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(Arguments)); + } + + private IDynamicIndexerAccessOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Operation => OperationAccessor(this.WrappedOperation); + public ImmutableArray Arguments => ArgumentsAccessor(this.WrappedOperation); + public static explicit operator IDynamicIndexerAccessOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IDynamicIndexerAccessOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IDynamicIndexerAccessOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IDynamicIndexerAccessOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDynamicInvocationOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDynamicInvocationOperationWrapper.g.cs new file mode 100644 index 000000000..218cd9e88 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDynamicInvocationOperationWrapper.g.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IDynamicInvocationOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IDynamicInvocationOperation"; + private static readonly Type WrappedType; + private static readonly Func OperationAccessor; + private static readonly Func> ArgumentsAccessor; + private readonly IOperation operation; + static IDynamicInvocationOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IDynamicInvocationOperationWrapper)); + OperationAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Operation)); + ArgumentsAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(Arguments)); + } + + private IDynamicInvocationOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Operation => OperationAccessor(this.WrappedOperation); + public ImmutableArray Arguments => ArgumentsAccessor(this.WrappedOperation); + public static explicit operator IDynamicInvocationOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IDynamicInvocationOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IDynamicInvocationOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IDynamicInvocationOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDynamicMemberReferenceOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDynamicMemberReferenceOperationWrapper.g.cs new file mode 100644 index 000000000..204c49498 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDynamicMemberReferenceOperationWrapper.g.cs @@ -0,0 +1,61 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IDynamicMemberReferenceOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IDynamicMemberReferenceOperation"; + private static readonly Type WrappedType; + private static readonly Func InstanceAccessor; + private static readonly Func MemberNameAccessor; + private static readonly Func> TypeArgumentsAccessor; + private static readonly Func ContainingTypeAccessor; + private readonly IOperation operation; + static IDynamicMemberReferenceOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IDynamicMemberReferenceOperationWrapper)); + InstanceAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Instance)); + MemberNameAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(MemberName)); + TypeArgumentsAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(TypeArguments)); + ContainingTypeAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(ContainingType)); + } + + private IDynamicMemberReferenceOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Instance => InstanceAccessor(this.WrappedOperation); + public string MemberName => MemberNameAccessor(this.WrappedOperation); + public ImmutableArray TypeArguments => TypeArgumentsAccessor(this.WrappedOperation); + public ITypeSymbol ContainingType => ContainingTypeAccessor(this.WrappedOperation); + public static explicit operator IDynamicMemberReferenceOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IDynamicMemberReferenceOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IDynamicMemberReferenceOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IDynamicMemberReferenceOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDynamicObjectCreationOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDynamicObjectCreationOperationWrapper.g.cs new file mode 100644 index 000000000..242077aea --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IDynamicObjectCreationOperationWrapper.g.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IDynamicObjectCreationOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IDynamicObjectCreationOperation"; + private static readonly Type WrappedType; + private static readonly Func InitializerAccessor; + private static readonly Func> ArgumentsAccessor; + private readonly IOperation operation; + static IDynamicObjectCreationOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IDynamicObjectCreationOperationWrapper)); + InitializerAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Initializer)); + ArgumentsAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(Arguments)); + } + + private IDynamicObjectCreationOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IObjectOrCollectionInitializerOperationWrapper Initializer => IObjectOrCollectionInitializerOperationWrapper.FromOperation(InitializerAccessor(this.WrappedOperation)); + public ImmutableArray Arguments => ArgumentsAccessor(this.WrappedOperation); + public static explicit operator IDynamicObjectCreationOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IDynamicObjectCreationOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IDynamicObjectCreationOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IDynamicObjectCreationOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IEmptyOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IEmptyOperationWrapper.g.cs new file mode 100644 index 000000000..5227ce196 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IEmptyOperationWrapper.g.cs @@ -0,0 +1,49 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IEmptyOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IEmptyOperation"; + private static readonly Type WrappedType; + private readonly IOperation operation; + static IEmptyOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IEmptyOperationWrapper)); + } + + private IEmptyOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public static explicit operator IEmptyOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IEmptyOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IEmptyOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IEmptyOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IEndOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IEndOperationWrapper.g.cs new file mode 100644 index 000000000..870ebe0e5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IEndOperationWrapper.g.cs @@ -0,0 +1,49 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IEndOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IEndOperation"; + private static readonly Type WrappedType; + private readonly IOperation operation; + static IEndOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IEndOperationWrapper)); + } + + private IEndOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public static explicit operator IEndOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IEndOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IEndOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IEndOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IEventAssignmentOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IEventAssignmentOperationWrapper.g.cs new file mode 100644 index 000000000..905cb2b44 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IEventAssignmentOperationWrapper.g.cs @@ -0,0 +1,58 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IEventAssignmentOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IEventAssignmentOperation"; + private static readonly Type WrappedType; + private static readonly Func EventReferenceAccessor; + private static readonly Func HandlerValueAccessor; + private static readonly Func AddsAccessor; + private readonly IOperation operation; + static IEventAssignmentOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IEventAssignmentOperationWrapper)); + EventReferenceAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(EventReference)); + HandlerValueAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(HandlerValue)); + AddsAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Adds)); + } + + private IEventAssignmentOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation EventReference => EventReferenceAccessor(this.WrappedOperation); + public IOperation HandlerValue => HandlerValueAccessor(this.WrappedOperation); + public bool Adds => AddsAccessor(this.WrappedOperation); + public static explicit operator IEventAssignmentOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IEventAssignmentOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IEventAssignmentOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IEventAssignmentOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IEventReferenceOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IEventReferenceOperationWrapper.g.cs new file mode 100644 index 000000000..96aa29fa9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IEventReferenceOperationWrapper.g.cs @@ -0,0 +1,56 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IEventReferenceOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IEventReferenceOperation"; + private static readonly Type WrappedType; + private static readonly Func EventAccessor; + private readonly IOperation operation; + static IEventReferenceOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IEventReferenceOperationWrapper)); + EventAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Event)); + } + + private IEventReferenceOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IEventSymbol Event => EventAccessor(this.WrappedOperation); + public static explicit operator IEventReferenceOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IEventReferenceOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public IOperation Instance => ((IMemberReferenceOperationWrapper)this).Instance; + public ISymbol Member => ((IMemberReferenceOperationWrapper)this).Member; + public static explicit operator IEventReferenceOperationWrapper(IMemberReferenceOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IMemberReferenceOperationWrapper(IEventReferenceOperationWrapper wrapper) => IMemberReferenceOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IEventReferenceOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IEventReferenceOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IExpressionStatementOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IExpressionStatementOperationWrapper.g.cs new file mode 100644 index 000000000..9ec328f97 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IExpressionStatementOperationWrapper.g.cs @@ -0,0 +1,52 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IExpressionStatementOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IExpressionStatementOperation"; + private static readonly Type WrappedType; + private static readonly Func OperationAccessor; + private readonly IOperation operation; + static IExpressionStatementOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IExpressionStatementOperationWrapper)); + OperationAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Operation)); + } + + private IExpressionStatementOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Operation => OperationAccessor(this.WrappedOperation); + public static explicit operator IExpressionStatementOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IExpressionStatementOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IExpressionStatementOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IExpressionStatementOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IFieldInitializerOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IFieldInitializerOperationWrapper.g.cs new file mode 100644 index 000000000..15b3b89de --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IFieldInitializerOperationWrapper.g.cs @@ -0,0 +1,56 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IFieldInitializerOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IFieldInitializerOperation"; + private static readonly Type WrappedType; + private static readonly Func> InitializedFieldsAccessor; + private readonly IOperation operation; + static IFieldInitializerOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IFieldInitializerOperationWrapper)); + InitializedFieldsAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(InitializedFields)); + } + + private IFieldInitializerOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ImmutableArray InitializedFields => InitializedFieldsAccessor(this.WrappedOperation); + public static explicit operator IFieldInitializerOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IFieldInitializerOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public ImmutableArray Locals => ((ISymbolInitializerOperationWrapper)this).Locals; + public IOperation Value => ((ISymbolInitializerOperationWrapper)this).Value; + public static explicit operator IFieldInitializerOperationWrapper(ISymbolInitializerOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator ISymbolInitializerOperationWrapper(IFieldInitializerOperationWrapper wrapper) => ISymbolInitializerOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IFieldInitializerOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IFieldInitializerOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IFieldReferenceOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IFieldReferenceOperationWrapper.g.cs new file mode 100644 index 000000000..6abd08ea7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IFieldReferenceOperationWrapper.g.cs @@ -0,0 +1,59 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IFieldReferenceOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IFieldReferenceOperation"; + private static readonly Type WrappedType; + private static readonly Func FieldAccessor; + private static readonly Func IsDeclarationAccessor; + private readonly IOperation operation; + static IFieldReferenceOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IFieldReferenceOperationWrapper)); + FieldAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Field)); + IsDeclarationAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsDeclaration)); + } + + private IFieldReferenceOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IFieldSymbol Field => FieldAccessor(this.WrappedOperation); + public bool IsDeclaration => IsDeclarationAccessor(this.WrappedOperation); + public static explicit operator IFieldReferenceOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IFieldReferenceOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public IOperation Instance => ((IMemberReferenceOperationWrapper)this).Instance; + public ISymbol Member => ((IMemberReferenceOperationWrapper)this).Member; + public static explicit operator IFieldReferenceOperationWrapper(IMemberReferenceOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IMemberReferenceOperationWrapper(IFieldReferenceOperationWrapper wrapper) => IMemberReferenceOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IFieldReferenceOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IFieldReferenceOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IFlowAnonymousFunctionOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IFlowAnonymousFunctionOperationWrapper.g.cs new file mode 100644 index 000000000..8190e6ba8 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IFlowAnonymousFunctionOperationWrapper.g.cs @@ -0,0 +1,52 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IFlowAnonymousFunctionOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.FlowAnalysis.IFlowAnonymousFunctionOperation"; + private static readonly Type WrappedType; + private static readonly Func SymbolAccessor; + private readonly IOperation operation; + static IFlowAnonymousFunctionOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IFlowAnonymousFunctionOperationWrapper)); + SymbolAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Symbol)); + } + + private IFlowAnonymousFunctionOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IMethodSymbol Symbol => SymbolAccessor(this.WrappedOperation); + public static explicit operator IFlowAnonymousFunctionOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IFlowAnonymousFunctionOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IFlowAnonymousFunctionOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IFlowAnonymousFunctionOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IFlowCaptureOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IFlowCaptureOperationWrapper.g.cs new file mode 100644 index 000000000..c2ea9dbce --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IFlowCaptureOperationWrapper.g.cs @@ -0,0 +1,53 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IFlowCaptureOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureOperation"; + private static readonly Type WrappedType; + private static readonly Func ValueAccessor; + private readonly IOperation operation; + static IFlowCaptureOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IFlowCaptureOperationWrapper)); + ValueAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Value)); + } + + private IFlowCaptureOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public object Id => throw new NotImplementedException("Property 'IFlowCaptureOperation.Id' has unsupported type 'CaptureId'"); + public IOperation Value => ValueAccessor(this.WrappedOperation); + public static explicit operator IFlowCaptureOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IFlowCaptureOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IFlowCaptureOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IFlowCaptureOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IFlowCaptureReferenceOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IFlowCaptureReferenceOperationWrapper.g.cs new file mode 100644 index 000000000..2fc7756c3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IFlowCaptureReferenceOperationWrapper.g.cs @@ -0,0 +1,50 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IFlowCaptureReferenceOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureReferenceOperation"; + private static readonly Type WrappedType; + private readonly IOperation operation; + static IFlowCaptureReferenceOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IFlowCaptureReferenceOperationWrapper)); + } + + private IFlowCaptureReferenceOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public object Id => throw new NotImplementedException("Property 'IFlowCaptureReferenceOperation.Id' has unsupported type 'CaptureId'"); + public static explicit operator IFlowCaptureReferenceOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IFlowCaptureReferenceOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IFlowCaptureReferenceOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IFlowCaptureReferenceOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IForEachLoopOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IForEachLoopOperationWrapper.g.cs new file mode 100644 index 000000000..58e008b59 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IForEachLoopOperationWrapper.g.cs @@ -0,0 +1,68 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IForEachLoopOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IForEachLoopOperation"; + private static readonly Type WrappedType; + private static readonly Func LoopControlVariableAccessor; + private static readonly Func CollectionAccessor; + private static readonly Func> NextVariablesAccessor; + private static readonly Func IsAsynchronousAccessor; + private readonly IOperation operation; + static IForEachLoopOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IForEachLoopOperationWrapper)); + LoopControlVariableAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(LoopControlVariable)); + CollectionAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Collection)); + NextVariablesAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(NextVariables)); + IsAsynchronousAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsAsynchronous)); + } + + private IForEachLoopOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation LoopControlVariable => LoopControlVariableAccessor(this.WrappedOperation); + public IOperation Collection => CollectionAccessor(this.WrappedOperation); + public ImmutableArray NextVariables => NextVariablesAccessor(this.WrappedOperation); + public bool IsAsynchronous => IsAsynchronousAccessor(this.WrappedOperation); + public static explicit operator IForEachLoopOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IForEachLoopOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public object LoopKind => ((ILoopOperationWrapper)this).LoopKind; + public IOperation Body => ((ILoopOperationWrapper)this).Body; + public ImmutableArray Locals => ((ILoopOperationWrapper)this).Locals; + public ILabelSymbol ContinueLabel => ((ILoopOperationWrapper)this).ContinueLabel; + public ILabelSymbol ExitLabel => ((ILoopOperationWrapper)this).ExitLabel; + public static explicit operator IForEachLoopOperationWrapper(ILoopOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator ILoopOperationWrapper(IForEachLoopOperationWrapper wrapper) => ILoopOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IForEachLoopOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IForEachLoopOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IForLoopOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IForLoopOperationWrapper.g.cs new file mode 100644 index 000000000..fdb5a3f13 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IForLoopOperationWrapper.g.cs @@ -0,0 +1,68 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IForLoopOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IForLoopOperation"; + private static readonly Type WrappedType; + private static readonly Func> BeforeAccessor; + private static readonly Func> ConditionLocalsAccessor; + private static readonly Func ConditionAccessor; + private static readonly Func> AtLoopBottomAccessor; + private readonly IOperation operation; + static IForLoopOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IForLoopOperationWrapper)); + BeforeAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(Before)); + ConditionLocalsAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(ConditionLocals)); + ConditionAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Condition)); + AtLoopBottomAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(AtLoopBottom)); + } + + private IForLoopOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ImmutableArray Before => BeforeAccessor(this.WrappedOperation); + public ImmutableArray ConditionLocals => ConditionLocalsAccessor(this.WrappedOperation); + public IOperation Condition => ConditionAccessor(this.WrappedOperation); + public ImmutableArray AtLoopBottom => AtLoopBottomAccessor(this.WrappedOperation); + public static explicit operator IForLoopOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IForLoopOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public object LoopKind => ((ILoopOperationWrapper)this).LoopKind; + public IOperation Body => ((ILoopOperationWrapper)this).Body; + public ImmutableArray Locals => ((ILoopOperationWrapper)this).Locals; + public ILabelSymbol ContinueLabel => ((ILoopOperationWrapper)this).ContinueLabel; + public ILabelSymbol ExitLabel => ((ILoopOperationWrapper)this).ExitLabel; + public static explicit operator IForLoopOperationWrapper(ILoopOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator ILoopOperationWrapper(IForLoopOperationWrapper wrapper) => ILoopOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IForLoopOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IForLoopOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IForToLoopOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IForToLoopOperationWrapper.g.cs new file mode 100644 index 000000000..7a76c4904 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IForToLoopOperationWrapper.g.cs @@ -0,0 +1,74 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IForToLoopOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IForToLoopOperation"; + private static readonly Type WrappedType; + private static readonly Func LoopControlVariableAccessor; + private static readonly Func InitialValueAccessor; + private static readonly Func LimitValueAccessor; + private static readonly Func StepValueAccessor; + private static readonly Func IsCheckedAccessor; + private static readonly Func> NextVariablesAccessor; + private readonly IOperation operation; + static IForToLoopOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IForToLoopOperationWrapper)); + LoopControlVariableAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(LoopControlVariable)); + InitialValueAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(InitialValue)); + LimitValueAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(LimitValue)); + StepValueAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(StepValue)); + IsCheckedAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsChecked)); + NextVariablesAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(NextVariables)); + } + + private IForToLoopOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation LoopControlVariable => LoopControlVariableAccessor(this.WrappedOperation); + public IOperation InitialValue => InitialValueAccessor(this.WrappedOperation); + public IOperation LimitValue => LimitValueAccessor(this.WrappedOperation); + public IOperation StepValue => StepValueAccessor(this.WrappedOperation); + public bool IsChecked => IsCheckedAccessor(this.WrappedOperation); + public ImmutableArray NextVariables => NextVariablesAccessor(this.WrappedOperation); + public static explicit operator IForToLoopOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IForToLoopOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public object LoopKind => ((ILoopOperationWrapper)this).LoopKind; + public IOperation Body => ((ILoopOperationWrapper)this).Body; + public ImmutableArray Locals => ((ILoopOperationWrapper)this).Locals; + public ILabelSymbol ContinueLabel => ((ILoopOperationWrapper)this).ContinueLabel; + public ILabelSymbol ExitLabel => ((ILoopOperationWrapper)this).ExitLabel; + public static explicit operator IForToLoopOperationWrapper(ILoopOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator ILoopOperationWrapper(IForToLoopOperationWrapper wrapper) => ILoopOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IForToLoopOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IForToLoopOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IIncrementOrDecrementOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IIncrementOrDecrementOperationWrapper.g.cs new file mode 100644 index 000000000..c455d3d5e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IIncrementOrDecrementOperationWrapper.g.cs @@ -0,0 +1,64 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IIncrementOrDecrementOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IIncrementOrDecrementOperation"; + private static readonly Type WrappedType; + private static readonly Func IsPostfixAccessor; + private static readonly Func IsLiftedAccessor; + private static readonly Func IsCheckedAccessor; + private static readonly Func TargetAccessor; + private static readonly Func OperatorMethodAccessor; + private readonly IOperation operation; + static IIncrementOrDecrementOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IIncrementOrDecrementOperationWrapper)); + IsPostfixAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsPostfix)); + IsLiftedAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsLifted)); + IsCheckedAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsChecked)); + TargetAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Target)); + OperatorMethodAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(OperatorMethod)); + } + + private IIncrementOrDecrementOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public bool IsPostfix => IsPostfixAccessor(this.WrappedOperation); + public bool IsLifted => IsLiftedAccessor(this.WrappedOperation); + public bool IsChecked => IsCheckedAccessor(this.WrappedOperation); + public IOperation Target => TargetAccessor(this.WrappedOperation); + public IMethodSymbol OperatorMethod => OperatorMethodAccessor(this.WrappedOperation); + public static explicit operator IIncrementOrDecrementOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IIncrementOrDecrementOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IIncrementOrDecrementOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IIncrementOrDecrementOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IInstanceReferenceOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IInstanceReferenceOperationWrapper.g.cs new file mode 100644 index 000000000..222f3f617 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IInstanceReferenceOperationWrapper.g.cs @@ -0,0 +1,50 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IInstanceReferenceOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IInstanceReferenceOperation"; + private static readonly Type WrappedType; + private readonly IOperation operation; + static IInstanceReferenceOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IInstanceReferenceOperationWrapper)); + } + + private IInstanceReferenceOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public object ReferenceKind => throw new NotImplementedException("Property 'IInstanceReferenceOperation.ReferenceKind' has unsupported type 'InstanceReferenceKind'"); + public static explicit operator IInstanceReferenceOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IInstanceReferenceOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IInstanceReferenceOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IInstanceReferenceOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IInterpolatedStringContentOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IInterpolatedStringContentOperationWrapper.g.cs new file mode 100644 index 000000000..ce38bc7af --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IInterpolatedStringContentOperationWrapper.g.cs @@ -0,0 +1,54 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IInterpolatedStringContentOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IInterpolatedStringContentOperation"; + private static readonly Type WrappedType; + private readonly IOperation operation; + static IInterpolatedStringContentOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IInterpolatedStringContentOperationWrapper)); + } + + private IInterpolatedStringContentOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public static explicit operator IInterpolatedStringContentOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IInterpolatedStringContentOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IInterpolatedStringContentOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IInterpolatedStringContentOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + + internal static IInterpolatedStringContentOperationWrapper FromUpcast(IOperation operation) + { + return new IInterpolatedStringContentOperationWrapper(operation); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IInterpolatedStringOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IInterpolatedStringOperationWrapper.g.cs new file mode 100644 index 000000000..8a4f9910c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IInterpolatedStringOperationWrapper.g.cs @@ -0,0 +1,52 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IInterpolatedStringOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IInterpolatedStringOperation"; + private static readonly Type WrappedType; + private static readonly Func> PartsAccessor; + private readonly IOperation operation; + static IInterpolatedStringOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IInterpolatedStringOperationWrapper)); + PartsAccessor = LightupHelpers.CreateOperationListPropertyAccessor(WrappedType, nameof(Parts)); + } + + private IInterpolatedStringOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ImmutableArray Parts => PartsAccessor(this.WrappedOperation); + public static explicit operator IInterpolatedStringOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IInterpolatedStringOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IInterpolatedStringOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IInterpolatedStringOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IInterpolatedStringTextOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IInterpolatedStringTextOperationWrapper.g.cs new file mode 100644 index 000000000..001b943e2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IInterpolatedStringTextOperationWrapper.g.cs @@ -0,0 +1,54 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IInterpolatedStringTextOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IInterpolatedStringTextOperation"; + private static readonly Type WrappedType; + private static readonly Func TextAccessor; + private readonly IOperation operation; + static IInterpolatedStringTextOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IInterpolatedStringTextOperationWrapper)); + TextAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Text)); + } + + private IInterpolatedStringTextOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Text => TextAccessor(this.WrappedOperation); + public static explicit operator IInterpolatedStringTextOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IInterpolatedStringTextOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static explicit operator IInterpolatedStringTextOperationWrapper(IInterpolatedStringContentOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IInterpolatedStringContentOperationWrapper(IInterpolatedStringTextOperationWrapper wrapper) => IInterpolatedStringContentOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IInterpolatedStringTextOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IInterpolatedStringTextOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IInterpolationOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IInterpolationOperationWrapper.g.cs new file mode 100644 index 000000000..1c83e04d4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IInterpolationOperationWrapper.g.cs @@ -0,0 +1,60 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IInterpolationOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IInterpolationOperation"; + private static readonly Type WrappedType; + private static readonly Func ExpressionAccessor; + private static readonly Func AlignmentAccessor; + private static readonly Func FormatStringAccessor; + private readonly IOperation operation; + static IInterpolationOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IInterpolationOperationWrapper)); + ExpressionAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Expression)); + AlignmentAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Alignment)); + FormatStringAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(FormatString)); + } + + private IInterpolationOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Expression => ExpressionAccessor(this.WrappedOperation); + public IOperation Alignment => AlignmentAccessor(this.WrappedOperation); + public IOperation FormatString => FormatStringAccessor(this.WrappedOperation); + public static explicit operator IInterpolationOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IInterpolationOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static explicit operator IInterpolationOperationWrapper(IInterpolatedStringContentOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IInterpolatedStringContentOperationWrapper(IInterpolationOperationWrapper wrapper) => IInterpolatedStringContentOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IInterpolationOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IInterpolationOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IInvalidOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IInvalidOperationWrapper.g.cs new file mode 100644 index 000000000..9ce2a81bc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IInvalidOperationWrapper.g.cs @@ -0,0 +1,49 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IInvalidOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IInvalidOperation"; + private static readonly Type WrappedType; + private readonly IOperation operation; + static IInvalidOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IInvalidOperationWrapper)); + } + + private IInvalidOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public static explicit operator IInvalidOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IInvalidOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IInvalidOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IInvalidOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IInvocationOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IInvocationOperationWrapper.g.cs new file mode 100644 index 000000000..fcf4d9b74 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IInvocationOperationWrapper.g.cs @@ -0,0 +1,61 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IInvocationOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IInvocationOperation"; + private static readonly Type WrappedType; + private static readonly Func TargetMethodAccessor; + private static readonly Func InstanceAccessor; + private static readonly Func IsVirtualAccessor; + private static readonly Func> ArgumentsAccessor; + private readonly IOperation operation; + static IInvocationOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IInvocationOperationWrapper)); + TargetMethodAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(TargetMethod)); + InstanceAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Instance)); + IsVirtualAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsVirtual)); + ArgumentsAccessor = LightupHelpers.CreateOperationListPropertyAccessor(WrappedType, nameof(Arguments)); + } + + private IInvocationOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IMethodSymbol TargetMethod => TargetMethodAccessor(this.WrappedOperation); + public IOperation Instance => InstanceAccessor(this.WrappedOperation); + public bool IsVirtual => IsVirtualAccessor(this.WrappedOperation); + public ImmutableArray Arguments => ArgumentsAccessor(this.WrappedOperation); + public static explicit operator IInvocationOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IInvocationOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IInvocationOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IInvocationOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IIsNullOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IIsNullOperationWrapper.g.cs new file mode 100644 index 000000000..d062479a2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IIsNullOperationWrapper.g.cs @@ -0,0 +1,52 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IIsNullOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.FlowAnalysis.IIsNullOperation"; + private static readonly Type WrappedType; + private static readonly Func OperandAccessor; + private readonly IOperation operation; + static IIsNullOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IIsNullOperationWrapper)); + OperandAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Operand)); + } + + private IIsNullOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Operand => OperandAccessor(this.WrappedOperation); + public static explicit operator IIsNullOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IIsNullOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IIsNullOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IIsNullOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IIsPatternOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IIsPatternOperationWrapper.g.cs new file mode 100644 index 000000000..952dfb654 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IIsPatternOperationWrapper.g.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IIsPatternOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IIsPatternOperation"; + private static readonly Type WrappedType; + private static readonly Func ValueAccessor; + private static readonly Func PatternAccessor; + private readonly IOperation operation; + static IIsPatternOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IIsPatternOperationWrapper)); + ValueAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Value)); + PatternAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Pattern)); + } + + private IIsPatternOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Value => ValueAccessor(this.WrappedOperation); + public IPatternOperationWrapper Pattern => IPatternOperationWrapper.FromOperation(PatternAccessor(this.WrappedOperation)); + public static explicit operator IIsPatternOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IIsPatternOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IIsPatternOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IIsPatternOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IIsTypeOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IIsTypeOperationWrapper.g.cs new file mode 100644 index 000000000..1d489b413 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IIsTypeOperationWrapper.g.cs @@ -0,0 +1,58 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IIsTypeOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IIsTypeOperation"; + private static readonly Type WrappedType; + private static readonly Func ValueOperandAccessor; + private static readonly Func TypeOperandAccessor; + private static readonly Func IsNegatedAccessor; + private readonly IOperation operation; + static IIsTypeOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IIsTypeOperationWrapper)); + ValueOperandAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(ValueOperand)); + TypeOperandAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(TypeOperand)); + IsNegatedAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsNegated)); + } + + private IIsTypeOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation ValueOperand => ValueOperandAccessor(this.WrappedOperation); + public ITypeSymbol TypeOperand => TypeOperandAccessor(this.WrappedOperation); + public bool IsNegated => IsNegatedAccessor(this.WrappedOperation); + public static explicit operator IIsTypeOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IIsTypeOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IIsTypeOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IIsTypeOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ILabeledOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ILabeledOperationWrapper.g.cs new file mode 100644 index 000000000..bef0f03e3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ILabeledOperationWrapper.g.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ILabeledOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ILabeledOperation"; + private static readonly Type WrappedType; + private static readonly Func LabelAccessor; + private static readonly Func OperationAccessor; + private readonly IOperation operation; + static ILabeledOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ILabeledOperationWrapper)); + LabelAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Label)); + OperationAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Operation)); + } + + private ILabeledOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ILabelSymbol Label => LabelAccessor(this.WrappedOperation); + public IOperation Operation => OperationAccessor(this.WrappedOperation); + public static explicit operator ILabeledOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ILabeledOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ILabeledOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ILabeledOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ILiteralOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ILiteralOperationWrapper.g.cs new file mode 100644 index 000000000..e21c59551 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ILiteralOperationWrapper.g.cs @@ -0,0 +1,49 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ILiteralOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ILiteralOperation"; + private static readonly Type WrappedType; + private readonly IOperation operation; + static ILiteralOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ILiteralOperationWrapper)); + } + + private ILiteralOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public static explicit operator ILiteralOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ILiteralOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ILiteralOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ILiteralOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ILocalFunctionOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ILocalFunctionOperationWrapper.g.cs new file mode 100644 index 000000000..893fc8e53 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ILocalFunctionOperationWrapper.g.cs @@ -0,0 +1,58 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ILocalFunctionOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ILocalFunctionOperation"; + private static readonly Type WrappedType; + private static readonly Func SymbolAccessor; + private static readonly Func BodyAccessor; + private static readonly Func IgnoredBodyAccessor; + private readonly IOperation operation; + static ILocalFunctionOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ILocalFunctionOperationWrapper)); + SymbolAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Symbol)); + BodyAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Body)); + IgnoredBodyAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IgnoredBody)); + } + + private ILocalFunctionOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IMethodSymbol Symbol => SymbolAccessor(this.WrappedOperation); + public IBlockOperationWrapper Body => IBlockOperationWrapper.FromOperation(BodyAccessor(this.WrappedOperation)); + public IBlockOperationWrapper IgnoredBody => IBlockOperationWrapper.FromOperation(IgnoredBodyAccessor(this.WrappedOperation)); + public static explicit operator ILocalFunctionOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ILocalFunctionOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ILocalFunctionOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ILocalFunctionOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ILocalReferenceOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ILocalReferenceOperationWrapper.g.cs new file mode 100644 index 000000000..27568607b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ILocalReferenceOperationWrapper.g.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ILocalReferenceOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ILocalReferenceOperation"; + private static readonly Type WrappedType; + private static readonly Func LocalAccessor; + private static readonly Func IsDeclarationAccessor; + private readonly IOperation operation; + static ILocalReferenceOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ILocalReferenceOperationWrapper)); + LocalAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Local)); + IsDeclarationAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsDeclaration)); + } + + private ILocalReferenceOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ILocalSymbol Local => LocalAccessor(this.WrappedOperation); + public bool IsDeclaration => IsDeclarationAccessor(this.WrappedOperation); + public static explicit operator ILocalReferenceOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ILocalReferenceOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ILocalReferenceOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ILocalReferenceOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ILockOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ILockOperationWrapper.g.cs new file mode 100644 index 000000000..bedd9005a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ILockOperationWrapper.g.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ILockOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ILockOperation"; + private static readonly Type WrappedType; + private static readonly Func LockedValueAccessor; + private static readonly Func BodyAccessor; + private readonly IOperation operation; + static ILockOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ILockOperationWrapper)); + LockedValueAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(LockedValue)); + BodyAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Body)); + } + + private ILockOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation LockedValue => LockedValueAccessor(this.WrappedOperation); + public IOperation Body => BodyAccessor(this.WrappedOperation); + public static explicit operator ILockOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ILockOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ILockOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ILockOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ILoopOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ILoopOperationWrapper.g.cs new file mode 100644 index 000000000..4cd599c4a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ILoopOperationWrapper.g.cs @@ -0,0 +1,67 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ILoopOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ILoopOperation"; + private static readonly Type WrappedType; + private static readonly Func BodyAccessor; + private static readonly Func> LocalsAccessor; + private static readonly Func ContinueLabelAccessor; + private static readonly Func ExitLabelAccessor; + private readonly IOperation operation; + static ILoopOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ILoopOperationWrapper)); + BodyAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Body)); + LocalsAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(Locals)); + ContinueLabelAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(ContinueLabel)); + ExitLabelAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(ExitLabel)); + } + + private ILoopOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public object LoopKind => throw new NotImplementedException("Property 'ILoopOperation.LoopKind' has unsupported type 'LoopKind'"); + public IOperation Body => BodyAccessor(this.WrappedOperation); + public ImmutableArray Locals => LocalsAccessor(this.WrappedOperation); + public ILabelSymbol ContinueLabel => ContinueLabelAccessor(this.WrappedOperation); + public ILabelSymbol ExitLabel => ExitLabelAccessor(this.WrappedOperation); + public static explicit operator ILoopOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ILoopOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ILoopOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ILoopOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + + internal static ILoopOperationWrapper FromUpcast(IOperation operation) + { + return new ILoopOperationWrapper(operation); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IMemberInitializerOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IMemberInitializerOperationWrapper.g.cs new file mode 100644 index 000000000..f3e1a795b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IMemberInitializerOperationWrapper.g.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IMemberInitializerOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IMemberInitializerOperation"; + private static readonly Type WrappedType; + private static readonly Func InitializedMemberAccessor; + private static readonly Func InitializerAccessor; + private readonly IOperation operation; + static IMemberInitializerOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IMemberInitializerOperationWrapper)); + InitializedMemberAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(InitializedMember)); + InitializerAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Initializer)); + } + + private IMemberInitializerOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation InitializedMember => InitializedMemberAccessor(this.WrappedOperation); + public IObjectOrCollectionInitializerOperationWrapper Initializer => IObjectOrCollectionInitializerOperationWrapper.FromOperation(InitializerAccessor(this.WrappedOperation)); + public static explicit operator IMemberInitializerOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IMemberInitializerOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IMemberInitializerOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IMemberInitializerOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IMemberReferenceOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IMemberReferenceOperationWrapper.g.cs new file mode 100644 index 000000000..3cab32b77 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IMemberReferenceOperationWrapper.g.cs @@ -0,0 +1,60 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IMemberReferenceOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IMemberReferenceOperation"; + private static readonly Type WrappedType; + private static readonly Func InstanceAccessor; + private static readonly Func MemberAccessor; + private readonly IOperation operation; + static IMemberReferenceOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IMemberReferenceOperationWrapper)); + InstanceAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Instance)); + MemberAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Member)); + } + + private IMemberReferenceOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Instance => InstanceAccessor(this.WrappedOperation); + public ISymbol Member => MemberAccessor(this.WrappedOperation); + public static explicit operator IMemberReferenceOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IMemberReferenceOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IMemberReferenceOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IMemberReferenceOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + + internal static IMemberReferenceOperationWrapper FromUpcast(IOperation operation) + { + return new IMemberReferenceOperationWrapper(operation); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IMethodBodyBaseOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IMethodBodyBaseOperationWrapper.g.cs new file mode 100644 index 000000000..279d8edeb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IMethodBodyBaseOperationWrapper.g.cs @@ -0,0 +1,60 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IMethodBodyBaseOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IMethodBodyBaseOperation"; + private static readonly Type WrappedType; + private static readonly Func BlockBodyAccessor; + private static readonly Func ExpressionBodyAccessor; + private readonly IOperation operation; + static IMethodBodyBaseOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IMethodBodyBaseOperationWrapper)); + BlockBodyAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(BlockBody)); + ExpressionBodyAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(ExpressionBody)); + } + + private IMethodBodyBaseOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IBlockOperationWrapper BlockBody => IBlockOperationWrapper.FromOperation(BlockBodyAccessor(this.WrappedOperation)); + public IBlockOperationWrapper ExpressionBody => IBlockOperationWrapper.FromOperation(ExpressionBodyAccessor(this.WrappedOperation)); + public static explicit operator IMethodBodyBaseOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IMethodBodyBaseOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IMethodBodyBaseOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IMethodBodyBaseOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + + internal static IMethodBodyBaseOperationWrapper FromUpcast(IOperation operation) + { + return new IMethodBodyBaseOperationWrapper(operation); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IMethodBodyOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IMethodBodyOperationWrapper.g.cs new file mode 100644 index 000000000..05cf1ccc7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IMethodBodyOperationWrapper.g.cs @@ -0,0 +1,53 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IMethodBodyOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IMethodBodyOperation"; + private static readonly Type WrappedType; + private readonly IOperation operation; + static IMethodBodyOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IMethodBodyOperationWrapper)); + } + + private IMethodBodyOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public static explicit operator IMethodBodyOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IMethodBodyOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public IBlockOperationWrapper BlockBody => ((IMethodBodyBaseOperationWrapper)this).BlockBody; + public IBlockOperationWrapper ExpressionBody => ((IMethodBodyBaseOperationWrapper)this).ExpressionBody; + public static explicit operator IMethodBodyOperationWrapper(IMethodBodyBaseOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IMethodBodyBaseOperationWrapper(IMethodBodyOperationWrapper wrapper) => IMethodBodyBaseOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IMethodBodyOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IMethodBodyOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IMethodReferenceOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IMethodReferenceOperationWrapper.g.cs new file mode 100644 index 000000000..743b0faef --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IMethodReferenceOperationWrapper.g.cs @@ -0,0 +1,59 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IMethodReferenceOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IMethodReferenceOperation"; + private static readonly Type WrappedType; + private static readonly Func MethodAccessor; + private static readonly Func IsVirtualAccessor; + private readonly IOperation operation; + static IMethodReferenceOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IMethodReferenceOperationWrapper)); + MethodAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Method)); + IsVirtualAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsVirtual)); + } + + private IMethodReferenceOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IMethodSymbol Method => MethodAccessor(this.WrappedOperation); + public bool IsVirtual => IsVirtualAccessor(this.WrappedOperation); + public static explicit operator IMethodReferenceOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IMethodReferenceOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public IOperation Instance => ((IMemberReferenceOperationWrapper)this).Instance; + public ISymbol Member => ((IMemberReferenceOperationWrapper)this).Member; + public static explicit operator IMethodReferenceOperationWrapper(IMemberReferenceOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IMemberReferenceOperationWrapper(IMethodReferenceOperationWrapper wrapper) => IMemberReferenceOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IMethodReferenceOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IMethodReferenceOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/INameOfOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/INameOfOperationWrapper.g.cs new file mode 100644 index 000000000..1fab5f4d7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/INameOfOperationWrapper.g.cs @@ -0,0 +1,52 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct INameOfOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.INameOfOperation"; + private static readonly Type WrappedType; + private static readonly Func ArgumentAccessor; + private readonly IOperation operation; + static INameOfOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(INameOfOperationWrapper)); + ArgumentAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Argument)); + } + + private INameOfOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Argument => ArgumentAccessor(this.WrappedOperation); + public static explicit operator INameOfOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(INameOfOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static INameOfOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new INameOfOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/INegatedPatternOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/INegatedPatternOperationWrapper.g.cs new file mode 100644 index 000000000..ab8639f69 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/INegatedPatternOperationWrapper.g.cs @@ -0,0 +1,56 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct INegatedPatternOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.INegatedPatternOperation"; + private static readonly Type WrappedType; + private static readonly Func PatternAccessor; + private readonly IOperation operation; + static INegatedPatternOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(INegatedPatternOperationWrapper)); + PatternAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Pattern)); + } + + private INegatedPatternOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IPatternOperationWrapper Pattern => IPatternOperationWrapper.FromOperation(PatternAccessor(this.WrappedOperation)); + public static explicit operator INegatedPatternOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(INegatedPatternOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public ITypeSymbol InputType => ((IPatternOperationWrapper)this).InputType; + public ITypeSymbol NarrowedType => ((IPatternOperationWrapper)this).NarrowedType; + public static explicit operator INegatedPatternOperationWrapper(IPatternOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IPatternOperationWrapper(INegatedPatternOperationWrapper wrapper) => IPatternOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static INegatedPatternOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new INegatedPatternOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IObjectCreationOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IObjectCreationOperationWrapper.g.cs new file mode 100644 index 000000000..2715fd04e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IObjectCreationOperationWrapper.g.cs @@ -0,0 +1,58 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IObjectCreationOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IObjectCreationOperation"; + private static readonly Type WrappedType; + private static readonly Func ConstructorAccessor; + private static readonly Func InitializerAccessor; + private static readonly Func> ArgumentsAccessor; + private readonly IOperation operation; + static IObjectCreationOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IObjectCreationOperationWrapper)); + ConstructorAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Constructor)); + InitializerAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Initializer)); + ArgumentsAccessor = LightupHelpers.CreateOperationListPropertyAccessor(WrappedType, nameof(Arguments)); + } + + private IObjectCreationOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IMethodSymbol Constructor => ConstructorAccessor(this.WrappedOperation); + public IObjectOrCollectionInitializerOperationWrapper Initializer => IObjectOrCollectionInitializerOperationWrapper.FromOperation(InitializerAccessor(this.WrappedOperation)); + public ImmutableArray Arguments => ArgumentsAccessor(this.WrappedOperation); + public static explicit operator IObjectCreationOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IObjectCreationOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IObjectCreationOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IObjectCreationOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IObjectOrCollectionInitializerOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IObjectOrCollectionInitializerOperationWrapper.g.cs new file mode 100644 index 000000000..2fa9e8867 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IObjectOrCollectionInitializerOperationWrapper.g.cs @@ -0,0 +1,52 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IObjectOrCollectionInitializerOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IObjectOrCollectionInitializerOperation"; + private static readonly Type WrappedType; + private static readonly Func> InitializersAccessor; + private readonly IOperation operation; + static IObjectOrCollectionInitializerOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IObjectOrCollectionInitializerOperationWrapper)); + InitializersAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(Initializers)); + } + + private IObjectOrCollectionInitializerOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ImmutableArray Initializers => InitializersAccessor(this.WrappedOperation); + public static explicit operator IObjectOrCollectionInitializerOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IObjectOrCollectionInitializerOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IObjectOrCollectionInitializerOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IObjectOrCollectionInitializerOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IOmittedArgumentOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IOmittedArgumentOperationWrapper.g.cs new file mode 100644 index 000000000..1c41fa9c5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IOmittedArgumentOperationWrapper.g.cs @@ -0,0 +1,49 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IOmittedArgumentOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IOmittedArgumentOperation"; + private static readonly Type WrappedType; + private readonly IOperation operation; + static IOmittedArgumentOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IOmittedArgumentOperationWrapper)); + } + + private IOmittedArgumentOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public static explicit operator IOmittedArgumentOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IOmittedArgumentOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IOmittedArgumentOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IOmittedArgumentOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IOperationWrapper.g.cs new file mode 100644 index 000000000..39dd87f56 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IOperationWrapper.g.cs @@ -0,0 +1,64 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Generic; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.IOperation"; + private static readonly Func ParentAccessor; + private static readonly Func> ChildrenAccessor; + private static readonly Func LanguageAccessor; + private static readonly Func IsImplicitAccessor; + private static readonly Func SemanticModelAccessor; + private readonly IOperation operation; + static IOperationWrapper() + { + ParentAccessor = LightupHelpers.CreateOperationPropertyAccessor(typeof(IOperation), nameof(Parent)); + ChildrenAccessor = LightupHelpers.CreateOperationPropertyAccessor>(typeof(IOperation), nameof(Children)); + LanguageAccessor = LightupHelpers.CreateOperationPropertyAccessor(typeof(IOperation), nameof(Language)); + IsImplicitAccessor = LightupHelpers.CreateOperationPropertyAccessor(typeof(IOperation), nameof(IsImplicit)); + SemanticModelAccessor = LightupHelpers.CreateOperationPropertyAccessor(typeof(IOperation), nameof(SemanticModel)); + } + + private IOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public IOperation Parent => ParentAccessor(this.WrappedOperation); + public OperationKind Kind => this.WrappedOperation.Kind; + public SyntaxNode Syntax => this.WrappedOperation.Syntax; + public ITypeSymbol Type => this.WrappedOperation.Type; + public Optional ConstantValue => this.WrappedOperation.ConstantValue; + public IEnumerable Children => ChildrenAccessor(this.WrappedOperation); + public string Language => LanguageAccessor(this.WrappedOperation); + public bool IsImplicit => IsImplicitAccessor(this.WrappedOperation); + public SemanticModel SemanticModel => SemanticModelAccessor(this.WrappedOperation); + public static IOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + return new IOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null; + } + + internal static IOperationWrapper FromUpcast(IOperation operation) + { + return new IOperationWrapper(operation); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IParameterInitializerOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IParameterInitializerOperationWrapper.g.cs new file mode 100644 index 000000000..c1bcc07eb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IParameterInitializerOperationWrapper.g.cs @@ -0,0 +1,56 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IParameterInitializerOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IParameterInitializerOperation"; + private static readonly Type WrappedType; + private static readonly Func ParameterAccessor; + private readonly IOperation operation; + static IParameterInitializerOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IParameterInitializerOperationWrapper)); + ParameterAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Parameter)); + } + + private IParameterInitializerOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IParameterSymbol Parameter => ParameterAccessor(this.WrappedOperation); + public static explicit operator IParameterInitializerOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IParameterInitializerOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public ImmutableArray Locals => ((ISymbolInitializerOperationWrapper)this).Locals; + public IOperation Value => ((ISymbolInitializerOperationWrapper)this).Value; + public static explicit operator IParameterInitializerOperationWrapper(ISymbolInitializerOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator ISymbolInitializerOperationWrapper(IParameterInitializerOperationWrapper wrapper) => ISymbolInitializerOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IParameterInitializerOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IParameterInitializerOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IParameterReferenceOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IParameterReferenceOperationWrapper.g.cs new file mode 100644 index 000000000..fa4d5e437 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IParameterReferenceOperationWrapper.g.cs @@ -0,0 +1,52 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IParameterReferenceOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IParameterReferenceOperation"; + private static readonly Type WrappedType; + private static readonly Func ParameterAccessor; + private readonly IOperation operation; + static IParameterReferenceOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IParameterReferenceOperationWrapper)); + ParameterAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Parameter)); + } + + private IParameterReferenceOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IParameterSymbol Parameter => ParameterAccessor(this.WrappedOperation); + public static explicit operator IParameterReferenceOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IParameterReferenceOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IParameterReferenceOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IParameterReferenceOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IParenthesizedOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IParenthesizedOperationWrapper.g.cs new file mode 100644 index 000000000..3d69102b6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IParenthesizedOperationWrapper.g.cs @@ -0,0 +1,52 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IParenthesizedOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IParenthesizedOperation"; + private static readonly Type WrappedType; + private static readonly Func OperandAccessor; + private readonly IOperation operation; + static IParenthesizedOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IParenthesizedOperationWrapper)); + OperandAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Operand)); + } + + private IParenthesizedOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Operand => OperandAccessor(this.WrappedOperation); + public static explicit operator IParenthesizedOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IParenthesizedOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IParenthesizedOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IParenthesizedOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IPatternCaseClauseOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IPatternCaseClauseOperationWrapper.g.cs new file mode 100644 index 000000000..8725fe4b9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IPatternCaseClauseOperationWrapper.g.cs @@ -0,0 +1,61 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IPatternCaseClauseOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IPatternCaseClauseOperation"; + private static readonly Type WrappedType; + private static readonly Func LabelAccessor; + private static readonly Func PatternAccessor; + private static readonly Func GuardAccessor; + private readonly IOperation operation; + static IPatternCaseClauseOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IPatternCaseClauseOperationWrapper)); + LabelAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Label)); + PatternAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Pattern)); + GuardAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Guard)); + } + + private IPatternCaseClauseOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ILabelSymbol Label => LabelAccessor(this.WrappedOperation); + public IPatternOperationWrapper Pattern => IPatternOperationWrapper.FromOperation(PatternAccessor(this.WrappedOperation)); + public IOperation Guard => GuardAccessor(this.WrappedOperation); + public static explicit operator IPatternCaseClauseOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IPatternCaseClauseOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public object CaseKind => ((ICaseClauseOperationWrapper)this).CaseKind; + public static explicit operator IPatternCaseClauseOperationWrapper(ICaseClauseOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator ICaseClauseOperationWrapper(IPatternCaseClauseOperationWrapper wrapper) => ICaseClauseOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IPatternCaseClauseOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IPatternCaseClauseOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IPatternOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IPatternOperationWrapper.g.cs new file mode 100644 index 000000000..ec2136da2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IPatternOperationWrapper.g.cs @@ -0,0 +1,60 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IPatternOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IPatternOperation"; + private static readonly Type WrappedType; + private static readonly Func InputTypeAccessor; + private static readonly Func NarrowedTypeAccessor; + private readonly IOperation operation; + static IPatternOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IPatternOperationWrapper)); + InputTypeAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(InputType)); + NarrowedTypeAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(NarrowedType)); + } + + private IPatternOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ITypeSymbol InputType => InputTypeAccessor(this.WrappedOperation); + public ITypeSymbol NarrowedType => NarrowedTypeAccessor(this.WrappedOperation); + public static explicit operator IPatternOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IPatternOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IPatternOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IPatternOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + + internal static IPatternOperationWrapper FromUpcast(IOperation operation) + { + return new IPatternOperationWrapper(operation); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IPropertyInitializerOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IPropertyInitializerOperationWrapper.g.cs new file mode 100644 index 000000000..9220f3697 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IPropertyInitializerOperationWrapper.g.cs @@ -0,0 +1,56 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IPropertyInitializerOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IPropertyInitializerOperation"; + private static readonly Type WrappedType; + private static readonly Func> InitializedPropertiesAccessor; + private readonly IOperation operation; + static IPropertyInitializerOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IPropertyInitializerOperationWrapper)); + InitializedPropertiesAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(InitializedProperties)); + } + + private IPropertyInitializerOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ImmutableArray InitializedProperties => InitializedPropertiesAccessor(this.WrappedOperation); + public static explicit operator IPropertyInitializerOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IPropertyInitializerOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public ImmutableArray Locals => ((ISymbolInitializerOperationWrapper)this).Locals; + public IOperation Value => ((ISymbolInitializerOperationWrapper)this).Value; + public static explicit operator IPropertyInitializerOperationWrapper(ISymbolInitializerOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator ISymbolInitializerOperationWrapper(IPropertyInitializerOperationWrapper wrapper) => ISymbolInitializerOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IPropertyInitializerOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IPropertyInitializerOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IPropertyReferenceOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IPropertyReferenceOperationWrapper.g.cs new file mode 100644 index 000000000..5c28964b4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IPropertyReferenceOperationWrapper.g.cs @@ -0,0 +1,59 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IPropertyReferenceOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IPropertyReferenceOperation"; + private static readonly Type WrappedType; + private static readonly Func PropertyAccessor; + private static readonly Func> ArgumentsAccessor; + private readonly IOperation operation; + static IPropertyReferenceOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IPropertyReferenceOperationWrapper)); + PropertyAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Property)); + ArgumentsAccessor = LightupHelpers.CreateOperationListPropertyAccessor(WrappedType, nameof(Arguments)); + } + + private IPropertyReferenceOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IPropertySymbol Property => PropertyAccessor(this.WrappedOperation); + public ImmutableArray Arguments => ArgumentsAccessor(this.WrappedOperation); + public static explicit operator IPropertyReferenceOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IPropertyReferenceOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public IOperation Instance => ((IMemberReferenceOperationWrapper)this).Instance; + public ISymbol Member => ((IMemberReferenceOperationWrapper)this).Member; + public static explicit operator IPropertyReferenceOperationWrapper(IMemberReferenceOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IMemberReferenceOperationWrapper(IPropertyReferenceOperationWrapper wrapper) => IMemberReferenceOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IPropertyReferenceOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IPropertyReferenceOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IPropertySubpatternOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IPropertySubpatternOperationWrapper.g.cs new file mode 100644 index 000000000..fb6b7131b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IPropertySubpatternOperationWrapper.g.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IPropertySubpatternOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IPropertySubpatternOperation"; + private static readonly Type WrappedType; + private static readonly Func MemberAccessor; + private static readonly Func PatternAccessor; + private readonly IOperation operation; + static IPropertySubpatternOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IPropertySubpatternOperationWrapper)); + MemberAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Member)); + PatternAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Pattern)); + } + + private IPropertySubpatternOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Member => MemberAccessor(this.WrappedOperation); + public IPatternOperationWrapper Pattern => IPatternOperationWrapper.FromOperation(PatternAccessor(this.WrappedOperation)); + public static explicit operator IPropertySubpatternOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IPropertySubpatternOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IPropertySubpatternOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IPropertySubpatternOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IRaiseEventOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IRaiseEventOperationWrapper.g.cs new file mode 100644 index 000000000..290e5fbeb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IRaiseEventOperationWrapper.g.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IRaiseEventOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IRaiseEventOperation"; + private static readonly Type WrappedType; + private static readonly Func EventReferenceAccessor; + private static readonly Func> ArgumentsAccessor; + private readonly IOperation operation; + static IRaiseEventOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IRaiseEventOperationWrapper)); + EventReferenceAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(EventReference)); + ArgumentsAccessor = LightupHelpers.CreateOperationListPropertyAccessor(WrappedType, nameof(Arguments)); + } + + private IRaiseEventOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IEventReferenceOperationWrapper EventReference => IEventReferenceOperationWrapper.FromOperation(EventReferenceAccessor(this.WrappedOperation)); + public ImmutableArray Arguments => ArgumentsAccessor(this.WrappedOperation); + public static explicit operator IRaiseEventOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IRaiseEventOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IRaiseEventOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IRaiseEventOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IRangeCaseClauseOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IRangeCaseClauseOperationWrapper.g.cs new file mode 100644 index 000000000..cdccda8a3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IRangeCaseClauseOperationWrapper.g.cs @@ -0,0 +1,59 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IRangeCaseClauseOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IRangeCaseClauseOperation"; + private static readonly Type WrappedType; + private static readonly Func MinimumValueAccessor; + private static readonly Func MaximumValueAccessor; + private readonly IOperation operation; + static IRangeCaseClauseOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IRangeCaseClauseOperationWrapper)); + MinimumValueAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(MinimumValue)); + MaximumValueAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(MaximumValue)); + } + + private IRangeCaseClauseOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation MinimumValue => MinimumValueAccessor(this.WrappedOperation); + public IOperation MaximumValue => MaximumValueAccessor(this.WrappedOperation); + public static explicit operator IRangeCaseClauseOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IRangeCaseClauseOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public object CaseKind => ((ICaseClauseOperationWrapper)this).CaseKind; + public ILabelSymbol Label => ((ICaseClauseOperationWrapper)this).Label; + public static explicit operator IRangeCaseClauseOperationWrapper(ICaseClauseOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator ICaseClauseOperationWrapper(IRangeCaseClauseOperationWrapper wrapper) => ICaseClauseOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IRangeCaseClauseOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IRangeCaseClauseOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IRangeOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IRangeOperationWrapper.g.cs new file mode 100644 index 000000000..813897004 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IRangeOperationWrapper.g.cs @@ -0,0 +1,61 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IRangeOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IRangeOperation"; + private static readonly Type WrappedType; + private static readonly Func LeftOperandAccessor; + private static readonly Func RightOperandAccessor; + private static readonly Func IsLiftedAccessor; + private static readonly Func MethodAccessor; + private readonly IOperation operation; + static IRangeOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IRangeOperationWrapper)); + LeftOperandAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(LeftOperand)); + RightOperandAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(RightOperand)); + IsLiftedAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsLifted)); + MethodAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Method)); + } + + private IRangeOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation LeftOperand => LeftOperandAccessor(this.WrappedOperation); + public IOperation RightOperand => RightOperandAccessor(this.WrappedOperation); + public bool IsLifted => IsLiftedAccessor(this.WrappedOperation); + public IMethodSymbol Method => MethodAccessor(this.WrappedOperation); + public static explicit operator IRangeOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IRangeOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IRangeOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IRangeOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IReDimClauseOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IReDimClauseOperationWrapper.g.cs new file mode 100644 index 000000000..dd2b33c2d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IReDimClauseOperationWrapper.g.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IReDimClauseOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IReDimClauseOperation"; + private static readonly Type WrappedType; + private static readonly Func OperandAccessor; + private static readonly Func> DimensionSizesAccessor; + private readonly IOperation operation; + static IReDimClauseOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IReDimClauseOperationWrapper)); + OperandAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Operand)); + DimensionSizesAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(DimensionSizes)); + } + + private IReDimClauseOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Operand => OperandAccessor(this.WrappedOperation); + public ImmutableArray DimensionSizes => DimensionSizesAccessor(this.WrappedOperation); + public static explicit operator IReDimClauseOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IReDimClauseOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IReDimClauseOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IReDimClauseOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IReDimOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IReDimOperationWrapper.g.cs new file mode 100644 index 000000000..dfcc5f121 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IReDimOperationWrapper.g.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IReDimOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IReDimOperation"; + private static readonly Type WrappedType; + private static readonly Func> ClausesAccessor; + private static readonly Func PreserveAccessor; + private readonly IOperation operation; + static IReDimOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IReDimOperationWrapper)); + ClausesAccessor = LightupHelpers.CreateOperationListPropertyAccessor(WrappedType, nameof(Clauses)); + PreserveAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Preserve)); + } + + private IReDimOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ImmutableArray Clauses => ClausesAccessor(this.WrappedOperation); + public bool Preserve => PreserveAccessor(this.WrappedOperation); + public static explicit operator IReDimOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IReDimOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IReDimOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IReDimOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IRecursivePatternOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IRecursivePatternOperationWrapper.g.cs new file mode 100644 index 000000000..96c5f8509 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IRecursivePatternOperationWrapper.g.cs @@ -0,0 +1,68 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IRecursivePatternOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IRecursivePatternOperation"; + private static readonly Type WrappedType; + private static readonly Func MatchedTypeAccessor; + private static readonly Func DeconstructSymbolAccessor; + private static readonly Func> DeconstructionSubpatternsAccessor; + private static readonly Func> PropertySubpatternsAccessor; + private static readonly Func DeclaredSymbolAccessor; + private readonly IOperation operation; + static IRecursivePatternOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IRecursivePatternOperationWrapper)); + MatchedTypeAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(MatchedType)); + DeconstructSymbolAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(DeconstructSymbol)); + DeconstructionSubpatternsAccessor = LightupHelpers.CreateOperationListPropertyAccessor(WrappedType, nameof(DeconstructionSubpatterns)); + PropertySubpatternsAccessor = LightupHelpers.CreateOperationListPropertyAccessor(WrappedType, nameof(PropertySubpatterns)); + DeclaredSymbolAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(DeclaredSymbol)); + } + + private IRecursivePatternOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ITypeSymbol MatchedType => MatchedTypeAccessor(this.WrappedOperation); + public ISymbol DeconstructSymbol => DeconstructSymbolAccessor(this.WrappedOperation); + public ImmutableArray DeconstructionSubpatterns => DeconstructionSubpatternsAccessor(this.WrappedOperation); + public ImmutableArray PropertySubpatterns => PropertySubpatternsAccessor(this.WrappedOperation); + public ISymbol DeclaredSymbol => DeclaredSymbolAccessor(this.WrappedOperation); + public static explicit operator IRecursivePatternOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IRecursivePatternOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public ITypeSymbol InputType => ((IPatternOperationWrapper)this).InputType; + public ITypeSymbol NarrowedType => ((IPatternOperationWrapper)this).NarrowedType; + public static explicit operator IRecursivePatternOperationWrapper(IPatternOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IPatternOperationWrapper(IRecursivePatternOperationWrapper wrapper) => IPatternOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IRecursivePatternOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IRecursivePatternOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IRelationalCaseClauseOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IRelationalCaseClauseOperationWrapper.g.cs new file mode 100644 index 000000000..d8b032455 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IRelationalCaseClauseOperationWrapper.g.cs @@ -0,0 +1,57 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IRelationalCaseClauseOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IRelationalCaseClauseOperation"; + private static readonly Type WrappedType; + private static readonly Func ValueAccessor; + private readonly IOperation operation; + static IRelationalCaseClauseOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IRelationalCaseClauseOperationWrapper)); + ValueAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Value)); + } + + private IRelationalCaseClauseOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Value => ValueAccessor(this.WrappedOperation); + public object Relation => throw new NotImplementedException("Property 'IRelationalCaseClauseOperation.Relation' has unsupported type 'BinaryOperatorKind'"); + public static explicit operator IRelationalCaseClauseOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IRelationalCaseClauseOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public object CaseKind => ((ICaseClauseOperationWrapper)this).CaseKind; + public ILabelSymbol Label => ((ICaseClauseOperationWrapper)this).Label; + public static explicit operator IRelationalCaseClauseOperationWrapper(ICaseClauseOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator ICaseClauseOperationWrapper(IRelationalCaseClauseOperationWrapper wrapper) => ICaseClauseOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IRelationalCaseClauseOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IRelationalCaseClauseOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IRelationalPatternOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IRelationalPatternOperationWrapper.g.cs new file mode 100644 index 000000000..002fb5a01 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IRelationalPatternOperationWrapper.g.cs @@ -0,0 +1,57 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IRelationalPatternOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IRelationalPatternOperation"; + private static readonly Type WrappedType; + private static readonly Func ValueAccessor; + private readonly IOperation operation; + static IRelationalPatternOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IRelationalPatternOperationWrapper)); + ValueAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Value)); + } + + private IRelationalPatternOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public object OperatorKind => throw new NotImplementedException("Property 'IRelationalPatternOperation.OperatorKind' has unsupported type 'BinaryOperatorKind'"); + public IOperation Value => ValueAccessor(this.WrappedOperation); + public static explicit operator IRelationalPatternOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IRelationalPatternOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public ITypeSymbol InputType => ((IPatternOperationWrapper)this).InputType; + public ITypeSymbol NarrowedType => ((IPatternOperationWrapper)this).NarrowedType; + public static explicit operator IRelationalPatternOperationWrapper(IPatternOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IPatternOperationWrapper(IRelationalPatternOperationWrapper wrapper) => IPatternOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IRelationalPatternOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IRelationalPatternOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IReturnOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IReturnOperationWrapper.g.cs new file mode 100644 index 000000000..6659d8729 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IReturnOperationWrapper.g.cs @@ -0,0 +1,52 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IReturnOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IReturnOperation"; + private static readonly Type WrappedType; + private static readonly Func ReturnedValueAccessor; + private readonly IOperation operation; + static IReturnOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IReturnOperationWrapper)); + ReturnedValueAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(ReturnedValue)); + } + + private IReturnOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation ReturnedValue => ReturnedValueAccessor(this.WrappedOperation); + public static explicit operator IReturnOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IReturnOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IReturnOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IReturnOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISimpleAssignmentOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISimpleAssignmentOperationWrapper.g.cs new file mode 100644 index 000000000..353642091 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISimpleAssignmentOperationWrapper.g.cs @@ -0,0 +1,56 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ISimpleAssignmentOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ISimpleAssignmentOperation"; + private static readonly Type WrappedType; + private static readonly Func IsRefAccessor; + private readonly IOperation operation; + static ISimpleAssignmentOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ISimpleAssignmentOperationWrapper)); + IsRefAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsRef)); + } + + private ISimpleAssignmentOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public bool IsRef => IsRefAccessor(this.WrappedOperation); + public static explicit operator ISimpleAssignmentOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ISimpleAssignmentOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public IOperation Target => ((IAssignmentOperationWrapper)this).Target; + public IOperation Value => ((IAssignmentOperationWrapper)this).Value; + public static explicit operator ISimpleAssignmentOperationWrapper(IAssignmentOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IAssignmentOperationWrapper(ISimpleAssignmentOperationWrapper wrapper) => IAssignmentOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ISimpleAssignmentOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ISimpleAssignmentOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISingleValueCaseClauseOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISingleValueCaseClauseOperationWrapper.g.cs new file mode 100644 index 000000000..81d950372 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISingleValueCaseClauseOperationWrapper.g.cs @@ -0,0 +1,56 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ISingleValueCaseClauseOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ISingleValueCaseClauseOperation"; + private static readonly Type WrappedType; + private static readonly Func ValueAccessor; + private readonly IOperation operation; + static ISingleValueCaseClauseOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ISingleValueCaseClauseOperationWrapper)); + ValueAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Value)); + } + + private ISingleValueCaseClauseOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Value => ValueAccessor(this.WrappedOperation); + public static explicit operator ISingleValueCaseClauseOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ISingleValueCaseClauseOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public object CaseKind => ((ICaseClauseOperationWrapper)this).CaseKind; + public ILabelSymbol Label => ((ICaseClauseOperationWrapper)this).Label; + public static explicit operator ISingleValueCaseClauseOperationWrapper(ICaseClauseOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator ICaseClauseOperationWrapper(ISingleValueCaseClauseOperationWrapper wrapper) => ICaseClauseOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ISingleValueCaseClauseOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ISingleValueCaseClauseOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISizeOfOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISizeOfOperationWrapper.g.cs new file mode 100644 index 000000000..df18e5d2d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISizeOfOperationWrapper.g.cs @@ -0,0 +1,52 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ISizeOfOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ISizeOfOperation"; + private static readonly Type WrappedType; + private static readonly Func TypeOperandAccessor; + private readonly IOperation operation; + static ISizeOfOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ISizeOfOperationWrapper)); + TypeOperandAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(TypeOperand)); + } + + private ISizeOfOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ITypeSymbol TypeOperand => TypeOperandAccessor(this.WrappedOperation); + public static explicit operator ISizeOfOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ISizeOfOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ISizeOfOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ISizeOfOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IStaticLocalInitializationSemaphoreOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IStaticLocalInitializationSemaphoreOperationWrapper.g.cs new file mode 100644 index 000000000..d1353805c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IStaticLocalInitializationSemaphoreOperationWrapper.g.cs @@ -0,0 +1,52 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IStaticLocalInitializationSemaphoreOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.FlowAnalysis.IStaticLocalInitializationSemaphoreOperation"; + private static readonly Type WrappedType; + private static readonly Func LocalAccessor; + private readonly IOperation operation; + static IStaticLocalInitializationSemaphoreOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IStaticLocalInitializationSemaphoreOperationWrapper)); + LocalAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Local)); + } + + private IStaticLocalInitializationSemaphoreOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ILocalSymbol Local => LocalAccessor(this.WrappedOperation); + public static explicit operator IStaticLocalInitializationSemaphoreOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IStaticLocalInitializationSemaphoreOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IStaticLocalInitializationSemaphoreOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IStaticLocalInitializationSemaphoreOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IStopOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IStopOperationWrapper.g.cs new file mode 100644 index 000000000..54816076a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IStopOperationWrapper.g.cs @@ -0,0 +1,49 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IStopOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IStopOperation"; + private static readonly Type WrappedType; + private readonly IOperation operation; + static IStopOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IStopOperationWrapper)); + } + + private IStopOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public static explicit operator IStopOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IStopOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IStopOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IStopOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISwitchCaseOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISwitchCaseOperationWrapper.g.cs new file mode 100644 index 000000000..f223babfc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISwitchCaseOperationWrapper.g.cs @@ -0,0 +1,58 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ISwitchCaseOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ISwitchCaseOperation"; + private static readonly Type WrappedType; + private static readonly Func> ClausesAccessor; + private static readonly Func> BodyAccessor; + private static readonly Func> LocalsAccessor; + private readonly IOperation operation; + static ISwitchCaseOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ISwitchCaseOperationWrapper)); + ClausesAccessor = LightupHelpers.CreateOperationListPropertyAccessor(WrappedType, nameof(Clauses)); + BodyAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(Body)); + LocalsAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(Locals)); + } + + private ISwitchCaseOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ImmutableArray Clauses => ClausesAccessor(this.WrappedOperation); + public ImmutableArray Body => BodyAccessor(this.WrappedOperation); + public ImmutableArray Locals => LocalsAccessor(this.WrappedOperation); + public static explicit operator ISwitchCaseOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ISwitchCaseOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ISwitchCaseOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ISwitchCaseOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISwitchExpressionArmOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISwitchExpressionArmOperationWrapper.g.cs new file mode 100644 index 000000000..ebff3fd46 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISwitchExpressionArmOperationWrapper.g.cs @@ -0,0 +1,61 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ISwitchExpressionArmOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ISwitchExpressionArmOperation"; + private static readonly Type WrappedType; + private static readonly Func PatternAccessor; + private static readonly Func GuardAccessor; + private static readonly Func ValueAccessor; + private static readonly Func> LocalsAccessor; + private readonly IOperation operation; + static ISwitchExpressionArmOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ISwitchExpressionArmOperationWrapper)); + PatternAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Pattern)); + GuardAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Guard)); + ValueAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Value)); + LocalsAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(Locals)); + } + + private ISwitchExpressionArmOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IPatternOperationWrapper Pattern => IPatternOperationWrapper.FromOperation(PatternAccessor(this.WrappedOperation)); + public IOperation Guard => GuardAccessor(this.WrappedOperation); + public IOperation Value => ValueAccessor(this.WrappedOperation); + public ImmutableArray Locals => LocalsAccessor(this.WrappedOperation); + public static explicit operator ISwitchExpressionArmOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ISwitchExpressionArmOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ISwitchExpressionArmOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ISwitchExpressionArmOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISwitchExpressionOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISwitchExpressionOperationWrapper.g.cs new file mode 100644 index 000000000..19a85d1cb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISwitchExpressionOperationWrapper.g.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ISwitchExpressionOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ISwitchExpressionOperation"; + private static readonly Type WrappedType; + private static readonly Func ValueAccessor; + private static readonly Func> ArmsAccessor; + private readonly IOperation operation; + static ISwitchExpressionOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ISwitchExpressionOperationWrapper)); + ValueAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Value)); + ArmsAccessor = LightupHelpers.CreateOperationListPropertyAccessor(WrappedType, nameof(Arms)); + } + + private ISwitchExpressionOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Value => ValueAccessor(this.WrappedOperation); + public ImmutableArray Arms => ArmsAccessor(this.WrappedOperation); + public static explicit operator ISwitchExpressionOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ISwitchExpressionOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ISwitchExpressionOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ISwitchExpressionOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISwitchOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISwitchOperationWrapper.g.cs new file mode 100644 index 000000000..51413969d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISwitchOperationWrapper.g.cs @@ -0,0 +1,61 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ISwitchOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ISwitchOperation"; + private static readonly Type WrappedType; + private static readonly Func> LocalsAccessor; + private static readonly Func ValueAccessor; + private static readonly Func> CasesAccessor; + private static readonly Func ExitLabelAccessor; + private readonly IOperation operation; + static ISwitchOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ISwitchOperationWrapper)); + LocalsAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(Locals)); + ValueAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Value)); + CasesAccessor = LightupHelpers.CreateOperationListPropertyAccessor(WrappedType, nameof(Cases)); + ExitLabelAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(ExitLabel)); + } + + private ISwitchOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ImmutableArray Locals => LocalsAccessor(this.WrappedOperation); + public IOperation Value => ValueAccessor(this.WrappedOperation); + public ImmutableArray Cases => CasesAccessor(this.WrappedOperation); + public ILabelSymbol ExitLabel => ExitLabelAccessor(this.WrappedOperation); + public static explicit operator ISwitchOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ISwitchOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ISwitchOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ISwitchOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISymbolInitializerOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISymbolInitializerOperationWrapper.g.cs new file mode 100644 index 000000000..ace41ae4e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ISymbolInitializerOperationWrapper.g.cs @@ -0,0 +1,60 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ISymbolInitializerOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ISymbolInitializerOperation"; + private static readonly Type WrappedType; + private static readonly Func> LocalsAccessor; + private static readonly Func ValueAccessor; + private readonly IOperation operation; + static ISymbolInitializerOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ISymbolInitializerOperationWrapper)); + LocalsAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(Locals)); + ValueAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Value)); + } + + private ISymbolInitializerOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ImmutableArray Locals => LocalsAccessor(this.WrappedOperation); + public IOperation Value => ValueAccessor(this.WrappedOperation); + public static explicit operator ISymbolInitializerOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ISymbolInitializerOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ISymbolInitializerOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ISymbolInitializerOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + + internal static ISymbolInitializerOperationWrapper FromUpcast(IOperation operation) + { + return new ISymbolInitializerOperationWrapper(operation); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IThrowOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IThrowOperationWrapper.g.cs new file mode 100644 index 000000000..6bde3ae49 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IThrowOperationWrapper.g.cs @@ -0,0 +1,52 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IThrowOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IThrowOperation"; + private static readonly Type WrappedType; + private static readonly Func ExceptionAccessor; + private readonly IOperation operation; + static IThrowOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IThrowOperationWrapper)); + ExceptionAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Exception)); + } + + private IThrowOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Exception => ExceptionAccessor(this.WrappedOperation); + public static explicit operator IThrowOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IThrowOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IThrowOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IThrowOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ITranslatedQueryOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ITranslatedQueryOperationWrapper.g.cs new file mode 100644 index 000000000..67e544376 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ITranslatedQueryOperationWrapper.g.cs @@ -0,0 +1,52 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ITranslatedQueryOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ITranslatedQueryOperation"; + private static readonly Type WrappedType; + private static readonly Func OperationAccessor; + private readonly IOperation operation; + static ITranslatedQueryOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ITranslatedQueryOperationWrapper)); + OperationAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Operation)); + } + + private ITranslatedQueryOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Operation => OperationAccessor(this.WrappedOperation); + public static explicit operator ITranslatedQueryOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ITranslatedQueryOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ITranslatedQueryOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ITranslatedQueryOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ITryOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ITryOperationWrapper.g.cs new file mode 100644 index 000000000..3f9a30eab --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ITryOperationWrapper.g.cs @@ -0,0 +1,61 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ITryOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ITryOperation"; + private static readonly Type WrappedType; + private static readonly Func BodyAccessor; + private static readonly Func> CatchesAccessor; + private static readonly Func FinallyAccessor; + private static readonly Func ExitLabelAccessor; + private readonly IOperation operation; + static ITryOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ITryOperationWrapper)); + BodyAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Body)); + CatchesAccessor = LightupHelpers.CreateOperationListPropertyAccessor(WrappedType, nameof(Catches)); + FinallyAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Finally)); + ExitLabelAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(ExitLabel)); + } + + private ITryOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IBlockOperationWrapper Body => IBlockOperationWrapper.FromOperation(BodyAccessor(this.WrappedOperation)); + public ImmutableArray Catches => CatchesAccessor(this.WrappedOperation); + public IBlockOperationWrapper Finally => IBlockOperationWrapper.FromOperation(FinallyAccessor(this.WrappedOperation)); + public ILabelSymbol ExitLabel => ExitLabelAccessor(this.WrappedOperation); + public static explicit operator ITryOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ITryOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ITryOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ITryOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ITupleBinaryOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ITupleBinaryOperationWrapper.g.cs new file mode 100644 index 000000000..ff7d19065 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ITupleBinaryOperationWrapper.g.cs @@ -0,0 +1,56 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ITupleBinaryOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ITupleBinaryOperation"; + private static readonly Type WrappedType; + private static readonly Func LeftOperandAccessor; + private static readonly Func RightOperandAccessor; + private readonly IOperation operation; + static ITupleBinaryOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ITupleBinaryOperationWrapper)); + LeftOperandAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(LeftOperand)); + RightOperandAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(RightOperand)); + } + + private ITupleBinaryOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public object OperatorKind => throw new NotImplementedException("Property 'ITupleBinaryOperation.OperatorKind' has unsupported type 'BinaryOperatorKind'"); + public IOperation LeftOperand => LeftOperandAccessor(this.WrappedOperation); + public IOperation RightOperand => RightOperandAccessor(this.WrappedOperation); + public static explicit operator ITupleBinaryOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ITupleBinaryOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ITupleBinaryOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ITupleBinaryOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ITupleOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ITupleOperationWrapper.g.cs new file mode 100644 index 000000000..2a0983508 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ITupleOperationWrapper.g.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ITupleOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ITupleOperation"; + private static readonly Type WrappedType; + private static readonly Func> ElementsAccessor; + private static readonly Func NaturalTypeAccessor; + private readonly IOperation operation; + static ITupleOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ITupleOperationWrapper)); + ElementsAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(Elements)); + NaturalTypeAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(NaturalType)); + } + + private ITupleOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ImmutableArray Elements => ElementsAccessor(this.WrappedOperation); + public ITypeSymbol NaturalType => NaturalTypeAccessor(this.WrappedOperation); + public static explicit operator ITupleOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ITupleOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ITupleOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ITupleOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ITypeOfOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ITypeOfOperationWrapper.g.cs new file mode 100644 index 000000000..00c4ada44 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ITypeOfOperationWrapper.g.cs @@ -0,0 +1,52 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ITypeOfOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ITypeOfOperation"; + private static readonly Type WrappedType; + private static readonly Func TypeOperandAccessor; + private readonly IOperation operation; + static ITypeOfOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ITypeOfOperationWrapper)); + TypeOperandAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(TypeOperand)); + } + + private ITypeOfOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ITypeSymbol TypeOperand => TypeOperandAccessor(this.WrappedOperation); + public static explicit operator ITypeOfOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ITypeOfOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ITypeOfOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ITypeOfOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ITypeParameterObjectCreationOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ITypeParameterObjectCreationOperationWrapper.g.cs new file mode 100644 index 000000000..7423a8935 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ITypeParameterObjectCreationOperationWrapper.g.cs @@ -0,0 +1,52 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ITypeParameterObjectCreationOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ITypeParameterObjectCreationOperation"; + private static readonly Type WrappedType; + private static readonly Func InitializerAccessor; + private readonly IOperation operation; + static ITypeParameterObjectCreationOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ITypeParameterObjectCreationOperationWrapper)); + InitializerAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Initializer)); + } + + private ITypeParameterObjectCreationOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IObjectOrCollectionInitializerOperationWrapper Initializer => IObjectOrCollectionInitializerOperationWrapper.FromOperation(InitializerAccessor(this.WrappedOperation)); + public static explicit operator ITypeParameterObjectCreationOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ITypeParameterObjectCreationOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ITypeParameterObjectCreationOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ITypeParameterObjectCreationOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ITypePatternOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ITypePatternOperationWrapper.g.cs new file mode 100644 index 000000000..46f15d8be --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/ITypePatternOperationWrapper.g.cs @@ -0,0 +1,56 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct ITypePatternOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.ITypePatternOperation"; + private static readonly Type WrappedType; + private static readonly Func MatchedTypeAccessor; + private readonly IOperation operation; + static ITypePatternOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(ITypePatternOperationWrapper)); + MatchedTypeAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(MatchedType)); + } + + private ITypePatternOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ITypeSymbol MatchedType => MatchedTypeAccessor(this.WrappedOperation); + public static explicit operator ITypePatternOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(ITypePatternOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public ITypeSymbol InputType => ((IPatternOperationWrapper)this).InputType; + public ITypeSymbol NarrowedType => ((IPatternOperationWrapper)this).NarrowedType; + public static explicit operator ITypePatternOperationWrapper(IPatternOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IPatternOperationWrapper(ITypePatternOperationWrapper wrapper) => IPatternOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static ITypePatternOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ITypePatternOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IUnaryOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IUnaryOperationWrapper.g.cs new file mode 100644 index 000000000..93b6c6c48 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IUnaryOperationWrapper.g.cs @@ -0,0 +1,62 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IUnaryOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IUnaryOperation"; + private static readonly Type WrappedType; + private static readonly Func OperandAccessor; + private static readonly Func IsLiftedAccessor; + private static readonly Func IsCheckedAccessor; + private static readonly Func OperatorMethodAccessor; + private readonly IOperation operation; + static IUnaryOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IUnaryOperationWrapper)); + OperandAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Operand)); + IsLiftedAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsLifted)); + IsCheckedAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsChecked)); + OperatorMethodAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(OperatorMethod)); + } + + private IUnaryOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public object OperatorKind => throw new NotImplementedException("Property 'IUnaryOperation.OperatorKind' has unsupported type 'UnaryOperatorKind'"); + public IOperation Operand => OperandAccessor(this.WrappedOperation); + public bool IsLifted => IsLiftedAccessor(this.WrappedOperation); + public bool IsChecked => IsCheckedAccessor(this.WrappedOperation); + public IMethodSymbol OperatorMethod => OperatorMethodAccessor(this.WrappedOperation); + public static explicit operator IUnaryOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IUnaryOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IUnaryOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IUnaryOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IUsingDeclarationOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IUsingDeclarationOperationWrapper.g.cs new file mode 100644 index 000000000..c2a15dc47 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IUsingDeclarationOperationWrapper.g.cs @@ -0,0 +1,55 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IUsingDeclarationOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IUsingDeclarationOperation"; + private static readonly Type WrappedType; + private static readonly Func DeclarationGroupAccessor; + private static readonly Func IsAsynchronousAccessor; + private readonly IOperation operation; + static IUsingDeclarationOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IUsingDeclarationOperationWrapper)); + DeclarationGroupAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(DeclarationGroup)); + IsAsynchronousAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsAsynchronous)); + } + + private IUsingDeclarationOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IVariableDeclarationGroupOperationWrapper DeclarationGroup => IVariableDeclarationGroupOperationWrapper.FromOperation(DeclarationGroupAccessor(this.WrappedOperation)); + public bool IsAsynchronous => IsAsynchronousAccessor(this.WrappedOperation); + public static explicit operator IUsingDeclarationOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IUsingDeclarationOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IUsingDeclarationOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IUsingDeclarationOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IUsingOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IUsingOperationWrapper.g.cs new file mode 100644 index 000000000..a4f4b0dd0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IUsingOperationWrapper.g.cs @@ -0,0 +1,61 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IUsingOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IUsingOperation"; + private static readonly Type WrappedType; + private static readonly Func ResourcesAccessor; + private static readonly Func BodyAccessor; + private static readonly Func> LocalsAccessor; + private static readonly Func IsAsynchronousAccessor; + private readonly IOperation operation; + static IUsingOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IUsingOperationWrapper)); + ResourcesAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Resources)); + BodyAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Body)); + LocalsAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(Locals)); + IsAsynchronousAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IsAsynchronous)); + } + + private IUsingOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Resources => ResourcesAccessor(this.WrappedOperation); + public IOperation Body => BodyAccessor(this.WrappedOperation); + public ImmutableArray Locals => LocalsAccessor(this.WrappedOperation); + public bool IsAsynchronous => IsAsynchronousAccessor(this.WrappedOperation); + public static explicit operator IUsingOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IUsingOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IUsingOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IUsingOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IVariableDeclarationGroupOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IVariableDeclarationGroupOperationWrapper.g.cs new file mode 100644 index 000000000..32e3c1365 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IVariableDeclarationGroupOperationWrapper.g.cs @@ -0,0 +1,52 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IVariableDeclarationGroupOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IVariableDeclarationGroupOperation"; + private static readonly Type WrappedType; + private static readonly Func> DeclarationsAccessor; + private readonly IOperation operation; + static IVariableDeclarationGroupOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IVariableDeclarationGroupOperationWrapper)); + DeclarationsAccessor = LightupHelpers.CreateOperationListPropertyAccessor(WrappedType, nameof(Declarations)); + } + + private IVariableDeclarationGroupOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ImmutableArray Declarations => DeclarationsAccessor(this.WrappedOperation); + public static explicit operator IVariableDeclarationGroupOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IVariableDeclarationGroupOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IVariableDeclarationGroupOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IVariableDeclarationGroupOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IVariableDeclarationOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IVariableDeclarationOperationWrapper.g.cs new file mode 100644 index 000000000..8c8b4948b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IVariableDeclarationOperationWrapper.g.cs @@ -0,0 +1,58 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IVariableDeclarationOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IVariableDeclarationOperation"; + private static readonly Type WrappedType; + private static readonly Func> DeclaratorsAccessor; + private static readonly Func InitializerAccessor; + private static readonly Func> IgnoredDimensionsAccessor; + private readonly IOperation operation; + static IVariableDeclarationOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IVariableDeclarationOperationWrapper)); + DeclaratorsAccessor = LightupHelpers.CreateOperationListPropertyAccessor(WrappedType, nameof(Declarators)); + InitializerAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Initializer)); + IgnoredDimensionsAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(IgnoredDimensions)); + } + + private IVariableDeclarationOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ImmutableArray Declarators => DeclaratorsAccessor(this.WrappedOperation); + public IVariableInitializerOperationWrapper Initializer => IVariableInitializerOperationWrapper.FromOperation(InitializerAccessor(this.WrappedOperation)); + public ImmutableArray IgnoredDimensions => IgnoredDimensionsAccessor(this.WrappedOperation); + public static explicit operator IVariableDeclarationOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IVariableDeclarationOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IVariableDeclarationOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IVariableDeclarationOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IVariableDeclaratorOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IVariableDeclaratorOperationWrapper.g.cs new file mode 100644 index 000000000..a5280d1a9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IVariableDeclaratorOperationWrapper.g.cs @@ -0,0 +1,58 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IVariableDeclaratorOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IVariableDeclaratorOperation"; + private static readonly Type WrappedType; + private static readonly Func SymbolAccessor; + private static readonly Func InitializerAccessor; + private static readonly Func> IgnoredArgumentsAccessor; + private readonly IOperation operation; + static IVariableDeclaratorOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IVariableDeclaratorOperationWrapper)); + SymbolAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Symbol)); + InitializerAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Initializer)); + IgnoredArgumentsAccessor = LightupHelpers.CreateOperationPropertyAccessor>(WrappedType, nameof(IgnoredArguments)); + } + + private IVariableDeclaratorOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public ILocalSymbol Symbol => SymbolAccessor(this.WrappedOperation); + public IVariableInitializerOperationWrapper Initializer => IVariableInitializerOperationWrapper.FromOperation(InitializerAccessor(this.WrappedOperation)); + public ImmutableArray IgnoredArguments => IgnoredArgumentsAccessor(this.WrappedOperation); + public static explicit operator IVariableDeclaratorOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IVariableDeclaratorOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IVariableDeclaratorOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IVariableDeclaratorOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IVariableInitializerOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IVariableInitializerOperationWrapper.g.cs new file mode 100644 index 000000000..ef145325d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IVariableInitializerOperationWrapper.g.cs @@ -0,0 +1,53 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IVariableInitializerOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IVariableInitializerOperation"; + private static readonly Type WrappedType; + private readonly IOperation operation; + static IVariableInitializerOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IVariableInitializerOperationWrapper)); + } + + private IVariableInitializerOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public static explicit operator IVariableInitializerOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IVariableInitializerOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public ImmutableArray Locals => ((ISymbolInitializerOperationWrapper)this).Locals; + public IOperation Value => ((ISymbolInitializerOperationWrapper)this).Value; + public static explicit operator IVariableInitializerOperationWrapper(ISymbolInitializerOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator ISymbolInitializerOperationWrapper(IVariableInitializerOperationWrapper wrapper) => ISymbolInitializerOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IVariableInitializerOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IVariableInitializerOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IWhileLoopOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IWhileLoopOperationWrapper.g.cs new file mode 100644 index 000000000..9f8af0f9b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IWhileLoopOperationWrapper.g.cs @@ -0,0 +1,68 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IWhileLoopOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IWhileLoopOperation"; + private static readonly Type WrappedType; + private static readonly Func ConditionAccessor; + private static readonly Func ConditionIsTopAccessor; + private static readonly Func ConditionIsUntilAccessor; + private static readonly Func IgnoredConditionAccessor; + private readonly IOperation operation; + static IWhileLoopOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IWhileLoopOperationWrapper)); + ConditionAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Condition)); + ConditionIsTopAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(ConditionIsTop)); + ConditionIsUntilAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(ConditionIsUntil)); + IgnoredConditionAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(IgnoredCondition)); + } + + private IWhileLoopOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Condition => ConditionAccessor(this.WrappedOperation); + public bool ConditionIsTop => ConditionIsTopAccessor(this.WrappedOperation); + public bool ConditionIsUntil => ConditionIsUntilAccessor(this.WrappedOperation); + public IOperation IgnoredCondition => IgnoredConditionAccessor(this.WrappedOperation); + public static explicit operator IWhileLoopOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IWhileLoopOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public object LoopKind => ((ILoopOperationWrapper)this).LoopKind; + public IOperation Body => ((ILoopOperationWrapper)this).Body; + public ImmutableArray Locals => ((ILoopOperationWrapper)this).Locals; + public ILabelSymbol ContinueLabel => ((ILoopOperationWrapper)this).ContinueLabel; + public ILabelSymbol ExitLabel => ((ILoopOperationWrapper)this).ExitLabel; + public static explicit operator IWhileLoopOperationWrapper(ILoopOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator ILoopOperationWrapper(IWhileLoopOperationWrapper wrapper) => ILoopOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IWhileLoopOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IWhileLoopOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IWithOperationWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IWithOperationWrapper.g.cs new file mode 100644 index 000000000..4a1f607b9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/IWithOperationWrapper.g.cs @@ -0,0 +1,58 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + + internal readonly struct IWithOperationWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Operations.IWithOperation"; + private static readonly Type WrappedType; + private static readonly Func OperandAccessor; + private static readonly Func CloneMethodAccessor; + private static readonly Func InitializerAccessor; + private readonly IOperation operation; + static IWithOperationWrapper() + { + WrappedType = OperationWrapperHelper.GetWrappedType(typeof(IWithOperationWrapper)); + OperandAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Operand)); + CloneMethodAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(CloneMethod)); + InitializerAccessor = LightupHelpers.CreateOperationPropertyAccessor(WrappedType, nameof(Initializer)); + } + + private IWithOperationWrapper(IOperation operation) + { + this.operation = operation; + } + + public IOperation WrappedOperation => this.operation; + public ITypeSymbol Type => this.WrappedOperation.Type; + public IOperation Operand => OperandAccessor(this.WrappedOperation); + public IMethodSymbol CloneMethod => CloneMethodAccessor(this.WrappedOperation); + public IObjectOrCollectionInitializerOperationWrapper Initializer => IObjectOrCollectionInitializerOperationWrapper.FromOperation(InitializerAccessor(this.WrappedOperation)); + public static explicit operator IWithOperationWrapper(IOperationWrapper wrapper) => FromOperation(wrapper.WrappedOperation); + public static implicit operator IOperationWrapper(IWithOperationWrapper wrapper) => IOperationWrapper.FromUpcast(wrapper.WrappedOperation); + public static IWithOperationWrapper FromOperation(IOperation operation) + { + if (operation == null) + { + return default; + } + + if (!IsInstance(operation)) + { + throw new InvalidCastException($"Cannot cast '{operation.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new IWithOperationWrapper(operation); + } + + public static bool IsInstance(IOperation operation) + { + return operation != null && LightupHelpers.CanWrapOperation(operation, WrappedType); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/OperationKindEx.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/OperationKindEx.g.cs new file mode 100644 index 000000000..25c1520b4 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/OperationKindEx.g.cs @@ -0,0 +1,121 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using Microsoft.CodeAnalysis; + + internal static class OperationKindEx + { + public const OperationKind Invalid = (OperationKind)0x1; + public const OperationKind Block = (OperationKind)0x2; + public const OperationKind VariableDeclarationGroup = (OperationKind)0x3; + public const OperationKind Switch = (OperationKind)0x4; + public const OperationKind Loop = (OperationKind)0x5; + public const OperationKind Labeled = (OperationKind)0x6; + public const OperationKind Branch = (OperationKind)0x7; + public const OperationKind Empty = (OperationKind)0x8; + public const OperationKind Return = (OperationKind)0x9; + public const OperationKind YieldBreak = (OperationKind)0xa; + public const OperationKind Lock = (OperationKind)0xb; + public const OperationKind Try = (OperationKind)0xc; + public const OperationKind Using = (OperationKind)0xd; + public const OperationKind YieldReturn = (OperationKind)0xe; + public const OperationKind ExpressionStatement = (OperationKind)0xf; + public const OperationKind LocalFunction = (OperationKind)0x10; + public const OperationKind Stop = (OperationKind)0x11; + public const OperationKind End = (OperationKind)0x12; + public const OperationKind RaiseEvent = (OperationKind)0x13; + public const OperationKind Literal = (OperationKind)0x14; + public const OperationKind Conversion = (OperationKind)0x15; + public const OperationKind Invocation = (OperationKind)0x16; + public const OperationKind ArrayElementReference = (OperationKind)0x17; + public const OperationKind LocalReference = (OperationKind)0x18; + public const OperationKind ParameterReference = (OperationKind)0x19; + public const OperationKind FieldReference = (OperationKind)0x1a; + public const OperationKind MethodReference = (OperationKind)0x1b; + public const OperationKind PropertyReference = (OperationKind)0x1c; + public const OperationKind EventReference = (OperationKind)0x1e; + public const OperationKind Unary = (OperationKind)0x1f; + public const OperationKind Binary = (OperationKind)0x20; + public const OperationKind Conditional = (OperationKind)0x21; + public const OperationKind Coalesce = (OperationKind)0x22; + public const OperationKind AnonymousFunction = (OperationKind)0x23; + public const OperationKind ObjectCreation = (OperationKind)0x24; + public const OperationKind TypeParameterObjectCreation = (OperationKind)0x25; + public const OperationKind ArrayCreation = (OperationKind)0x26; + public const OperationKind InstanceReference = (OperationKind)0x27; + public const OperationKind IsType = (OperationKind)0x28; + public const OperationKind Await = (OperationKind)0x29; + public const OperationKind SimpleAssignment = (OperationKind)0x2a; + public const OperationKind CompoundAssignment = (OperationKind)0x2b; + public const OperationKind Parenthesized = (OperationKind)0x2c; + public const OperationKind EventAssignment = (OperationKind)0x2d; + public const OperationKind ConditionalAccess = (OperationKind)0x2e; + public const OperationKind ConditionalAccessInstance = (OperationKind)0x2f; + public const OperationKind InterpolatedString = (OperationKind)0x30; + public const OperationKind AnonymousObjectCreation = (OperationKind)0x31; + public const OperationKind ObjectOrCollectionInitializer = (OperationKind)0x32; + public const OperationKind MemberInitializer = (OperationKind)0x33; + public const OperationKind CollectionElementInitializer = (OperationKind)0x34; + public const OperationKind NameOf = (OperationKind)0x35; + public const OperationKind Tuple = (OperationKind)0x36; + public const OperationKind DynamicObjectCreation = (OperationKind)0x37; + public const OperationKind DynamicMemberReference = (OperationKind)0x38; + public const OperationKind DynamicInvocation = (OperationKind)0x39; + public const OperationKind DynamicIndexerAccess = (OperationKind)0x3a; + public const OperationKind TranslatedQuery = (OperationKind)0x3b; + public const OperationKind DelegateCreation = (OperationKind)0x3c; + public const OperationKind DefaultValue = (OperationKind)0x3d; + public const OperationKind TypeOf = (OperationKind)0x3e; + public const OperationKind SizeOf = (OperationKind)0x3f; + public const OperationKind AddressOf = (OperationKind)0x40; + public const OperationKind IsPattern = (OperationKind)0x41; + public const OperationKind Increment = (OperationKind)0x42; + public const OperationKind Throw = (OperationKind)0x43; + public const OperationKind Decrement = (OperationKind)0x44; + public const OperationKind DeconstructionAssignment = (OperationKind)0x45; + public const OperationKind DeclarationExpression = (OperationKind)0x46; + public const OperationKind OmittedArgument = (OperationKind)0x47; + public const OperationKind FieldInitializer = (OperationKind)0x48; + public const OperationKind VariableInitializer = (OperationKind)0x49; + public const OperationKind PropertyInitializer = (OperationKind)0x4a; + public const OperationKind ParameterInitializer = (OperationKind)0x4b; + public const OperationKind ArrayInitializer = (OperationKind)0x4c; + public const OperationKind VariableDeclarator = (OperationKind)0x4d; + public const OperationKind VariableDeclaration = (OperationKind)0x4e; + public const OperationKind Argument = (OperationKind)0x4f; + public const OperationKind CatchClause = (OperationKind)0x50; + public const OperationKind SwitchCase = (OperationKind)0x51; + public const OperationKind CaseClause = (OperationKind)0x52; + public const OperationKind InterpolatedStringText = (OperationKind)0x53; + public const OperationKind Interpolation = (OperationKind)0x54; + public const OperationKind ConstantPattern = (OperationKind)0x55; + public const OperationKind DeclarationPattern = (OperationKind)0x56; + public const OperationKind TupleBinary = (OperationKind)0x57; + public const OperationKind MethodBody = (OperationKind)0x58; + public const OperationKind ConstructorBody = (OperationKind)0x59; + public const OperationKind Discard = (OperationKind)0x5a; + public const OperationKind FlowCapture = (OperationKind)0x5b; + public const OperationKind FlowCaptureReference = (OperationKind)0x5c; + public const OperationKind IsNull = (OperationKind)0x5d; + public const OperationKind CaughtException = (OperationKind)0x5e; + public const OperationKind StaticLocalInitializationSemaphore = (OperationKind)0x5f; + public const OperationKind FlowAnonymousFunction = (OperationKind)0x60; + public const OperationKind CoalesceAssignment = (OperationKind)0x61; + public const OperationKind Range = (OperationKind)0x63; + public const OperationKind ReDim = (OperationKind)0x65; + public const OperationKind ReDimClause = (OperationKind)0x66; + public const OperationKind RecursivePattern = (OperationKind)0x67; + public const OperationKind DiscardPattern = (OperationKind)0x68; + public const OperationKind SwitchExpression = (OperationKind)0x69; + public const OperationKind SwitchExpressionArm = (OperationKind)0x6a; + public const OperationKind PropertySubpattern = (OperationKind)0x6b; + public const OperationKind UsingDeclaration = (OperationKind)0x6c; + public const OperationKind NegatedPattern = (OperationKind)0x6d; + public const OperationKind BinaryPattern = (OperationKind)0x6e; + public const OperationKind TypePattern = (OperationKind)0x6f; + public const OperationKind RelationalPattern = (OperationKind)0x70; + public const OperationKind With = (OperationKind)0x71; + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/OperationWrapperHelper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/OperationWrapperHelper.g.cs new file mode 100644 index 000000000..f1f2d212b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.OperationLightupGenerator/OperationWrapperHelper.g.cs @@ -0,0 +1,159 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using System.Reflection; + using Microsoft.CodeAnalysis; + + internal static class OperationWrapperHelper + { + private static readonly ImmutableDictionary WrappedTypes; + static OperationWrapperHelper() + { + var codeAnalysisAssembly = typeof(SyntaxNode).GetTypeInfo().Assembly; + var builder = ImmutableDictionary.CreateBuilder(); + builder.Add(typeof(IOperationWrapper), typeof(IOperation)); + builder.Add(typeof(ILoopOperationWrapper), codeAnalysisAssembly.GetType(ILoopOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IMemberReferenceOperationWrapper), codeAnalysisAssembly.GetType(IMemberReferenceOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IAssignmentOperationWrapper), codeAnalysisAssembly.GetType(IAssignmentOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ISymbolInitializerOperationWrapper), codeAnalysisAssembly.GetType(ISymbolInitializerOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ICaseClauseOperationWrapper), codeAnalysisAssembly.GetType(ICaseClauseOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IInterpolatedStringContentOperationWrapper), codeAnalysisAssembly.GetType(IInterpolatedStringContentOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IPatternOperationWrapper), codeAnalysisAssembly.GetType(IPatternOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IMethodBodyBaseOperationWrapper), codeAnalysisAssembly.GetType(IMethodBodyBaseOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IInvalidOperationWrapper), codeAnalysisAssembly.GetType(IInvalidOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IBlockOperationWrapper), codeAnalysisAssembly.GetType(IBlockOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IVariableDeclarationGroupOperationWrapper), codeAnalysisAssembly.GetType(IVariableDeclarationGroupOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ISwitchOperationWrapper), codeAnalysisAssembly.GetType(ISwitchOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IForEachLoopOperationWrapper), codeAnalysisAssembly.GetType(IForEachLoopOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IForLoopOperationWrapper), codeAnalysisAssembly.GetType(IForLoopOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IForToLoopOperationWrapper), codeAnalysisAssembly.GetType(IForToLoopOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IWhileLoopOperationWrapper), codeAnalysisAssembly.GetType(IWhileLoopOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ILabeledOperationWrapper), codeAnalysisAssembly.GetType(ILabeledOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IBranchOperationWrapper), codeAnalysisAssembly.GetType(IBranchOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IEmptyOperationWrapper), codeAnalysisAssembly.GetType(IEmptyOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IReturnOperationWrapper), codeAnalysisAssembly.GetType(IReturnOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ILockOperationWrapper), codeAnalysisAssembly.GetType(ILockOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ITryOperationWrapper), codeAnalysisAssembly.GetType(ITryOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IUsingOperationWrapper), codeAnalysisAssembly.GetType(IUsingOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IExpressionStatementOperationWrapper), codeAnalysisAssembly.GetType(IExpressionStatementOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ILocalFunctionOperationWrapper), codeAnalysisAssembly.GetType(ILocalFunctionOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IStopOperationWrapper), codeAnalysisAssembly.GetType(IStopOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IEndOperationWrapper), codeAnalysisAssembly.GetType(IEndOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IRaiseEventOperationWrapper), codeAnalysisAssembly.GetType(IRaiseEventOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ILiteralOperationWrapper), codeAnalysisAssembly.GetType(ILiteralOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IConversionOperationWrapper), codeAnalysisAssembly.GetType(IConversionOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IInvocationOperationWrapper), codeAnalysisAssembly.GetType(IInvocationOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IArrayElementReferenceOperationWrapper), codeAnalysisAssembly.GetType(IArrayElementReferenceOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ILocalReferenceOperationWrapper), codeAnalysisAssembly.GetType(ILocalReferenceOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IParameterReferenceOperationWrapper), codeAnalysisAssembly.GetType(IParameterReferenceOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IFieldReferenceOperationWrapper), codeAnalysisAssembly.GetType(IFieldReferenceOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IMethodReferenceOperationWrapper), codeAnalysisAssembly.GetType(IMethodReferenceOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IPropertyReferenceOperationWrapper), codeAnalysisAssembly.GetType(IPropertyReferenceOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IEventReferenceOperationWrapper), codeAnalysisAssembly.GetType(IEventReferenceOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IUnaryOperationWrapper), codeAnalysisAssembly.GetType(IUnaryOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IBinaryOperationWrapper), codeAnalysisAssembly.GetType(IBinaryOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IConditionalOperationWrapper), codeAnalysisAssembly.GetType(IConditionalOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ICoalesceOperationWrapper), codeAnalysisAssembly.GetType(ICoalesceOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IAnonymousFunctionOperationWrapper), codeAnalysisAssembly.GetType(IAnonymousFunctionOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IObjectCreationOperationWrapper), codeAnalysisAssembly.GetType(IObjectCreationOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ITypeParameterObjectCreationOperationWrapper), codeAnalysisAssembly.GetType(ITypeParameterObjectCreationOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IArrayCreationOperationWrapper), codeAnalysisAssembly.GetType(IArrayCreationOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IInstanceReferenceOperationWrapper), codeAnalysisAssembly.GetType(IInstanceReferenceOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IIsTypeOperationWrapper), codeAnalysisAssembly.GetType(IIsTypeOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IAwaitOperationWrapper), codeAnalysisAssembly.GetType(IAwaitOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ISimpleAssignmentOperationWrapper), codeAnalysisAssembly.GetType(ISimpleAssignmentOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ICompoundAssignmentOperationWrapper), codeAnalysisAssembly.GetType(ICompoundAssignmentOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IParenthesizedOperationWrapper), codeAnalysisAssembly.GetType(IParenthesizedOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IEventAssignmentOperationWrapper), codeAnalysisAssembly.GetType(IEventAssignmentOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IConditionalAccessOperationWrapper), codeAnalysisAssembly.GetType(IConditionalAccessOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IConditionalAccessInstanceOperationWrapper), codeAnalysisAssembly.GetType(IConditionalAccessInstanceOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IInterpolatedStringOperationWrapper), codeAnalysisAssembly.GetType(IInterpolatedStringOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IAnonymousObjectCreationOperationWrapper), codeAnalysisAssembly.GetType(IAnonymousObjectCreationOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IObjectOrCollectionInitializerOperationWrapper), codeAnalysisAssembly.GetType(IObjectOrCollectionInitializerOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IMemberInitializerOperationWrapper), codeAnalysisAssembly.GetType(IMemberInitializerOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ICollectionElementInitializerOperationWrapper), codeAnalysisAssembly.GetType(ICollectionElementInitializerOperationWrapper.WrappedTypeName)); + builder.Add(typeof(INameOfOperationWrapper), codeAnalysisAssembly.GetType(INameOfOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ITupleOperationWrapper), codeAnalysisAssembly.GetType(ITupleOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IDynamicObjectCreationOperationWrapper), codeAnalysisAssembly.GetType(IDynamicObjectCreationOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IDynamicMemberReferenceOperationWrapper), codeAnalysisAssembly.GetType(IDynamicMemberReferenceOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IDynamicInvocationOperationWrapper), codeAnalysisAssembly.GetType(IDynamicInvocationOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IDynamicIndexerAccessOperationWrapper), codeAnalysisAssembly.GetType(IDynamicIndexerAccessOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ITranslatedQueryOperationWrapper), codeAnalysisAssembly.GetType(ITranslatedQueryOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IDelegateCreationOperationWrapper), codeAnalysisAssembly.GetType(IDelegateCreationOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IDefaultValueOperationWrapper), codeAnalysisAssembly.GetType(IDefaultValueOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ITypeOfOperationWrapper), codeAnalysisAssembly.GetType(ITypeOfOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ISizeOfOperationWrapper), codeAnalysisAssembly.GetType(ISizeOfOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IAddressOfOperationWrapper), codeAnalysisAssembly.GetType(IAddressOfOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IIsPatternOperationWrapper), codeAnalysisAssembly.GetType(IIsPatternOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IIncrementOrDecrementOperationWrapper), codeAnalysisAssembly.GetType(IIncrementOrDecrementOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IThrowOperationWrapper), codeAnalysisAssembly.GetType(IThrowOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IDeconstructionAssignmentOperationWrapper), codeAnalysisAssembly.GetType(IDeconstructionAssignmentOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IDeclarationExpressionOperationWrapper), codeAnalysisAssembly.GetType(IDeclarationExpressionOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IOmittedArgumentOperationWrapper), codeAnalysisAssembly.GetType(IOmittedArgumentOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IFieldInitializerOperationWrapper), codeAnalysisAssembly.GetType(IFieldInitializerOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IVariableInitializerOperationWrapper), codeAnalysisAssembly.GetType(IVariableInitializerOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IPropertyInitializerOperationWrapper), codeAnalysisAssembly.GetType(IPropertyInitializerOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IParameterInitializerOperationWrapper), codeAnalysisAssembly.GetType(IParameterInitializerOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IArrayInitializerOperationWrapper), codeAnalysisAssembly.GetType(IArrayInitializerOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IVariableDeclaratorOperationWrapper), codeAnalysisAssembly.GetType(IVariableDeclaratorOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IVariableDeclarationOperationWrapper), codeAnalysisAssembly.GetType(IVariableDeclarationOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IArgumentOperationWrapper), codeAnalysisAssembly.GetType(IArgumentOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ICatchClauseOperationWrapper), codeAnalysisAssembly.GetType(ICatchClauseOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ISwitchCaseOperationWrapper), codeAnalysisAssembly.GetType(ISwitchCaseOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IDefaultCaseClauseOperationWrapper), codeAnalysisAssembly.GetType(IDefaultCaseClauseOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IPatternCaseClauseOperationWrapper), codeAnalysisAssembly.GetType(IPatternCaseClauseOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IRangeCaseClauseOperationWrapper), codeAnalysisAssembly.GetType(IRangeCaseClauseOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IRelationalCaseClauseOperationWrapper), codeAnalysisAssembly.GetType(IRelationalCaseClauseOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ISingleValueCaseClauseOperationWrapper), codeAnalysisAssembly.GetType(ISingleValueCaseClauseOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IInterpolatedStringTextOperationWrapper), codeAnalysisAssembly.GetType(IInterpolatedStringTextOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IInterpolationOperationWrapper), codeAnalysisAssembly.GetType(IInterpolationOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IConstantPatternOperationWrapper), codeAnalysisAssembly.GetType(IConstantPatternOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IDeclarationPatternOperationWrapper), codeAnalysisAssembly.GetType(IDeclarationPatternOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ITupleBinaryOperationWrapper), codeAnalysisAssembly.GetType(ITupleBinaryOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IMethodBodyOperationWrapper), codeAnalysisAssembly.GetType(IMethodBodyOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IConstructorBodyOperationWrapper), codeAnalysisAssembly.GetType(IConstructorBodyOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IDiscardOperationWrapper), codeAnalysisAssembly.GetType(IDiscardOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IFlowCaptureOperationWrapper), codeAnalysisAssembly.GetType(IFlowCaptureOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IFlowCaptureReferenceOperationWrapper), codeAnalysisAssembly.GetType(IFlowCaptureReferenceOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IIsNullOperationWrapper), codeAnalysisAssembly.GetType(IIsNullOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ICaughtExceptionOperationWrapper), codeAnalysisAssembly.GetType(ICaughtExceptionOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IStaticLocalInitializationSemaphoreOperationWrapper), codeAnalysisAssembly.GetType(IStaticLocalInitializationSemaphoreOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IFlowAnonymousFunctionOperationWrapper), codeAnalysisAssembly.GetType(IFlowAnonymousFunctionOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ICoalesceAssignmentOperationWrapper), codeAnalysisAssembly.GetType(ICoalesceAssignmentOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IRangeOperationWrapper), codeAnalysisAssembly.GetType(IRangeOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IReDimOperationWrapper), codeAnalysisAssembly.GetType(IReDimOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IReDimClauseOperationWrapper), codeAnalysisAssembly.GetType(IReDimClauseOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IRecursivePatternOperationWrapper), codeAnalysisAssembly.GetType(IRecursivePatternOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IDiscardPatternOperationWrapper), codeAnalysisAssembly.GetType(IDiscardPatternOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ISwitchExpressionOperationWrapper), codeAnalysisAssembly.GetType(ISwitchExpressionOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ISwitchExpressionArmOperationWrapper), codeAnalysisAssembly.GetType(ISwitchExpressionArmOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IPropertySubpatternOperationWrapper), codeAnalysisAssembly.GetType(IPropertySubpatternOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IUsingDeclarationOperationWrapper), codeAnalysisAssembly.GetType(IUsingDeclarationOperationWrapper.WrappedTypeName)); + builder.Add(typeof(INegatedPatternOperationWrapper), codeAnalysisAssembly.GetType(INegatedPatternOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IBinaryPatternOperationWrapper), codeAnalysisAssembly.GetType(IBinaryPatternOperationWrapper.WrappedTypeName)); + builder.Add(typeof(ITypePatternOperationWrapper), codeAnalysisAssembly.GetType(ITypePatternOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IRelationalPatternOperationWrapper), codeAnalysisAssembly.GetType(IRelationalPatternOperationWrapper.WrappedTypeName)); + builder.Add(typeof(IWithOperationWrapper), codeAnalysisAssembly.GetType(IWithOperationWrapper.WrappedTypeName)); + WrappedTypes = builder.ToImmutable(); + } + + /// + /// Gets the type that is wrapped by the given wrapper. + /// + /// Type of the wrapper for which the wrapped type should be retrieved. + /// The wrapped type, or null if there is no info. + internal static Type GetWrappedType(Type wrapperType) + { + if (WrappedTypes.TryGetValue(wrapperType, out Type wrappedType)) + { + return wrappedType; + } + + return null; + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/BaseExpressionColonSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/BaseExpressionColonSyntaxWrapper.g.cs new file mode 100644 index 000000000..954c53bca --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/BaseExpressionColonSyntaxWrapper.g.cs @@ -0,0 +1,96 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct BaseExpressionColonSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.BaseExpressionColonSyntax"; + private static readonly Type WrappedType; + + private static readonly Func ExpressionAccessor; + private static readonly Func ColonTokenAccessor; + private static readonly Func WithExpressionAccessor; + private static readonly Func WithColonTokenAccessor; + + private readonly CSharpSyntaxNode node; + + static BaseExpressionColonSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(BaseExpressionColonSyntaxWrapper)); + ExpressionAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Expression)); + ColonTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(ColonToken)); + WithExpressionAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Expression)); + WithColonTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(ColonToken)); + } + + private BaseExpressionColonSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public ExpressionSyntax Expression + { + get + { + return ExpressionAccessor(this.SyntaxNode); + } + } + + public SyntaxToken ColonToken + { + get + { + return ColonTokenAccessor(this.SyntaxNode); + } + } + + public static explicit operator BaseExpressionColonSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new BaseExpressionColonSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator CSharpSyntaxNode(BaseExpressionColonSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public BaseExpressionColonSyntaxWrapper WithExpression(ExpressionSyntax expression) + { + return new BaseExpressionColonSyntaxWrapper(WithExpressionAccessor(this.SyntaxNode, expression)); + } + + public BaseExpressionColonSyntaxWrapper WithColonToken(SyntaxToken colonToken) + { + return new BaseExpressionColonSyntaxWrapper(WithColonTokenAccessor(this.SyntaxNode, colonToken)); + } + + internal static BaseExpressionColonSyntaxWrapper FromUpcast(CSharpSyntaxNode node) + { + return new BaseExpressionColonSyntaxWrapper(node); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/BaseNamespaceDeclarationSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/BaseNamespaceDeclarationSyntaxWrapper.g.cs new file mode 100644 index 000000000..79637d5e1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/BaseNamespaceDeclarationSyntaxWrapper.g.cs @@ -0,0 +1,147 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct BaseNamespaceDeclarationSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.BaseNamespaceDeclarationSyntax"; + private static readonly Type WrappedType; + + private static readonly Func NamespaceKeywordAccessor; + private static readonly Func NameAccessor; + private static readonly Func> ExternsAccessor; + private static readonly Func> UsingsAccessor; + private static readonly Func> MembersAccessor; + private static readonly Func WithNamespaceKeywordAccessor; + private static readonly Func WithNameAccessor; + private static readonly Func, MemberDeclarationSyntax> WithExternsAccessor; + private static readonly Func, MemberDeclarationSyntax> WithUsingsAccessor; + private static readonly Func, MemberDeclarationSyntax> WithMembersAccessor; + + private readonly MemberDeclarationSyntax node; + + static BaseNamespaceDeclarationSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(BaseNamespaceDeclarationSyntaxWrapper)); + NamespaceKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(NamespaceKeyword)); + NameAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Name)); + ExternsAccessor = LightupHelpers.CreateSyntaxPropertyAccessor>(WrappedType, nameof(Externs)); + UsingsAccessor = LightupHelpers.CreateSyntaxPropertyAccessor>(WrappedType, nameof(Usings)); + MembersAccessor = LightupHelpers.CreateSyntaxPropertyAccessor>(WrappedType, nameof(Members)); + WithNamespaceKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(NamespaceKeyword)); + WithNameAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Name)); + WithExternsAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor>(WrappedType, nameof(Externs)); + WithUsingsAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor>(WrappedType, nameof(Usings)); + WithMembersAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor>(WrappedType, nameof(Members)); + } + + private BaseNamespaceDeclarationSyntaxWrapper(MemberDeclarationSyntax node) + { + this.node = node; + } + + public MemberDeclarationSyntax SyntaxNode => this.node; + + public SyntaxToken NamespaceKeyword + { + get + { + return NamespaceKeywordAccessor(this.SyntaxNode); + } + } + + public NameSyntax Name + { + get + { + return NameAccessor(this.SyntaxNode); + } + } + + public SyntaxList Externs + { + get + { + return ExternsAccessor(this.SyntaxNode); + } + } + + public SyntaxList Usings + { + get + { + return UsingsAccessor(this.SyntaxNode); + } + } + + public SyntaxList Members + { + get + { + return MembersAccessor(this.SyntaxNode); + } + } + + public static explicit operator BaseNamespaceDeclarationSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new BaseNamespaceDeclarationSyntaxWrapper((MemberDeclarationSyntax)node); + } + + public static implicit operator MemberDeclarationSyntax(BaseNamespaceDeclarationSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public BaseNamespaceDeclarationSyntaxWrapper WithNamespaceKeyword(SyntaxToken namespaceKeyword) + { + return new BaseNamespaceDeclarationSyntaxWrapper(WithNamespaceKeywordAccessor(this.SyntaxNode, namespaceKeyword)); + } + + public BaseNamespaceDeclarationSyntaxWrapper WithName(NameSyntax name) + { + return new BaseNamespaceDeclarationSyntaxWrapper(WithNameAccessor(this.SyntaxNode, name)); + } + + public BaseNamespaceDeclarationSyntaxWrapper WithExterns(SyntaxList externs) + { + return new BaseNamespaceDeclarationSyntaxWrapper(WithExternsAccessor(this.SyntaxNode, externs)); + } + + public BaseNamespaceDeclarationSyntaxWrapper WithUsings(SyntaxList usings) + { + return new BaseNamespaceDeclarationSyntaxWrapper(WithUsingsAccessor(this.SyntaxNode, usings)); + } + + public BaseNamespaceDeclarationSyntaxWrapper WithMembers(SyntaxList members) + { + return new BaseNamespaceDeclarationSyntaxWrapper(WithMembersAccessor(this.SyntaxNode, members)); + } + + internal static BaseNamespaceDeclarationSyntaxWrapper FromUpcast(MemberDeclarationSyntax node) + { + return new BaseNamespaceDeclarationSyntaxWrapper(node); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/BaseObjectCreationExpressionSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/BaseObjectCreationExpressionSyntaxWrapper.g.cs new file mode 100644 index 000000000..74f02aab9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/BaseObjectCreationExpressionSyntaxWrapper.g.cs @@ -0,0 +1,113 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct BaseObjectCreationExpressionSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.BaseObjectCreationExpressionSyntax"; + private static readonly Type WrappedType; + + private static readonly Func NewKeywordAccessor; + private static readonly Func ArgumentListAccessor; + private static readonly Func InitializerAccessor; + private static readonly Func WithNewKeywordAccessor; + private static readonly Func WithArgumentListAccessor; + private static readonly Func WithInitializerAccessor; + + private readonly ExpressionSyntax node; + + static BaseObjectCreationExpressionSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(BaseObjectCreationExpressionSyntaxWrapper)); + NewKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(NewKeyword)); + ArgumentListAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(ArgumentList)); + InitializerAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Initializer)); + WithNewKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(NewKeyword)); + WithArgumentListAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(ArgumentList)); + WithInitializerAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Initializer)); + } + + private BaseObjectCreationExpressionSyntaxWrapper(ExpressionSyntax node) + { + this.node = node; + } + + public ExpressionSyntax SyntaxNode => this.node; + + public SyntaxToken NewKeyword + { + get + { + return NewKeywordAccessor(this.SyntaxNode); + } + } + + public ArgumentListSyntax ArgumentList + { + get + { + return ArgumentListAccessor(this.SyntaxNode); + } + } + + public InitializerExpressionSyntax Initializer + { + get + { + return InitializerAccessor(this.SyntaxNode); + } + } + + public static explicit operator BaseObjectCreationExpressionSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new BaseObjectCreationExpressionSyntaxWrapper((ExpressionSyntax)node); + } + + public static implicit operator ExpressionSyntax(BaseObjectCreationExpressionSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public BaseObjectCreationExpressionSyntaxWrapper WithNewKeyword(SyntaxToken newKeyword) + { + return new BaseObjectCreationExpressionSyntaxWrapper(WithNewKeywordAccessor(this.SyntaxNode, newKeyword)); + } + + public BaseObjectCreationExpressionSyntaxWrapper WithArgumentList(ArgumentListSyntax argumentList) + { + return new BaseObjectCreationExpressionSyntaxWrapper(WithArgumentListAccessor(this.SyntaxNode, argumentList)); + } + + public BaseObjectCreationExpressionSyntaxWrapper WithInitializer(InitializerExpressionSyntax initializer) + { + return new BaseObjectCreationExpressionSyntaxWrapper(WithInitializerAccessor(this.SyntaxNode, initializer)); + } + + internal static BaseObjectCreationExpressionSyntaxWrapper FromUpcast(ExpressionSyntax node) + { + return new BaseObjectCreationExpressionSyntaxWrapper(node); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/BaseParameterSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/BaseParameterSyntaxWrapper.g.cs new file mode 100644 index 000000000..139edba39 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/BaseParameterSyntaxWrapper.g.cs @@ -0,0 +1,113 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct BaseParameterSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.BaseParameterSyntax"; + private static readonly Type WrappedType; + + private static readonly Func> AttributeListsAccessor; + private static readonly Func ModifiersAccessor; + private static readonly Func TypeAccessor; + private static readonly Func, CSharpSyntaxNode> WithAttributeListsAccessor; + private static readonly Func WithModifiersAccessor; + private static readonly Func WithTypeAccessor; + + private readonly CSharpSyntaxNode node; + + static BaseParameterSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(BaseParameterSyntaxWrapper)); + AttributeListsAccessor = LightupHelpers.CreateSyntaxPropertyAccessor>(WrappedType, nameof(AttributeLists)); + ModifiersAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Modifiers)); + TypeAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Type)); + WithAttributeListsAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor>(WrappedType, nameof(AttributeLists)); + WithModifiersAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Modifiers)); + WithTypeAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Type)); + } + + private BaseParameterSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public SyntaxList AttributeLists + { + get + { + return AttributeListsAccessor(this.SyntaxNode); + } + } + + public SyntaxTokenList Modifiers + { + get + { + return ModifiersAccessor(this.SyntaxNode); + } + } + + public TypeSyntax Type + { + get + { + return TypeAccessor(this.SyntaxNode); + } + } + + public static explicit operator BaseParameterSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new BaseParameterSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator CSharpSyntaxNode(BaseParameterSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public BaseParameterSyntaxWrapper WithAttributeLists(SyntaxList attributeLists) + { + return new BaseParameterSyntaxWrapper(WithAttributeListsAccessor(this.SyntaxNode, attributeLists)); + } + + public BaseParameterSyntaxWrapper WithModifiers(SyntaxTokenList modifiers) + { + return new BaseParameterSyntaxWrapper(WithModifiersAccessor(this.SyntaxNode, modifiers)); + } + + public BaseParameterSyntaxWrapper WithType(TypeSyntax type) + { + return new BaseParameterSyntaxWrapper(WithTypeAccessor(this.SyntaxNode, type)); + } + + internal static BaseParameterSyntaxWrapper FromUpcast(CSharpSyntaxNode node) + { + return new BaseParameterSyntaxWrapper(node); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/BinaryPatternSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/BinaryPatternSyntaxWrapper.g.cs new file mode 100644 index 000000000..305a42df2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/BinaryPatternSyntaxWrapper.g.cs @@ -0,0 +1,128 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct BinaryPatternSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.BinaryPatternSyntax"; + private static readonly Type WrappedType; + + private static readonly Func LeftAccessor; + private static readonly Func OperatorTokenAccessor; + private static readonly Func RightAccessor; + private static readonly Func WithLeftAccessor; + private static readonly Func WithOperatorTokenAccessor; + private static readonly Func WithRightAccessor; + + private readonly CSharpSyntaxNode node; + + static BinaryPatternSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(BinaryPatternSyntaxWrapper)); + LeftAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Left)); + OperatorTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(OperatorToken)); + RightAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Right)); + WithLeftAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Left)); + WithOperatorTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(OperatorToken)); + WithRightAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Right)); + } + + private BinaryPatternSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public PatternSyntaxWrapper Left + { + get + { + return (PatternSyntaxWrapper)LeftAccessor(this.SyntaxNode); + } + } + + public SyntaxToken OperatorToken + { + get + { + return OperatorTokenAccessor(this.SyntaxNode); + } + } + + public PatternSyntaxWrapper Right + { + get + { + return (PatternSyntaxWrapper)RightAccessor(this.SyntaxNode); + } + } + + public static explicit operator BinaryPatternSyntaxWrapper(PatternSyntaxWrapper node) + { + return (BinaryPatternSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator BinaryPatternSyntaxWrapper(ExpressionOrPatternSyntaxWrapper node) + { + return (BinaryPatternSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator BinaryPatternSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new BinaryPatternSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator PatternSyntaxWrapper(BinaryPatternSyntaxWrapper wrapper) + { + return PatternSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator ExpressionOrPatternSyntaxWrapper(BinaryPatternSyntaxWrapper wrapper) + { + return ExpressionOrPatternSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator CSharpSyntaxNode(BinaryPatternSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public BinaryPatternSyntaxWrapper WithLeft(PatternSyntaxWrapper left) + { + return new BinaryPatternSyntaxWrapper(WithLeftAccessor(this.SyntaxNode, left)); + } + + public BinaryPatternSyntaxWrapper WithOperatorToken(SyntaxToken operatorToken) + { + return new BinaryPatternSyntaxWrapper(WithOperatorTokenAccessor(this.SyntaxNode, operatorToken)); + } + + public BinaryPatternSyntaxWrapper WithRight(PatternSyntaxWrapper right) + { + return new BinaryPatternSyntaxWrapper(WithRightAccessor(this.SyntaxNode, right)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CasePatternSwitchLabelSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/CasePatternSwitchLabelSyntaxWrapper.g.cs similarity index 85% rename from StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CasePatternSwitchLabelSyntaxWrapper.cs rename to StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/CasePatternSwitchLabelSyntaxWrapper.g.cs index 1cffd13a6..927e6dea9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CasePatternSwitchLabelSyntaxWrapper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/CasePatternSwitchLabelSyntaxWrapper.g.cs @@ -1,14 +1,15 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Lightup { using System; + using System.Collections.Immutable; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; - internal struct CasePatternSwitchLabelSyntaxWrapper : ISyntaxWrapper + internal readonly partial struct CasePatternSwitchLabelSyntaxWrapper : ISyntaxWrapper { internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax"; private static readonly Type WrappedType; @@ -16,21 +17,21 @@ internal struct CasePatternSwitchLabelSyntaxWrapper : ISyntaxWrapper PatternAccessor; private static readonly Func WhenClauseAccessor; private static readonly Func WithKeywordAccessor; - private static readonly Func WithColonTokenAccessor; private static readonly Func WithPatternAccessor; private static readonly Func WithWhenClauseAccessor; + private static readonly Func WithColonTokenAccessor; private readonly SwitchLabelSyntax node; static CasePatternSwitchLabelSyntaxWrapper() { - WrappedType = WrapperHelper.GetWrappedType(typeof(CasePatternSwitchLabelSyntaxWrapper)); + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(CasePatternSwitchLabelSyntaxWrapper)); PatternAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Pattern)); WhenClauseAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(WhenClause)); - WithKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(SwitchLabelSyntax.Keyword)); - WithColonTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(SwitchLabelSyntax.ColonToken)); + WithKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Keyword)); WithPatternAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Pattern)); WithWhenClauseAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(WhenClause)); + WithColonTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(ColonToken)); } private CasePatternSwitchLabelSyntaxWrapper(SwitchLabelSyntax node) @@ -40,6 +41,14 @@ private CasePatternSwitchLabelSyntaxWrapper(SwitchLabelSyntax node) public SwitchLabelSyntax SyntaxNode => this.node; + public SyntaxToken Keyword + { + get + { + return this.SyntaxNode.Keyword; + } + } + public PatternSyntaxWrapper Pattern { get @@ -56,11 +65,19 @@ public WhenClauseSyntaxWrapper WhenClause } } + public SyntaxToken ColonToken + { + get + { + return this.SyntaxNode.ColonToken; + } + } + public static explicit operator CasePatternSwitchLabelSyntaxWrapper(SyntaxNode node) { if (node == null) { - return default(CasePatternSwitchLabelSyntaxWrapper); + return default; } if (!IsInstance(node)) @@ -86,11 +103,6 @@ public CasePatternSwitchLabelSyntaxWrapper WithKeyword(SyntaxToken keyword) return new CasePatternSwitchLabelSyntaxWrapper(WithKeywordAccessor(this.SyntaxNode, keyword)); } - public CasePatternSwitchLabelSyntaxWrapper WithColonToken(SyntaxToken colonToken) - { - return new CasePatternSwitchLabelSyntaxWrapper(WithColonTokenAccessor(this.SyntaxNode, colonToken)); - } - public CasePatternSwitchLabelSyntaxWrapper WithPattern(PatternSyntaxWrapper pattern) { return new CasePatternSwitchLabelSyntaxWrapper(WithPatternAccessor(this.SyntaxNode, pattern)); @@ -100,5 +112,10 @@ public CasePatternSwitchLabelSyntaxWrapper WithWhenClause(WhenClauseSyntaxWrappe { return new CasePatternSwitchLabelSyntaxWrapper(WithWhenClauseAccessor(this.SyntaxNode, whenClause)); } + + public CasePatternSwitchLabelSyntaxWrapper WithColonToken(SyntaxToken colonToken) + { + return new CasePatternSwitchLabelSyntaxWrapper(WithColonTokenAccessor(this.SyntaxNode, colonToken)); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/CommonForEachStatementSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/CommonForEachStatementSyntaxWrapper.g.cs new file mode 100644 index 000000000..8e91cd2ef --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/CommonForEachStatementSyntaxWrapper.g.cs @@ -0,0 +1,181 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct CommonForEachStatementSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax"; + private static readonly Type WrappedType; + + private static readonly Func AwaitKeywordAccessor; + private static readonly Func ForEachKeywordAccessor; + private static readonly Func OpenParenTokenAccessor; + private static readonly Func InKeywordAccessor; + private static readonly Func ExpressionAccessor; + private static readonly Func CloseParenTokenAccessor; + private static readonly Func StatementAccessor; + private static readonly Func WithAwaitKeywordAccessor; + private static readonly Func WithForEachKeywordAccessor; + private static readonly Func WithOpenParenTokenAccessor; + private static readonly Func WithInKeywordAccessor; + private static readonly Func WithExpressionAccessor; + private static readonly Func WithCloseParenTokenAccessor; + private static readonly Func WithStatementAccessor; + + private readonly StatementSyntax node; + + static CommonForEachStatementSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(CommonForEachStatementSyntaxWrapper)); + AwaitKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(AwaitKeyword)); + ForEachKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(ForEachKeyword)); + OpenParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(OpenParenToken)); + InKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(InKeyword)); + ExpressionAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Expression)); + CloseParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(CloseParenToken)); + StatementAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Statement)); + WithAwaitKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(AwaitKeyword)); + WithForEachKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(ForEachKeyword)); + WithOpenParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(OpenParenToken)); + WithInKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(InKeyword)); + WithExpressionAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Expression)); + WithCloseParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(CloseParenToken)); + WithStatementAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Statement)); + } + + private CommonForEachStatementSyntaxWrapper(StatementSyntax node) + { + this.node = node; + } + + public StatementSyntax SyntaxNode => this.node; + + public SyntaxToken AwaitKeyword + { + get + { + return AwaitKeywordAccessor(this.SyntaxNode); + } + } + + public SyntaxToken ForEachKeyword + { + get + { + return ForEachKeywordAccessor(this.SyntaxNode); + } + } + + public SyntaxToken OpenParenToken + { + get + { + return OpenParenTokenAccessor(this.SyntaxNode); + } + } + + public SyntaxToken InKeyword + { + get + { + return InKeywordAccessor(this.SyntaxNode); + } + } + + public ExpressionSyntax Expression + { + get + { + return ExpressionAccessor(this.SyntaxNode); + } + } + + public SyntaxToken CloseParenToken + { + get + { + return CloseParenTokenAccessor(this.SyntaxNode); + } + } + + public StatementSyntax Statement + { + get + { + return StatementAccessor(this.SyntaxNode); + } + } + + public static explicit operator CommonForEachStatementSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new CommonForEachStatementSyntaxWrapper((StatementSyntax)node); + } + + public static implicit operator StatementSyntax(CommonForEachStatementSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public CommonForEachStatementSyntaxWrapper WithAwaitKeyword(SyntaxToken awaitKeyword) + { + return new CommonForEachStatementSyntaxWrapper(WithAwaitKeywordAccessor(this.SyntaxNode, awaitKeyword)); + } + + public CommonForEachStatementSyntaxWrapper WithForEachKeyword(SyntaxToken forEachKeyword) + { + return new CommonForEachStatementSyntaxWrapper(WithForEachKeywordAccessor(this.SyntaxNode, forEachKeyword)); + } + + public CommonForEachStatementSyntaxWrapper WithOpenParenToken(SyntaxToken openParenToken) + { + return new CommonForEachStatementSyntaxWrapper(WithOpenParenTokenAccessor(this.SyntaxNode, openParenToken)); + } + + public CommonForEachStatementSyntaxWrapper WithInKeyword(SyntaxToken inKeyword) + { + return new CommonForEachStatementSyntaxWrapper(WithInKeywordAccessor(this.SyntaxNode, inKeyword)); + } + + public CommonForEachStatementSyntaxWrapper WithExpression(ExpressionSyntax expression) + { + return new CommonForEachStatementSyntaxWrapper(WithExpressionAccessor(this.SyntaxNode, expression)); + } + + public CommonForEachStatementSyntaxWrapper WithCloseParenToken(SyntaxToken closeParenToken) + { + return new CommonForEachStatementSyntaxWrapper(WithCloseParenTokenAccessor(this.SyntaxNode, closeParenToken)); + } + + public CommonForEachStatementSyntaxWrapper WithStatement(StatementSyntax statement) + { + return new CommonForEachStatementSyntaxWrapper(WithStatementAccessor(this.SyntaxNode, statement)); + } + + internal static CommonForEachStatementSyntaxWrapper FromUpcast(StatementSyntax node) + { + return new CommonForEachStatementSyntaxWrapper(node); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ConstantPatternSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ConstantPatternSyntaxWrapper.g.cs similarity index 77% rename from StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ConstantPatternSyntaxWrapper.cs rename to StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ConstantPatternSyntaxWrapper.g.cs index 5509d924d..b9edf71fb 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ConstantPatternSyntaxWrapper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ConstantPatternSyntaxWrapper.g.cs @@ -1,14 +1,15 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Lightup { using System; + using System.Collections.Immutable; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; - internal struct ConstantPatternSyntaxWrapper : ISyntaxWrapper + internal readonly partial struct ConstantPatternSyntaxWrapper : ISyntaxWrapper { internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.ConstantPatternSyntax"; private static readonly Type WrappedType; @@ -20,7 +21,7 @@ internal struct ConstantPatternSyntaxWrapper : ISyntaxWrapper static ConstantPatternSyntaxWrapper() { - WrappedType = WrapperHelper.GetWrappedType(typeof(ConstantPatternSyntaxWrapper)); + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(ConstantPatternSyntaxWrapper)); ExpressionAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Expression)); WithExpressionAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Expression)); } @@ -45,11 +46,16 @@ public static explicit operator ConstantPatternSyntaxWrapper(PatternSyntaxWrappe return (ConstantPatternSyntaxWrapper)node.SyntaxNode; } + public static explicit operator ConstantPatternSyntaxWrapper(ExpressionOrPatternSyntaxWrapper node) + { + return (ConstantPatternSyntaxWrapper)node.SyntaxNode; + } + public static explicit operator ConstantPatternSyntaxWrapper(SyntaxNode node) { if (node == null) { - return default(ConstantPatternSyntaxWrapper); + return default; } if (!IsInstance(node)) @@ -65,6 +71,11 @@ public static implicit operator PatternSyntaxWrapper(ConstantPatternSyntaxWrappe return PatternSyntaxWrapper.FromUpcast(wrapper.node); } + public static implicit operator ExpressionOrPatternSyntaxWrapper(ConstantPatternSyntaxWrapper wrapper) + { + return ExpressionOrPatternSyntaxWrapper.FromUpcast(wrapper.node); + } + public static implicit operator CSharpSyntaxNode(ConstantPatternSyntaxWrapper wrapper) { return wrapper.node; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DeclarationExpressionSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/DeclarationExpressionSyntaxWrapper.g.cs similarity index 88% rename from StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DeclarationExpressionSyntaxWrapper.cs rename to StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/DeclarationExpressionSyntaxWrapper.g.cs index 9695671e8..a5feafe03 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DeclarationExpressionSyntaxWrapper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/DeclarationExpressionSyntaxWrapper.g.cs @@ -1,14 +1,15 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Lightup { using System; + using System.Collections.Immutable; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; - internal struct DeclarationExpressionSyntaxWrapper : ISyntaxWrapper + internal readonly partial struct DeclarationExpressionSyntaxWrapper : ISyntaxWrapper { internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationExpressionSyntax"; private static readonly Type WrappedType; @@ -22,7 +23,7 @@ internal struct DeclarationExpressionSyntaxWrapper : ISyntaxWrapper(WrappedType, nameof(Type)); DesignationAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Designation)); WithTypeAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Type)); @@ -56,7 +57,7 @@ public static explicit operator DeclarationExpressionSyntaxWrapper(SyntaxNode no { if (node == null) { - return default(DeclarationExpressionSyntaxWrapper); + return default; } if (!IsInstance(node)) @@ -84,7 +85,7 @@ public DeclarationExpressionSyntaxWrapper WithType(TypeSyntax type) public DeclarationExpressionSyntaxWrapper WithDesignation(VariableDesignationSyntaxWrapper designation) { - return new DeclarationExpressionSyntaxWrapper(WithDesignationAccessor(this.SyntaxNode, designation.SyntaxNode)); + return new DeclarationExpressionSyntaxWrapper(WithDesignationAccessor(this.SyntaxNode, designation)); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DeclarationPatternSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/DeclarationPatternSyntaxWrapper.g.cs similarity index 81% rename from StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DeclarationPatternSyntaxWrapper.cs rename to StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/DeclarationPatternSyntaxWrapper.g.cs index 3c8d334ab..f0dee0a3e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DeclarationPatternSyntaxWrapper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/DeclarationPatternSyntaxWrapper.g.cs @@ -1,14 +1,15 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Lightup { using System; + using System.Collections.Immutable; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; - internal struct DeclarationPatternSyntaxWrapper : ISyntaxWrapper + internal readonly partial struct DeclarationPatternSyntaxWrapper : ISyntaxWrapper { internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationPatternSyntax"; private static readonly Type WrappedType; @@ -22,7 +23,7 @@ internal struct DeclarationPatternSyntaxWrapper : ISyntaxWrapper(WrappedType, nameof(Type)); DesignationAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Designation)); WithTypeAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Type)); @@ -57,11 +58,16 @@ public static explicit operator DeclarationPatternSyntaxWrapper(PatternSyntaxWra return (DeclarationPatternSyntaxWrapper)node.SyntaxNode; } + public static explicit operator DeclarationPatternSyntaxWrapper(ExpressionOrPatternSyntaxWrapper node) + { + return (DeclarationPatternSyntaxWrapper)node.SyntaxNode; + } + public static explicit operator DeclarationPatternSyntaxWrapper(SyntaxNode node) { if (node == null) { - return default(DeclarationPatternSyntaxWrapper); + return default; } if (!IsInstance(node)) @@ -77,6 +83,11 @@ public static implicit operator PatternSyntaxWrapper(DeclarationPatternSyntaxWra return PatternSyntaxWrapper.FromUpcast(wrapper.node); } + public static implicit operator ExpressionOrPatternSyntaxWrapper(DeclarationPatternSyntaxWrapper wrapper) + { + return ExpressionOrPatternSyntaxWrapper.FromUpcast(wrapper.node); + } + public static implicit operator CSharpSyntaxNode(DeclarationPatternSyntaxWrapper wrapper) { return wrapper.node; @@ -94,7 +105,7 @@ public DeclarationPatternSyntaxWrapper WithType(TypeSyntax type) public DeclarationPatternSyntaxWrapper WithDesignation(VariableDesignationSyntaxWrapper designation) { - return new DeclarationPatternSyntaxWrapper(WithDesignationAccessor(this.SyntaxNode, designation.SyntaxNode)); + return new DeclarationPatternSyntaxWrapper(WithDesignationAccessor(this.SyntaxNode, designation)); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/DefaultConstraintSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/DefaultConstraintSyntaxWrapper.g.cs new file mode 100644 index 000000000..905714e83 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/DefaultConstraintSyntaxWrapper.g.cs @@ -0,0 +1,74 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct DefaultConstraintSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.DefaultConstraintSyntax"; + private static readonly Type WrappedType; + + private static readonly Func DefaultKeywordAccessor; + private static readonly Func WithDefaultKeywordAccessor; + + private readonly TypeParameterConstraintSyntax node; + + static DefaultConstraintSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(DefaultConstraintSyntaxWrapper)); + DefaultKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(DefaultKeyword)); + WithDefaultKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(DefaultKeyword)); + } + + private DefaultConstraintSyntaxWrapper(TypeParameterConstraintSyntax node) + { + this.node = node; + } + + public TypeParameterConstraintSyntax SyntaxNode => this.node; + + public SyntaxToken DefaultKeyword + { + get + { + return DefaultKeywordAccessor(this.SyntaxNode); + } + } + + public static explicit operator DefaultConstraintSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new DefaultConstraintSyntaxWrapper((TypeParameterConstraintSyntax)node); + } + + public static implicit operator TypeParameterConstraintSyntax(DefaultConstraintSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public DefaultConstraintSyntaxWrapper WithDefaultKeyword(SyntaxToken defaultKeyword) + { + return new DefaultConstraintSyntaxWrapper(WithDefaultKeywordAccessor(this.SyntaxNode, defaultKeyword)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DiscardDesignationSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/DiscardDesignationSyntaxWrapper.g.cs similarity index 84% rename from StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DiscardDesignationSyntaxWrapper.cs rename to StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/DiscardDesignationSyntaxWrapper.g.cs index 59f79e09c..c2a8eb70b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DiscardDesignationSyntaxWrapper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/DiscardDesignationSyntaxWrapper.g.cs @@ -1,13 +1,15 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Lightup { using System; + using System.Collections.Immutable; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; - internal struct DiscardDesignationSyntaxWrapper : ISyntaxWrapper + internal readonly partial struct DiscardDesignationSyntaxWrapper : ISyntaxWrapper { internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.DiscardDesignationSyntax"; private static readonly Type WrappedType; @@ -19,7 +21,7 @@ internal struct DiscardDesignationSyntaxWrapper : ISyntaxWrapper(WrappedType, nameof(UnderscoreToken)); WithUnderscoreTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(UnderscoreToken)); } @@ -48,7 +50,7 @@ public static explicit operator DiscardDesignationSyntaxWrapper(SyntaxNode node) { if (node == null) { - return default(DiscardDesignationSyntaxWrapper); + return default; } if (!IsInstance(node)) @@ -74,9 +76,9 @@ public static bool IsInstance(SyntaxNode node) return node != null && LightupHelpers.CanWrapNode(node, WrappedType); } - public DiscardDesignationSyntaxWrapper WithUnderscoreToken(SyntaxToken identifier) + public DiscardDesignationSyntaxWrapper WithUnderscoreToken(SyntaxToken underscoreToken) { - return new DiscardDesignationSyntaxWrapper(WithUnderscoreTokenAccessor(this.SyntaxNode, identifier)); + return new DiscardDesignationSyntaxWrapper(WithUnderscoreTokenAccessor(this.SyntaxNode, underscoreToken)); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/DiscardPatternSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/DiscardPatternSyntaxWrapper.g.cs new file mode 100644 index 000000000..992c06ae6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/DiscardPatternSyntaxWrapper.g.cs @@ -0,0 +1,94 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct DiscardPatternSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.DiscardPatternSyntax"; + private static readonly Type WrappedType; + + private static readonly Func UnderscoreTokenAccessor; + private static readonly Func WithUnderscoreTokenAccessor; + + private readonly CSharpSyntaxNode node; + + static DiscardPatternSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(DiscardPatternSyntaxWrapper)); + UnderscoreTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(UnderscoreToken)); + WithUnderscoreTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(UnderscoreToken)); + } + + private DiscardPatternSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public SyntaxToken UnderscoreToken + { + get + { + return UnderscoreTokenAccessor(this.SyntaxNode); + } + } + + public static explicit operator DiscardPatternSyntaxWrapper(PatternSyntaxWrapper node) + { + return (DiscardPatternSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator DiscardPatternSyntaxWrapper(ExpressionOrPatternSyntaxWrapper node) + { + return (DiscardPatternSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator DiscardPatternSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new DiscardPatternSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator PatternSyntaxWrapper(DiscardPatternSyntaxWrapper wrapper) + { + return PatternSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator ExpressionOrPatternSyntaxWrapper(DiscardPatternSyntaxWrapper wrapper) + { + return ExpressionOrPatternSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator CSharpSyntaxNode(DiscardPatternSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public DiscardPatternSyntaxWrapper WithUnderscoreToken(SyntaxToken underscoreToken) + { + return new DiscardPatternSyntaxWrapper(WithUnderscoreTokenAccessor(this.SyntaxNode, underscoreToken)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ExpressionColonSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ExpressionColonSyntaxWrapper.g.cs new file mode 100644 index 000000000..3a01e8de2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ExpressionColonSyntaxWrapper.g.cs @@ -0,0 +1,96 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct ExpressionColonSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionColonSyntax"; + private static readonly Type WrappedType; + private static readonly Func WithExpressionAccessor; + private static readonly Func WithColonTokenAccessor; + + private readonly CSharpSyntaxNode node; + + static ExpressionColonSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(ExpressionColonSyntaxWrapper)); + WithExpressionAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Expression)); + WithColonTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(ColonToken)); + } + + private ExpressionColonSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public ExpressionSyntax Expression + { + get + { + return ((BaseExpressionColonSyntaxWrapper)this).Expression; + } + } + + public SyntaxToken ColonToken + { + get + { + return ((BaseExpressionColonSyntaxWrapper)this).ColonToken; + } + } + + public static explicit operator ExpressionColonSyntaxWrapper(BaseExpressionColonSyntaxWrapper node) + { + return (ExpressionColonSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator ExpressionColonSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ExpressionColonSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator BaseExpressionColonSyntaxWrapper(ExpressionColonSyntaxWrapper wrapper) + { + return BaseExpressionColonSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator CSharpSyntaxNode(ExpressionColonSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public ExpressionColonSyntaxWrapper WithExpression(ExpressionSyntax expression) + { + return new ExpressionColonSyntaxWrapper(WithExpressionAccessor(this.SyntaxNode, expression)); + } + + public ExpressionColonSyntaxWrapper WithColonToken(SyntaxToken colonToken) + { + return new ExpressionColonSyntaxWrapper(WithColonTokenAccessor(this.SyntaxNode, colonToken)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ExpressionOrPatternSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ExpressionOrPatternSyntaxWrapper.g.cs new file mode 100644 index 000000000..5c4ae69d7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ExpressionOrPatternSyntaxWrapper.g.cs @@ -0,0 +1,61 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct ExpressionOrPatternSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionOrPatternSyntax"; + private static readonly Type WrappedType; + + private readonly CSharpSyntaxNode node; + + static ExpressionOrPatternSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(ExpressionOrPatternSyntaxWrapper)); + } + + private ExpressionOrPatternSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public static explicit operator ExpressionOrPatternSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ExpressionOrPatternSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator CSharpSyntaxNode(ExpressionOrPatternSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + internal static ExpressionOrPatternSyntaxWrapper FromUpcast(CSharpSyntaxNode node) + { + return new ExpressionOrPatternSyntaxWrapper(node); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/FileScopedNamespaceDeclarationSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/FileScopedNamespaceDeclarationSyntaxWrapper.g.cs new file mode 100644 index 000000000..4d45bb464 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/FileScopedNamespaceDeclarationSyntaxWrapper.g.cs @@ -0,0 +1,189 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct FileScopedNamespaceDeclarationSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.FileScopedNamespaceDeclarationSyntax"; + private static readonly Type WrappedType; + + private static readonly Func SemicolonTokenAccessor; + private static readonly Func, MemberDeclarationSyntax> WithAttributeListsAccessor; + private static readonly Func WithModifiersAccessor; + private static readonly Func WithNamespaceKeywordAccessor; + private static readonly Func WithNameAccessor; + private static readonly Func WithSemicolonTokenAccessor; + private static readonly Func, MemberDeclarationSyntax> WithExternsAccessor; + private static readonly Func, MemberDeclarationSyntax> WithUsingsAccessor; + private static readonly Func, MemberDeclarationSyntax> WithMembersAccessor; + + private readonly MemberDeclarationSyntax node; + + static FileScopedNamespaceDeclarationSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(FileScopedNamespaceDeclarationSyntaxWrapper)); + SemicolonTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(SemicolonToken)); + WithAttributeListsAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor>(WrappedType, nameof(AttributeLists)); + WithModifiersAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Modifiers)); + WithNamespaceKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(NamespaceKeyword)); + WithNameAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Name)); + WithSemicolonTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(SemicolonToken)); + WithExternsAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor>(WrappedType, nameof(Externs)); + WithUsingsAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor>(WrappedType, nameof(Usings)); + WithMembersAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor>(WrappedType, nameof(Members)); + } + + private FileScopedNamespaceDeclarationSyntaxWrapper(MemberDeclarationSyntax node) + { + this.node = node; + } + + public MemberDeclarationSyntax SyntaxNode => this.node; + + public SyntaxList AttributeLists + { + get + { + return this.SyntaxNode.AttributeLists(); + } + } + + public SyntaxTokenList Modifiers + { + get + { + return this.SyntaxNode.Modifiers(); + } + } + + public SyntaxToken NamespaceKeyword + { + get + { + return ((BaseNamespaceDeclarationSyntaxWrapper)this).NamespaceKeyword; + } + } + + public NameSyntax Name + { + get + { + return ((BaseNamespaceDeclarationSyntaxWrapper)this).Name; + } + } + + public SyntaxToken SemicolonToken + { + get + { + return SemicolonTokenAccessor(this.SyntaxNode); + } + } + + public SyntaxList Externs + { + get + { + return ((BaseNamespaceDeclarationSyntaxWrapper)this).Externs; + } + } + + public SyntaxList Usings + { + get + { + return ((BaseNamespaceDeclarationSyntaxWrapper)this).Usings; + } + } + + public SyntaxList Members + { + get + { + return ((BaseNamespaceDeclarationSyntaxWrapper)this).Members; + } + } + + public static explicit operator FileScopedNamespaceDeclarationSyntaxWrapper(BaseNamespaceDeclarationSyntaxWrapper node) + { + return (FileScopedNamespaceDeclarationSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator FileScopedNamespaceDeclarationSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new FileScopedNamespaceDeclarationSyntaxWrapper((MemberDeclarationSyntax)node); + } + + public static implicit operator BaseNamespaceDeclarationSyntaxWrapper(FileScopedNamespaceDeclarationSyntaxWrapper wrapper) + { + return BaseNamespaceDeclarationSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator MemberDeclarationSyntax(FileScopedNamespaceDeclarationSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public FileScopedNamespaceDeclarationSyntaxWrapper WithAttributeLists(SyntaxList attributeLists) + { + return new FileScopedNamespaceDeclarationSyntaxWrapper(WithAttributeListsAccessor(this.SyntaxNode, attributeLists)); + } + + public FileScopedNamespaceDeclarationSyntaxWrapper WithModifiers(SyntaxTokenList modifiers) + { + return new FileScopedNamespaceDeclarationSyntaxWrapper(WithModifiersAccessor(this.SyntaxNode, modifiers)); + } + + public FileScopedNamespaceDeclarationSyntaxWrapper WithNamespaceKeyword(SyntaxToken namespaceKeyword) + { + return new FileScopedNamespaceDeclarationSyntaxWrapper(WithNamespaceKeywordAccessor(this.SyntaxNode, namespaceKeyword)); + } + + public FileScopedNamespaceDeclarationSyntaxWrapper WithName(NameSyntax name) + { + return new FileScopedNamespaceDeclarationSyntaxWrapper(WithNameAccessor(this.SyntaxNode, name)); + } + + public FileScopedNamespaceDeclarationSyntaxWrapper WithSemicolonToken(SyntaxToken semicolonToken) + { + return new FileScopedNamespaceDeclarationSyntaxWrapper(WithSemicolonTokenAccessor(this.SyntaxNode, semicolonToken)); + } + + public FileScopedNamespaceDeclarationSyntaxWrapper WithExterns(SyntaxList externs) + { + return new FileScopedNamespaceDeclarationSyntaxWrapper(WithExternsAccessor(this.SyntaxNode, externs)); + } + + public FileScopedNamespaceDeclarationSyntaxWrapper WithUsings(SyntaxList usings) + { + return new FileScopedNamespaceDeclarationSyntaxWrapper(WithUsingsAccessor(this.SyntaxNode, usings)); + } + + public FileScopedNamespaceDeclarationSyntaxWrapper WithMembers(SyntaxList members) + { + return new FileScopedNamespaceDeclarationSyntaxWrapper(WithMembersAccessor(this.SyntaxNode, members)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ForEachVariableStatementSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ForEachVariableStatementSyntaxWrapper.g.cs similarity index 78% rename from StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ForEachVariableStatementSyntaxWrapper.cs rename to StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ForEachVariableStatementSyntaxWrapper.g.cs index 4c3a11bc9..49c71ed60 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ForEachVariableStatementSyntaxWrapper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ForEachVariableStatementSyntaxWrapper.g.cs @@ -1,18 +1,22 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Lightup { using System; + using System.Collections.Immutable; using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; - internal struct ForEachVariableStatementSyntaxWrapper : ISyntaxWrapper + internal readonly partial struct ForEachVariableStatementSyntaxWrapper : ISyntaxWrapper { internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax"; private static readonly Type WrappedType; private static readonly Func VariableAccessor; + private static readonly Func, StatementSyntax> WithAttributeListsAccessor; + private static readonly Func WithAwaitKeywordAccessor; private static readonly Func WithForEachKeywordAccessor; private static readonly Func WithOpenParenTokenAccessor; private static readonly Func WithVariableAccessor; @@ -25,8 +29,10 @@ internal struct ForEachVariableStatementSyntaxWrapper : ISyntaxWrapper(WrappedType, nameof(Variable)); + WithAttributeListsAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor>(WrappedType, nameof(AttributeLists)); + WithAwaitKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(AwaitKeyword)); WithForEachKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(ForEachKeyword)); WithOpenParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(OpenParenToken)); WithVariableAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Variable)); @@ -43,6 +49,22 @@ private ForEachVariableStatementSyntaxWrapper(StatementSyntax node) public StatementSyntax SyntaxNode => this.node; + public SyntaxList AttributeLists + { + get + { + return this.SyntaxNode.AttributeLists(); + } + } + + public SyntaxToken AwaitKeyword + { + get + { + return ((CommonForEachStatementSyntaxWrapper)this).AwaitKeyword; + } + } + public SyntaxToken ForEachKeyword { get @@ -108,7 +130,7 @@ public static explicit operator ForEachVariableStatementSyntaxWrapper(SyntaxNode { if (node == null) { - return default(ForEachVariableStatementSyntaxWrapper); + return default; } if (!IsInstance(node)) @@ -134,6 +156,16 @@ public static bool IsInstance(SyntaxNode node) return node != null && LightupHelpers.CanWrapNode(node, WrappedType); } + public ForEachVariableStatementSyntaxWrapper WithAttributeLists(SyntaxList attributeLists) + { + return new ForEachVariableStatementSyntaxWrapper(WithAttributeListsAccessor(this.SyntaxNode, attributeLists)); + } + + public ForEachVariableStatementSyntaxWrapper WithAwaitKeyword(SyntaxToken awaitKeyword) + { + return new ForEachVariableStatementSyntaxWrapper(WithAwaitKeywordAccessor(this.SyntaxNode, awaitKeyword)); + } + public ForEachVariableStatementSyntaxWrapper WithForEachKeyword(SyntaxToken forEachKeyword) { return new ForEachVariableStatementSyntaxWrapper(WithForEachKeywordAccessor(this.SyntaxNode, forEachKeyword)); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/FunctionPointerCallingConventionSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/FunctionPointerCallingConventionSyntaxWrapper.g.cs new file mode 100644 index 000000000..99b4ba222 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/FunctionPointerCallingConventionSyntaxWrapper.g.cs @@ -0,0 +1,91 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct FunctionPointerCallingConventionSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.FunctionPointerCallingConventionSyntax"; + private static readonly Type WrappedType; + + private static readonly Func ManagedOrUnmanagedKeywordAccessor; + private static readonly Func UnmanagedCallingConventionListAccessor; + private static readonly Func WithManagedOrUnmanagedKeywordAccessor; + private static readonly Func WithUnmanagedCallingConventionListAccessor; + + private readonly CSharpSyntaxNode node; + + static FunctionPointerCallingConventionSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(FunctionPointerCallingConventionSyntaxWrapper)); + ManagedOrUnmanagedKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(ManagedOrUnmanagedKeyword)); + UnmanagedCallingConventionListAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(UnmanagedCallingConventionList)); + WithManagedOrUnmanagedKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(ManagedOrUnmanagedKeyword)); + WithUnmanagedCallingConventionListAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(UnmanagedCallingConventionList)); + } + + private FunctionPointerCallingConventionSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public SyntaxToken ManagedOrUnmanagedKeyword + { + get + { + return ManagedOrUnmanagedKeywordAccessor(this.SyntaxNode); + } + } + + public FunctionPointerUnmanagedCallingConventionListSyntaxWrapper UnmanagedCallingConventionList + { + get + { + return (FunctionPointerUnmanagedCallingConventionListSyntaxWrapper)UnmanagedCallingConventionListAccessor(this.SyntaxNode); + } + } + + public static explicit operator FunctionPointerCallingConventionSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new FunctionPointerCallingConventionSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator CSharpSyntaxNode(FunctionPointerCallingConventionSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public FunctionPointerCallingConventionSyntaxWrapper WithManagedOrUnmanagedKeyword(SyntaxToken managedOrUnmanagedKeyword) + { + return new FunctionPointerCallingConventionSyntaxWrapper(WithManagedOrUnmanagedKeywordAccessor(this.SyntaxNode, managedOrUnmanagedKeyword)); + } + + public FunctionPointerCallingConventionSyntaxWrapper WithUnmanagedCallingConventionList(FunctionPointerUnmanagedCallingConventionListSyntaxWrapper unmanagedCallingConventionList) + { + return new FunctionPointerCallingConventionSyntaxWrapper(WithUnmanagedCallingConventionListAccessor(this.SyntaxNode, unmanagedCallingConventionList)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/FunctionPointerParameterListSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/FunctionPointerParameterListSyntaxWrapper.g.cs new file mode 100644 index 000000000..f20723c86 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/FunctionPointerParameterListSyntaxWrapper.g.cs @@ -0,0 +1,108 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct FunctionPointerParameterListSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.FunctionPointerParameterListSyntax"; + private static readonly Type WrappedType; + + private static readonly Func LessThanTokenAccessor; + private static readonly Func> ParametersAccessor; + private static readonly Func GreaterThanTokenAccessor; + private static readonly Func WithLessThanTokenAccessor; + private static readonly Func, CSharpSyntaxNode> WithParametersAccessor; + private static readonly Func WithGreaterThanTokenAccessor; + + private readonly CSharpSyntaxNode node; + + static FunctionPointerParameterListSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(FunctionPointerParameterListSyntaxWrapper)); + LessThanTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(LessThanToken)); + ParametersAccessor = LightupHelpers.CreateSeparatedSyntaxListPropertyAccessor(WrappedType, nameof(Parameters)); + GreaterThanTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(GreaterThanToken)); + WithLessThanTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(LessThanToken)); + WithParametersAccessor = LightupHelpers.CreateSeparatedSyntaxListWithPropertyAccessor(WrappedType, nameof(Parameters)); + WithGreaterThanTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(GreaterThanToken)); + } + + private FunctionPointerParameterListSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public SyntaxToken LessThanToken + { + get + { + return LessThanTokenAccessor(this.SyntaxNode); + } + } + + public SeparatedSyntaxListWrapper Parameters + { + get + { + return ParametersAccessor(this.SyntaxNode); + } + } + + public SyntaxToken GreaterThanToken + { + get + { + return GreaterThanTokenAccessor(this.SyntaxNode); + } + } + + public static explicit operator FunctionPointerParameterListSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new FunctionPointerParameterListSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator CSharpSyntaxNode(FunctionPointerParameterListSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public FunctionPointerParameterListSyntaxWrapper WithLessThanToken(SyntaxToken lessThanToken) + { + return new FunctionPointerParameterListSyntaxWrapper(WithLessThanTokenAccessor(this.SyntaxNode, lessThanToken)); + } + + public FunctionPointerParameterListSyntaxWrapper WithParameters(SeparatedSyntaxListWrapper parameters) + { + return new FunctionPointerParameterListSyntaxWrapper(WithParametersAccessor(this.SyntaxNode, parameters)); + } + + public FunctionPointerParameterListSyntaxWrapper WithGreaterThanToken(SyntaxToken greaterThanToken) + { + return new FunctionPointerParameterListSyntaxWrapper(WithGreaterThanTokenAccessor(this.SyntaxNode, greaterThanToken)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/FunctionPointerParameterSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/FunctionPointerParameterSyntaxWrapper.g.cs new file mode 100644 index 000000000..46968ca70 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/FunctionPointerParameterSyntaxWrapper.g.cs @@ -0,0 +1,111 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct FunctionPointerParameterSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.FunctionPointerParameterSyntax"; + private static readonly Type WrappedType; + private static readonly Func, CSharpSyntaxNode> WithAttributeListsAccessor; + private static readonly Func WithModifiersAccessor; + private static readonly Func WithTypeAccessor; + + private readonly CSharpSyntaxNode node; + + static FunctionPointerParameterSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(FunctionPointerParameterSyntaxWrapper)); + WithAttributeListsAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor>(WrappedType, nameof(AttributeLists)); + WithModifiersAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Modifiers)); + WithTypeAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Type)); + } + + private FunctionPointerParameterSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public SyntaxList AttributeLists + { + get + { + return ((BaseParameterSyntaxWrapper)this).AttributeLists; + } + } + + public SyntaxTokenList Modifiers + { + get + { + return ((BaseParameterSyntaxWrapper)this).Modifiers; + } + } + + public TypeSyntax Type + { + get + { + return ((BaseParameterSyntaxWrapper)this).Type; + } + } + + public static explicit operator FunctionPointerParameterSyntaxWrapper(BaseParameterSyntaxWrapper node) + { + return (FunctionPointerParameterSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator FunctionPointerParameterSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new FunctionPointerParameterSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator BaseParameterSyntaxWrapper(FunctionPointerParameterSyntaxWrapper wrapper) + { + return BaseParameterSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator CSharpSyntaxNode(FunctionPointerParameterSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public FunctionPointerParameterSyntaxWrapper WithAttributeLists(SyntaxList attributeLists) + { + return new FunctionPointerParameterSyntaxWrapper(WithAttributeListsAccessor(this.SyntaxNode, attributeLists)); + } + + public FunctionPointerParameterSyntaxWrapper WithModifiers(SyntaxTokenList modifiers) + { + return new FunctionPointerParameterSyntaxWrapper(WithModifiersAccessor(this.SyntaxNode, modifiers)); + } + + public FunctionPointerParameterSyntaxWrapper WithType(TypeSyntax type) + { + return new FunctionPointerParameterSyntaxWrapper(WithTypeAccessor(this.SyntaxNode, type)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/FunctionPointerTypeSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/FunctionPointerTypeSyntaxWrapper.g.cs new file mode 100644 index 000000000..5d1cb86b5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/FunctionPointerTypeSyntaxWrapper.g.cs @@ -0,0 +1,125 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct FunctionPointerTypeSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.FunctionPointerTypeSyntax"; + private static readonly Type WrappedType; + + private static readonly Func DelegateKeywordAccessor; + private static readonly Func AsteriskTokenAccessor; + private static readonly Func CallingConventionAccessor; + private static readonly Func ParameterListAccessor; + private static readonly Func WithDelegateKeywordAccessor; + private static readonly Func WithAsteriskTokenAccessor; + private static readonly Func WithCallingConventionAccessor; + private static readonly Func WithParameterListAccessor; + + private readonly TypeSyntax node; + + static FunctionPointerTypeSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(FunctionPointerTypeSyntaxWrapper)); + DelegateKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(DelegateKeyword)); + AsteriskTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(AsteriskToken)); + CallingConventionAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(CallingConvention)); + ParameterListAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(ParameterList)); + WithDelegateKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(DelegateKeyword)); + WithAsteriskTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(AsteriskToken)); + WithCallingConventionAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(CallingConvention)); + WithParameterListAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(ParameterList)); + } + + private FunctionPointerTypeSyntaxWrapper(TypeSyntax node) + { + this.node = node; + } + + public TypeSyntax SyntaxNode => this.node; + + public SyntaxToken DelegateKeyword + { + get + { + return DelegateKeywordAccessor(this.SyntaxNode); + } + } + + public SyntaxToken AsteriskToken + { + get + { + return AsteriskTokenAccessor(this.SyntaxNode); + } + } + + public FunctionPointerCallingConventionSyntaxWrapper CallingConvention + { + get + { + return (FunctionPointerCallingConventionSyntaxWrapper)CallingConventionAccessor(this.SyntaxNode); + } + } + + public FunctionPointerParameterListSyntaxWrapper ParameterList + { + get + { + return (FunctionPointerParameterListSyntaxWrapper)ParameterListAccessor(this.SyntaxNode); + } + } + + public static explicit operator FunctionPointerTypeSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new FunctionPointerTypeSyntaxWrapper((TypeSyntax)node); + } + + public static implicit operator TypeSyntax(FunctionPointerTypeSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public FunctionPointerTypeSyntaxWrapper WithDelegateKeyword(SyntaxToken delegateKeyword) + { + return new FunctionPointerTypeSyntaxWrapper(WithDelegateKeywordAccessor(this.SyntaxNode, delegateKeyword)); + } + + public FunctionPointerTypeSyntaxWrapper WithAsteriskToken(SyntaxToken asteriskToken) + { + return new FunctionPointerTypeSyntaxWrapper(WithAsteriskTokenAccessor(this.SyntaxNode, asteriskToken)); + } + + public FunctionPointerTypeSyntaxWrapper WithCallingConvention(FunctionPointerCallingConventionSyntaxWrapper callingConvention) + { + return new FunctionPointerTypeSyntaxWrapper(WithCallingConventionAccessor(this.SyntaxNode, callingConvention)); + } + + public FunctionPointerTypeSyntaxWrapper WithParameterList(FunctionPointerParameterListSyntaxWrapper parameterList) + { + return new FunctionPointerTypeSyntaxWrapper(WithParameterListAccessor(this.SyntaxNode, parameterList)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/FunctionPointerUnmanagedCallingConventionListSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/FunctionPointerUnmanagedCallingConventionListSyntaxWrapper.g.cs new file mode 100644 index 000000000..d4660617e --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/FunctionPointerUnmanagedCallingConventionListSyntaxWrapper.g.cs @@ -0,0 +1,108 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct FunctionPointerUnmanagedCallingConventionListSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.FunctionPointerUnmanagedCallingConventionListSyntax"; + private static readonly Type WrappedType; + + private static readonly Func OpenBracketTokenAccessor; + private static readonly Func> CallingConventionsAccessor; + private static readonly Func CloseBracketTokenAccessor; + private static readonly Func WithOpenBracketTokenAccessor; + private static readonly Func, CSharpSyntaxNode> WithCallingConventionsAccessor; + private static readonly Func WithCloseBracketTokenAccessor; + + private readonly CSharpSyntaxNode node; + + static FunctionPointerUnmanagedCallingConventionListSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(FunctionPointerUnmanagedCallingConventionListSyntaxWrapper)); + OpenBracketTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(OpenBracketToken)); + CallingConventionsAccessor = LightupHelpers.CreateSeparatedSyntaxListPropertyAccessor(WrappedType, nameof(CallingConventions)); + CloseBracketTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(CloseBracketToken)); + WithOpenBracketTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(OpenBracketToken)); + WithCallingConventionsAccessor = LightupHelpers.CreateSeparatedSyntaxListWithPropertyAccessor(WrappedType, nameof(CallingConventions)); + WithCloseBracketTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(CloseBracketToken)); + } + + private FunctionPointerUnmanagedCallingConventionListSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public SyntaxToken OpenBracketToken + { + get + { + return OpenBracketTokenAccessor(this.SyntaxNode); + } + } + + public SeparatedSyntaxListWrapper CallingConventions + { + get + { + return CallingConventionsAccessor(this.SyntaxNode); + } + } + + public SyntaxToken CloseBracketToken + { + get + { + return CloseBracketTokenAccessor(this.SyntaxNode); + } + } + + public static explicit operator FunctionPointerUnmanagedCallingConventionListSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new FunctionPointerUnmanagedCallingConventionListSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator CSharpSyntaxNode(FunctionPointerUnmanagedCallingConventionListSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public FunctionPointerUnmanagedCallingConventionListSyntaxWrapper WithOpenBracketToken(SyntaxToken openBracketToken) + { + return new FunctionPointerUnmanagedCallingConventionListSyntaxWrapper(WithOpenBracketTokenAccessor(this.SyntaxNode, openBracketToken)); + } + + public FunctionPointerUnmanagedCallingConventionListSyntaxWrapper WithCallingConventions(SeparatedSyntaxListWrapper callingConventions) + { + return new FunctionPointerUnmanagedCallingConventionListSyntaxWrapper(WithCallingConventionsAccessor(this.SyntaxNode, callingConventions)); + } + + public FunctionPointerUnmanagedCallingConventionListSyntaxWrapper WithCloseBracketToken(SyntaxToken closeBracketToken) + { + return new FunctionPointerUnmanagedCallingConventionListSyntaxWrapper(WithCloseBracketTokenAccessor(this.SyntaxNode, closeBracketToken)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/FunctionPointerUnmanagedCallingConventionSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/FunctionPointerUnmanagedCallingConventionSyntaxWrapper.g.cs new file mode 100644 index 000000000..da6a24f7f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/FunctionPointerUnmanagedCallingConventionSyntaxWrapper.g.cs @@ -0,0 +1,74 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct FunctionPointerUnmanagedCallingConventionSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.FunctionPointerUnmanagedCallingConventionSyntax"; + private static readonly Type WrappedType; + + private static readonly Func NameAccessor; + private static readonly Func WithNameAccessor; + + private readonly CSharpSyntaxNode node; + + static FunctionPointerUnmanagedCallingConventionSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(FunctionPointerUnmanagedCallingConventionSyntaxWrapper)); + NameAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Name)); + WithNameAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Name)); + } + + private FunctionPointerUnmanagedCallingConventionSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public SyntaxToken Name + { + get + { + return NameAccessor(this.SyntaxNode); + } + } + + public static explicit operator FunctionPointerUnmanagedCallingConventionSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new FunctionPointerUnmanagedCallingConventionSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator CSharpSyntaxNode(FunctionPointerUnmanagedCallingConventionSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public FunctionPointerUnmanagedCallingConventionSyntaxWrapper WithName(SyntaxToken name) + { + return new FunctionPointerUnmanagedCallingConventionSyntaxWrapper(WithNameAccessor(this.SyntaxNode, name)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ImplicitObjectCreationExpressionSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ImplicitObjectCreationExpressionSyntaxWrapper.g.cs new file mode 100644 index 000000000..a5c2dab62 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ImplicitObjectCreationExpressionSyntaxWrapper.g.cs @@ -0,0 +1,111 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct ImplicitObjectCreationExpressionSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitObjectCreationExpressionSyntax"; + private static readonly Type WrappedType; + private static readonly Func WithNewKeywordAccessor; + private static readonly Func WithArgumentListAccessor; + private static readonly Func WithInitializerAccessor; + + private readonly ExpressionSyntax node; + + static ImplicitObjectCreationExpressionSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(ImplicitObjectCreationExpressionSyntaxWrapper)); + WithNewKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(NewKeyword)); + WithArgumentListAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(ArgumentList)); + WithInitializerAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Initializer)); + } + + private ImplicitObjectCreationExpressionSyntaxWrapper(ExpressionSyntax node) + { + this.node = node; + } + + public ExpressionSyntax SyntaxNode => this.node; + + public SyntaxToken NewKeyword + { + get + { + return ((BaseObjectCreationExpressionSyntaxWrapper)this).NewKeyword; + } + } + + public ArgumentListSyntax ArgumentList + { + get + { + return ((BaseObjectCreationExpressionSyntaxWrapper)this).ArgumentList; + } + } + + public InitializerExpressionSyntax Initializer + { + get + { + return ((BaseObjectCreationExpressionSyntaxWrapper)this).Initializer; + } + } + + public static explicit operator ImplicitObjectCreationExpressionSyntaxWrapper(BaseObjectCreationExpressionSyntaxWrapper node) + { + return (ImplicitObjectCreationExpressionSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator ImplicitObjectCreationExpressionSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ImplicitObjectCreationExpressionSyntaxWrapper((ExpressionSyntax)node); + } + + public static implicit operator BaseObjectCreationExpressionSyntaxWrapper(ImplicitObjectCreationExpressionSyntaxWrapper wrapper) + { + return BaseObjectCreationExpressionSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator ExpressionSyntax(ImplicitObjectCreationExpressionSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public ImplicitObjectCreationExpressionSyntaxWrapper WithNewKeyword(SyntaxToken newKeyword) + { + return new ImplicitObjectCreationExpressionSyntaxWrapper(WithNewKeywordAccessor(this.SyntaxNode, newKeyword)); + } + + public ImplicitObjectCreationExpressionSyntaxWrapper WithArgumentList(ArgumentListSyntax argumentList) + { + return new ImplicitObjectCreationExpressionSyntaxWrapper(WithArgumentListAccessor(this.SyntaxNode, argumentList)); + } + + public ImplicitObjectCreationExpressionSyntaxWrapper WithInitializer(InitializerExpressionSyntax initializer) + { + return new ImplicitObjectCreationExpressionSyntaxWrapper(WithInitializerAccessor(this.SyntaxNode, initializer)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ImplicitStackAllocArrayCreationExpressionSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ImplicitStackAllocArrayCreationExpressionSyntaxWrapper.g.cs new file mode 100644 index 000000000..0cdf569f2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ImplicitStackAllocArrayCreationExpressionSyntaxWrapper.g.cs @@ -0,0 +1,125 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct ImplicitStackAllocArrayCreationExpressionSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax"; + private static readonly Type WrappedType; + + private static readonly Func StackAllocKeywordAccessor; + private static readonly Func OpenBracketTokenAccessor; + private static readonly Func CloseBracketTokenAccessor; + private static readonly Func InitializerAccessor; + private static readonly Func WithStackAllocKeywordAccessor; + private static readonly Func WithOpenBracketTokenAccessor; + private static readonly Func WithCloseBracketTokenAccessor; + private static readonly Func WithInitializerAccessor; + + private readonly ExpressionSyntax node; + + static ImplicitStackAllocArrayCreationExpressionSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(ImplicitStackAllocArrayCreationExpressionSyntaxWrapper)); + StackAllocKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(StackAllocKeyword)); + OpenBracketTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(OpenBracketToken)); + CloseBracketTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(CloseBracketToken)); + InitializerAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Initializer)); + WithStackAllocKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(StackAllocKeyword)); + WithOpenBracketTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(OpenBracketToken)); + WithCloseBracketTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(CloseBracketToken)); + WithInitializerAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Initializer)); + } + + private ImplicitStackAllocArrayCreationExpressionSyntaxWrapper(ExpressionSyntax node) + { + this.node = node; + } + + public ExpressionSyntax SyntaxNode => this.node; + + public SyntaxToken StackAllocKeyword + { + get + { + return StackAllocKeywordAccessor(this.SyntaxNode); + } + } + + public SyntaxToken OpenBracketToken + { + get + { + return OpenBracketTokenAccessor(this.SyntaxNode); + } + } + + public SyntaxToken CloseBracketToken + { + get + { + return CloseBracketTokenAccessor(this.SyntaxNode); + } + } + + public InitializerExpressionSyntax Initializer + { + get + { + return InitializerAccessor(this.SyntaxNode); + } + } + + public static explicit operator ImplicitStackAllocArrayCreationExpressionSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ImplicitStackAllocArrayCreationExpressionSyntaxWrapper((ExpressionSyntax)node); + } + + public static implicit operator ExpressionSyntax(ImplicitStackAllocArrayCreationExpressionSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public ImplicitStackAllocArrayCreationExpressionSyntaxWrapper WithStackAllocKeyword(SyntaxToken stackAllocKeyword) + { + return new ImplicitStackAllocArrayCreationExpressionSyntaxWrapper(WithStackAllocKeywordAccessor(this.SyntaxNode, stackAllocKeyword)); + } + + public ImplicitStackAllocArrayCreationExpressionSyntaxWrapper WithOpenBracketToken(SyntaxToken openBracketToken) + { + return new ImplicitStackAllocArrayCreationExpressionSyntaxWrapper(WithOpenBracketTokenAccessor(this.SyntaxNode, openBracketToken)); + } + + public ImplicitStackAllocArrayCreationExpressionSyntaxWrapper WithCloseBracketToken(SyntaxToken closeBracketToken) + { + return new ImplicitStackAllocArrayCreationExpressionSyntaxWrapper(WithCloseBracketTokenAccessor(this.SyntaxNode, closeBracketToken)); + } + + public ImplicitStackAllocArrayCreationExpressionSyntaxWrapper WithInitializer(InitializerExpressionSyntax initializer) + { + return new ImplicitStackAllocArrayCreationExpressionSyntaxWrapper(WithInitializerAccessor(this.SyntaxNode, initializer)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/IsPatternExpressionSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/IsPatternExpressionSyntaxWrapper.g.cs similarity index 90% rename from StyleCop.Analyzers/StyleCop.Analyzers/Lightup/IsPatternExpressionSyntaxWrapper.cs rename to StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/IsPatternExpressionSyntaxWrapper.g.cs index 7e1e80d8d..d71a757a3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/IsPatternExpressionSyntaxWrapper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/IsPatternExpressionSyntaxWrapper.g.cs @@ -1,14 +1,15 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Lightup { using System; + using System.Collections.Immutable; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; - internal struct IsPatternExpressionSyntaxWrapper : ISyntaxWrapper + internal readonly partial struct IsPatternExpressionSyntaxWrapper : ISyntaxWrapper { internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.IsPatternExpressionSyntax"; private static readonly Type WrappedType; @@ -24,7 +25,7 @@ internal struct IsPatternExpressionSyntaxWrapper : ISyntaxWrapper(WrappedType, nameof(Expression)); IsKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(IsKeyword)); PatternAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Pattern)); @@ -68,7 +69,7 @@ public static explicit operator IsPatternExpressionSyntaxWrapper(SyntaxNode node { if (node == null) { - return default(IsPatternExpressionSyntaxWrapper); + return default; } if (!IsInstance(node)) @@ -101,7 +102,7 @@ public IsPatternExpressionSyntaxWrapper WithIsKeyword(SyntaxToken isKeyword) public IsPatternExpressionSyntaxWrapper WithPattern(PatternSyntaxWrapper pattern) { - return new IsPatternExpressionSyntaxWrapper(WithPatternAccessor(this.SyntaxNode, pattern.SyntaxNode)); + return new IsPatternExpressionSyntaxWrapper(WithPatternAccessor(this.SyntaxNode, pattern)); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/LineDirectivePositionSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/LineDirectivePositionSyntaxWrapper.g.cs new file mode 100644 index 000000000..c2a7cca4d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/LineDirectivePositionSyntaxWrapper.g.cs @@ -0,0 +1,142 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct LineDirectivePositionSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.LineDirectivePositionSyntax"; + private static readonly Type WrappedType; + + private static readonly Func OpenParenTokenAccessor; + private static readonly Func LineAccessor; + private static readonly Func CommaTokenAccessor; + private static readonly Func CharacterAccessor; + private static readonly Func CloseParenTokenAccessor; + private static readonly Func WithOpenParenTokenAccessor; + private static readonly Func WithLineAccessor; + private static readonly Func WithCommaTokenAccessor; + private static readonly Func WithCharacterAccessor; + private static readonly Func WithCloseParenTokenAccessor; + + private readonly CSharpSyntaxNode node; + + static LineDirectivePositionSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(LineDirectivePositionSyntaxWrapper)); + OpenParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(OpenParenToken)); + LineAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Line)); + CommaTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(CommaToken)); + CharacterAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Character)); + CloseParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(CloseParenToken)); + WithOpenParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(OpenParenToken)); + WithLineAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Line)); + WithCommaTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(CommaToken)); + WithCharacterAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Character)); + WithCloseParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(CloseParenToken)); + } + + private LineDirectivePositionSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public SyntaxToken OpenParenToken + { + get + { + return OpenParenTokenAccessor(this.SyntaxNode); + } + } + + public SyntaxToken Line + { + get + { + return LineAccessor(this.SyntaxNode); + } + } + + public SyntaxToken CommaToken + { + get + { + return CommaTokenAccessor(this.SyntaxNode); + } + } + + public SyntaxToken Character + { + get + { + return CharacterAccessor(this.SyntaxNode); + } + } + + public SyntaxToken CloseParenToken + { + get + { + return CloseParenTokenAccessor(this.SyntaxNode); + } + } + + public static explicit operator LineDirectivePositionSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new LineDirectivePositionSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator CSharpSyntaxNode(LineDirectivePositionSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public LineDirectivePositionSyntaxWrapper WithOpenParenToken(SyntaxToken openParenToken) + { + return new LineDirectivePositionSyntaxWrapper(WithOpenParenTokenAccessor(this.SyntaxNode, openParenToken)); + } + + public LineDirectivePositionSyntaxWrapper WithLine(SyntaxToken line) + { + return new LineDirectivePositionSyntaxWrapper(WithLineAccessor(this.SyntaxNode, line)); + } + + public LineDirectivePositionSyntaxWrapper WithCommaToken(SyntaxToken commaToken) + { + return new LineDirectivePositionSyntaxWrapper(WithCommaTokenAccessor(this.SyntaxNode, commaToken)); + } + + public LineDirectivePositionSyntaxWrapper WithCharacter(SyntaxToken character) + { + return new LineDirectivePositionSyntaxWrapper(WithCharacterAccessor(this.SyntaxNode, character)); + } + + public LineDirectivePositionSyntaxWrapper WithCloseParenToken(SyntaxToken closeParenToken) + { + return new LineDirectivePositionSyntaxWrapper(WithCloseParenTokenAccessor(this.SyntaxNode, closeParenToken)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/LineOrSpanDirectiveTriviaSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/LineOrSpanDirectiveTriviaSyntaxWrapper.g.cs new file mode 100644 index 000000000..340bc01ed --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/LineOrSpanDirectiveTriviaSyntaxWrapper.g.cs @@ -0,0 +1,96 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct LineOrSpanDirectiveTriviaSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.LineOrSpanDirectiveTriviaSyntax"; + private static readonly Type WrappedType; + + private static readonly Func LineKeywordAccessor; + private static readonly Func FileAccessor; + private static readonly Func WithLineKeywordAccessor; + private static readonly Func WithFileAccessor; + + private readonly DirectiveTriviaSyntax node; + + static LineOrSpanDirectiveTriviaSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(LineOrSpanDirectiveTriviaSyntaxWrapper)); + LineKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(LineKeyword)); + FileAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(File)); + WithLineKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(LineKeyword)); + WithFileAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(File)); + } + + private LineOrSpanDirectiveTriviaSyntaxWrapper(DirectiveTriviaSyntax node) + { + this.node = node; + } + + public DirectiveTriviaSyntax SyntaxNode => this.node; + + public SyntaxToken LineKeyword + { + get + { + return LineKeywordAccessor(this.SyntaxNode); + } + } + + public SyntaxToken File + { + get + { + return FileAccessor(this.SyntaxNode); + } + } + + public static explicit operator LineOrSpanDirectiveTriviaSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new LineOrSpanDirectiveTriviaSyntaxWrapper((DirectiveTriviaSyntax)node); + } + + public static implicit operator DirectiveTriviaSyntax(LineOrSpanDirectiveTriviaSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public LineOrSpanDirectiveTriviaSyntaxWrapper WithLineKeyword(SyntaxToken lineKeyword) + { + return new LineOrSpanDirectiveTriviaSyntaxWrapper(WithLineKeywordAccessor(this.SyntaxNode, lineKeyword)); + } + + public LineOrSpanDirectiveTriviaSyntaxWrapper WithFile(SyntaxToken file) + { + return new LineOrSpanDirectiveTriviaSyntaxWrapper(WithFileAccessor(this.SyntaxNode, file)); + } + + internal static LineOrSpanDirectiveTriviaSyntaxWrapper FromUpcast(DirectiveTriviaSyntax node) + { + return new LineOrSpanDirectiveTriviaSyntaxWrapper(node); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/LineSpanDirectiveTriviaSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/LineSpanDirectiveTriviaSyntaxWrapper.g.cs new file mode 100644 index 000000000..39b149b06 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/LineSpanDirectiveTriviaSyntaxWrapper.g.cs @@ -0,0 +1,210 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct LineSpanDirectiveTriviaSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.LineSpanDirectiveTriviaSyntax"; + private static readonly Type WrappedType; + + private static readonly Func StartAccessor; + private static readonly Func MinusTokenAccessor; + private static readonly Func EndAccessor; + private static readonly Func CharacterOffsetAccessor; + private static readonly Func WithHashTokenAccessor; + private static readonly Func WithLineKeywordAccessor; + private static readonly Func WithStartAccessor; + private static readonly Func WithMinusTokenAccessor; + private static readonly Func WithEndAccessor; + private static readonly Func WithCharacterOffsetAccessor; + private static readonly Func WithFileAccessor; + private static readonly Func WithEndOfDirectiveTokenAccessor; + private static readonly Func WithIsActiveAccessor; + + private readonly DirectiveTriviaSyntax node; + + static LineSpanDirectiveTriviaSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(LineSpanDirectiveTriviaSyntaxWrapper)); + StartAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Start)); + MinusTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(MinusToken)); + EndAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(End)); + CharacterOffsetAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(CharacterOffset)); + WithHashTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(HashToken)); + WithLineKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(LineKeyword)); + WithStartAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Start)); + WithMinusTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(MinusToken)); + WithEndAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(End)); + WithCharacterOffsetAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(CharacterOffset)); + WithFileAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(File)); + WithEndOfDirectiveTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(EndOfDirectiveToken)); + WithIsActiveAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(IsActive)); + } + + private LineSpanDirectiveTriviaSyntaxWrapper(DirectiveTriviaSyntax node) + { + this.node = node; + } + + public DirectiveTriviaSyntax SyntaxNode => this.node; + + public SyntaxToken HashToken + { + get + { + return this.SyntaxNode.HashToken; + } + } + + public SyntaxToken LineKeyword + { + get + { + return ((LineOrSpanDirectiveTriviaSyntaxWrapper)this).LineKeyword; + } + } + + public LineDirectivePositionSyntaxWrapper Start + { + get + { + return (LineDirectivePositionSyntaxWrapper)StartAccessor(this.SyntaxNode); + } + } + + public SyntaxToken MinusToken + { + get + { + return MinusTokenAccessor(this.SyntaxNode); + } + } + + public LineDirectivePositionSyntaxWrapper End + { + get + { + return (LineDirectivePositionSyntaxWrapper)EndAccessor(this.SyntaxNode); + } + } + + public SyntaxToken CharacterOffset + { + get + { + return CharacterOffsetAccessor(this.SyntaxNode); + } + } + + public SyntaxToken File + { + get + { + return ((LineOrSpanDirectiveTriviaSyntaxWrapper)this).File; + } + } + + public SyntaxToken EndOfDirectiveToken + { + get + { + return this.SyntaxNode.EndOfDirectiveToken; + } + } + + public bool IsActive + { + get + { + return this.SyntaxNode.IsActive; + } + } + + public static explicit operator LineSpanDirectiveTriviaSyntaxWrapper(LineOrSpanDirectiveTriviaSyntaxWrapper node) + { + return (LineSpanDirectiveTriviaSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator LineSpanDirectiveTriviaSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new LineSpanDirectiveTriviaSyntaxWrapper((DirectiveTriviaSyntax)node); + } + + public static implicit operator LineOrSpanDirectiveTriviaSyntaxWrapper(LineSpanDirectiveTriviaSyntaxWrapper wrapper) + { + return LineOrSpanDirectiveTriviaSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator DirectiveTriviaSyntax(LineSpanDirectiveTriviaSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public LineSpanDirectiveTriviaSyntaxWrapper WithHashToken(SyntaxToken hashToken) + { + return new LineSpanDirectiveTriviaSyntaxWrapper(WithHashTokenAccessor(this.SyntaxNode, hashToken)); + } + + public LineSpanDirectiveTriviaSyntaxWrapper WithLineKeyword(SyntaxToken lineKeyword) + { + return new LineSpanDirectiveTriviaSyntaxWrapper(WithLineKeywordAccessor(this.SyntaxNode, lineKeyword)); + } + + public LineSpanDirectiveTriviaSyntaxWrapper WithStart(LineDirectivePositionSyntaxWrapper start) + { + return new LineSpanDirectiveTriviaSyntaxWrapper(WithStartAccessor(this.SyntaxNode, start)); + } + + public LineSpanDirectiveTriviaSyntaxWrapper WithMinusToken(SyntaxToken minusToken) + { + return new LineSpanDirectiveTriviaSyntaxWrapper(WithMinusTokenAccessor(this.SyntaxNode, minusToken)); + } + + public LineSpanDirectiveTriviaSyntaxWrapper WithEnd(LineDirectivePositionSyntaxWrapper end) + { + return new LineSpanDirectiveTriviaSyntaxWrapper(WithEndAccessor(this.SyntaxNode, end)); + } + + public LineSpanDirectiveTriviaSyntaxWrapper WithCharacterOffset(SyntaxToken characterOffset) + { + return new LineSpanDirectiveTriviaSyntaxWrapper(WithCharacterOffsetAccessor(this.SyntaxNode, characterOffset)); + } + + public LineSpanDirectiveTriviaSyntaxWrapper WithFile(SyntaxToken file) + { + return new LineSpanDirectiveTriviaSyntaxWrapper(WithFileAccessor(this.SyntaxNode, file)); + } + + public LineSpanDirectiveTriviaSyntaxWrapper WithEndOfDirectiveToken(SyntaxToken endOfDirectiveToken) + { + return new LineSpanDirectiveTriviaSyntaxWrapper(WithEndOfDirectiveTokenAccessor(this.SyntaxNode, endOfDirectiveToken)); + } + + public LineSpanDirectiveTriviaSyntaxWrapper WithIsActive(bool isActive) + { + return new LineSpanDirectiveTriviaSyntaxWrapper(WithIsActiveAccessor(this.SyntaxNode, isActive)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/LocalFunctionStatementSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/LocalFunctionStatementSyntaxWrapper.g.cs new file mode 100644 index 000000000..e1940b11c --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/LocalFunctionStatementSyntaxWrapper.g.cs @@ -0,0 +1,225 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct LocalFunctionStatementSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax"; + private static readonly Type WrappedType; + + private static readonly Func ModifiersAccessor; + private static readonly Func ReturnTypeAccessor; + private static readonly Func IdentifierAccessor; + private static readonly Func TypeParameterListAccessor; + private static readonly Func ParameterListAccessor; + private static readonly Func> ConstraintClausesAccessor; + private static readonly Func BodyAccessor; + private static readonly Func ExpressionBodyAccessor; + private static readonly Func SemicolonTokenAccessor; + private static readonly Func, StatementSyntax> WithAttributeListsAccessor; + private static readonly Func WithModifiersAccessor; + private static readonly Func WithReturnTypeAccessor; + private static readonly Func WithIdentifierAccessor; + private static readonly Func WithTypeParameterListAccessor; + private static readonly Func WithParameterListAccessor; + private static readonly Func, StatementSyntax> WithConstraintClausesAccessor; + private static readonly Func WithBodyAccessor; + private static readonly Func WithExpressionBodyAccessor; + private static readonly Func WithSemicolonTokenAccessor; + + private readonly StatementSyntax node; + + static LocalFunctionStatementSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(LocalFunctionStatementSyntaxWrapper)); + ModifiersAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Modifiers)); + ReturnTypeAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(ReturnType)); + IdentifierAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Identifier)); + TypeParameterListAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(TypeParameterList)); + ParameterListAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(ParameterList)); + ConstraintClausesAccessor = LightupHelpers.CreateSyntaxPropertyAccessor>(WrappedType, nameof(ConstraintClauses)); + BodyAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Body)); + ExpressionBodyAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(ExpressionBody)); + SemicolonTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(SemicolonToken)); + WithAttributeListsAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor>(WrappedType, nameof(AttributeLists)); + WithModifiersAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Modifiers)); + WithReturnTypeAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(ReturnType)); + WithIdentifierAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Identifier)); + WithTypeParameterListAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(TypeParameterList)); + WithParameterListAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(ParameterList)); + WithConstraintClausesAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor>(WrappedType, nameof(ConstraintClauses)); + WithBodyAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Body)); + WithExpressionBodyAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(ExpressionBody)); + WithSemicolonTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(SemicolonToken)); + } + + private LocalFunctionStatementSyntaxWrapper(StatementSyntax node) + { + this.node = node; + } + + public StatementSyntax SyntaxNode => this.node; + + public SyntaxList AttributeLists + { + get + { + return this.SyntaxNode.AttributeLists(); + } + } + + public SyntaxTokenList Modifiers + { + get + { + return ModifiersAccessor(this.SyntaxNode); + } + } + + public TypeSyntax ReturnType + { + get + { + return ReturnTypeAccessor(this.SyntaxNode); + } + } + + public SyntaxToken Identifier + { + get + { + return IdentifierAccessor(this.SyntaxNode); + } + } + + public TypeParameterListSyntax TypeParameterList + { + get + { + return TypeParameterListAccessor(this.SyntaxNode); + } + } + + public ParameterListSyntax ParameterList + { + get + { + return ParameterListAccessor(this.SyntaxNode); + } + } + + public SyntaxList ConstraintClauses + { + get + { + return ConstraintClausesAccessor(this.SyntaxNode); + } + } + + public BlockSyntax Body + { + get + { + return BodyAccessor(this.SyntaxNode); + } + } + + public ArrowExpressionClauseSyntax ExpressionBody + { + get + { + return ExpressionBodyAccessor(this.SyntaxNode); + } + } + + public SyntaxToken SemicolonToken + { + get + { + return SemicolonTokenAccessor(this.SyntaxNode); + } + } + + public static explicit operator LocalFunctionStatementSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new LocalFunctionStatementSyntaxWrapper((StatementSyntax)node); + } + + public static implicit operator StatementSyntax(LocalFunctionStatementSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public LocalFunctionStatementSyntaxWrapper WithAttributeLists(SyntaxList attributeLists) + { + return new LocalFunctionStatementSyntaxWrapper(WithAttributeListsAccessor(this.SyntaxNode, attributeLists)); + } + + public LocalFunctionStatementSyntaxWrapper WithModifiers(SyntaxTokenList modifiers) + { + return new LocalFunctionStatementSyntaxWrapper(WithModifiersAccessor(this.SyntaxNode, modifiers)); + } + + public LocalFunctionStatementSyntaxWrapper WithReturnType(TypeSyntax returnType) + { + return new LocalFunctionStatementSyntaxWrapper(WithReturnTypeAccessor(this.SyntaxNode, returnType)); + } + + public LocalFunctionStatementSyntaxWrapper WithIdentifier(SyntaxToken identifier) + { + return new LocalFunctionStatementSyntaxWrapper(WithIdentifierAccessor(this.SyntaxNode, identifier)); + } + + public LocalFunctionStatementSyntaxWrapper WithTypeParameterList(TypeParameterListSyntax typeParameterList) + { + return new LocalFunctionStatementSyntaxWrapper(WithTypeParameterListAccessor(this.SyntaxNode, typeParameterList)); + } + + public LocalFunctionStatementSyntaxWrapper WithParameterList(ParameterListSyntax parameterList) + { + return new LocalFunctionStatementSyntaxWrapper(WithParameterListAccessor(this.SyntaxNode, parameterList)); + } + + public LocalFunctionStatementSyntaxWrapper WithConstraintClauses(SyntaxList constraintClauses) + { + return new LocalFunctionStatementSyntaxWrapper(WithConstraintClausesAccessor(this.SyntaxNode, constraintClauses)); + } + + public LocalFunctionStatementSyntaxWrapper WithBody(BlockSyntax body) + { + return new LocalFunctionStatementSyntaxWrapper(WithBodyAccessor(this.SyntaxNode, body)); + } + + public LocalFunctionStatementSyntaxWrapper WithExpressionBody(ArrowExpressionClauseSyntax expressionBody) + { + return new LocalFunctionStatementSyntaxWrapper(WithExpressionBodyAccessor(this.SyntaxNode, expressionBody)); + } + + public LocalFunctionStatementSyntaxWrapper WithSemicolonToken(SyntaxToken semicolonToken) + { + return new LocalFunctionStatementSyntaxWrapper(WithSemicolonTokenAccessor(this.SyntaxNode, semicolonToken)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/NullableDirectiveTriviaSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/NullableDirectiveTriviaSyntaxWrapper.g.cs new file mode 100644 index 000000000..5c6bfd9d7 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/NullableDirectiveTriviaSyntaxWrapper.g.cs @@ -0,0 +1,153 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct NullableDirectiveTriviaSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax"; + private static readonly Type WrappedType; + + private static readonly Func NullableKeywordAccessor; + private static readonly Func SettingTokenAccessor; + private static readonly Func TargetTokenAccessor; + private static readonly Func WithHashTokenAccessor; + private static readonly Func WithNullableKeywordAccessor; + private static readonly Func WithSettingTokenAccessor; + private static readonly Func WithTargetTokenAccessor; + private static readonly Func WithEndOfDirectiveTokenAccessor; + private static readonly Func WithIsActiveAccessor; + + private readonly DirectiveTriviaSyntax node; + + static NullableDirectiveTriviaSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(NullableDirectiveTriviaSyntaxWrapper)); + NullableKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(NullableKeyword)); + SettingTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(SettingToken)); + TargetTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(TargetToken)); + WithHashTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(HashToken)); + WithNullableKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(NullableKeyword)); + WithSettingTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(SettingToken)); + WithTargetTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(TargetToken)); + WithEndOfDirectiveTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(EndOfDirectiveToken)); + WithIsActiveAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(IsActive)); + } + + private NullableDirectiveTriviaSyntaxWrapper(DirectiveTriviaSyntax node) + { + this.node = node; + } + + public DirectiveTriviaSyntax SyntaxNode => this.node; + + public SyntaxToken HashToken + { + get + { + return this.SyntaxNode.HashToken; + } + } + + public SyntaxToken NullableKeyword + { + get + { + return NullableKeywordAccessor(this.SyntaxNode); + } + } + + public SyntaxToken SettingToken + { + get + { + return SettingTokenAccessor(this.SyntaxNode); + } + } + + public SyntaxToken TargetToken + { + get + { + return TargetTokenAccessor(this.SyntaxNode); + } + } + + public SyntaxToken EndOfDirectiveToken + { + get + { + return this.SyntaxNode.EndOfDirectiveToken; + } + } + + public bool IsActive + { + get + { + return this.SyntaxNode.IsActive; + } + } + + public static explicit operator NullableDirectiveTriviaSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new NullableDirectiveTriviaSyntaxWrapper((DirectiveTriviaSyntax)node); + } + + public static implicit operator DirectiveTriviaSyntax(NullableDirectiveTriviaSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public NullableDirectiveTriviaSyntaxWrapper WithHashToken(SyntaxToken hashToken) + { + return new NullableDirectiveTriviaSyntaxWrapper(WithHashTokenAccessor(this.SyntaxNode, hashToken)); + } + + public NullableDirectiveTriviaSyntaxWrapper WithNullableKeyword(SyntaxToken nullableKeyword) + { + return new NullableDirectiveTriviaSyntaxWrapper(WithNullableKeywordAccessor(this.SyntaxNode, nullableKeyword)); + } + + public NullableDirectiveTriviaSyntaxWrapper WithSettingToken(SyntaxToken settingToken) + { + return new NullableDirectiveTriviaSyntaxWrapper(WithSettingTokenAccessor(this.SyntaxNode, settingToken)); + } + + public NullableDirectiveTriviaSyntaxWrapper WithTargetToken(SyntaxToken targetToken) + { + return new NullableDirectiveTriviaSyntaxWrapper(WithTargetTokenAccessor(this.SyntaxNode, targetToken)); + } + + public NullableDirectiveTriviaSyntaxWrapper WithEndOfDirectiveToken(SyntaxToken endOfDirectiveToken) + { + return new NullableDirectiveTriviaSyntaxWrapper(WithEndOfDirectiveTokenAccessor(this.SyntaxNode, endOfDirectiveToken)); + } + + public NullableDirectiveTriviaSyntaxWrapper WithIsActive(bool isActive) + { + return new NullableDirectiveTriviaSyntaxWrapper(WithIsActiveAccessor(this.SyntaxNode, isActive)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ParenthesizedPatternSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ParenthesizedPatternSyntaxWrapper.g.cs new file mode 100644 index 000000000..2ebc2af84 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ParenthesizedPatternSyntaxWrapper.g.cs @@ -0,0 +1,128 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct ParenthesizedPatternSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedPatternSyntax"; + private static readonly Type WrappedType; + + private static readonly Func OpenParenTokenAccessor; + private static readonly Func PatternAccessor; + private static readonly Func CloseParenTokenAccessor; + private static readonly Func WithOpenParenTokenAccessor; + private static readonly Func WithPatternAccessor; + private static readonly Func WithCloseParenTokenAccessor; + + private readonly CSharpSyntaxNode node; + + static ParenthesizedPatternSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(ParenthesizedPatternSyntaxWrapper)); + OpenParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(OpenParenToken)); + PatternAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Pattern)); + CloseParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(CloseParenToken)); + WithOpenParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(OpenParenToken)); + WithPatternAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Pattern)); + WithCloseParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(CloseParenToken)); + } + + private ParenthesizedPatternSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public SyntaxToken OpenParenToken + { + get + { + return OpenParenTokenAccessor(this.SyntaxNode); + } + } + + public PatternSyntaxWrapper Pattern + { + get + { + return (PatternSyntaxWrapper)PatternAccessor(this.SyntaxNode); + } + } + + public SyntaxToken CloseParenToken + { + get + { + return CloseParenTokenAccessor(this.SyntaxNode); + } + } + + public static explicit operator ParenthesizedPatternSyntaxWrapper(PatternSyntaxWrapper node) + { + return (ParenthesizedPatternSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator ParenthesizedPatternSyntaxWrapper(ExpressionOrPatternSyntaxWrapper node) + { + return (ParenthesizedPatternSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator ParenthesizedPatternSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ParenthesizedPatternSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator PatternSyntaxWrapper(ParenthesizedPatternSyntaxWrapper wrapper) + { + return PatternSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator ExpressionOrPatternSyntaxWrapper(ParenthesizedPatternSyntaxWrapper wrapper) + { + return ExpressionOrPatternSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator CSharpSyntaxNode(ParenthesizedPatternSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public ParenthesizedPatternSyntaxWrapper WithOpenParenToken(SyntaxToken openParenToken) + { + return new ParenthesizedPatternSyntaxWrapper(WithOpenParenTokenAccessor(this.SyntaxNode, openParenToken)); + } + + public ParenthesizedPatternSyntaxWrapper WithPattern(PatternSyntaxWrapper pattern) + { + return new ParenthesizedPatternSyntaxWrapper(WithPatternAccessor(this.SyntaxNode, pattern)); + } + + public ParenthesizedPatternSyntaxWrapper WithCloseParenToken(SyntaxToken closeParenToken) + { + return new ParenthesizedPatternSyntaxWrapper(WithCloseParenTokenAccessor(this.SyntaxNode, closeParenToken)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ParenthesizedVariableDesignationSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ParenthesizedVariableDesignationSyntaxWrapper.g.cs new file mode 100644 index 000000000..d0b4aff67 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ParenthesizedVariableDesignationSyntaxWrapper.g.cs @@ -0,0 +1,118 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct ParenthesizedVariableDesignationSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax"; + private static readonly Type WrappedType; + + private static readonly Func OpenParenTokenAccessor; + private static readonly Func> VariablesAccessor; + private static readonly Func CloseParenTokenAccessor; + private static readonly Func WithOpenParenTokenAccessor; + private static readonly Func, CSharpSyntaxNode> WithVariablesAccessor; + private static readonly Func WithCloseParenTokenAccessor; + + private readonly CSharpSyntaxNode node; + + static ParenthesizedVariableDesignationSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(ParenthesizedVariableDesignationSyntaxWrapper)); + OpenParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(OpenParenToken)); + VariablesAccessor = LightupHelpers.CreateSeparatedSyntaxListPropertyAccessor(WrappedType, nameof(Variables)); + CloseParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(CloseParenToken)); + WithOpenParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(OpenParenToken)); + WithVariablesAccessor = LightupHelpers.CreateSeparatedSyntaxListWithPropertyAccessor(WrappedType, nameof(Variables)); + WithCloseParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(CloseParenToken)); + } + + private ParenthesizedVariableDesignationSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public SyntaxToken OpenParenToken + { + get + { + return OpenParenTokenAccessor(this.SyntaxNode); + } + } + + public SeparatedSyntaxListWrapper Variables + { + get + { + return VariablesAccessor(this.SyntaxNode); + } + } + + public SyntaxToken CloseParenToken + { + get + { + return CloseParenTokenAccessor(this.SyntaxNode); + } + } + + public static explicit operator ParenthesizedVariableDesignationSyntaxWrapper(VariableDesignationSyntaxWrapper node) + { + return (ParenthesizedVariableDesignationSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator ParenthesizedVariableDesignationSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new ParenthesizedVariableDesignationSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator VariableDesignationSyntaxWrapper(ParenthesizedVariableDesignationSyntaxWrapper wrapper) + { + return VariableDesignationSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator CSharpSyntaxNode(ParenthesizedVariableDesignationSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public ParenthesizedVariableDesignationSyntaxWrapper WithOpenParenToken(SyntaxToken openParenToken) + { + return new ParenthesizedVariableDesignationSyntaxWrapper(WithOpenParenTokenAccessor(this.SyntaxNode, openParenToken)); + } + + public ParenthesizedVariableDesignationSyntaxWrapper WithVariables(SeparatedSyntaxListWrapper variables) + { + return new ParenthesizedVariableDesignationSyntaxWrapper(WithVariablesAccessor(this.SyntaxNode, variables)); + } + + public ParenthesizedVariableDesignationSyntaxWrapper WithCloseParenToken(SyntaxToken closeParenToken) + { + return new ParenthesizedVariableDesignationSyntaxWrapper(WithCloseParenTokenAccessor(this.SyntaxNode, closeParenToken)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/PatternSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/PatternSyntaxWrapper.g.cs similarity index 65% rename from StyleCop.Analyzers/StyleCop.Analyzers/Lightup/PatternSyntaxWrapper.cs rename to StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/PatternSyntaxWrapper.g.cs index 237b3ad1c..4b52b4bfe 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/PatternSyntaxWrapper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/PatternSyntaxWrapper.g.cs @@ -1,13 +1,15 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Lightup { using System; + using System.Collections.Immutable; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; - internal struct PatternSyntaxWrapper : ISyntaxWrapper + internal readonly partial struct PatternSyntaxWrapper : ISyntaxWrapper { internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax"; private static readonly Type WrappedType; @@ -16,7 +18,7 @@ internal struct PatternSyntaxWrapper : ISyntaxWrapper static PatternSyntaxWrapper() { - WrappedType = WrapperHelper.GetWrappedType(typeof(PatternSyntaxWrapper)); + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(PatternSyntaxWrapper)); } private PatternSyntaxWrapper(CSharpSyntaxNode node) @@ -26,11 +28,16 @@ private PatternSyntaxWrapper(CSharpSyntaxNode node) public CSharpSyntaxNode SyntaxNode => this.node; + public static explicit operator PatternSyntaxWrapper(ExpressionOrPatternSyntaxWrapper node) + { + return (PatternSyntaxWrapper)node.SyntaxNode; + } + public static explicit operator PatternSyntaxWrapper(SyntaxNode node) { if (node == null) { - return default(PatternSyntaxWrapper); + return default; } if (!IsInstance(node)) @@ -41,6 +48,11 @@ public static explicit operator PatternSyntaxWrapper(SyntaxNode node) return new PatternSyntaxWrapper((CSharpSyntaxNode)node); } + public static implicit operator ExpressionOrPatternSyntaxWrapper(PatternSyntaxWrapper wrapper) + { + return ExpressionOrPatternSyntaxWrapper.FromUpcast(wrapper.node); + } + public static implicit operator CSharpSyntaxNode(PatternSyntaxWrapper wrapper) { return wrapper.node; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/PositionalPatternClauseSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/PositionalPatternClauseSyntaxWrapper.g.cs new file mode 100644 index 000000000..d69bd45bf --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/PositionalPatternClauseSyntaxWrapper.g.cs @@ -0,0 +1,108 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct PositionalPatternClauseSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax"; + private static readonly Type WrappedType; + + private static readonly Func OpenParenTokenAccessor; + private static readonly Func> SubpatternsAccessor; + private static readonly Func CloseParenTokenAccessor; + private static readonly Func WithOpenParenTokenAccessor; + private static readonly Func, CSharpSyntaxNode> WithSubpatternsAccessor; + private static readonly Func WithCloseParenTokenAccessor; + + private readonly CSharpSyntaxNode node; + + static PositionalPatternClauseSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(PositionalPatternClauseSyntaxWrapper)); + OpenParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(OpenParenToken)); + SubpatternsAccessor = LightupHelpers.CreateSeparatedSyntaxListPropertyAccessor(WrappedType, nameof(Subpatterns)); + CloseParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(CloseParenToken)); + WithOpenParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(OpenParenToken)); + WithSubpatternsAccessor = LightupHelpers.CreateSeparatedSyntaxListWithPropertyAccessor(WrappedType, nameof(Subpatterns)); + WithCloseParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(CloseParenToken)); + } + + private PositionalPatternClauseSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public SyntaxToken OpenParenToken + { + get + { + return OpenParenTokenAccessor(this.SyntaxNode); + } + } + + public SeparatedSyntaxListWrapper Subpatterns + { + get + { + return SubpatternsAccessor(this.SyntaxNode); + } + } + + public SyntaxToken CloseParenToken + { + get + { + return CloseParenTokenAccessor(this.SyntaxNode); + } + } + + public static explicit operator PositionalPatternClauseSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new PositionalPatternClauseSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator CSharpSyntaxNode(PositionalPatternClauseSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public PositionalPatternClauseSyntaxWrapper WithOpenParenToken(SyntaxToken openParenToken) + { + return new PositionalPatternClauseSyntaxWrapper(WithOpenParenTokenAccessor(this.SyntaxNode, openParenToken)); + } + + public PositionalPatternClauseSyntaxWrapper WithSubpatterns(SeparatedSyntaxListWrapper subpatterns) + { + return new PositionalPatternClauseSyntaxWrapper(WithSubpatternsAccessor(this.SyntaxNode, subpatterns)); + } + + public PositionalPatternClauseSyntaxWrapper WithCloseParenToken(SyntaxToken closeParenToken) + { + return new PositionalPatternClauseSyntaxWrapper(WithCloseParenTokenAccessor(this.SyntaxNode, closeParenToken)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/PrimaryConstructorBaseTypeSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/PrimaryConstructorBaseTypeSyntaxWrapper.g.cs new file mode 100644 index 000000000..5d04961fc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/PrimaryConstructorBaseTypeSyntaxWrapper.g.cs @@ -0,0 +1,89 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct PrimaryConstructorBaseTypeSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.PrimaryConstructorBaseTypeSyntax"; + private static readonly Type WrappedType; + + private static readonly Func ArgumentListAccessor; + private static readonly Func WithTypeAccessor; + private static readonly Func WithArgumentListAccessor; + + private readonly BaseTypeSyntax node; + + static PrimaryConstructorBaseTypeSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(PrimaryConstructorBaseTypeSyntaxWrapper)); + ArgumentListAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(ArgumentList)); + WithTypeAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Type)); + WithArgumentListAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(ArgumentList)); + } + + private PrimaryConstructorBaseTypeSyntaxWrapper(BaseTypeSyntax node) + { + this.node = node; + } + + public BaseTypeSyntax SyntaxNode => this.node; + + public TypeSyntax Type + { + get + { + return this.SyntaxNode.Type; + } + } + + public ArgumentListSyntax ArgumentList + { + get + { + return ArgumentListAccessor(this.SyntaxNode); + } + } + + public static explicit operator PrimaryConstructorBaseTypeSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new PrimaryConstructorBaseTypeSyntaxWrapper((BaseTypeSyntax)node); + } + + public static implicit operator BaseTypeSyntax(PrimaryConstructorBaseTypeSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public PrimaryConstructorBaseTypeSyntaxWrapper WithType(TypeSyntax type) + { + return new PrimaryConstructorBaseTypeSyntaxWrapper(WithTypeAccessor(this.SyntaxNode, type)); + } + + public PrimaryConstructorBaseTypeSyntaxWrapper WithArgumentList(ArgumentListSyntax argumentList) + { + return new PrimaryConstructorBaseTypeSyntaxWrapper(WithArgumentListAccessor(this.SyntaxNode, argumentList)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/PropertyPatternClauseSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/PropertyPatternClauseSyntaxWrapper.g.cs new file mode 100644 index 000000000..7d27a3d08 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/PropertyPatternClauseSyntaxWrapper.g.cs @@ -0,0 +1,108 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct PropertyPatternClauseSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax"; + private static readonly Type WrappedType; + + private static readonly Func OpenBraceTokenAccessor; + private static readonly Func> SubpatternsAccessor; + private static readonly Func CloseBraceTokenAccessor; + private static readonly Func WithOpenBraceTokenAccessor; + private static readonly Func, CSharpSyntaxNode> WithSubpatternsAccessor; + private static readonly Func WithCloseBraceTokenAccessor; + + private readonly CSharpSyntaxNode node; + + static PropertyPatternClauseSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(PropertyPatternClauseSyntaxWrapper)); + OpenBraceTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(OpenBraceToken)); + SubpatternsAccessor = LightupHelpers.CreateSeparatedSyntaxListPropertyAccessor(WrappedType, nameof(Subpatterns)); + CloseBraceTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(CloseBraceToken)); + WithOpenBraceTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(OpenBraceToken)); + WithSubpatternsAccessor = LightupHelpers.CreateSeparatedSyntaxListWithPropertyAccessor(WrappedType, nameof(Subpatterns)); + WithCloseBraceTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(CloseBraceToken)); + } + + private PropertyPatternClauseSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public SyntaxToken OpenBraceToken + { + get + { + return OpenBraceTokenAccessor(this.SyntaxNode); + } + } + + public SeparatedSyntaxListWrapper Subpatterns + { + get + { + return SubpatternsAccessor(this.SyntaxNode); + } + } + + public SyntaxToken CloseBraceToken + { + get + { + return CloseBraceTokenAccessor(this.SyntaxNode); + } + } + + public static explicit operator PropertyPatternClauseSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new PropertyPatternClauseSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator CSharpSyntaxNode(PropertyPatternClauseSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public PropertyPatternClauseSyntaxWrapper WithOpenBraceToken(SyntaxToken openBraceToken) + { + return new PropertyPatternClauseSyntaxWrapper(WithOpenBraceTokenAccessor(this.SyntaxNode, openBraceToken)); + } + + public PropertyPatternClauseSyntaxWrapper WithSubpatterns(SeparatedSyntaxListWrapper subpatterns) + { + return new PropertyPatternClauseSyntaxWrapper(WithSubpatternsAccessor(this.SyntaxNode, subpatterns)); + } + + public PropertyPatternClauseSyntaxWrapper WithCloseBraceToken(SyntaxToken closeBraceToken) + { + return new PropertyPatternClauseSyntaxWrapper(WithCloseBraceTokenAccessor(this.SyntaxNode, closeBraceToken)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/RangeExpressionSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/RangeExpressionSyntaxWrapper.g.cs new file mode 100644 index 000000000..97dd7d931 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/RangeExpressionSyntaxWrapper.g.cs @@ -0,0 +1,108 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct RangeExpressionSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.RangeExpressionSyntax"; + private static readonly Type WrappedType; + + private static readonly Func LeftOperandAccessor; + private static readonly Func OperatorTokenAccessor; + private static readonly Func RightOperandAccessor; + private static readonly Func WithLeftOperandAccessor; + private static readonly Func WithOperatorTokenAccessor; + private static readonly Func WithRightOperandAccessor; + + private readonly ExpressionSyntax node; + + static RangeExpressionSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(RangeExpressionSyntaxWrapper)); + LeftOperandAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(LeftOperand)); + OperatorTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(OperatorToken)); + RightOperandAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(RightOperand)); + WithLeftOperandAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(LeftOperand)); + WithOperatorTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(OperatorToken)); + WithRightOperandAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(RightOperand)); + } + + private RangeExpressionSyntaxWrapper(ExpressionSyntax node) + { + this.node = node; + } + + public ExpressionSyntax SyntaxNode => this.node; + + public ExpressionSyntax LeftOperand + { + get + { + return LeftOperandAccessor(this.SyntaxNode); + } + } + + public SyntaxToken OperatorToken + { + get + { + return OperatorTokenAccessor(this.SyntaxNode); + } + } + + public ExpressionSyntax RightOperand + { + get + { + return RightOperandAccessor(this.SyntaxNode); + } + } + + public static explicit operator RangeExpressionSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new RangeExpressionSyntaxWrapper((ExpressionSyntax)node); + } + + public static implicit operator ExpressionSyntax(RangeExpressionSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public RangeExpressionSyntaxWrapper WithLeftOperand(ExpressionSyntax leftOperand) + { + return new RangeExpressionSyntaxWrapper(WithLeftOperandAccessor(this.SyntaxNode, leftOperand)); + } + + public RangeExpressionSyntaxWrapper WithOperatorToken(SyntaxToken operatorToken) + { + return new RangeExpressionSyntaxWrapper(WithOperatorTokenAccessor(this.SyntaxNode, operatorToken)); + } + + public RangeExpressionSyntaxWrapper WithRightOperand(ExpressionSyntax rightOperand) + { + return new RangeExpressionSyntaxWrapper(WithRightOperandAccessor(this.SyntaxNode, rightOperand)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/RecordDeclarationSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/RecordDeclarationSyntaxWrapper.g.cs new file mode 100644 index 000000000..16baa432b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/RecordDeclarationSyntaxWrapper.g.cs @@ -0,0 +1,256 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct RecordDeclarationSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.RecordDeclarationSyntax"; + private static readonly Type WrappedType; + + private static readonly Func ClassOrStructKeywordAccessor; + private static readonly Func ParameterListAccessor; + private static readonly Func, TypeDeclarationSyntax> WithAttributeListsAccessor; + private static readonly Func WithModifiersAccessor; + private static readonly Func WithKeywordAccessor; + private static readonly Func WithClassOrStructKeywordAccessor; + private static readonly Func WithIdentifierAccessor; + private static readonly Func WithTypeParameterListAccessor; + private static readonly Func WithParameterListAccessor; + private static readonly Func WithBaseListAccessor; + private static readonly Func, TypeDeclarationSyntax> WithConstraintClausesAccessor; + private static readonly Func WithOpenBraceTokenAccessor; + private static readonly Func, TypeDeclarationSyntax> WithMembersAccessor; + private static readonly Func WithCloseBraceTokenAccessor; + private static readonly Func WithSemicolonTokenAccessor; + + private readonly TypeDeclarationSyntax node; + + static RecordDeclarationSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(RecordDeclarationSyntaxWrapper)); + ClassOrStructKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(ClassOrStructKeyword)); + ParameterListAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(ParameterList)); + WithAttributeListsAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor>(WrappedType, nameof(AttributeLists)); + WithModifiersAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Modifiers)); + WithKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Keyword)); + WithClassOrStructKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(ClassOrStructKeyword)); + WithIdentifierAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Identifier)); + WithTypeParameterListAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(TypeParameterList)); + WithParameterListAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(ParameterList)); + WithBaseListAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(BaseList)); + WithConstraintClausesAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor>(WrappedType, nameof(ConstraintClauses)); + WithOpenBraceTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(OpenBraceToken)); + WithMembersAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor>(WrappedType, nameof(Members)); + WithCloseBraceTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(CloseBraceToken)); + WithSemicolonTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(SemicolonToken)); + } + + private RecordDeclarationSyntaxWrapper(TypeDeclarationSyntax node) + { + this.node = node; + } + + public TypeDeclarationSyntax SyntaxNode => this.node; + + public SyntaxList AttributeLists + { + get + { + return this.SyntaxNode.AttributeLists(); + } + } + + public SyntaxTokenList Modifiers + { + get + { + return this.SyntaxNode.Modifiers(); + } + } + + public SyntaxToken Keyword + { + get + { + return this.SyntaxNode.Keyword; + } + } + + public SyntaxToken ClassOrStructKeyword + { + get + { + return ClassOrStructKeywordAccessor(this.SyntaxNode); + } + } + + public SyntaxToken Identifier + { + get + { + return this.SyntaxNode.Identifier; + } + } + + public TypeParameterListSyntax TypeParameterList + { + get + { + return this.SyntaxNode.TypeParameterList; + } + } + + public ParameterListSyntax ParameterList + { + get + { + return ParameterListAccessor(this.SyntaxNode); + } + } + + public BaseListSyntax BaseList + { + get + { + return this.SyntaxNode.BaseList; + } + } + + public SyntaxList ConstraintClauses + { + get + { + return this.SyntaxNode.ConstraintClauses; + } + } + + public SyntaxToken OpenBraceToken + { + get + { + return this.SyntaxNode.OpenBraceToken; + } + } + + public SyntaxList Members + { + get + { + return this.SyntaxNode.Members; + } + } + + public SyntaxToken CloseBraceToken + { + get + { + return this.SyntaxNode.CloseBraceToken; + } + } + + public SyntaxToken SemicolonToken + { + get + { + return this.SyntaxNode.SemicolonToken; + } + } + + public static explicit operator RecordDeclarationSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new RecordDeclarationSyntaxWrapper((TypeDeclarationSyntax)node); + } + + public static implicit operator TypeDeclarationSyntax(RecordDeclarationSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public RecordDeclarationSyntaxWrapper WithAttributeLists(SyntaxList attributeLists) + { + return new RecordDeclarationSyntaxWrapper(WithAttributeListsAccessor(this.SyntaxNode, attributeLists)); + } + + public RecordDeclarationSyntaxWrapper WithModifiers(SyntaxTokenList modifiers) + { + return new RecordDeclarationSyntaxWrapper(WithModifiersAccessor(this.SyntaxNode, modifiers)); + } + + public RecordDeclarationSyntaxWrapper WithKeyword(SyntaxToken keyword) + { + return new RecordDeclarationSyntaxWrapper(WithKeywordAccessor(this.SyntaxNode, keyword)); + } + + public RecordDeclarationSyntaxWrapper WithClassOrStructKeyword(SyntaxToken classOrStructKeyword) + { + return new RecordDeclarationSyntaxWrapper(WithClassOrStructKeywordAccessor(this.SyntaxNode, classOrStructKeyword)); + } + + public RecordDeclarationSyntaxWrapper WithIdentifier(SyntaxToken identifier) + { + return new RecordDeclarationSyntaxWrapper(WithIdentifierAccessor(this.SyntaxNode, identifier)); + } + + public RecordDeclarationSyntaxWrapper WithTypeParameterList(TypeParameterListSyntax typeParameterList) + { + return new RecordDeclarationSyntaxWrapper(WithTypeParameterListAccessor(this.SyntaxNode, typeParameterList)); + } + + public RecordDeclarationSyntaxWrapper WithParameterList(ParameterListSyntax parameterList) + { + return new RecordDeclarationSyntaxWrapper(WithParameterListAccessor(this.SyntaxNode, parameterList)); + } + + public RecordDeclarationSyntaxWrapper WithBaseList(BaseListSyntax baseList) + { + return new RecordDeclarationSyntaxWrapper(WithBaseListAccessor(this.SyntaxNode, baseList)); + } + + public RecordDeclarationSyntaxWrapper WithConstraintClauses(SyntaxList constraintClauses) + { + return new RecordDeclarationSyntaxWrapper(WithConstraintClausesAccessor(this.SyntaxNode, constraintClauses)); + } + + public RecordDeclarationSyntaxWrapper WithOpenBraceToken(SyntaxToken openBraceToken) + { + return new RecordDeclarationSyntaxWrapper(WithOpenBraceTokenAccessor(this.SyntaxNode, openBraceToken)); + } + + public RecordDeclarationSyntaxWrapper WithMembers(SyntaxList members) + { + return new RecordDeclarationSyntaxWrapper(WithMembersAccessor(this.SyntaxNode, members)); + } + + public RecordDeclarationSyntaxWrapper WithCloseBraceToken(SyntaxToken closeBraceToken) + { + return new RecordDeclarationSyntaxWrapper(WithCloseBraceTokenAccessor(this.SyntaxNode, closeBraceToken)); + } + + public RecordDeclarationSyntaxWrapper WithSemicolonToken(SyntaxToken semicolonToken) + { + return new RecordDeclarationSyntaxWrapper(WithSemicolonTokenAccessor(this.SyntaxNode, semicolonToken)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/RecursivePatternSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/RecursivePatternSyntaxWrapper.g.cs new file mode 100644 index 000000000..a805c3a82 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/RecursivePatternSyntaxWrapper.g.cs @@ -0,0 +1,145 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct RecursivePatternSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax"; + private static readonly Type WrappedType; + + private static readonly Func TypeAccessor; + private static readonly Func PositionalPatternClauseAccessor; + private static readonly Func PropertyPatternClauseAccessor; + private static readonly Func DesignationAccessor; + private static readonly Func WithTypeAccessor; + private static readonly Func WithPositionalPatternClauseAccessor; + private static readonly Func WithPropertyPatternClauseAccessor; + private static readonly Func WithDesignationAccessor; + + private readonly CSharpSyntaxNode node; + + static RecursivePatternSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(RecursivePatternSyntaxWrapper)); + TypeAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Type)); + PositionalPatternClauseAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(PositionalPatternClause)); + PropertyPatternClauseAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(PropertyPatternClause)); + DesignationAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Designation)); + WithTypeAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Type)); + WithPositionalPatternClauseAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(PositionalPatternClause)); + WithPropertyPatternClauseAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(PropertyPatternClause)); + WithDesignationAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Designation)); + } + + private RecursivePatternSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public TypeSyntax Type + { + get + { + return TypeAccessor(this.SyntaxNode); + } + } + + public PositionalPatternClauseSyntaxWrapper PositionalPatternClause + { + get + { + return (PositionalPatternClauseSyntaxWrapper)PositionalPatternClauseAccessor(this.SyntaxNode); + } + } + + public PropertyPatternClauseSyntaxWrapper PropertyPatternClause + { + get + { + return (PropertyPatternClauseSyntaxWrapper)PropertyPatternClauseAccessor(this.SyntaxNode); + } + } + + public VariableDesignationSyntaxWrapper Designation + { + get + { + return (VariableDesignationSyntaxWrapper)DesignationAccessor(this.SyntaxNode); + } + } + + public static explicit operator RecursivePatternSyntaxWrapper(PatternSyntaxWrapper node) + { + return (RecursivePatternSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator RecursivePatternSyntaxWrapper(ExpressionOrPatternSyntaxWrapper node) + { + return (RecursivePatternSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator RecursivePatternSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new RecursivePatternSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator PatternSyntaxWrapper(RecursivePatternSyntaxWrapper wrapper) + { + return PatternSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator ExpressionOrPatternSyntaxWrapper(RecursivePatternSyntaxWrapper wrapper) + { + return ExpressionOrPatternSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator CSharpSyntaxNode(RecursivePatternSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public RecursivePatternSyntaxWrapper WithType(TypeSyntax type) + { + return new RecursivePatternSyntaxWrapper(WithTypeAccessor(this.SyntaxNode, type)); + } + + public RecursivePatternSyntaxWrapper WithPositionalPatternClause(PositionalPatternClauseSyntaxWrapper positionalPatternClause) + { + return new RecursivePatternSyntaxWrapper(WithPositionalPatternClauseAccessor(this.SyntaxNode, positionalPatternClause)); + } + + public RecursivePatternSyntaxWrapper WithPropertyPatternClause(PropertyPatternClauseSyntaxWrapper propertyPatternClause) + { + return new RecursivePatternSyntaxWrapper(WithPropertyPatternClauseAccessor(this.SyntaxNode, propertyPatternClause)); + } + + public RecursivePatternSyntaxWrapper WithDesignation(VariableDesignationSyntaxWrapper designation) + { + return new RecursivePatternSyntaxWrapper(WithDesignationAccessor(this.SyntaxNode, designation)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/RefExpressionSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/RefExpressionSyntaxWrapper.g.cs similarity index 88% rename from StyleCop.Analyzers/StyleCop.Analyzers/Lightup/RefExpressionSyntaxWrapper.cs rename to StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/RefExpressionSyntaxWrapper.g.cs index 0dfe1b24a..66ccf7529 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/RefExpressionSyntaxWrapper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/RefExpressionSyntaxWrapper.g.cs @@ -1,13 +1,15 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Lightup { using System; + using System.Collections.Immutable; using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; - internal struct RefExpressionSyntaxWrapper : ISyntaxWrapper + internal readonly partial struct RefExpressionSyntaxWrapper : ISyntaxWrapper { internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.RefExpressionSyntax"; private static readonly Type WrappedType; @@ -21,7 +23,7 @@ internal struct RefExpressionSyntaxWrapper : ISyntaxWrapper static RefExpressionSyntaxWrapper() { - WrappedType = WrapperHelper.GetWrappedType(typeof(RefExpressionSyntaxWrapper)); + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(RefExpressionSyntaxWrapper)); RefKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(RefKeyword)); ExpressionAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Expression)); WithRefKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(RefKeyword)); @@ -55,7 +57,7 @@ public static explicit operator RefExpressionSyntaxWrapper(SyntaxNode node) { if (node == null) { - return default(RefExpressionSyntaxWrapper); + return default; } if (!IsInstance(node)) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/RefTypeSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/RefTypeSyntaxWrapper.g.cs similarity index 69% rename from StyleCop.Analyzers/StyleCop.Analyzers/Lightup/RefTypeSyntaxWrapper.cs rename to StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/RefTypeSyntaxWrapper.g.cs index 8a7e59e07..aa2234671 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/RefTypeSyntaxWrapper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/RefTypeSyntaxWrapper.g.cs @@ -1,30 +1,36 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Lightup { using System; + using System.Collections.Immutable; using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; - internal struct RefTypeSyntaxWrapper : ISyntaxWrapper + internal readonly partial struct RefTypeSyntaxWrapper : ISyntaxWrapper { internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax"; private static readonly Type WrappedType; private static readonly Func RefKeywordAccessor; + private static readonly Func ReadOnlyKeywordAccessor; private static readonly Func TypeAccessor; private static readonly Func WithRefKeywordAccessor; + private static readonly Func WithReadOnlyKeywordAccessor; private static readonly Func WithTypeAccessor; private readonly TypeSyntax node; static RefTypeSyntaxWrapper() { - WrappedType = WrapperHelper.GetWrappedType(typeof(RefTypeSyntaxWrapper)); + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(RefTypeSyntaxWrapper)); RefKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(RefKeyword)); + ReadOnlyKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(ReadOnlyKeyword)); TypeAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Type)); WithRefKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(RefKeyword)); + WithReadOnlyKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(ReadOnlyKeyword)); WithTypeAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Type)); } @@ -43,6 +49,14 @@ public SyntaxToken RefKeyword } } + public SyntaxToken ReadOnlyKeyword + { + get + { + return ReadOnlyKeywordAccessor(this.SyntaxNode); + } + } + public TypeSyntax Type { get @@ -55,7 +69,7 @@ public static explicit operator RefTypeSyntaxWrapper(SyntaxNode node) { if (node == null) { - return default(RefTypeSyntaxWrapper); + return default; } if (!IsInstance(node)) @@ -81,6 +95,11 @@ public RefTypeSyntaxWrapper WithRefKeyword(SyntaxToken refKeyword) return new RefTypeSyntaxWrapper(WithRefKeywordAccessor(this.SyntaxNode, refKeyword)); } + public RefTypeSyntaxWrapper WithReadOnlyKeyword(SyntaxToken readOnlyKeyword) + { + return new RefTypeSyntaxWrapper(WithReadOnlyKeywordAccessor(this.SyntaxNode, readOnlyKeyword)); + } + public RefTypeSyntaxWrapper WithType(TypeSyntax type) { return new RefTypeSyntaxWrapper(WithTypeAccessor(this.SyntaxNode, type)); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/RelationalPatternSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/RelationalPatternSyntaxWrapper.g.cs new file mode 100644 index 000000000..70d4ba4bc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/RelationalPatternSyntaxWrapper.g.cs @@ -0,0 +1,111 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct RelationalPatternSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.RelationalPatternSyntax"; + private static readonly Type WrappedType; + + private static readonly Func OperatorTokenAccessor; + private static readonly Func ExpressionAccessor; + private static readonly Func WithOperatorTokenAccessor; + private static readonly Func WithExpressionAccessor; + + private readonly CSharpSyntaxNode node; + + static RelationalPatternSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(RelationalPatternSyntaxWrapper)); + OperatorTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(OperatorToken)); + ExpressionAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Expression)); + WithOperatorTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(OperatorToken)); + WithExpressionAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Expression)); + } + + private RelationalPatternSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public SyntaxToken OperatorToken + { + get + { + return OperatorTokenAccessor(this.SyntaxNode); + } + } + + public ExpressionSyntax Expression + { + get + { + return ExpressionAccessor(this.SyntaxNode); + } + } + + public static explicit operator RelationalPatternSyntaxWrapper(PatternSyntaxWrapper node) + { + return (RelationalPatternSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator RelationalPatternSyntaxWrapper(ExpressionOrPatternSyntaxWrapper node) + { + return (RelationalPatternSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator RelationalPatternSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new RelationalPatternSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator PatternSyntaxWrapper(RelationalPatternSyntaxWrapper wrapper) + { + return PatternSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator ExpressionOrPatternSyntaxWrapper(RelationalPatternSyntaxWrapper wrapper) + { + return ExpressionOrPatternSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator CSharpSyntaxNode(RelationalPatternSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public RelationalPatternSyntaxWrapper WithOperatorToken(SyntaxToken operatorToken) + { + return new RelationalPatternSyntaxWrapper(WithOperatorTokenAccessor(this.SyntaxNode, operatorToken)); + } + + public RelationalPatternSyntaxWrapper WithExpression(ExpressionSyntax expression) + { + return new RelationalPatternSyntaxWrapper(WithExpressionAccessor(this.SyntaxNode, expression)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SingleVariableDesignationSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/SingleVariableDesignationSyntaxWrapper.g.cs similarity index 86% rename from StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SingleVariableDesignationSyntaxWrapper.cs rename to StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/SingleVariableDesignationSyntaxWrapper.g.cs index aebb7bef2..95bf87c9d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SingleVariableDesignationSyntaxWrapper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/SingleVariableDesignationSyntaxWrapper.g.cs @@ -1,13 +1,15 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Lightup { using System; + using System.Collections.Immutable; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; - internal struct SingleVariableDesignationSyntaxWrapper : ISyntaxWrapper + internal readonly partial struct SingleVariableDesignationSyntaxWrapper : ISyntaxWrapper { internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.SingleVariableDesignationSyntax"; private static readonly Type WrappedType; @@ -19,7 +21,7 @@ internal struct SingleVariableDesignationSyntaxWrapper : ISyntaxWrapper(WrappedType, nameof(Identifier)); WithIdentifierAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Identifier)); } @@ -48,7 +50,7 @@ public static explicit operator SingleVariableDesignationSyntaxWrapper(SyntaxNod { if (node == null) { - return default(SingleVariableDesignationSyntaxWrapper); + return default; } if (!IsInstance(node)) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/SubpatternSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/SubpatternSyntaxWrapper.g.cs new file mode 100644 index 000000000..1c0786cd3 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/SubpatternSyntaxWrapper.g.cs @@ -0,0 +1,91 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct SubpatternSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternSyntax"; + private static readonly Type WrappedType; + + private static readonly Func ExpressionColonAccessor; + private static readonly Func PatternAccessor; + private static readonly Func WithExpressionColonAccessor; + private static readonly Func WithPatternAccessor; + + private readonly CSharpSyntaxNode node; + + static SubpatternSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(SubpatternSyntaxWrapper)); + ExpressionColonAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(ExpressionColon)); + PatternAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Pattern)); + WithExpressionColonAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(ExpressionColon)); + WithPatternAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Pattern)); + } + + private SubpatternSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public BaseExpressionColonSyntaxWrapper ExpressionColon + { + get + { + return (BaseExpressionColonSyntaxWrapper)ExpressionColonAccessor(this.SyntaxNode); + } + } + + public PatternSyntaxWrapper Pattern + { + get + { + return (PatternSyntaxWrapper)PatternAccessor(this.SyntaxNode); + } + } + + public static explicit operator SubpatternSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new SubpatternSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator CSharpSyntaxNode(SubpatternSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public SubpatternSyntaxWrapper WithExpressionColon(BaseExpressionColonSyntaxWrapper expressionColon) + { + return new SubpatternSyntaxWrapper(WithExpressionColonAccessor(this.SyntaxNode, expressionColon)); + } + + public SubpatternSyntaxWrapper WithPattern(PatternSyntaxWrapper pattern) + { + return new SubpatternSyntaxWrapper(WithPatternAccessor(this.SyntaxNode, pattern)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/SwitchExpressionArmSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/SwitchExpressionArmSyntaxWrapper.g.cs new file mode 100644 index 000000000..d7216f44b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/SwitchExpressionArmSyntaxWrapper.g.cs @@ -0,0 +1,125 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct SwitchExpressionArmSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax"; + private static readonly Type WrappedType; + + private static readonly Func PatternAccessor; + private static readonly Func WhenClauseAccessor; + private static readonly Func EqualsGreaterThanTokenAccessor; + private static readonly Func ExpressionAccessor; + private static readonly Func WithPatternAccessor; + private static readonly Func WithWhenClauseAccessor; + private static readonly Func WithEqualsGreaterThanTokenAccessor; + private static readonly Func WithExpressionAccessor; + + private readonly CSharpSyntaxNode node; + + static SwitchExpressionArmSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(SwitchExpressionArmSyntaxWrapper)); + PatternAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Pattern)); + WhenClauseAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(WhenClause)); + EqualsGreaterThanTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(EqualsGreaterThanToken)); + ExpressionAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Expression)); + WithPatternAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Pattern)); + WithWhenClauseAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(WhenClause)); + WithEqualsGreaterThanTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(EqualsGreaterThanToken)); + WithExpressionAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Expression)); + } + + private SwitchExpressionArmSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public PatternSyntaxWrapper Pattern + { + get + { + return (PatternSyntaxWrapper)PatternAccessor(this.SyntaxNode); + } + } + + public WhenClauseSyntaxWrapper WhenClause + { + get + { + return (WhenClauseSyntaxWrapper)WhenClauseAccessor(this.SyntaxNode); + } + } + + public SyntaxToken EqualsGreaterThanToken + { + get + { + return EqualsGreaterThanTokenAccessor(this.SyntaxNode); + } + } + + public ExpressionSyntax Expression + { + get + { + return ExpressionAccessor(this.SyntaxNode); + } + } + + public static explicit operator SwitchExpressionArmSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new SwitchExpressionArmSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator CSharpSyntaxNode(SwitchExpressionArmSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public SwitchExpressionArmSyntaxWrapper WithPattern(PatternSyntaxWrapper pattern) + { + return new SwitchExpressionArmSyntaxWrapper(WithPatternAccessor(this.SyntaxNode, pattern)); + } + + public SwitchExpressionArmSyntaxWrapper WithWhenClause(WhenClauseSyntaxWrapper whenClause) + { + return new SwitchExpressionArmSyntaxWrapper(WithWhenClauseAccessor(this.SyntaxNode, whenClause)); + } + + public SwitchExpressionArmSyntaxWrapper WithEqualsGreaterThanToken(SyntaxToken equalsGreaterThanToken) + { + return new SwitchExpressionArmSyntaxWrapper(WithEqualsGreaterThanTokenAccessor(this.SyntaxNode, equalsGreaterThanToken)); + } + + public SwitchExpressionArmSyntaxWrapper WithExpression(ExpressionSyntax expression) + { + return new SwitchExpressionArmSyntaxWrapper(WithExpressionAccessor(this.SyntaxNode, expression)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/SwitchExpressionSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/SwitchExpressionSyntaxWrapper.g.cs new file mode 100644 index 000000000..85a737efb --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/SwitchExpressionSyntaxWrapper.g.cs @@ -0,0 +1,142 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct SwitchExpressionSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax"; + private static readonly Type WrappedType; + + private static readonly Func GoverningExpressionAccessor; + private static readonly Func SwitchKeywordAccessor; + private static readonly Func OpenBraceTokenAccessor; + private static readonly Func> ArmsAccessor; + private static readonly Func CloseBraceTokenAccessor; + private static readonly Func WithGoverningExpressionAccessor; + private static readonly Func WithSwitchKeywordAccessor; + private static readonly Func WithOpenBraceTokenAccessor; + private static readonly Func, ExpressionSyntax> WithArmsAccessor; + private static readonly Func WithCloseBraceTokenAccessor; + + private readonly ExpressionSyntax node; + + static SwitchExpressionSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(SwitchExpressionSyntaxWrapper)); + GoverningExpressionAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(GoverningExpression)); + SwitchKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(SwitchKeyword)); + OpenBraceTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(OpenBraceToken)); + ArmsAccessor = LightupHelpers.CreateSeparatedSyntaxListPropertyAccessor(WrappedType, nameof(Arms)); + CloseBraceTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(CloseBraceToken)); + WithGoverningExpressionAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(GoverningExpression)); + WithSwitchKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(SwitchKeyword)); + WithOpenBraceTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(OpenBraceToken)); + WithArmsAccessor = LightupHelpers.CreateSeparatedSyntaxListWithPropertyAccessor(WrappedType, nameof(Arms)); + WithCloseBraceTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(CloseBraceToken)); + } + + private SwitchExpressionSyntaxWrapper(ExpressionSyntax node) + { + this.node = node; + } + + public ExpressionSyntax SyntaxNode => this.node; + + public ExpressionSyntax GoverningExpression + { + get + { + return GoverningExpressionAccessor(this.SyntaxNode); + } + } + + public SyntaxToken SwitchKeyword + { + get + { + return SwitchKeywordAccessor(this.SyntaxNode); + } + } + + public SyntaxToken OpenBraceToken + { + get + { + return OpenBraceTokenAccessor(this.SyntaxNode); + } + } + + public SeparatedSyntaxListWrapper Arms + { + get + { + return ArmsAccessor(this.SyntaxNode); + } + } + + public SyntaxToken CloseBraceToken + { + get + { + return CloseBraceTokenAccessor(this.SyntaxNode); + } + } + + public static explicit operator SwitchExpressionSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new SwitchExpressionSyntaxWrapper((ExpressionSyntax)node); + } + + public static implicit operator ExpressionSyntax(SwitchExpressionSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public SwitchExpressionSyntaxWrapper WithGoverningExpression(ExpressionSyntax governingExpression) + { + return new SwitchExpressionSyntaxWrapper(WithGoverningExpressionAccessor(this.SyntaxNode, governingExpression)); + } + + public SwitchExpressionSyntaxWrapper WithSwitchKeyword(SyntaxToken switchKeyword) + { + return new SwitchExpressionSyntaxWrapper(WithSwitchKeywordAccessor(this.SyntaxNode, switchKeyword)); + } + + public SwitchExpressionSyntaxWrapper WithOpenBraceToken(SyntaxToken openBraceToken) + { + return new SwitchExpressionSyntaxWrapper(WithOpenBraceTokenAccessor(this.SyntaxNode, openBraceToken)); + } + + public SwitchExpressionSyntaxWrapper WithArms(SeparatedSyntaxListWrapper arms) + { + return new SwitchExpressionSyntaxWrapper(WithArmsAccessor(this.SyntaxNode, arms)); + } + + public SwitchExpressionSyntaxWrapper WithCloseBraceToken(SyntaxToken closeBraceToken) + { + return new SwitchExpressionSyntaxWrapper(WithCloseBraceTokenAccessor(this.SyntaxNode, closeBraceToken)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/SyntaxWrapperHelper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/SyntaxWrapperHelper.g.cs new file mode 100644 index 000000000..1cbe26b7f --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/SyntaxWrapperHelper.g.cs @@ -0,0 +1,101 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + + internal static class SyntaxWrapperHelper + { + private static readonly ImmutableDictionary WrappedTypes; + + static SyntaxWrapperHelper() + { + var csharpCodeAnalysisAssembly = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly; + var builder = ImmutableDictionary.CreateBuilder(); + builder.Add(typeof(BaseExpressionColonSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(BaseExpressionColonSyntaxWrapper.WrappedTypeName)); + + var baseNamespaceDeclarationSyntaxType = csharpCodeAnalysisAssembly.GetType(BaseNamespaceDeclarationSyntaxWrapper.WrappedTypeName) ?? csharpCodeAnalysisAssembly.GetType(BaseNamespaceDeclarationSyntaxWrapper.FallbackWrappedTypeName); + builder.Add(typeof(BaseNamespaceDeclarationSyntaxWrapper), baseNamespaceDeclarationSyntaxType); + + var objectCreationExpressionSyntaxType = csharpCodeAnalysisAssembly.GetType(BaseObjectCreationExpressionSyntaxWrapper.WrappedTypeName) ?? csharpCodeAnalysisAssembly.GetType(BaseObjectCreationExpressionSyntaxWrapper.FallbackWrappedTypeName); + builder.Add(typeof(BaseObjectCreationExpressionSyntaxWrapper), objectCreationExpressionSyntaxType); + builder.Add(typeof(BaseParameterSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(BaseParameterSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(BinaryPatternSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(BinaryPatternSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(CasePatternSwitchLabelSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(CasePatternSwitchLabelSyntaxWrapper.WrappedTypeName)); + var forEachStatementSyntaxType = csharpCodeAnalysisAssembly.GetType(CommonForEachStatementSyntaxWrapper.WrappedTypeName) ?? csharpCodeAnalysisAssembly.GetType(CommonForEachStatementSyntaxWrapper.FallbackWrappedTypeName); + builder.Add(typeof(CommonForEachStatementSyntaxWrapper), forEachStatementSyntaxType); + builder.Add(typeof(ConstantPatternSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(ConstantPatternSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(DeclarationExpressionSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(DeclarationExpressionSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(DeclarationPatternSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(DeclarationPatternSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(DefaultConstraintSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(DefaultConstraintSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(DiscardDesignationSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(DiscardDesignationSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(DiscardPatternSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(DiscardPatternSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(ExpressionColonSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(ExpressionColonSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(ExpressionOrPatternSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(ExpressionOrPatternSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(FileScopedNamespaceDeclarationSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(FileScopedNamespaceDeclarationSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(ForEachVariableStatementSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(ForEachVariableStatementSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(FunctionPointerCallingConventionSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(FunctionPointerCallingConventionSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(FunctionPointerParameterListSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(FunctionPointerParameterListSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(FunctionPointerParameterSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(FunctionPointerParameterSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(FunctionPointerTypeSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(FunctionPointerTypeSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(FunctionPointerUnmanagedCallingConventionListSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(FunctionPointerUnmanagedCallingConventionListSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(FunctionPointerUnmanagedCallingConventionSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(FunctionPointerUnmanagedCallingConventionSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(ImplicitObjectCreationExpressionSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(ImplicitObjectCreationExpressionSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(ImplicitStackAllocArrayCreationExpressionSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(ImplicitStackAllocArrayCreationExpressionSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(IsPatternExpressionSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(IsPatternExpressionSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(LineDirectivePositionSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(LineDirectivePositionSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(LineOrSpanDirectiveTriviaSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(LineOrSpanDirectiveTriviaSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(LineSpanDirectiveTriviaSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(LineSpanDirectiveTriviaSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(LocalFunctionStatementSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(LocalFunctionStatementSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(NullableDirectiveTriviaSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(NullableDirectiveTriviaSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(ParenthesizedPatternSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(ParenthesizedPatternSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(ParenthesizedVariableDesignationSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(ParenthesizedVariableDesignationSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(PatternSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(PatternSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(PositionalPatternClauseSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(PositionalPatternClauseSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(PrimaryConstructorBaseTypeSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(PrimaryConstructorBaseTypeSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(PropertyPatternClauseSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(PropertyPatternClauseSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(RangeExpressionSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(RangeExpressionSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(RecordDeclarationSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(RecordDeclarationSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(RecursivePatternSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(RecursivePatternSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(RefExpressionSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(RefExpressionSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(RefTypeSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(RefTypeSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(RelationalPatternSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(RelationalPatternSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(SingleVariableDesignationSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(SingleVariableDesignationSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(SubpatternSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(SubpatternSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(SwitchExpressionArmSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(SwitchExpressionArmSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(SwitchExpressionSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(SwitchExpressionSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(ThrowExpressionSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(ThrowExpressionSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(TupleElementSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(TupleElementSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(TupleExpressionSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(TupleExpressionSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(TupleTypeSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(TupleTypeSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(TypePatternSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(TypePatternSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(UnaryPatternSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(UnaryPatternSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(VariableDesignationSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(VariableDesignationSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(VarPatternSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(VarPatternSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(WhenClauseSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(WhenClauseSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(WithExpressionSyntaxWrapper), csharpCodeAnalysisAssembly.GetType(WithExpressionSyntaxWrapper.WrappedTypeName)); + + WrappedTypes = builder.ToImmutable(); + } + + /// + /// Gets the type that is wrapped by the given wrapper. + /// + /// Type of the wrapper for which the wrapped type should be retrieved. + /// The wrapped type, or null if there is no info. + internal static Type GetWrappedType(Type wrapperType) + { + if (WrappedTypes.TryGetValue(wrapperType, out Type wrappedType)) + { + return wrappedType; + } + + return null; + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ThrowExpressionSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ThrowExpressionSyntaxWrapper.g.cs similarity index 88% rename from StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ThrowExpressionSyntaxWrapper.cs rename to StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ThrowExpressionSyntaxWrapper.g.cs index 257615e4b..d85d4613e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ThrowExpressionSyntaxWrapper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/ThrowExpressionSyntaxWrapper.g.cs @@ -1,13 +1,15 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Lightup { using System; + using System.Collections.Immutable; using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; - internal struct ThrowExpressionSyntaxWrapper : ISyntaxWrapper + internal readonly partial struct ThrowExpressionSyntaxWrapper : ISyntaxWrapper { internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax"; private static readonly Type WrappedType; @@ -21,7 +23,7 @@ internal struct ThrowExpressionSyntaxWrapper : ISyntaxWrapper static ThrowExpressionSyntaxWrapper() { - WrappedType = WrapperHelper.GetWrappedType(typeof(ThrowExpressionSyntaxWrapper)); + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(ThrowExpressionSyntaxWrapper)); ThrowKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(ThrowKeyword)); ExpressionAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Expression)); WithThrowKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(ThrowKeyword)); @@ -55,7 +57,7 @@ public static explicit operator ThrowExpressionSyntaxWrapper(SyntaxNode node) { if (node == null) { - return default(ThrowExpressionSyntaxWrapper); + return default; } if (!IsInstance(node)) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TupleElementSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/TupleElementSyntaxWrapper.g.cs similarity index 89% rename from StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TupleElementSyntaxWrapper.cs rename to StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/TupleElementSyntaxWrapper.g.cs index 462373ead..508c25cf4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TupleElementSyntaxWrapper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/TupleElementSyntaxWrapper.g.cs @@ -1,32 +1,33 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Lightup { using System; + using System.Collections.Immutable; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; - internal struct TupleElementSyntaxWrapper : ISyntaxWrapper + internal readonly partial struct TupleElementSyntaxWrapper : ISyntaxWrapper { internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax"; private static readonly Type WrappedType; - private static readonly Func IdentifierAccessor; private static readonly Func TypeAccessor; - private static readonly Func WithIdentifierAccessor; + private static readonly Func IdentifierAccessor; private static readonly Func WithTypeAccessor; + private static readonly Func WithIdentifierAccessor; private readonly CSharpSyntaxNode node; static TupleElementSyntaxWrapper() { - WrappedType = WrapperHelper.GetWrappedType(typeof(TupleElementSyntaxWrapper)); - IdentifierAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Identifier)); + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(TupleElementSyntaxWrapper)); TypeAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Type)); - WithIdentifierAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Identifier)); + IdentifierAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Identifier)); WithTypeAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Type)); + WithIdentifierAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Identifier)); } private TupleElementSyntaxWrapper(CSharpSyntaxNode node) @@ -36,19 +37,19 @@ private TupleElementSyntaxWrapper(CSharpSyntaxNode node) public CSharpSyntaxNode SyntaxNode => this.node; - public SyntaxToken Identifier + public TypeSyntax Type { get { - return IdentifierAccessor(this.SyntaxNode); + return TypeAccessor(this.SyntaxNode); } } - public TypeSyntax Type + public SyntaxToken Identifier { get { - return TypeAccessor(this.SyntaxNode); + return IdentifierAccessor(this.SyntaxNode); } } @@ -56,7 +57,7 @@ public static explicit operator TupleElementSyntaxWrapper(SyntaxNode node) { if (node == null) { - return default(TupleElementSyntaxWrapper); + return default; } if (!IsInstance(node)) @@ -77,14 +78,14 @@ public static bool IsInstance(SyntaxNode node) return node != null && LightupHelpers.CanWrapNode(node, WrappedType); } - public TupleElementSyntaxWrapper WithIdentifier(SyntaxToken identifier) + public TupleElementSyntaxWrapper WithType(TypeSyntax type) { - return new TupleElementSyntaxWrapper(WithIdentifierAccessor(this.SyntaxNode, identifier)); + return new TupleElementSyntaxWrapper(WithTypeAccessor(this.SyntaxNode, type)); } - public TupleElementSyntaxWrapper WithType(TypeSyntax type) + public TupleElementSyntaxWrapper WithIdentifier(SyntaxToken identifier) { - return new TupleElementSyntaxWrapper(WithTypeAccessor(this.SyntaxNode, type)); + return new TupleElementSyntaxWrapper(WithIdentifierAccessor(this.SyntaxNode, identifier)); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/TupleExpressionSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/TupleExpressionSyntaxWrapper.g.cs new file mode 100644 index 000000000..e05a152c9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/TupleExpressionSyntaxWrapper.g.cs @@ -0,0 +1,108 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct TupleExpressionSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax"; + private static readonly Type WrappedType; + + private static readonly Func OpenParenTokenAccessor; + private static readonly Func> ArgumentsAccessor; + private static readonly Func CloseParenTokenAccessor; + private static readonly Func WithOpenParenTokenAccessor; + private static readonly Func, ExpressionSyntax> WithArgumentsAccessor; + private static readonly Func WithCloseParenTokenAccessor; + + private readonly ExpressionSyntax node; + + static TupleExpressionSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(TupleExpressionSyntaxWrapper)); + OpenParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(OpenParenToken)); + ArgumentsAccessor = LightupHelpers.CreateSyntaxPropertyAccessor>(WrappedType, nameof(Arguments)); + CloseParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(CloseParenToken)); + WithOpenParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(OpenParenToken)); + WithArgumentsAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor>(WrappedType, nameof(Arguments)); + WithCloseParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(CloseParenToken)); + } + + private TupleExpressionSyntaxWrapper(ExpressionSyntax node) + { + this.node = node; + } + + public ExpressionSyntax SyntaxNode => this.node; + + public SyntaxToken OpenParenToken + { + get + { + return OpenParenTokenAccessor(this.SyntaxNode); + } + } + + public SeparatedSyntaxList Arguments + { + get + { + return ArgumentsAccessor(this.SyntaxNode); + } + } + + public SyntaxToken CloseParenToken + { + get + { + return CloseParenTokenAccessor(this.SyntaxNode); + } + } + + public static explicit operator TupleExpressionSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new TupleExpressionSyntaxWrapper((ExpressionSyntax)node); + } + + public static implicit operator ExpressionSyntax(TupleExpressionSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public TupleExpressionSyntaxWrapper WithOpenParenToken(SyntaxToken openParenToken) + { + return new TupleExpressionSyntaxWrapper(WithOpenParenTokenAccessor(this.SyntaxNode, openParenToken)); + } + + public TupleExpressionSyntaxWrapper WithArguments(SeparatedSyntaxList arguments) + { + return new TupleExpressionSyntaxWrapper(WithArgumentsAccessor(this.SyntaxNode, arguments)); + } + + public TupleExpressionSyntaxWrapper WithCloseParenToken(SyntaxToken closeParenToken) + { + return new TupleExpressionSyntaxWrapper(WithCloseParenTokenAccessor(this.SyntaxNode, closeParenToken)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/TupleTypeSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/TupleTypeSyntaxWrapper.g.cs new file mode 100644 index 000000000..d0117fc61 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/TupleTypeSyntaxWrapper.g.cs @@ -0,0 +1,108 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct TupleTypeSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax"; + private static readonly Type WrappedType; + + private static readonly Func OpenParenTokenAccessor; + private static readonly Func> ElementsAccessor; + private static readonly Func CloseParenTokenAccessor; + private static readonly Func WithOpenParenTokenAccessor; + private static readonly Func, TypeSyntax> WithElementsAccessor; + private static readonly Func WithCloseParenTokenAccessor; + + private readonly TypeSyntax node; + + static TupleTypeSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(TupleTypeSyntaxWrapper)); + OpenParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(OpenParenToken)); + ElementsAccessor = LightupHelpers.CreateSeparatedSyntaxListPropertyAccessor(WrappedType, nameof(Elements)); + CloseParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(CloseParenToken)); + WithOpenParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(OpenParenToken)); + WithElementsAccessor = LightupHelpers.CreateSeparatedSyntaxListWithPropertyAccessor(WrappedType, nameof(Elements)); + WithCloseParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(CloseParenToken)); + } + + private TupleTypeSyntaxWrapper(TypeSyntax node) + { + this.node = node; + } + + public TypeSyntax SyntaxNode => this.node; + + public SyntaxToken OpenParenToken + { + get + { + return OpenParenTokenAccessor(this.SyntaxNode); + } + } + + public SeparatedSyntaxListWrapper Elements + { + get + { + return ElementsAccessor(this.SyntaxNode); + } + } + + public SyntaxToken CloseParenToken + { + get + { + return CloseParenTokenAccessor(this.SyntaxNode); + } + } + + public static explicit operator TupleTypeSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new TupleTypeSyntaxWrapper((TypeSyntax)node); + } + + public static implicit operator TypeSyntax(TupleTypeSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public TupleTypeSyntaxWrapper WithOpenParenToken(SyntaxToken openParenToken) + { + return new TupleTypeSyntaxWrapper(WithOpenParenTokenAccessor(this.SyntaxNode, openParenToken)); + } + + public TupleTypeSyntaxWrapper WithElements(SeparatedSyntaxListWrapper elements) + { + return new TupleTypeSyntaxWrapper(WithElementsAccessor(this.SyntaxNode, elements)); + } + + public TupleTypeSyntaxWrapper WithCloseParenToken(SyntaxToken closeParenToken) + { + return new TupleTypeSyntaxWrapper(WithCloseParenTokenAccessor(this.SyntaxNode, closeParenToken)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/TypePatternSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/TypePatternSyntaxWrapper.g.cs new file mode 100644 index 000000000..4bf6195c2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/TypePatternSyntaxWrapper.g.cs @@ -0,0 +1,94 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct TypePatternSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.TypePatternSyntax"; + private static readonly Type WrappedType; + + private static readonly Func TypeAccessor; + private static readonly Func WithTypeAccessor; + + private readonly CSharpSyntaxNode node; + + static TypePatternSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(TypePatternSyntaxWrapper)); + TypeAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Type)); + WithTypeAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Type)); + } + + private TypePatternSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public TypeSyntax Type + { + get + { + return TypeAccessor(this.SyntaxNode); + } + } + + public static explicit operator TypePatternSyntaxWrapper(PatternSyntaxWrapper node) + { + return (TypePatternSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator TypePatternSyntaxWrapper(ExpressionOrPatternSyntaxWrapper node) + { + return (TypePatternSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator TypePatternSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new TypePatternSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator PatternSyntaxWrapper(TypePatternSyntaxWrapper wrapper) + { + return PatternSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator ExpressionOrPatternSyntaxWrapper(TypePatternSyntaxWrapper wrapper) + { + return ExpressionOrPatternSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator CSharpSyntaxNode(TypePatternSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public TypePatternSyntaxWrapper WithType(TypeSyntax type) + { + return new TypePatternSyntaxWrapper(WithTypeAccessor(this.SyntaxNode, type)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/UnaryPatternSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/UnaryPatternSyntaxWrapper.g.cs new file mode 100644 index 000000000..51d2560c1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/UnaryPatternSyntaxWrapper.g.cs @@ -0,0 +1,111 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct UnaryPatternSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.UnaryPatternSyntax"; + private static readonly Type WrappedType; + + private static readonly Func OperatorTokenAccessor; + private static readonly Func PatternAccessor; + private static readonly Func WithOperatorTokenAccessor; + private static readonly Func WithPatternAccessor; + + private readonly CSharpSyntaxNode node; + + static UnaryPatternSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(UnaryPatternSyntaxWrapper)); + OperatorTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(OperatorToken)); + PatternAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Pattern)); + WithOperatorTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(OperatorToken)); + WithPatternAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Pattern)); + } + + private UnaryPatternSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public SyntaxToken OperatorToken + { + get + { + return OperatorTokenAccessor(this.SyntaxNode); + } + } + + public PatternSyntaxWrapper Pattern + { + get + { + return (PatternSyntaxWrapper)PatternAccessor(this.SyntaxNode); + } + } + + public static explicit operator UnaryPatternSyntaxWrapper(PatternSyntaxWrapper node) + { + return (UnaryPatternSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator UnaryPatternSyntaxWrapper(ExpressionOrPatternSyntaxWrapper node) + { + return (UnaryPatternSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator UnaryPatternSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new UnaryPatternSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator PatternSyntaxWrapper(UnaryPatternSyntaxWrapper wrapper) + { + return PatternSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator ExpressionOrPatternSyntaxWrapper(UnaryPatternSyntaxWrapper wrapper) + { + return ExpressionOrPatternSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator CSharpSyntaxNode(UnaryPatternSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public UnaryPatternSyntaxWrapper WithOperatorToken(SyntaxToken operatorToken) + { + return new UnaryPatternSyntaxWrapper(WithOperatorTokenAccessor(this.SyntaxNode, operatorToken)); + } + + public UnaryPatternSyntaxWrapper WithPattern(PatternSyntaxWrapper pattern) + { + return new UnaryPatternSyntaxWrapper(WithPatternAccessor(this.SyntaxNode, pattern)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/VarPatternSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/VarPatternSyntaxWrapper.g.cs new file mode 100644 index 000000000..13784a24a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/VarPatternSyntaxWrapper.g.cs @@ -0,0 +1,111 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct VarPatternSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.VarPatternSyntax"; + private static readonly Type WrappedType; + + private static readonly Func VarKeywordAccessor; + private static readonly Func DesignationAccessor; + private static readonly Func WithVarKeywordAccessor; + private static readonly Func WithDesignationAccessor; + + private readonly CSharpSyntaxNode node; + + static VarPatternSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(VarPatternSyntaxWrapper)); + VarKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(VarKeyword)); + DesignationAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Designation)); + WithVarKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(VarKeyword)); + WithDesignationAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Designation)); + } + + private VarPatternSyntaxWrapper(CSharpSyntaxNode node) + { + this.node = node; + } + + public CSharpSyntaxNode SyntaxNode => this.node; + + public SyntaxToken VarKeyword + { + get + { + return VarKeywordAccessor(this.SyntaxNode); + } + } + + public VariableDesignationSyntaxWrapper Designation + { + get + { + return (VariableDesignationSyntaxWrapper)DesignationAccessor(this.SyntaxNode); + } + } + + public static explicit operator VarPatternSyntaxWrapper(PatternSyntaxWrapper node) + { + return (VarPatternSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator VarPatternSyntaxWrapper(ExpressionOrPatternSyntaxWrapper node) + { + return (VarPatternSyntaxWrapper)node.SyntaxNode; + } + + public static explicit operator VarPatternSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new VarPatternSyntaxWrapper((CSharpSyntaxNode)node); + } + + public static implicit operator PatternSyntaxWrapper(VarPatternSyntaxWrapper wrapper) + { + return PatternSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator ExpressionOrPatternSyntaxWrapper(VarPatternSyntaxWrapper wrapper) + { + return ExpressionOrPatternSyntaxWrapper.FromUpcast(wrapper.node); + } + + public static implicit operator CSharpSyntaxNode(VarPatternSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public VarPatternSyntaxWrapper WithVarKeyword(SyntaxToken varKeyword) + { + return new VarPatternSyntaxWrapper(WithVarKeywordAccessor(this.SyntaxNode, varKeyword)); + } + + public VarPatternSyntaxWrapper WithDesignation(VariableDesignationSyntaxWrapper designation) + { + return new VarPatternSyntaxWrapper(WithDesignationAccessor(this.SyntaxNode, designation)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/VariableDesignationSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/VariableDesignationSyntaxWrapper.g.cs similarity index 79% rename from StyleCop.Analyzers/StyleCop.Analyzers/Lightup/VariableDesignationSyntaxWrapper.cs rename to StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/VariableDesignationSyntaxWrapper.g.cs index 4db9302d2..0cf306f9b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/VariableDesignationSyntaxWrapper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/VariableDesignationSyntaxWrapper.g.cs @@ -1,13 +1,15 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Lightup { using System; + using System.Collections.Immutable; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; - internal struct VariableDesignationSyntaxWrapper : ISyntaxWrapper + internal readonly partial struct VariableDesignationSyntaxWrapper : ISyntaxWrapper { internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax"; private static readonly Type WrappedType; @@ -16,7 +18,7 @@ internal struct VariableDesignationSyntaxWrapper : ISyntaxWrapper + internal readonly partial struct WhenClauseSyntaxWrapper : ISyntaxWrapper { internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax"; private static readonly Type WrappedType; @@ -22,7 +23,7 @@ internal struct WhenClauseSyntaxWrapper : ISyntaxWrapper static WhenClauseSyntaxWrapper() { - WrappedType = WrapperHelper.GetWrappedType(typeof(WhenClauseSyntaxWrapper)); + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(WhenClauseSyntaxWrapper)); WhenKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(WhenKeyword)); ConditionAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Condition)); WithWhenKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(WhenKeyword)); @@ -56,7 +57,7 @@ public static explicit operator WhenClauseSyntaxWrapper(SyntaxNode node) { if (node == null) { - return default(WhenClauseSyntaxWrapper); + return default; } if (!IsInstance(node)) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/WithExpressionSyntaxWrapper.g.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/WithExpressionSyntaxWrapper.g.cs new file mode 100644 index 000000000..ec72fe681 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/.generated/StyleCop.Analyzers.CodeGeneration/StyleCop.Analyzers.CodeGeneration.SyntaxLightupGenerator/WithExpressionSyntaxWrapper.g.cs @@ -0,0 +1,108 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal readonly partial struct WithExpressionSyntaxWrapper : ISyntaxWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.WithExpressionSyntax"; + private static readonly Type WrappedType; + + private static readonly Func ExpressionAccessor; + private static readonly Func WithKeywordAccessor; + private static readonly Func InitializerAccessor; + private static readonly Func WithExpressionAccessor; + private static readonly Func WithWithKeywordAccessor; + private static readonly Func WithInitializerAccessor; + + private readonly ExpressionSyntax node; + + static WithExpressionSyntaxWrapper() + { + WrappedType = SyntaxWrapperHelper.GetWrappedType(typeof(WithExpressionSyntaxWrapper)); + ExpressionAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Expression)); + WithKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(WithKeyword)); + InitializerAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Initializer)); + WithExpressionAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Expression)); + WithWithKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(WithKeyword)); + WithInitializerAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Initializer)); + } + + private WithExpressionSyntaxWrapper(ExpressionSyntax node) + { + this.node = node; + } + + public ExpressionSyntax SyntaxNode => this.node; + + public ExpressionSyntax Expression + { + get + { + return ExpressionAccessor(this.SyntaxNode); + } + } + + public SyntaxToken WithKeyword + { + get + { + return WithKeywordAccessor(this.SyntaxNode); + } + } + + public InitializerExpressionSyntax Initializer + { + get + { + return InitializerAccessor(this.SyntaxNode); + } + } + + public static explicit operator WithExpressionSyntaxWrapper(SyntaxNode node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new WithExpressionSyntaxWrapper((ExpressionSyntax)node); + } + + public static implicit operator ExpressionSyntax(WithExpressionSyntaxWrapper wrapper) + { + return wrapper.node; + } + + public static bool IsInstance(SyntaxNode node) + { + return node != null && LightupHelpers.CanWrapNode(node, WrappedType); + } + + public WithExpressionSyntaxWrapper WithExpression(ExpressionSyntax expression) + { + return new WithExpressionSyntaxWrapper(WithExpressionAccessor(this.SyntaxNode, expression)); + } + + public WithExpressionSyntaxWrapper WithWithKeyword(SyntaxToken withKeyword) + { + return new WithExpressionSyntaxWrapper(WithWithKeywordAccessor(this.SyntaxNode, withKeyword)); + } + + public WithExpressionSyntaxWrapper WithInitializer(InitializerExpressionSyntax initializer) + { + return new WithExpressionSyntaxWrapper(WithInitializerAccessor(this.SyntaxNode, initializer)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/AccessorDeclarationSyntaxExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/AccessorDeclarationSyntaxExtensions.cs index 53b395870..d92594148 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/AccessorDeclarationSyntaxExtensions.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/AccessorDeclarationSyntaxExtensions.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/AnalyzerConfigOptionsProviderWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/AnalyzerConfigOptionsProviderWrapper.cs new file mode 100644 index 000000000..e4ebaff5d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/AnalyzerConfigOptionsProviderWrapper.cs @@ -0,0 +1,103 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.Diagnostics; + + internal readonly struct AnalyzerConfigOptionsProviderWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptionsProvider"; + private static readonly Type WrappedType; + + private static readonly Func GlobalOptionsAccessor; + private static readonly Func GetOptionsSyntaxTreeAccessor; + private static readonly Func GetOptionsAdditionalTextAccessor; + + private readonly object node; + + static AnalyzerConfigOptionsProviderWrapper() + { + WrappedType = WrapperHelper.GetWrappedType(typeof(AnalyzerConfigOptionsProviderWrapper)); + + GlobalOptionsAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(GlobalOptions)); + GetOptionsSyntaxTreeAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, typeof(SyntaxTree), nameof(GetOptions)); + GetOptionsAdditionalTextAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, typeof(AdditionalText), nameof(GetOptions)); + } + + private AnalyzerConfigOptionsProviderWrapper(object node) + { + this.node = node; + } + + public AnalyzerConfigOptionsWrapper GlobalOptions + { + get + { + if (this.node == null && WrappedType == null) + { + // Gracefully fall back to a collection with no values + return AnalyzerConfigOptionsWrapper.FromObject(null); + } + + return AnalyzerConfigOptionsWrapper.FromObject(GlobalOptionsAccessor(this.node)); + } + } + + public static AnalyzerConfigOptionsProviderWrapper FromObject(object node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new AnalyzerConfigOptionsProviderWrapper(node); + } + + public static bool IsInstance(object obj) + { + return obj != null && LightupHelpers.CanWrapObject(obj, WrappedType); + } + + public AnalyzerConfigOptionsWrapper GetOptions(SyntaxTree tree) + { + if (this.node == null && WrappedType == null) + { + // Gracefully fall back to a collection with no values + if (tree == null) + { + throw new ArgumentNullException(nameof(tree)); + } + + return AnalyzerConfigOptionsWrapper.FromObject(null); + } + + return AnalyzerConfigOptionsWrapper.FromObject(GetOptionsSyntaxTreeAccessor(this.node, tree)); + } + + public AnalyzerConfigOptionsWrapper GetOptions(AdditionalText textFile) + { + if (this.node == null && WrappedType == null) + { + // Gracefully fall back to a collection with no values + if (textFile == null) + { + throw new ArgumentNullException(nameof(textFile)); + } + + return AnalyzerConfigOptionsWrapper.FromObject(null); + } + + return AnalyzerConfigOptionsWrapper.FromObject(GetOptionsAdditionalTextAccessor(this.node, textFile)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/AnalyzerConfigOptionsWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/AnalyzerConfigOptionsWrapper.cs new file mode 100644 index 000000000..44b572ba9 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/AnalyzerConfigOptionsWrapper.cs @@ -0,0 +1,79 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using System; + + internal readonly struct AnalyzerConfigOptionsWrapper + { + internal const string WrappedTypeName = "Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions"; + private static readonly Type WrappedType; + + private static readonly Func KeyComparerAccessor; + private static readonly TryGetValueAccessor TryGetValueAccessor; + + private readonly object node; + + static AnalyzerConfigOptionsWrapper() + { + WrappedType = WrapperHelper.GetWrappedType(typeof(AnalyzerConfigOptionsWrapper)); + + KeyComparerAccessor = LightupHelpers.CreateStaticPropertyAccessor(WrappedType, nameof(KeyComparer)); + TryGetValueAccessor = LightupHelpers.CreateTryGetValueAccessor(WrappedType, typeof(string), nameof(TryGetValue)); + } + + private AnalyzerConfigOptionsWrapper(object node) + { + this.node = node; + } + + public static StringComparer KeyComparer + { + get + { + if (WrappedType is null) + { + // Gracefully fall back to a collection with no values + return StringComparer.Ordinal; + } + + return KeyComparerAccessor(); + } + } + + public static AnalyzerConfigOptionsWrapper FromObject(object node) + { + if (node == null) + { + return default; + } + + if (!IsInstance(node)) + { + throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); + } + + return new AnalyzerConfigOptionsWrapper(node); + } + + public static bool IsInstance(object obj) + { + return obj != null && LightupHelpers.CanWrapObject(obj, WrappedType); + } + + public bool TryGetValue(string key, out string value) + { + if (this.node is null && WrappedType is null) + { + // Gracefully fall back to a collection with no values + value = null; + return false; + } + + return TryGetValueAccessor(this.node, key, out value); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/AnalyzerOptionsExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/AnalyzerOptionsExtensions.cs new file mode 100644 index 000000000..f81e69298 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/AnalyzerOptionsExtensions.cs @@ -0,0 +1,25 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using Microsoft.CodeAnalysis.Diagnostics; + + internal static class AnalyzerOptionsExtensions + { + private static readonly Func AnalyzerConfigOptionsProviderAccessor; + + static AnalyzerOptionsExtensions() + { + AnalyzerConfigOptionsProviderAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(typeof(AnalyzerOptions), nameof(AnalyzerConfigOptionsProvider)); + } + + public static AnalyzerConfigOptionsProviderWrapper AnalyzerConfigOptionsProvider(this AnalyzerOptions options) + { + return AnalyzerConfigOptionsProviderWrapper.FromObject(AnalyzerConfigOptionsProviderAccessor(options)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ArgumentSyntaxExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ArgumentSyntaxExtensions.cs new file mode 100644 index 000000000..c4b09a3a1 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ArgumentSyntaxExtensions.cs @@ -0,0 +1,33 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal static class ArgumentSyntaxExtensions + { + private static readonly Func RefKindKeywordAccessor; + private static readonly Func WithRefKindKeywordAccessor; + + static ArgumentSyntaxExtensions() + { + RefKindKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(typeof(ArgumentSyntax), nameof(RefKindKeyword)); + WithRefKindKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(typeof(ArgumentSyntax), nameof(RefKindKeyword)); + } + + public static SyntaxToken RefKindKeyword(this ArgumentSyntax syntax) + { + return RefKindKeywordAccessor(syntax); + } + + public static ArgumentSyntax WithRefKindKeyword(this ArgumentSyntax syntax, SyntaxToken refKindKeyword) + { + return WithRefKindKeywordAccessor(syntax, refKindKeyword); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/BaseMethodDeclarationSyntaxExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/BaseMethodDeclarationSyntaxExtensions.cs index d6bc3e948..33f3a6593 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/BaseMethodDeclarationSyntaxExtensions.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/BaseMethodDeclarationSyntaxExtensions.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/BaseNamespaceDeclarationSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/BaseNamespaceDeclarationSyntaxWrapper.cs new file mode 100644 index 000000000..369a3eb5d --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/BaseNamespaceDeclarationSyntaxWrapper.cs @@ -0,0 +1,19 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal partial struct BaseNamespaceDeclarationSyntaxWrapper : ISyntaxWrapper + { + internal const string FallbackWrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.NamespaceDeclarationSyntax"; + + public static implicit operator BaseNamespaceDeclarationSyntaxWrapper(NamespaceDeclarationSyntax node) + { + return new BaseNamespaceDeclarationSyntaxWrapper(node); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/BaseObjectCreationExpressionSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/BaseObjectCreationExpressionSyntaxWrapper.cs new file mode 100644 index 000000000..2fff57171 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/BaseObjectCreationExpressionSyntaxWrapper.cs @@ -0,0 +1,19 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal partial struct BaseObjectCreationExpressionSyntaxWrapper : ISyntaxWrapper + { + internal const string FallbackWrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.ObjectCreationExpressionSyntax"; + + public static implicit operator BaseObjectCreationExpressionSyntaxWrapper(ObjectCreationExpressionSyntax node) + { + return new BaseObjectCreationExpressionSyntaxWrapper(node); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CSharp7.md b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CSharp7.md index 1542ed5ca..9777e79f2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CSharp7.md +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CSharp7.md @@ -1,5 +1,7 @@ # C# 7 APIs supported via light-up +See [dotnet/roslyn@c2af711](https://github.com/dotnet/roslyn/commit/c2af71127234e2b6df231fad3b9f7db6cc7cb444). + ## Semantics * [ ] `Microsoft.CodeAnalysis.CommandLineArguments.DisplayVersion.get -> bool` @@ -59,7 +61,7 @@ * [ ] `Microsoft.CodeAnalysis.IArrayTypeSymbol.Sizes.get -> System.Collections.Immutable.ImmutableArray` * [ ] `Microsoft.CodeAnalysis.IDiscardSymbol` * [ ] `Microsoft.CodeAnalysis.IDiscardSymbol.Type.get -> Microsoft.CodeAnalysis.ITypeSymbol` -* [ ] `Microsoft.CodeAnalysis.IFieldSymbol.CorrespondingTupleField.get -> Microsoft.CodeAnalysis.IFieldSymbol` +* [x] `Microsoft.CodeAnalysis.IFieldSymbol.CorrespondingTupleField.get -> Microsoft.CodeAnalysis.IFieldSymbol` * [ ] `Microsoft.CodeAnalysis.ILocalSymbol.IsRef.get -> bool` * [ ] `Microsoft.CodeAnalysis.IMethodSymbol.RefCustomModifiers.get -> System.Collections.Immutable.ImmutableArray` * [ ] `Microsoft.CodeAnalysis.IMethodSymbol.ReturnsByRef.get -> bool` @@ -396,12 +398,12 @@ * [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.SingleVariableDesignation(Microsoft.CodeAnalysis.SyntaxToken identifier) -> Microsoft.CodeAnalysis.CSharp.Syntax.SingleVariableDesignationSyntax` * [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ThrowExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax` * [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ThrowExpression(Microsoft.CodeAnalysis.SyntaxToken throwKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.ThrowExpressionSyntax` -* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.TupleElement(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax` -* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.TupleElement(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.SyntaxToken identifier) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax` -* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.TupleExpression(Microsoft.CodeAnalysis.SeparatedSyntaxList arguments = default(Microsoft.CodeAnalysis.SeparatedSyntaxList)) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax` -* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.TupleExpression(Microsoft.CodeAnalysis.SyntaxToken openParenToken, Microsoft.CodeAnalysis.SeparatedSyntaxList arguments, Microsoft.CodeAnalysis.SyntaxToken closeParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax` -* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.TupleType(Microsoft.CodeAnalysis.SeparatedSyntaxList elements = default(Microsoft.CodeAnalysis.SeparatedSyntaxList)) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax` -* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.TupleType(Microsoft.CodeAnalysis.SyntaxToken openParenToken, Microsoft.CodeAnalysis.SeparatedSyntaxList elements, Microsoft.CodeAnalysis.SyntaxToken closeParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax` +* [x] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.TupleElement(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax` +* [x] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.TupleElement(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.SyntaxToken identifier) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleElementSyntax` +* [x] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.TupleExpression(Microsoft.CodeAnalysis.SeparatedSyntaxList arguments = default(Microsoft.CodeAnalysis.SeparatedSyntaxList)) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax` +* [x] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.TupleExpression(Microsoft.CodeAnalysis.SyntaxToken openParenToken, Microsoft.CodeAnalysis.SeparatedSyntaxList arguments, Microsoft.CodeAnalysis.SyntaxToken closeParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax` +* [x] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.TupleType(Microsoft.CodeAnalysis.SeparatedSyntaxList elements = default(Microsoft.CodeAnalysis.SeparatedSyntaxList)) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax` +* [x] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.TupleType(Microsoft.CodeAnalysis.SyntaxToken openParenToken, Microsoft.CodeAnalysis.SeparatedSyntaxList elements, Microsoft.CodeAnalysis.SyntaxToken closeParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax` * [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.WhenClause(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax condition) -> Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax` * [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.WhenClause(Microsoft.CodeAnalysis.SyntaxToken whenKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax condition) -> Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax` * [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitCasePatternSwitchLabel(Microsoft.CodeAnalysis.CSharp.Syntax.CasePatternSwitchLabelSyntax node) -> void` diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CSharp71.md b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CSharp71.md new file mode 100644 index 000000000..4952858a0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CSharp71.md @@ -0,0 +1,29 @@ +# C# 7.1 APIs supported via light-up + +See [dotnet/roslyn@5520eac](https://github.com/dotnet/roslyn/commit/5520eaccd5d22ae98a39a5f88120277f02097dbf). + +## Semantics + +* [ ] `Microsoft.CodeAnalysis.CSharp.LanguageVersionFacts` +* [ ] `const Microsoft.CodeAnalysis.LanguageNames.FSharp = "F#" -> string` +* [ ] `Microsoft.CodeAnalysis.CommandLineArguments.OutputRefFilePath.get -> string` +* [ ] `Microsoft.CodeAnalysis.CommandLineArguments.RuleSetPath.get -> string` +* [ ] `Microsoft.CodeAnalysis.CommandLineReference.CommandLineReference(string reference, Microsoft.CodeAnalysis.MetadataReferenceProperties properties) -> void` +* [ ] `Microsoft.CodeAnalysis.CommandLineSourceFile.CommandLineSourceFile(string path, bool isScript) -> void` +* [ ] `Microsoft.CodeAnalysis.Compilation.Emit(System.IO.Stream peStream, System.IO.Stream pdbStream = null, System.IO.Stream xmlDocumentationStream = null, System.IO.Stream win32Resources = null, System.Collections.Generic.IEnumerable manifestResources = null, Microsoft.CodeAnalysis.Emit.EmitOptions options = null, Microsoft.CodeAnalysis.IMethodSymbol debugEntryPoint = null, System.IO.Stream sourceLinkStream = null, System.Collections.Generic.IEnumerable embeddedTexts = null, System.IO.Stream metadataPEStream = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.Emit.EmitResult` +* [ ] `Microsoft.CodeAnalysis.Compilation.Emit(System.IO.Stream peStream, System.IO.Stream pdbStream, System.IO.Stream xmlDocumentationStream, System.IO.Stream win32Resources, System.Collections.Generic.IEnumerable manifestResources, Microsoft.CodeAnalysis.Emit.EmitOptions options, Microsoft.CodeAnalysis.IMethodSymbol debugEntryPoint, System.IO.Stream sourceLinkStream, System.Collections.Generic.IEnumerable embeddedTexts, System.Threading.CancellationToken cancellationToken) -> Microsoft.CodeAnalysis.Emit.EmitResult` +* [ ] `Microsoft.CodeAnalysis.Emit.EmitOptions.EmitOptions(bool metadataOnly = false, Microsoft.CodeAnalysis.Emit.DebugInformationFormat debugInformationFormat = (Microsoft.CodeAnalysis.Emit.DebugInformationFormat)0, string pdbFilePath = null, string outputNameOverride = null, int fileAlignment = 0, ulong baseAddress = 0, bool highEntropyVirtualAddressSpace = false, Microsoft.CodeAnalysis.SubsystemVersion subsystemVersion = default(Microsoft.CodeAnalysis.SubsystemVersion), string runtimeMetadataVersion = null, bool tolerateErrors = false, bool includePrivateMembers = true, System.Collections.Immutable.ImmutableArray instrumentationKinds = default(System.Collections.Immutable.ImmutableArray)) -> void` +* [ ] `Microsoft.CodeAnalysis.ParseOptions.Errors.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.ParseOptions.SpecifiedKind.get -> Microsoft.CodeAnalysis.SourceCodeKind` +* [ ] `static Microsoft.CodeAnalysis.Compilation.GetRequiredLanguageVersion(Microsoft.CodeAnalysis.Diagnostic diagnostic) -> string` +* [ ] `static Microsoft.CodeAnalysis.CSharp.LanguageVersionFacts.MapSpecifiedToEffectiveVersion(this Microsoft.CodeAnalysis.CSharp.LanguageVersion version) -> Microsoft.CodeAnalysis.CSharp.LanguageVersion` +* [ ] `static Microsoft.CodeAnalysis.CSharp.LanguageVersionFacts.ToDisplayString(this Microsoft.CodeAnalysis.CSharp.LanguageVersion version) -> string` +* [ ] `static Microsoft.CodeAnalysis.CSharp.LanguageVersionFacts.TryParse(this string version, out Microsoft.CodeAnalysis.CSharp.LanguageVersion result) -> bool` + +## Syntax + +* [x] `Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp7_1 = 701 -> Microsoft.CodeAnalysis.CSharp.LanguageVersion` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.ConflictMarkerTrivia = 8564 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.DefaultLiteralExpression = 8755 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `static Microsoft.CodeAnalysis.CSharp.SyntaxFacts.IsReservedTupleElementName(string elementName) -> bool` +* [x] `static Microsoft.CodeAnalysis.CSharp.SyntaxFacts.TryGetInferredMemberName(this Microsoft.CodeAnalysis.SyntaxNode syntax) -> string` diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CSharp72.md b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CSharp72.md new file mode 100644 index 000000000..7e329037a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CSharp72.md @@ -0,0 +1,725 @@ +# C# 7.2 APIs supported via light-up + +See [dotnet/roslyn@30a68f1](https://github.com/dotnet/roslyn/commit/30a68f16a0cb3d154a0fca41df38ec509dfe703c). + +## Semantics + +* [ ] `abstract Microsoft.CodeAnalysis.Diagnostics.OperationBlockStartAnalysisContext.RegisterOperationAction(System.Action action, System.Collections.Immutable.ImmutableArray operationKinds) -> void` +* [ ] `abstract Microsoft.CodeAnalysis.Diagnostics.OperationBlockStartAnalysisContext.RegisterOperationBlockEndAction(System.Action action) -> void` +* [ ] `abstract Microsoft.CodeAnalysis.SemanticModel.GetOperationCore(Microsoft.CodeAnalysis.SyntaxNode node, System.Threading.CancellationToken cancellationToken) -> Microsoft.CodeAnalysis.IOperation` +* [ ] `abstract Microsoft.CodeAnalysis.SemanticModel.RootCore.get -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `Microsoft.CodeAnalysis.CommandLineArguments.DisplayLangVersions.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.AnalysisContext.RegisterOperationAction(System.Action action, params Microsoft.CodeAnalysis.OperationKind[] operationKinds) -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.CompilationStartAnalysisContext.RegisterOperationAction(System.Action action, params Microsoft.CodeAnalysis.OperationKind[] operationKinds) -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationAnalysisContext` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationAnalysisContext.CancellationToken.get -> System.Threading.CancellationToken` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationAnalysisContext.Compilation.get -> Microsoft.CodeAnalysis.Compilation` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationAnalysisContext.ContainingSymbol.get -> Microsoft.CodeAnalysis.ISymbol` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationAnalysisContext.Operation.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationAnalysisContext.OperationAnalysisContext(Microsoft.CodeAnalysis.IOperation operation, Microsoft.CodeAnalysis.ISymbol containingSymbol, Microsoft.CodeAnalysis.Compilation compilation, Microsoft.CodeAnalysis.Diagnostics.AnalyzerOptions options, System.Action reportDiagnostic, System.Func isSupportedDiagnostic, System.Threading.CancellationToken cancellationToken) -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationAnalysisContext.Options.get -> Microsoft.CodeAnalysis.Diagnostics.AnalyzerOptions` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationAnalysisContext.ReportDiagnostic(Microsoft.CodeAnalysis.Diagnostic diagnostic) -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationBlockAnalysisContext` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationBlockAnalysisContext.CancellationToken.get -> System.Threading.CancellationToken` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationBlockAnalysisContext.Compilation.get -> Microsoft.CodeAnalysis.Compilation` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationBlockAnalysisContext.OperationBlockAnalysisContext(System.Collections.Immutable.ImmutableArray operationBlocks, Microsoft.CodeAnalysis.ISymbol owningSymbol, Microsoft.CodeAnalysis.Compilation compilation, Microsoft.CodeAnalysis.Diagnostics.AnalyzerOptions options, System.Action reportDiagnostic, System.Func isSupportedDiagnostic, System.Threading.CancellationToken cancellationToken) -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationBlockAnalysisContext.OperationBlocks.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationBlockAnalysisContext.Options.get -> Microsoft.CodeAnalysis.Diagnostics.AnalyzerOptions` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationBlockAnalysisContext.OwningSymbol.get -> Microsoft.CodeAnalysis.ISymbol` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationBlockAnalysisContext.ReportDiagnostic(Microsoft.CodeAnalysis.Diagnostic diagnostic) -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationBlockStartAnalysisContext` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationBlockStartAnalysisContext.CancellationToken.get -> System.Threading.CancellationToken` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationBlockStartAnalysisContext.Compilation.get -> Microsoft.CodeAnalysis.Compilation` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationBlockStartAnalysisContext.OperationBlockStartAnalysisContext(System.Collections.Immutable.ImmutableArray operationBlocks, Microsoft.CodeAnalysis.ISymbol owningSymbol, Microsoft.CodeAnalysis.Compilation compilation, Microsoft.CodeAnalysis.Diagnostics.AnalyzerOptions options, System.Threading.CancellationToken cancellationToken) -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationBlockStartAnalysisContext.OperationBlocks.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationBlockStartAnalysisContext.Options.get -> Microsoft.CodeAnalysis.Diagnostics.AnalyzerOptions` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationBlockStartAnalysisContext.OwningSymbol.get -> Microsoft.CodeAnalysis.ISymbol` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationBlockStartAnalysisContext.RegisterOperationAction(System.Action action, params Microsoft.CodeAnalysis.OperationKind[] operationKinds) -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.OperationActionsCount.get -> int` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.OperationActionsCount.set -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.OperationBlockActionsCount.get -> int` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.OperationBlockActionsCount.set -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.OperationBlockEndActionsCount.get -> int` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.OperationBlockEndActionsCount.set -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.OperationBlockStartActionsCount.get -> int` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.OperationBlockStartActionsCount.set -> void` +* [ ] `Microsoft.CodeAnalysis.ILocalSymbol.RefKind.get -> Microsoft.CodeAnalysis.RefKind` +* [ ] `Microsoft.CodeAnalysis.IMethodSymbol.RefKind.get -> Microsoft.CodeAnalysis.RefKind` +* [ ] `Microsoft.CodeAnalysis.IMethodSymbol.ReturnsByRefReadonly.get -> bool` +* [ ] `Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.IOperation.Accept(Microsoft.CodeAnalysis.Operations.OperationVisitor visitor) -> void` +* [ ] `Microsoft.CodeAnalysis.IOperation.Accept(Microsoft.CodeAnalysis.Operations.OperationVisitor visitor, TArgument argument) -> TResult` +* [ ] `Microsoft.CodeAnalysis.IOperation.Children.get -> System.Collections.Generic.IEnumerable` +* [ ] `Microsoft.CodeAnalysis.IOperation.ConstantValue.get -> Microsoft.CodeAnalysis.Optional` +* [ ] `Microsoft.CodeAnalysis.IOperation.IsImplicit.get -> bool` +* [ ] `Microsoft.CodeAnalysis.IOperation.Kind.get -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.IOperation.Language.get -> string` +* [ ] `Microsoft.CodeAnalysis.IOperation.Parent.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.IOperation.Syntax.get -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `Microsoft.CodeAnalysis.IOperation.Type.get -> Microsoft.CodeAnalysis.ITypeSymbol` +* [ ] `Microsoft.CodeAnalysis.IPropertySymbol.RefKind.get -> Microsoft.CodeAnalysis.RefKind` +* [ ] `Microsoft.CodeAnalysis.IPropertySymbol.ReturnsByRefReadonly.get -> bool` +* [ ] `Microsoft.CodeAnalysis.ModuleMetadata.IsDisposed.get -> bool` +* [ ] `Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.AddressOf = 64 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.AnonymousFunction = 35 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.AnonymousObjectCreation = 49 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Argument = 79 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.ArrayCreation = 38 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.ArrayElementReference = 23 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.ArrayInitializer = 76 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Await = 41 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.BinaryOperator = 32 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Block = 2 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Branch = 7 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.CaseClause = 82 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.CatchClause = 80 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Coalesce = 34 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.CollectionElementInitializer = 52 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.CompoundAssignment = 43 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Conditional = 33 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.ConditionalAccess = 46 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.ConditionalAccessInstance = 47 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.ConstantPattern = 85 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Conversion = 21 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.DeclarationExpression = 70 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.DeclarationPattern = 86 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.DeconstructionAssignment = 69 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Decrement = 68 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.DefaultValue = 61 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.DelegateCreation = 60 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.DynamicIndexerAccess = 58 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.DynamicInvocation = 57 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.DynamicMemberReference = 56 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.DynamicObjectCreation = 55 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Empty = 8 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.End = 18 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.EventAssignment = 45 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.EventReference = 30 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.ExpressionStatement = 15 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.FieldInitializer = 72 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.FieldReference = 26 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Increment = 66 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.InstanceReference = 39 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.InterpolatedString = 48 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.InterpolatedStringText = 83 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Interpolation = 84 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Invalid = 1 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Invocation = 22 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.IsPattern = 65 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.IsType = 40 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Labeled = 6 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Literal = 20 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.LocalFunction = 16 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.LocalReference = 24 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Lock = 11 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Loop = 5 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.MemberInitializer = 51 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.MethodReference = 27 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.NameOf = 53 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.None = 0 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.ObjectCreation = 36 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.ObjectOrCollectionInitializer = 50 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.OmittedArgument = 71 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.ParameterInitializer = 75 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.ParameterReference = 25 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Parenthesized = 44 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.PropertyInitializer = 74 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.PropertyReference = 28 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.RaiseEvent = 19 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Return = 9 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.SimpleAssignment = 42 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.SizeOf = 63 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Stop = 17 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Switch = 4 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.SwitchCase = 81 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Throw = 67 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.TranslatedQuery = 59 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Try = 12 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Tuple = 54 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.TypeOf = 62 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.TypeParameterObjectCreation = 37 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.UnaryOperator = 31 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Using = 13 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.VariableDeclaration = 78 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.VariableDeclarationGroup = 3 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.VariableDeclarator = 77 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.VariableInitializer = 73 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.YieldBreak = 10 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.YieldReturn = 14 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.Operations.ArgumentKind` +* [ ] `Microsoft.CodeAnalysis.Operations.ArgumentKind.DefaultValue = 3 -> Microsoft.CodeAnalysis.Operations.ArgumentKind` +* [ ] `Microsoft.CodeAnalysis.Operations.ArgumentKind.Explicit = 1 -> Microsoft.CodeAnalysis.Operations.ArgumentKind` +* [ ] `Microsoft.CodeAnalysis.Operations.ArgumentKind.None = 0 -> Microsoft.CodeAnalysis.Operations.ArgumentKind` +* [ ] `Microsoft.CodeAnalysis.Operations.ArgumentKind.ParamArray = 2 -> Microsoft.CodeAnalysis.Operations.ArgumentKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.Add = 1 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.And = 10 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.Concatenate = 15 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.ConditionalAnd = 13 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.ConditionalOr = 14 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.Divide = 4 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.Equals = 16 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.ExclusiveOr = 12 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.GreaterThan = 23 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.GreaterThanOrEqual = 22 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.IntegerDivide = 5 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.LeftShift = 8 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.LessThan = 20 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.LessThanOrEqual = 21 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.Like = 24 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.Multiply = 3 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.None = 0 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.NotEquals = 18 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.ObjectValueEquals = 17 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.ObjectValueNotEquals = 19 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.Or = 11 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.Power = 7 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.Remainder = 6 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.RightShift = 9 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BinaryOperatorKind.Subtract = 2 -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BranchKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BranchKind.Break = 2 -> Microsoft.CodeAnalysis.Operations.BranchKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BranchKind.Continue = 1 -> Microsoft.CodeAnalysis.Operations.BranchKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BranchKind.GoTo = 3 -> Microsoft.CodeAnalysis.Operations.BranchKind` +* [ ] `Microsoft.CodeAnalysis.Operations.BranchKind.None = 0 -> Microsoft.CodeAnalysis.Operations.BranchKind` +* [ ] `Microsoft.CodeAnalysis.Operations.CaseKind` +* [ ] `Microsoft.CodeAnalysis.Operations.CaseKind.Default = 4 -> Microsoft.CodeAnalysis.Operations.CaseKind` +* [ ] `Microsoft.CodeAnalysis.Operations.CaseKind.None = 0 -> Microsoft.CodeAnalysis.Operations.CaseKind` +* [ ] `Microsoft.CodeAnalysis.Operations.CaseKind.Pattern = 5 -> Microsoft.CodeAnalysis.Operations.CaseKind` +* [ ] `Microsoft.CodeAnalysis.Operations.CaseKind.Range = 3 -> Microsoft.CodeAnalysis.Operations.CaseKind` +* [ ] `Microsoft.CodeAnalysis.Operations.CaseKind.Relational = 2 -> Microsoft.CodeAnalysis.Operations.CaseKind` +* [ ] `Microsoft.CodeAnalysis.Operations.CaseKind.SingleValue = 1 -> Microsoft.CodeAnalysis.Operations.CaseKind` +* [ ] `Microsoft.CodeAnalysis.Operations.CommonConversion` +* [ ] `Microsoft.CodeAnalysis.Operations.CommonConversion.Exists.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.CommonConversion.IsIdentity.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.CommonConversion.IsNumeric.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.CommonConversion.IsReference.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.CommonConversion.IsUserDefined.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.CommonConversion.MethodSymbol.get -> Microsoft.CodeAnalysis.IMethodSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IAddressOfOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IAddressOfOperation.Reference.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IAnonymousFunctionOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IAnonymousFunctionOperation.Body.get -> Microsoft.CodeAnalysis.Operations.IBlockOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IAnonymousFunctionOperation.Symbol.get -> Microsoft.CodeAnalysis.IMethodSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IAnonymousObjectCreationOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IAnonymousObjectCreationOperation.Initializers.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IArgumentOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IArgumentOperation.ArgumentKind.get -> Microsoft.CodeAnalysis.Operations.ArgumentKind` +* [ ] `Microsoft.CodeAnalysis.Operations.IArgumentOperation.InConversion.get -> Microsoft.CodeAnalysis.Operations.CommonConversion` +* [ ] `Microsoft.CodeAnalysis.Operations.IArgumentOperation.OutConversion.get -> Microsoft.CodeAnalysis.Operations.CommonConversion` +* [ ] `Microsoft.CodeAnalysis.Operations.IArgumentOperation.Parameter.get -> Microsoft.CodeAnalysis.IParameterSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IArgumentOperation.Value.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IArrayCreationOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IArrayCreationOperation.DimensionSizes.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IArrayCreationOperation.Initializer.get -> Microsoft.CodeAnalysis.Operations.IArrayInitializerOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IArrayElementReferenceOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IArrayElementReferenceOperation.ArrayReference.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IArrayElementReferenceOperation.Indices.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IArrayInitializerOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IArrayInitializerOperation.ElementValues.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IAssignmentOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IAssignmentOperation.Target.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IAssignmentOperation.Value.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IAwaitOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IAwaitOperation.Operation.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IBinaryOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IBinaryOperation.IsChecked.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.IBinaryOperation.IsCompareText.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.IBinaryOperation.IsLifted.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.IBinaryOperation.LeftOperand.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IBinaryOperation.OperatorKind.get -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.IBinaryOperation.OperatorMethod.get -> Microsoft.CodeAnalysis.IMethodSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IBinaryOperation.RightOperand.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IBlockOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IBlockOperation.Locals.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IBlockOperation.Operations.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IBranchOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IBranchOperation.BranchKind.get -> Microsoft.CodeAnalysis.Operations.BranchKind` +* [ ] `Microsoft.CodeAnalysis.Operations.IBranchOperation.Target.get -> Microsoft.CodeAnalysis.ILabelSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.ICaseClauseOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ICaseClauseOperation.CaseKind.get -> Microsoft.CodeAnalysis.Operations.CaseKind` +* [ ] `Microsoft.CodeAnalysis.Operations.ICatchClauseOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ICatchClauseOperation.ExceptionDeclarationOrExpression.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ICatchClauseOperation.ExceptionType.get -> Microsoft.CodeAnalysis.ITypeSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.ICatchClauseOperation.Filter.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ICatchClauseOperation.Handler.get -> Microsoft.CodeAnalysis.Operations.IBlockOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ICatchClauseOperation.Locals.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.ICoalesceOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ICoalesceOperation.Value.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ICoalesceOperation.WhenNull.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ICollectionElementInitializerOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ICollectionElementInitializerOperation.AddMethod.get -> Microsoft.CodeAnalysis.IMethodSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.ICollectionElementInitializerOperation.Arguments.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.ICollectionElementInitializerOperation.IsDynamic.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.ICompoundAssignmentOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ICompoundAssignmentOperation.InConversion.get -> Microsoft.CodeAnalysis.Operations.CommonConversion` +* [ ] `Microsoft.CodeAnalysis.Operations.ICompoundAssignmentOperation.IsChecked.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.ICompoundAssignmentOperation.IsLifted.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.ICompoundAssignmentOperation.OperatorKind.get -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.ICompoundAssignmentOperation.OperatorMethod.get -> Microsoft.CodeAnalysis.IMethodSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.ICompoundAssignmentOperation.OutConversion.get -> Microsoft.CodeAnalysis.Operations.CommonConversion` +* [ ] `Microsoft.CodeAnalysis.Operations.IConditionalAccessInstanceOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IConditionalAccessOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IConditionalAccessOperation.Operation.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IConditionalAccessOperation.WhenNotNull.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IConditionalOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IConditionalOperation.Condition.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IConditionalOperation.IsRef.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.IConditionalOperation.WhenFalse.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IConditionalOperation.WhenTrue.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IConstantPatternOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IConstantPatternOperation.Value.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IConversionOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IConversionOperation.Conversion.get -> Microsoft.CodeAnalysis.Operations.CommonConversion` +* [ ] `Microsoft.CodeAnalysis.Operations.IConversionOperation.IsChecked.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.IConversionOperation.IsTryCast.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.IConversionOperation.Operand.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IConversionOperation.OperatorMethod.get -> Microsoft.CodeAnalysis.IMethodSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IDeclarationExpressionOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IDeclarationExpressionOperation.Expression.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IDeclarationPatternOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IDeclarationPatternOperation.DeclaredSymbol.get -> Microsoft.CodeAnalysis.ISymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IDeconstructionAssignmentOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IDefaultCaseClauseOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IDefaultValueOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IDelegateCreationOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IDelegateCreationOperation.Target.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IDynamicIndexerAccessOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IDynamicIndexerAccessOperation.Arguments.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IDynamicIndexerAccessOperation.Operation.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IDynamicInvocationOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IDynamicInvocationOperation.Arguments.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IDynamicInvocationOperation.Operation.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IDynamicMemberReferenceOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IDynamicMemberReferenceOperation.ContainingType.get -> Microsoft.CodeAnalysis.ITypeSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IDynamicMemberReferenceOperation.Instance.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IDynamicMemberReferenceOperation.MemberName.get -> string` +* [ ] `Microsoft.CodeAnalysis.Operations.IDynamicMemberReferenceOperation.TypeArguments.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IDynamicObjectCreationOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IDynamicObjectCreationOperation.Arguments.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IDynamicObjectCreationOperation.Initializer.get -> Microsoft.CodeAnalysis.Operations.IObjectOrCollectionInitializerOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IEmptyOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IEndOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IEventAssignmentOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IEventAssignmentOperation.Adds.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.IEventAssignmentOperation.EventReference.get -> Microsoft.CodeAnalysis.Operations.IEventReferenceOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IEventAssignmentOperation.HandlerValue.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IEventReferenceOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IEventReferenceOperation.Event.get -> Microsoft.CodeAnalysis.IEventSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IExpressionStatementOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IExpressionStatementOperation.Operation.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IFieldInitializerOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IFieldInitializerOperation.InitializedFields.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IFieldReferenceOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IFieldReferenceOperation.Field.get -> Microsoft.CodeAnalysis.IFieldSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IFieldReferenceOperation.IsDeclaration.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.IForEachLoopOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IForEachLoopOperation.Collection.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IForEachLoopOperation.LoopControlVariable.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IForEachLoopOperation.NextVariables.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IForLoopOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IForLoopOperation.AtLoopBottom.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IForLoopOperation.Before.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IForLoopOperation.Condition.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IForToLoopOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IForToLoopOperation.InitialValue.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IForToLoopOperation.LimitValue.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IForToLoopOperation.LoopControlVariable.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IForToLoopOperation.NextVariables.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IForToLoopOperation.StepValue.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IIncrementOrDecrementOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IIncrementOrDecrementOperation.IsChecked.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.IIncrementOrDecrementOperation.IsLifted.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.IIncrementOrDecrementOperation.IsPostfix.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.IIncrementOrDecrementOperation.OperatorMethod.get -> Microsoft.CodeAnalysis.IMethodSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IIncrementOrDecrementOperation.Target.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IInstanceReferenceOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IInterpolatedStringContentOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IInterpolatedStringOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IInterpolatedStringOperation.Parts.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IInterpolatedStringTextOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IInterpolatedStringTextOperation.Text.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IInterpolationOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IInterpolationOperation.Alignment.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IInterpolationOperation.Expression.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IInterpolationOperation.FormatString.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IInvalidOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IInvocationOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IInvocationOperation.Arguments.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IInvocationOperation.Instance.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IInvocationOperation.IsVirtual.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.IInvocationOperation.TargetMethod.get -> Microsoft.CodeAnalysis.IMethodSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IIsPatternOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IIsPatternOperation.Pattern.get -> Microsoft.CodeAnalysis.Operations.IPatternOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IIsPatternOperation.Value.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IIsTypeOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IIsTypeOperation.IsNegated.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.IIsTypeOperation.TypeOperand.get -> Microsoft.CodeAnalysis.ITypeSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IIsTypeOperation.ValueOperand.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ILabeledOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ILabeledOperation.Label.get -> Microsoft.CodeAnalysis.ILabelSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.ILabeledOperation.Operation.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ILiteralOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ILocalFunctionOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ILocalFunctionOperation.Body.get -> Microsoft.CodeAnalysis.Operations.IBlockOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ILocalFunctionOperation.Symbol.get -> Microsoft.CodeAnalysis.IMethodSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.ILocalReferenceOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ILocalReferenceOperation.IsDeclaration.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.ILocalReferenceOperation.Local.get -> Microsoft.CodeAnalysis.ILocalSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.ILockOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ILockOperation.Body.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ILockOperation.LockedValue.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ILoopOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ILoopOperation.Body.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ILoopOperation.Locals.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.ILoopOperation.LoopKind.get -> Microsoft.CodeAnalysis.Operations.LoopKind` +* [ ] `Microsoft.CodeAnalysis.Operations.IMemberInitializerOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IMemberInitializerOperation.InitializedMember.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IMemberInitializerOperation.Initializer.get -> Microsoft.CodeAnalysis.Operations.IObjectOrCollectionInitializerOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IMemberReferenceOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IMemberReferenceOperation.Instance.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IMemberReferenceOperation.Member.get -> Microsoft.CodeAnalysis.ISymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IMethodReferenceOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IMethodReferenceOperation.IsVirtual.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.IMethodReferenceOperation.Method.get -> Microsoft.CodeAnalysis.IMethodSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.INameOfOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.INameOfOperation.Argument.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IObjectCreationOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IObjectCreationOperation.Arguments.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IObjectCreationOperation.Constructor.get -> Microsoft.CodeAnalysis.IMethodSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IObjectCreationOperation.Initializer.get -> Microsoft.CodeAnalysis.Operations.IObjectOrCollectionInitializerOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IObjectOrCollectionInitializerOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IObjectOrCollectionInitializerOperation.Initializers.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IOmittedArgumentOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IParameterInitializerOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IParameterInitializerOperation.Parameter.get -> Microsoft.CodeAnalysis.IParameterSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IParameterReferenceOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IParameterReferenceOperation.Parameter.get -> Microsoft.CodeAnalysis.IParameterSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IParenthesizedOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IParenthesizedOperation.Operand.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IPatternCaseClauseOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IPatternCaseClauseOperation.Guard.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IPatternCaseClauseOperation.Label.get -> Microsoft.CodeAnalysis.ILabelSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IPatternCaseClauseOperation.Pattern.get -> Microsoft.CodeAnalysis.Operations.IPatternOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IPatternOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IPropertyInitializerOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IPropertyInitializerOperation.InitializedProperties.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IPropertyReferenceOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IPropertyReferenceOperation.Arguments.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IPropertyReferenceOperation.Property.get -> Microsoft.CodeAnalysis.IPropertySymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IRaiseEventOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IRaiseEventOperation.Arguments.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IRaiseEventOperation.EventReference.get -> Microsoft.CodeAnalysis.Operations.IEventReferenceOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IRangeCaseClauseOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IRangeCaseClauseOperation.MaximumValue.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IRangeCaseClauseOperation.MinimumValue.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IRelationalCaseClauseOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IRelationalCaseClauseOperation.Relation.get -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.IRelationalCaseClauseOperation.Value.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IReturnOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IReturnOperation.ReturnedValue.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ISimpleAssignmentOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ISimpleAssignmentOperation.IsRef.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.ISingleValueCaseClauseOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ISingleValueCaseClauseOperation.Value.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ISizeOfOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ISizeOfOperation.TypeOperand.get -> Microsoft.CodeAnalysis.ITypeSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IStopOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ISwitchCaseOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ISwitchCaseOperation.Body.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.ISwitchCaseOperation.Clauses.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.ISwitchOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ISwitchOperation.Cases.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.ISwitchOperation.Value.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ISymbolInitializerOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ISymbolInitializerOperation.Value.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IThrowOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IThrowOperation.Exception.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ITranslatedQueryOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ITranslatedQueryOperation.Operation.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ITryOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ITryOperation.Body.get -> Microsoft.CodeAnalysis.Operations.IBlockOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ITryOperation.Catches.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.ITryOperation.Finally.get -> Microsoft.CodeAnalysis.Operations.IBlockOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ITupleOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ITupleOperation.Elements.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.ITypeOfOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ITypeOfOperation.TypeOperand.get -> Microsoft.CodeAnalysis.ITypeSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.ITypeParameterObjectCreationOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ITypeParameterObjectCreationOperation.Initializer.get -> Microsoft.CodeAnalysis.Operations.IObjectOrCollectionInitializerOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IUnaryOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IUnaryOperation.IsChecked.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.IUnaryOperation.IsLifted.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.IUnaryOperation.Operand.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IUnaryOperation.OperatorKind.get -> Microsoft.CodeAnalysis.Operations.UnaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.IUnaryOperation.OperatorMethod.get -> Microsoft.CodeAnalysis.IMethodSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IUsingOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IUsingOperation.Body.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IUsingOperation.Resources.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IVariableDeclarationGroupOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IVariableDeclarationGroupOperation.Declarations.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IVariableDeclarationOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IVariableDeclarationOperation.Declarators.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IVariableDeclarationOperation.Initializer.get -> Microsoft.CodeAnalysis.Operations.IVariableInitializerOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IVariableDeclaratorOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IVariableDeclaratorOperation.IgnoredArguments.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IVariableDeclaratorOperation.Initializer.get -> Microsoft.CodeAnalysis.Operations.IVariableInitializerOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IVariableDeclaratorOperation.Symbol.get -> Microsoft.CodeAnalysis.ILocalSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IVariableInitializerOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IWhileLoopOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IWhileLoopOperation.Condition.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IWhileLoopOperation.ConditionIsTop.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.IWhileLoopOperation.ConditionIsUntil.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.IWhileLoopOperation.IgnoredCondition.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.LoopKind` +* [ ] `Microsoft.CodeAnalysis.Operations.LoopKind.For = 2 -> Microsoft.CodeAnalysis.Operations.LoopKind` +* [ ] `Microsoft.CodeAnalysis.Operations.LoopKind.ForEach = 4 -> Microsoft.CodeAnalysis.Operations.LoopKind` +* [ ] `Microsoft.CodeAnalysis.Operations.LoopKind.ForTo = 3 -> Microsoft.CodeAnalysis.Operations.LoopKind` +* [ ] `Microsoft.CodeAnalysis.Operations.LoopKind.None = 0 -> Microsoft.CodeAnalysis.Operations.LoopKind` +* [ ] `Microsoft.CodeAnalysis.Operations.LoopKind.While = 1 -> Microsoft.CodeAnalysis.Operations.LoopKind` +* [ ] `Microsoft.CodeAnalysis.Operations.OperationExtensions` +* [ ] `Microsoft.CodeAnalysis.Operations.OperationVisitor` +* [ ] `Microsoft.CodeAnalysis.Operations.OperationVisitor.OperationVisitor() -> void` +* [ ] `Microsoft.CodeAnalysis.Operations.OperationVisitor` +* [ ] `Microsoft.CodeAnalysis.Operations.OperationVisitor.OperationVisitor() -> void` +* [ ] `Microsoft.CodeAnalysis.Operations.OperationWalker` +* [ ] `Microsoft.CodeAnalysis.Operations.OperationWalker.OperationWalker() -> void` +* [ ] `Microsoft.CodeAnalysis.Operations.UnaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.UnaryOperatorKind.BitwiseNegation = 1 -> Microsoft.CodeAnalysis.Operations.UnaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.UnaryOperatorKind.False = 6 -> Microsoft.CodeAnalysis.Operations.UnaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.UnaryOperatorKind.Minus = 4 -> Microsoft.CodeAnalysis.Operations.UnaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.UnaryOperatorKind.None = 0 -> Microsoft.CodeAnalysis.Operations.UnaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.UnaryOperatorKind.Not = 2 -> Microsoft.CodeAnalysis.Operations.UnaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.UnaryOperatorKind.Plus = 3 -> Microsoft.CodeAnalysis.Operations.UnaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.UnaryOperatorKind.True = 5 -> Microsoft.CodeAnalysis.Operations.UnaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.RefKind.In = 3 -> Microsoft.CodeAnalysis.RefKind` +* [ ] `Microsoft.CodeAnalysis.RefKind.RefReadOnly = 3 -> Microsoft.CodeAnalysis.RefKind` +* [ ] `Microsoft.CodeAnalysis.SemanticModel.GetOperation(Microsoft.CodeAnalysis.SyntaxNode node, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.SyntaxList.SyntaxList(System.Collections.Generic.IEnumerable nodes) -> void` +* [ ] `Microsoft.CodeAnalysis.SyntaxList.SyntaxList(TNode node) -> void` +* [ ] `Microsoft.CodeAnalysis.SyntaxNodeOrTokenList.SyntaxNodeOrTokenList(System.Collections.Generic.IEnumerable nodesAndTokens) -> void` +* [ ] `Microsoft.CodeAnalysis.SyntaxNodeOrTokenList.SyntaxNodeOrTokenList(params Microsoft.CodeAnalysis.SyntaxNodeOrToken[] nodesAndTokens) -> void` +* [ ] `Microsoft.CodeAnalysis.SyntaxTokenList.SyntaxTokenList(Microsoft.CodeAnalysis.SyntaxToken token) -> void` +* [ ] `Microsoft.CodeAnalysis.SyntaxTokenList.SyntaxTokenList(System.Collections.Generic.IEnumerable tokens) -> void` +* [ ] `Microsoft.CodeAnalysis.SyntaxTokenList.SyntaxTokenList(params Microsoft.CodeAnalysis.SyntaxToken[] tokens) -> void` +* [ ] `Microsoft.CodeAnalysis.SyntaxTriviaList.SyntaxTriviaList(Microsoft.CodeAnalysis.SyntaxTrivia trivia) -> void` +* [ ] `Microsoft.CodeAnalysis.SyntaxTriviaList.SyntaxTriviaList(System.Collections.Generic.IEnumerable trivias) -> void` +* [ ] `Microsoft.CodeAnalysis.SyntaxTriviaList.SyntaxTriviaList(params Microsoft.CodeAnalysis.SyntaxTrivia[] trivias) -> void` +* [ ] `override Microsoft.CodeAnalysis.Operations.OperationWalker.DefaultVisit(Microsoft.CodeAnalysis.IOperation operation) -> void` +* [ ] `override Microsoft.CodeAnalysis.Operations.OperationWalker.Visit(Microsoft.CodeAnalysis.IOperation operation) -> void` +* [ ] `override Microsoft.CodeAnalysis.Optional.ToString() -> string` +* [ ] `static Microsoft.CodeAnalysis.Emit.EmitBaseline.CreateInitialBaseline(Microsoft.CodeAnalysis.ModuleMetadata module, System.Func debugInformationProvider, System.Func localSignatureProvider, bool hasPortableDebugInformation) -> Microsoft.CodeAnalysis.Emit.EmitBaseline` +* [ ] `static Microsoft.CodeAnalysis.Operations.OperationExtensions.Descendants(this Microsoft.CodeAnalysis.IOperation operation) -> System.Collections.Generic.IEnumerable` +* [ ] `static Microsoft.CodeAnalysis.Operations.OperationExtensions.DescendantsAndSelf(this Microsoft.CodeAnalysis.IOperation operation) -> System.Collections.Generic.IEnumerable` +* [ ] `static Microsoft.CodeAnalysis.Operations.OperationExtensions.GetArgumentName(this Microsoft.CodeAnalysis.Operations.IDynamicIndexerAccessOperation dynamicOperation, int index) -> string` +* [ ] `static Microsoft.CodeAnalysis.Operations.OperationExtensions.GetArgumentName(this Microsoft.CodeAnalysis.Operations.IDynamicInvocationOperation dynamicOperation, int index) -> string` +* [ ] `static Microsoft.CodeAnalysis.Operations.OperationExtensions.GetArgumentName(this Microsoft.CodeAnalysis.Operations.IDynamicObjectCreationOperation dynamicOperation, int index) -> string` +* [ ] `static Microsoft.CodeAnalysis.Operations.OperationExtensions.GetArgumentRefKind(this Microsoft.CodeAnalysis.Operations.IDynamicIndexerAccessOperation dynamicOperation, int index) -> Microsoft.CodeAnalysis.RefKind?` +* [ ] `static Microsoft.CodeAnalysis.Operations.OperationExtensions.GetArgumentRefKind(this Microsoft.CodeAnalysis.Operations.IDynamicInvocationOperation dynamicOperation, int index) -> Microsoft.CodeAnalysis.RefKind?` +* [ ] `static Microsoft.CodeAnalysis.Operations.OperationExtensions.GetArgumentRefKind(this Microsoft.CodeAnalysis.Operations.IDynamicObjectCreationOperation dynamicOperation, int index) -> Microsoft.CodeAnalysis.RefKind?` +* [ ] `static Microsoft.CodeAnalysis.Operations.OperationExtensions.GetDeclaredVariables(this Microsoft.CodeAnalysis.Operations.IVariableDeclarationGroupOperation declarationGroup) -> System.Collections.Immutable.ImmutableArray` +* [ ] `static Microsoft.CodeAnalysis.Operations.OperationExtensions.GetDeclaredVariables(this Microsoft.CodeAnalysis.Operations.IVariableDeclarationOperation declaration) -> System.Collections.Immutable.ImmutableArray` +* [ ] `static Microsoft.CodeAnalysis.Operations.OperationExtensions.GetVariableInitializer(this Microsoft.CodeAnalysis.Operations.IVariableDeclaratorOperation declarationOperation) -> Microsoft.CodeAnalysis.Operations.IVariableInitializerOperation` +* [ ] `virtual Microsoft.CodeAnalysis.Diagnostics.AnalysisContext.RegisterOperationAction(System.Action action, System.Collections.Immutable.ImmutableArray operationKinds) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Diagnostics.AnalysisContext.RegisterOperationBlockAction(System.Action action) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Diagnostics.AnalysisContext.RegisterOperationBlockStartAction(System.Action action) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Diagnostics.CompilationStartAnalysisContext.RegisterOperationAction(System.Action action, System.Collections.Immutable.ImmutableArray operationKinds) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Diagnostics.CompilationStartAnalysisContext.RegisterOperationBlockAction(System.Action action) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Diagnostics.CompilationStartAnalysisContext.RegisterOperationBlockStartAction(System.Action action) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.DefaultVisit(Microsoft.CodeAnalysis.IOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.Visit(Microsoft.CodeAnalysis.IOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitAddressOf(Microsoft.CodeAnalysis.Operations.IAddressOfOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitAnonymousFunction(Microsoft.CodeAnalysis.Operations.IAnonymousFunctionOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitAnonymousObjectCreation(Microsoft.CodeAnalysis.Operations.IAnonymousObjectCreationOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitArgument(Microsoft.CodeAnalysis.Operations.IArgumentOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitArrayCreation(Microsoft.CodeAnalysis.Operations.IArrayCreationOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitArrayElementReference(Microsoft.CodeAnalysis.Operations.IArrayElementReferenceOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitArrayInitializer(Microsoft.CodeAnalysis.Operations.IArrayInitializerOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitAwait(Microsoft.CodeAnalysis.Operations.IAwaitOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitBinaryOperator(Microsoft.CodeAnalysis.Operations.IBinaryOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitBlock(Microsoft.CodeAnalysis.Operations.IBlockOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitBranch(Microsoft.CodeAnalysis.Operations.IBranchOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitCatchClause(Microsoft.CodeAnalysis.Operations.ICatchClauseOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitCoalesce(Microsoft.CodeAnalysis.Operations.ICoalesceOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitCollectionElementInitializer(Microsoft.CodeAnalysis.Operations.ICollectionElementInitializerOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitCompoundAssignment(Microsoft.CodeAnalysis.Operations.ICompoundAssignmentOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitConditional(Microsoft.CodeAnalysis.Operations.IConditionalOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitConditionalAccess(Microsoft.CodeAnalysis.Operations.IConditionalAccessOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitConditionalAccessInstance(Microsoft.CodeAnalysis.Operations.IConditionalAccessInstanceOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitConstantPattern(Microsoft.CodeAnalysis.Operations.IConstantPatternOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitConversion(Microsoft.CodeAnalysis.Operations.IConversionOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDeclarationExpression(Microsoft.CodeAnalysis.Operations.IDeclarationExpressionOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDeclarationPattern(Microsoft.CodeAnalysis.Operations.IDeclarationPatternOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDeconstructionAssignment(Microsoft.CodeAnalysis.Operations.IDeconstructionAssignmentOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDefaultCaseClause(Microsoft.CodeAnalysis.Operations.IDefaultCaseClauseOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDefaultValue(Microsoft.CodeAnalysis.Operations.IDefaultValueOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDelegateCreation(Microsoft.CodeAnalysis.Operations.IDelegateCreationOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDynamicIndexerAccess(Microsoft.CodeAnalysis.Operations.IDynamicIndexerAccessOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDynamicInvocation(Microsoft.CodeAnalysis.Operations.IDynamicInvocationOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDynamicMemberReference(Microsoft.CodeAnalysis.Operations.IDynamicMemberReferenceOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDynamicObjectCreation(Microsoft.CodeAnalysis.Operations.IDynamicObjectCreationOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitEmpty(Microsoft.CodeAnalysis.Operations.IEmptyOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitEnd(Microsoft.CodeAnalysis.Operations.IEndOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitEventAssignment(Microsoft.CodeAnalysis.Operations.IEventAssignmentOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitEventReference(Microsoft.CodeAnalysis.Operations.IEventReferenceOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitExpressionStatement(Microsoft.CodeAnalysis.Operations.IExpressionStatementOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitFieldInitializer(Microsoft.CodeAnalysis.Operations.IFieldInitializerOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitFieldReference(Microsoft.CodeAnalysis.Operations.IFieldReferenceOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitForEachLoop(Microsoft.CodeAnalysis.Operations.IForEachLoopOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitForLoop(Microsoft.CodeAnalysis.Operations.IForLoopOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitForToLoop(Microsoft.CodeAnalysis.Operations.IForToLoopOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitIncrementOrDecrement(Microsoft.CodeAnalysis.Operations.IIncrementOrDecrementOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitInstanceReference(Microsoft.CodeAnalysis.Operations.IInstanceReferenceOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitInterpolatedString(Microsoft.CodeAnalysis.Operations.IInterpolatedStringOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitInterpolatedStringText(Microsoft.CodeAnalysis.Operations.IInterpolatedStringTextOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitInterpolation(Microsoft.CodeAnalysis.Operations.IInterpolationOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitInvalid(Microsoft.CodeAnalysis.Operations.IInvalidOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitInvocation(Microsoft.CodeAnalysis.Operations.IInvocationOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitIsPattern(Microsoft.CodeAnalysis.Operations.IIsPatternOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitIsType(Microsoft.CodeAnalysis.Operations.IIsTypeOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitLabeled(Microsoft.CodeAnalysis.Operations.ILabeledOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitLiteral(Microsoft.CodeAnalysis.Operations.ILiteralOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitLocalFunction(Microsoft.CodeAnalysis.Operations.ILocalFunctionOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitLocalReference(Microsoft.CodeAnalysis.Operations.ILocalReferenceOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitLock(Microsoft.CodeAnalysis.Operations.ILockOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitMemberInitializer(Microsoft.CodeAnalysis.Operations.IMemberInitializerOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitMethodReference(Microsoft.CodeAnalysis.Operations.IMethodReferenceOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitNameOf(Microsoft.CodeAnalysis.Operations.INameOfOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitObjectCreation(Microsoft.CodeAnalysis.Operations.IObjectCreationOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitObjectOrCollectionInitializer(Microsoft.CodeAnalysis.Operations.IObjectOrCollectionInitializerOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitOmittedArgument(Microsoft.CodeAnalysis.Operations.IOmittedArgumentOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitParameterInitializer(Microsoft.CodeAnalysis.Operations.IParameterInitializerOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitParameterReference(Microsoft.CodeAnalysis.Operations.IParameterReferenceOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitParenthesized(Microsoft.CodeAnalysis.Operations.IParenthesizedOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitPatternCaseClause(Microsoft.CodeAnalysis.Operations.IPatternCaseClauseOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitPropertyInitializer(Microsoft.CodeAnalysis.Operations.IPropertyInitializerOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitPropertyReference(Microsoft.CodeAnalysis.Operations.IPropertyReferenceOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitRaiseEvent(Microsoft.CodeAnalysis.Operations.IRaiseEventOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitRangeCaseClause(Microsoft.CodeAnalysis.Operations.IRangeCaseClauseOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitRelationalCaseClause(Microsoft.CodeAnalysis.Operations.IRelationalCaseClauseOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitReturn(Microsoft.CodeAnalysis.Operations.IReturnOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitSimpleAssignment(Microsoft.CodeAnalysis.Operations.ISimpleAssignmentOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitSingleValueCaseClause(Microsoft.CodeAnalysis.Operations.ISingleValueCaseClauseOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitSizeOf(Microsoft.CodeAnalysis.Operations.ISizeOfOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitStop(Microsoft.CodeAnalysis.Operations.IStopOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitSwitch(Microsoft.CodeAnalysis.Operations.ISwitchOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitSwitchCase(Microsoft.CodeAnalysis.Operations.ISwitchCaseOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitThrow(Microsoft.CodeAnalysis.Operations.IThrowOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitTranslatedQuery(Microsoft.CodeAnalysis.Operations.ITranslatedQueryOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitTry(Microsoft.CodeAnalysis.Operations.ITryOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitTuple(Microsoft.CodeAnalysis.Operations.ITupleOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitTypeOf(Microsoft.CodeAnalysis.Operations.ITypeOfOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitTypeParameterObjectCreation(Microsoft.CodeAnalysis.Operations.ITypeParameterObjectCreationOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitUnaryOperator(Microsoft.CodeAnalysis.Operations.IUnaryOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitUsing(Microsoft.CodeAnalysis.Operations.IUsingOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitVariableDeclaration(Microsoft.CodeAnalysis.Operations.IVariableDeclarationOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitVariableDeclarationGroup(Microsoft.CodeAnalysis.Operations.IVariableDeclarationGroupOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitVariableDeclarator(Microsoft.CodeAnalysis.Operations.IVariableDeclaratorOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitVariableInitializer(Microsoft.CodeAnalysis.Operations.IVariableInitializerOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitWhileLoop(Microsoft.CodeAnalysis.Operations.IWhileLoopOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.DefaultVisit(Microsoft.CodeAnalysis.IOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.Visit(Microsoft.CodeAnalysis.IOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitAddressOf(Microsoft.CodeAnalysis.Operations.IAddressOfOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitAnonymousFunction(Microsoft.CodeAnalysis.Operations.IAnonymousFunctionOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitAnonymousObjectCreation(Microsoft.CodeAnalysis.Operations.IAnonymousObjectCreationOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitArgument(Microsoft.CodeAnalysis.Operations.IArgumentOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitArrayCreation(Microsoft.CodeAnalysis.Operations.IArrayCreationOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitArrayElementReference(Microsoft.CodeAnalysis.Operations.IArrayElementReferenceOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitArrayInitializer(Microsoft.CodeAnalysis.Operations.IArrayInitializerOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitAwait(Microsoft.CodeAnalysis.Operations.IAwaitOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitBinaryOperator(Microsoft.CodeAnalysis.Operations.IBinaryOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitBlock(Microsoft.CodeAnalysis.Operations.IBlockOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitBranch(Microsoft.CodeAnalysis.Operations.IBranchOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitCatchClause(Microsoft.CodeAnalysis.Operations.ICatchClauseOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitCoalesce(Microsoft.CodeAnalysis.Operations.ICoalesceOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitCollectionElementInitializer(Microsoft.CodeAnalysis.Operations.ICollectionElementInitializerOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitCompoundAssignment(Microsoft.CodeAnalysis.Operations.ICompoundAssignmentOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitConditional(Microsoft.CodeAnalysis.Operations.IConditionalOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitConditionalAccess(Microsoft.CodeAnalysis.Operations.IConditionalAccessOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitConditionalAccessInstance(Microsoft.CodeAnalysis.Operations.IConditionalAccessInstanceOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitConstantPattern(Microsoft.CodeAnalysis.Operations.IConstantPatternOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitConversion(Microsoft.CodeAnalysis.Operations.IConversionOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDeclarationExpression(Microsoft.CodeAnalysis.Operations.IDeclarationExpressionOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDeclarationPattern(Microsoft.CodeAnalysis.Operations.IDeclarationPatternOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDeconstructionAssignment(Microsoft.CodeAnalysis.Operations.IDeconstructionAssignmentOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDefaultCaseClause(Microsoft.CodeAnalysis.Operations.IDefaultCaseClauseOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDefaultValue(Microsoft.CodeAnalysis.Operations.IDefaultValueOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDelegateCreation(Microsoft.CodeAnalysis.Operations.IDelegateCreationOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDynamicIndexerAccess(Microsoft.CodeAnalysis.Operations.IDynamicIndexerAccessOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDynamicInvocation(Microsoft.CodeAnalysis.Operations.IDynamicInvocationOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDynamicMemberReference(Microsoft.CodeAnalysis.Operations.IDynamicMemberReferenceOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDynamicObjectCreation(Microsoft.CodeAnalysis.Operations.IDynamicObjectCreationOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitEmpty(Microsoft.CodeAnalysis.Operations.IEmptyOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitEnd(Microsoft.CodeAnalysis.Operations.IEndOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitEventAssignment(Microsoft.CodeAnalysis.Operations.IEventAssignmentOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitEventReference(Microsoft.CodeAnalysis.Operations.IEventReferenceOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitExpressionStatement(Microsoft.CodeAnalysis.Operations.IExpressionStatementOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitFieldInitializer(Microsoft.CodeAnalysis.Operations.IFieldInitializerOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitFieldReference(Microsoft.CodeAnalysis.Operations.IFieldReferenceOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitForEachLoop(Microsoft.CodeAnalysis.Operations.IForEachLoopOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitForLoop(Microsoft.CodeAnalysis.Operations.IForLoopOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitForToLoop(Microsoft.CodeAnalysis.Operations.IForToLoopOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitIncrementOrDecrement(Microsoft.CodeAnalysis.Operations.IIncrementOrDecrementOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitInstanceReference(Microsoft.CodeAnalysis.Operations.IInstanceReferenceOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitInterpolatedString(Microsoft.CodeAnalysis.Operations.IInterpolatedStringOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitInterpolatedStringText(Microsoft.CodeAnalysis.Operations.IInterpolatedStringTextOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitInterpolation(Microsoft.CodeAnalysis.Operations.IInterpolationOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitInvalid(Microsoft.CodeAnalysis.Operations.IInvalidOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitInvocation(Microsoft.CodeAnalysis.Operations.IInvocationOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitIsPattern(Microsoft.CodeAnalysis.Operations.IIsPatternOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitIsType(Microsoft.CodeAnalysis.Operations.IIsTypeOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitLabeled(Microsoft.CodeAnalysis.Operations.ILabeledOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitLiteral(Microsoft.CodeAnalysis.Operations.ILiteralOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitLocalFunction(Microsoft.CodeAnalysis.Operations.ILocalFunctionOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitLocalReference(Microsoft.CodeAnalysis.Operations.ILocalReferenceOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitLock(Microsoft.CodeAnalysis.Operations.ILockOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitMemberInitializer(Microsoft.CodeAnalysis.Operations.IMemberInitializerOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitMethodReference(Microsoft.CodeAnalysis.Operations.IMethodReferenceOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitNameOf(Microsoft.CodeAnalysis.Operations.INameOfOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitObjectCreation(Microsoft.CodeAnalysis.Operations.IObjectCreationOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitObjectOrCollectionInitializer(Microsoft.CodeAnalysis.Operations.IObjectOrCollectionInitializerOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitOmittedArgument(Microsoft.CodeAnalysis.Operations.IOmittedArgumentOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitParameterInitializer(Microsoft.CodeAnalysis.Operations.IParameterInitializerOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitParameterReference(Microsoft.CodeAnalysis.Operations.IParameterReferenceOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitParenthesized(Microsoft.CodeAnalysis.Operations.IParenthesizedOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitPatternCaseClause(Microsoft.CodeAnalysis.Operations.IPatternCaseClauseOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitPropertyInitializer(Microsoft.CodeAnalysis.Operations.IPropertyInitializerOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitPropertyReference(Microsoft.CodeAnalysis.Operations.IPropertyReferenceOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitRaiseEvent(Microsoft.CodeAnalysis.Operations.IRaiseEventOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitRangeCaseClause(Microsoft.CodeAnalysis.Operations.IRangeCaseClauseOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitRelationalCaseClause(Microsoft.CodeAnalysis.Operations.IRelationalCaseClauseOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitReturn(Microsoft.CodeAnalysis.Operations.IReturnOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitSimpleAssignment(Microsoft.CodeAnalysis.Operations.ISimpleAssignmentOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitSingleValueCaseClause(Microsoft.CodeAnalysis.Operations.ISingleValueCaseClauseOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitSizeOf(Microsoft.CodeAnalysis.Operations.ISizeOfOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitStop(Microsoft.CodeAnalysis.Operations.IStopOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitSwitch(Microsoft.CodeAnalysis.Operations.ISwitchOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitSwitchCase(Microsoft.CodeAnalysis.Operations.ISwitchCaseOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitThrow(Microsoft.CodeAnalysis.Operations.IThrowOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitTranslatedQuery(Microsoft.CodeAnalysis.Operations.ITranslatedQueryOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitTry(Microsoft.CodeAnalysis.Operations.ITryOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitTuple(Microsoft.CodeAnalysis.Operations.ITupleOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitTypeOf(Microsoft.CodeAnalysis.Operations.ITypeOfOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitTypeParameterObjectCreation(Microsoft.CodeAnalysis.Operations.ITypeParameterObjectCreationOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitUnaryOperator(Microsoft.CodeAnalysis.Operations.IUnaryOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitUsing(Microsoft.CodeAnalysis.Operations.IUsingOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitVariableDeclaration(Microsoft.CodeAnalysis.Operations.IVariableDeclarationOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitVariableDeclarationGroup(Microsoft.CodeAnalysis.Operations.IVariableDeclarationGroupOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitVariableDeclarator(Microsoft.CodeAnalysis.Operations.IVariableDeclaratorOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitVariableInitializer(Microsoft.CodeAnalysis.Operations.IVariableInitializerOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitWhileLoop(Microsoft.CodeAnalysis.Operations.IWhileLoopOperation operation, TArgument argument) -> TResult` + +* [ ] `Microsoft.CodeAnalysis.CSharp.Conversion.IsStackAlloc.get -> bool` +* [ ] `Microsoft.CodeAnalysis.CSharp.Conversion.ToCommonConversion() -> Microsoft.CodeAnalysis.Operations.CommonConversion` +* [ ] `static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetConversion(this Microsoft.CodeAnalysis.Operations.IConversionOperation conversionExpression) -> Microsoft.CodeAnalysis.CSharp.Conversion` +* [ ] `static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetInConversion(this Microsoft.CodeAnalysis.Operations.ICompoundAssignmentOperation compoundAssignment) -> Microsoft.CodeAnalysis.CSharp.Conversion` +* [ ] `static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetOutConversion(this Microsoft.CodeAnalysis.Operations.ICompoundAssignmentOperation compoundAssignment) -> Microsoft.CodeAnalysis.CSharp.Conversion` + +## Syntax + +* [x] `Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp7_2 = 702 -> Microsoft.CodeAnalysis.CSharp.LanguageVersion` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.ReadOnlyKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken refKeyword, Microsoft.CodeAnalysis.SyntaxToken readOnlyKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax.WithReadOnlyKeyword(Microsoft.CodeAnalysis.SyntaxToken readOnlyKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RefType(Microsoft.CodeAnalysis.SyntaxToken refKeyword, Microsoft.CodeAnalysis.SyntaxToken readOnlyKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RefTypeSyntax` diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CSharp73.md b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CSharp73.md new file mode 100644 index 000000000..ee0f7c91a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CSharp73.md @@ -0,0 +1,94 @@ +# C# 7.3 APIs supported via light-up + +See [dotnet/roslyn@e60c9fe](https://github.com/dotnet/roslyn/commit/e60c9fe8accc442218b7858ca79f07b115e493b2). + +## Semantics + +* [ ] `abstract Microsoft.CodeAnalysis.DataFlowAnalysis.CapturedInside.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `abstract Microsoft.CodeAnalysis.DataFlowAnalysis.CapturedOutside.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `const Microsoft.CodeAnalysis.WellKnownMemberNames.DeconstructMethodName = "Deconstruct" -> string` +* [ ] `Microsoft.CodeAnalysis.CompilationOptions.MetadataImportOptions.get -> Microsoft.CodeAnalysis.MetadataImportOptions` +* [ ] `Microsoft.CodeAnalysis.CompilationOptions.WithMetadataImportOptions(Microsoft.CodeAnalysis.MetadataImportOptions value) -> Microsoft.CodeAnalysis.CompilationOptions` +* [ ] `Microsoft.CodeAnalysis.Emit.EmitOptions.EmitOptions(bool metadataOnly = false, Microsoft.CodeAnalysis.Emit.DebugInformationFormat debugInformationFormat = (Microsoft.CodeAnalysis.Emit.DebugInformationFormat)0, string pdbFilePath = null, string outputNameOverride = null, int fileAlignment = 0, ulong baseAddress = 0, bool highEntropyVirtualAddressSpace = false, Microsoft.CodeAnalysis.SubsystemVersion subsystemVersion = default(Microsoft.CodeAnalysis.SubsystemVersion), string runtimeMetadataVersion = null, bool tolerateErrors = false, bool includePrivateMembers = true, System.Collections.Immutable.ImmutableArray instrumentationKinds = default(System.Collections.Immutable.ImmutableArray), System.Security.Cryptography.HashAlgorithmName? pdbChecksumAlgorithm = null) -> void` +* [ ] `Microsoft.CodeAnalysis.Emit.EmitOptions.EmitOptions(bool metadataOnly, Microsoft.CodeAnalysis.Emit.DebugInformationFormat debugInformationFormat, string pdbFilePath, string outputNameOverride, int fileAlignment, ulong baseAddress, bool highEntropyVirtualAddressSpace, Microsoft.CodeAnalysis.SubsystemVersion subsystemVersion, string runtimeMetadataVersion, bool tolerateErrors, bool includePrivateMembers, System.Collections.Immutable.ImmutableArray instrumentationKinds) -> void` +* [ ] `Microsoft.CodeAnalysis.Emit.EmitOptions.PdbChecksumAlgorithm.get -> System.Security.Cryptography.HashAlgorithmName` +* [ ] `Microsoft.CodeAnalysis.Emit.EmitOptions.WithPdbChecksumAlgorithm(System.Security.Cryptography.HashAlgorithmName name) -> Microsoft.CodeAnalysis.Emit.EmitOptions` +* [x] `Microsoft.CodeAnalysis.INamedTypeSymbol.IsSerializable.get -> bool` +* [x] `Microsoft.CodeAnalysis.ITypeParameterSymbol.HasUnmanagedTypeConstraint.get -> bool` +* [ ] `Microsoft.CodeAnalysis.MetadataImportOptions` +* [ ] `Microsoft.CodeAnalysis.MetadataImportOptions.All = 2 -> Microsoft.CodeAnalysis.MetadataImportOptions` +* [ ] `Microsoft.CodeAnalysis.MetadataImportOptions.Internal = 1 -> Microsoft.CodeAnalysis.MetadataImportOptions` +* [ ] `Microsoft.CodeAnalysis.MetadataImportOptions.Public = 0 -> Microsoft.CodeAnalysis.MetadataImportOptions` +* [ ] `Microsoft.CodeAnalysis.OperationKind.ConstructorBodyOperation = 89 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Discard = 90 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.MethodBodyOperation = 88 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.TupleBinaryOperator = 87 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.Operations.IConstructorBodyOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IConstructorBodyOperation.Initializer.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IConstructorBodyOperation.Locals.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IDiscardOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IDiscardOperation.DiscardSymbol.get -> Microsoft.CodeAnalysis.IDiscardSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.ILocalFunctionOperation.IgnoredBody.get -> Microsoft.CodeAnalysis.Operations.IBlockOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IMethodBodyBaseOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IMethodBodyBaseOperation.BlockBody.get -> Microsoft.CodeAnalysis.Operations.IBlockOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IMethodBodyBaseOperation.ExpressionBody.get -> Microsoft.CodeAnalysis.Operations.IBlockOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IMethodBodyOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ISymbolInitializerOperation.Locals.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.ITupleBinaryOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ITupleBinaryOperation.LeftOperand.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ITupleBinaryOperation.OperatorKind.get -> Microsoft.CodeAnalysis.Operations.BinaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.Operations.ITupleBinaryOperation.RightOperand.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ITupleOperation.NaturalType.get -> Microsoft.CodeAnalysis.ITypeSymbol` +* [ ] `Microsoft.CodeAnalysis.Platform.Arm64 = 6 -> Microsoft.CodeAnalysis.Platform` +* [ ] `static Microsoft.CodeAnalysis.Diagnostic.Create(Microsoft.CodeAnalysis.DiagnosticDescriptor descriptor, Microsoft.CodeAnalysis.Location location, Microsoft.CodeAnalysis.DiagnosticSeverity effectiveSeverity, System.Collections.Generic.IEnumerable additionalLocations, System.Collections.Immutable.ImmutableDictionary properties, params object[] messageArgs) -> Microsoft.CodeAnalysis.Diagnostic` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitConstructorBodyOperation(Microsoft.CodeAnalysis.Operations.IConstructorBodyOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDiscardOperation(Microsoft.CodeAnalysis.Operations.IDiscardOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitMethodBodyOperation(Microsoft.CodeAnalysis.Operations.IMethodBodyOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitTupleBinaryOperator(Microsoft.CodeAnalysis.Operations.ITupleBinaryOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitConstructorBodyOperation(Microsoft.CodeAnalysis.Operations.IConstructorBodyOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDiscardOperation(Microsoft.CodeAnalysis.Operations.IDiscardOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitMethodBodyOperation(Microsoft.CodeAnalysis.Operations.IMethodBodyOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitTupleBinaryOperator(Microsoft.CodeAnalysis.Operations.ITupleBinaryOperation operation, TArgument argument) -> TResult` +* [ ] `Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.CSharpCompilationOptions(Microsoft.CodeAnalysis.OutputKind outputKind, bool reportSuppressedDiagnostics = false, string moduleName = null, string mainTypeName = null, string scriptClassName = null, System.Collections.Generic.IEnumerable usings = null, Microsoft.CodeAnalysis.OptimizationLevel optimizationLevel = Microsoft.CodeAnalysis.OptimizationLevel.Debug, bool checkOverflow = false, bool allowUnsafe = false, string cryptoKeyContainer = null, string cryptoKeyFile = null, System.Collections.Immutable.ImmutableArray cryptoPublicKey = default(System.Collections.Immutable.ImmutableArray), bool? delaySign = null, Microsoft.CodeAnalysis.Platform platform = Microsoft.CodeAnalysis.Platform.AnyCpu, Microsoft.CodeAnalysis.ReportDiagnostic generalDiagnosticOption = Microsoft.CodeAnalysis.ReportDiagnostic.Default, int warningLevel = 4, System.Collections.Generic.IEnumerable> specificDiagnosticOptions = null, bool concurrentBuild = true, bool deterministic = false, Microsoft.CodeAnalysis.XmlReferenceResolver xmlReferenceResolver = null, Microsoft.CodeAnalysis.SourceReferenceResolver sourceReferenceResolver = null, Microsoft.CodeAnalysis.MetadataReferenceResolver metadataReferenceResolver = null, Microsoft.CodeAnalysis.AssemblyIdentityComparer assemblyIdentityComparer = null, Microsoft.CodeAnalysis.StrongNameProvider strongNameProvider = null, bool publicSign = false, Microsoft.CodeAnalysis.MetadataImportOptions metadataImportOptions = Microsoft.CodeAnalysis.MetadataImportOptions.Public) -> void` +* [ ] `Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.CSharpCompilationOptions(Microsoft.CodeAnalysis.OutputKind outputKind, bool reportSuppressedDiagnostics, string moduleName, string mainTypeName, string scriptClassName, System.Collections.Generic.IEnumerable usings, Microsoft.CodeAnalysis.OptimizationLevel optimizationLevel, bool checkOverflow, bool allowUnsafe, string cryptoKeyContainer, string cryptoKeyFile, System.Collections.Immutable.ImmutableArray cryptoPublicKey, bool? delaySign, Microsoft.CodeAnalysis.Platform platform, Microsoft.CodeAnalysis.ReportDiagnostic generalDiagnosticOption, int warningLevel, System.Collections.Generic.IEnumerable> specificDiagnosticOptions, bool concurrentBuild, bool deterministic, Microsoft.CodeAnalysis.XmlReferenceResolver xmlReferenceResolver, Microsoft.CodeAnalysis.SourceReferenceResolver sourceReferenceResolver, Microsoft.CodeAnalysis.MetadataReferenceResolver metadataReferenceResolver, Microsoft.CodeAnalysis.AssemblyIdentityComparer assemblyIdentityComparer, Microsoft.CodeAnalysis.StrongNameProvider strongNameProvider, bool publicSign) -> void` +* [ ] `Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.WithMetadataImportOptions(Microsoft.CodeAnalysis.MetadataImportOptions value) -> Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions` +* [ ] `Microsoft.CodeAnalysis.CSharp.DeconstructionInfo` +* [ ] `Microsoft.CodeAnalysis.CSharp.DeconstructionInfo.Conversion.get -> Microsoft.CodeAnalysis.CSharp.Conversion?` +* [ ] `Microsoft.CodeAnalysis.CSharp.DeconstructionInfo.Method.get -> Microsoft.CodeAnalysis.IMethodSymbol` +* [ ] `Microsoft.CodeAnalysis.CSharp.DeconstructionInfo.Nested.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `static Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser.Script.get -> Microsoft.CodeAnalysis.CSharp.CSharpCommandLineParser` +* [ ] `static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetDeconstructionInfo(this Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.CSharp.Syntax.AssignmentExpressionSyntax assignment) -> Microsoft.CodeAnalysis.CSharp.DeconstructionInfo` +* [ ] `static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetDeconstructionInfo(this Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax foreach) -> Microsoft.CodeAnalysis.CSharp.DeconstructionInfo` + +## Syntax + +* [x] `Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp7_3 = 703 -> Microsoft.CodeAnalysis.CSharp.LanguageVersion` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ArgumentSyntax.RefKindKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ArgumentSyntax.WithRefKindKeyword(Microsoft.CodeAnalysis.SyntaxToken refKindKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.ArgumentSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.CrefParameterSyntax.RefKindKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.CrefParameterSyntax.WithRefKindKeyword(Microsoft.CodeAnalysis.SyntaxToken refKindKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.CrefParameterSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax.AddInitializerExpressions(params Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax.CloseBracketToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax.Initializer.get -> Microsoft.CodeAnalysis.CSharp.Syntax.InitializerExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax.OpenBracketToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax.StackAllocKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken stackAllocKeyword, Microsoft.CodeAnalysis.SyntaxToken openBracketToken, Microsoft.CodeAnalysis.SyntaxToken closeBracketToken, Microsoft.CodeAnalysis.CSharp.Syntax.InitializerExpressionSyntax initializer) -> Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax.WithCloseBracketToken(Microsoft.CodeAnalysis.SyntaxToken closeBracketToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax.WithInitializer(Microsoft.CodeAnalysis.CSharp.Syntax.InitializerExpressionSyntax initializer) -> Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax.WithOpenBracketToken(Microsoft.CodeAnalysis.SyntaxToken openBracketToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax.WithStackAllocKeyword(Microsoft.CodeAnalysis.SyntaxToken stackAllocKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.StackAllocArrayCreationExpressionSyntax.Initializer.get -> Microsoft.CodeAnalysis.CSharp.Syntax.InitializerExpressionSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.StackAllocArrayCreationExpressionSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken stackAllocKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.CSharp.Syntax.InitializerExpressionSyntax initializer) -> Microsoft.CodeAnalysis.CSharp.Syntax.StackAllocArrayCreationExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.StackAllocArrayCreationExpressionSyntax.WithInitializer(Microsoft.CodeAnalysis.CSharp.Syntax.InitializerExpressionSyntax initializer) -> Microsoft.CodeAnalysis.CSharp.Syntax.StackAllocArrayCreationExpressionSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax.IsUnmanaged.get -> bool` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.ImplicitStackAllocArrayCreationExpression = 9053 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitImplicitStackAllocArrayCreationExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ImplicitStackAllocArrayCreationExpression(Microsoft.CodeAnalysis.CSharp.Syntax.InitializerExpressionSyntax initializer) -> Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ImplicitStackAllocArrayCreationExpression(Microsoft.CodeAnalysis.SyntaxToken stackAllocKeyword, Microsoft.CodeAnalysis.SyntaxToken openBracketToken, Microsoft.CodeAnalysis.SyntaxToken closeBracketToken, Microsoft.CodeAnalysis.CSharp.Syntax.InitializerExpressionSyntax initializer) -> Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.StackAllocArrayCreationExpression(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.CSharp.Syntax.InitializerExpressionSyntax initializer) -> Microsoft.CodeAnalysis.CSharp.Syntax.StackAllocArrayCreationExpressionSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.StackAllocArrayCreationExpression(Microsoft.CodeAnalysis.SyntaxToken stackAllocKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.CSharp.Syntax.InitializerExpressionSyntax initializer) -> Microsoft.CodeAnalysis.CSharp.Syntax.StackAllocArrayCreationExpressionSyntax` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitImplicitStackAllocArrayCreationExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitImplicitStackAllocArrayCreationExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ImplicitStackAllocArrayCreationExpressionSyntax node) -> TResult` diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CSharp8.md b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CSharp8.md new file mode 100644 index 000000000..47b1012ce --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CSharp8.md @@ -0,0 +1,794 @@ +# C# 8 APIs supported via light-up + +## Semantics + +## Syntax + +## Uncategorized + +See [Microsoft.CodeAnalysis release/dev16.3@c955f3c99b5698c906e0700ef691b5b1571c8136](https://raw.githubusercontent.com/dotnet/roslyn/c955f3c99b5698c906e0700ef691b5b1571c8136/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt) + +* [ ] `*REMOVED*Microsoft.CodeAnalysis.Operations.IEventAssignmentOperation.EventReference.get -> Microsoft.CodeAnalysis.Operations.IEventReferenceOperation` +* [ ] `*REMOVED*Microsoft.CodeAnalysis.SpecialType.Count = 43 -> Microsoft.CodeAnalysis.SpecialType` +* [ ] `Microsoft.CodeAnalysis.CommandLineArguments.EmitPdbFile.get -> bool` +* [ ] `Microsoft.CodeAnalysis.CommandLineArguments.GetOutputFilePath(string outputFileName) -> string` +* [ ] `Microsoft.CodeAnalysis.CommandLineArguments.GetPdbFilePath(string outputFileName) -> string` +* [ ] `*REMOVED*Microsoft.CodeAnalysis.Compilation.CreateTupleTypeSymbol(Microsoft.CodeAnalysis.INamedTypeSymbol underlyingType, System.Collections.Immutable.ImmutableArray elementNames = default(System.Collections.Immutable.ImmutableArray), System.Collections.Immutable.ImmutableArray elementLocations = default(System.Collections.Immutable.ImmutableArray)) -> Microsoft.CodeAnalysis.INamedTypeSymbol` +* [ ] `Microsoft.CodeAnalysis.Compilation.CreateAnonymousTypeSymbol(System.Collections.Immutable.ImmutableArray memberTypes, System.Collections.Immutable.ImmutableArray memberNames, System.Collections.Immutable.ImmutableArray memberIsReadOnly = default(System.Collections.Immutable.ImmutableArray), System.Collections.Immutable.ImmutableArray memberLocations = default(System.Collections.Immutable.ImmutableArray), System.Collections.Immutable.ImmutableArray memberNullableAnnotations = default(System.Collections.Immutable.ImmutableArray)) -> Microsoft.CodeAnalysis.INamedTypeSymbol` +* [ ] `*REMOVED*Microsoft.CodeAnalysis.Compilation.CreateAnonymousTypeSymbol(System.Collections.Immutable.ImmutableArray memberTypes, System.Collections.Immutable.ImmutableArray memberNames, System.Collections.Immutable.ImmutableArray memberIsReadOnly = default(System.Collections.Immutable.ImmutableArray), System.Collections.Immutable.ImmutableArray memberLocations = default(System.Collections.Immutable.ImmutableArray)) -> Microsoft.CodeAnalysis.INamedTypeSymbol` +* [ ] `Microsoft.CodeAnalysis.Compilation.CreateAnonymousTypeSymbol(System.Collections.Immutable.ImmutableArray memberTypes, System.Collections.Immutable.ImmutableArray memberNames, System.Collections.Immutable.ImmutableArray memberIsReadOnly, System.Collections.Immutable.ImmutableArray memberLocations) -> Microsoft.CodeAnalysis.INamedTypeSymbol` +* [ ] `Microsoft.CodeAnalysis.Compilation.CreateArrayTypeSymbol(Microsoft.CodeAnalysis.ITypeSymbol elementType, int rank = 1, Microsoft.CodeAnalysis.NullableAnnotation elementNullableAnnotation = Microsoft.CodeAnalysis.NullableAnnotation.None) -> Microsoft.CodeAnalysis.IArrayTypeSymbol` +* [ ] `*REMOVED*Microsoft.CodeAnalysis.Compilation.CreateArrayTypeSymbol(Microsoft.CodeAnalysis.ITypeSymbol elementType, int rank = 1) -> Microsoft.CodeAnalysis.IArrayTypeSymbol` +* [ ] `Microsoft.CodeAnalysis.Compilation.CreateArrayTypeSymbol(Microsoft.CodeAnalysis.ITypeSymbol elementType, int rank) -> Microsoft.CodeAnalysis.IArrayTypeSymbol` +* [ ] `Microsoft.CodeAnalysis.Compilation.CreateTupleTypeSymbol(Microsoft.CodeAnalysis.INamedTypeSymbol underlyingType, System.Collections.Immutable.ImmutableArray elementNames = default(System.Collections.Immutable.ImmutableArray), System.Collections.Immutable.ImmutableArray elementLocations = default(System.Collections.Immutable.ImmutableArray), System.Collections.Immutable.ImmutableArray elementNullableAnnotations = default(System.Collections.Immutable.ImmutableArray)) -> Microsoft.CodeAnalysis.INamedTypeSymbol` +* [ ] `Microsoft.CodeAnalysis.Compilation.CreateTupleTypeSymbol(Microsoft.CodeAnalysis.INamedTypeSymbol underlyingType, System.Collections.Immutable.ImmutableArray elementNames, System.Collections.Immutable.ImmutableArray elementLocations) -> Microsoft.CodeAnalysis.INamedTypeSymbol` +* [ ] `*REMOVED*Microsoft.CodeAnalysis.Compilation.CreateTupleTypeSymbol(System.Collections.Immutable.ImmutableArray elementTypes, System.Collections.Immutable.ImmutableArray elementNames = default(System.Collections.Immutable.ImmutableArray), System.Collections.Immutable.ImmutableArray elementLocations = default(System.Collections.Immutable.ImmutableArray)) -> Microsoft.CodeAnalysis.INamedTypeSymbol` +* [ ] `Microsoft.CodeAnalysis.Compilation.CreateTupleTypeSymbol(System.Collections.Immutable.ImmutableArray elementTypes, System.Collections.Immutable.ImmutableArray elementNames = default(System.Collections.Immutable.ImmutableArray), System.Collections.Immutable.ImmutableArray elementLocations = default(System.Collections.Immutable.ImmutableArray), System.Collections.Immutable.ImmutableArray elementNullableAnnotations = default(System.Collections.Immutable.ImmutableArray)) -> Microsoft.CodeAnalysis.INamedTypeSymbol` +* [ ] `Microsoft.CodeAnalysis.Compilation.CreateTupleTypeSymbol(System.Collections.Immutable.ImmutableArray elementTypes, System.Collections.Immutable.ImmutableArray elementNames, System.Collections.Immutable.ImmutableArray elementLocations) -> Microsoft.CodeAnalysis.INamedTypeSymbol` +* [ ] `Microsoft.CodeAnalysis.Compilation.HasImplicitConversion(Microsoft.CodeAnalysis.ITypeSymbol fromType, Microsoft.CodeAnalysis.ITypeSymbol toType) -> bool` +* [ ] `Microsoft.CodeAnalysis.Compilation.IsSymbolAccessibleWithin(Microsoft.CodeAnalysis.ISymbol symbol, Microsoft.CodeAnalysis.ISymbol within, Microsoft.CodeAnalysis.ITypeSymbol throughType = null) -> bool` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.DiagnosticSuppressor` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.DiagnosticSuppressor.DiagnosticSuppressor() -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Suppression` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Suppression.Descriptor.get -> Microsoft.CodeAnalysis.SuppressionDescriptor` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Suppression.SuppressedDiagnostic.get -> Microsoft.CodeAnalysis.Diagnostic` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.SuppressionAnalysisContext` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.SuppressionAnalysisContext.CancellationToken.get -> System.Threading.CancellationToken` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.SuppressionAnalysisContext.Compilation.get -> Microsoft.CodeAnalysis.Compilation` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.SuppressionAnalysisContext.GetSemanticModel(Microsoft.CodeAnalysis.SyntaxTree syntaxTree) -> Microsoft.CodeAnalysis.SemanticModel` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.SuppressionAnalysisContext.Options.get -> Microsoft.CodeAnalysis.Diagnostics.AnalyzerOptions` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.SuppressionAnalysisContext.ReportSuppression(Microsoft.CodeAnalysis.Diagnostics.Suppression suppression) -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.SuppressionAnalysisContext.ReportedDiagnostics.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.SuppressionActionsCount.get -> int` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.SuppressionActionsCount.set -> void` +* [ ] `Microsoft.CodeAnalysis.IArrayTypeSymbol.ElementNullableAnnotation.get -> Microsoft.CodeAnalysis.NullableAnnotation` +* [ ] `Microsoft.CodeAnalysis.IDiscardSymbol.NullableAnnotation.get -> Microsoft.CodeAnalysis.NullableAnnotation` +* [ ] `Microsoft.CodeAnalysis.IEventSymbol.NullableAnnotation.get -> Microsoft.CodeAnalysis.NullableAnnotation` +* [ ] `Microsoft.CodeAnalysis.IFieldSymbol.NullableAnnotation.get -> Microsoft.CodeAnalysis.NullableAnnotation` +* [ ] `Microsoft.CodeAnalysis.ILocalSymbol.NullableAnnotation.get -> Microsoft.CodeAnalysis.NullableAnnotation` +* [ ] `Microsoft.CodeAnalysis.IMethodSymbol.Construct(System.Collections.Immutable.ImmutableArray typeArguments, System.Collections.Immutable.ImmutableArray typeArgumentNullableAnnotations) -> Microsoft.CodeAnalysis.IMethodSymbol` +* [ ] `Microsoft.CodeAnalysis.IMethodSymbol.ReceiverNullableAnnotation.get -> Microsoft.CodeAnalysis.NullableAnnotation` +* [ ] `Microsoft.CodeAnalysis.IMethodSymbol.ReturnNullableAnnotation.get -> Microsoft.CodeAnalysis.NullableAnnotation` +* [ ] `Microsoft.CodeAnalysis.IMethodSymbol.TypeArgumentNullableAnnotations.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.INamedTypeSymbol.Construct(System.Collections.Immutable.ImmutableArray typeArguments, System.Collections.Immutable.ImmutableArray typeArgumentNullableAnnotations) -> Microsoft.CodeAnalysis.INamedTypeSymbol` +* [ ] `Microsoft.CodeAnalysis.INamedTypeSymbol.TypeArgumentNullableAnnotations.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.IParameterSymbol.NullableAnnotation.get -> Microsoft.CodeAnalysis.NullableAnnotation` +* [ ] `Microsoft.CodeAnalysis.IPropertySymbol.NullableAnnotation.get -> Microsoft.CodeAnalysis.NullableAnnotation` +* [ ] `Microsoft.CodeAnalysis.ISymbol.Equals(Microsoft.CodeAnalysis.ISymbol other, Microsoft.CodeAnalysis.SymbolEqualityComparer equalityComparer) -> bool` +* [ ] `Microsoft.CodeAnalysis.ITypeParameterSymbol.ConstraintNullableAnnotations.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.ITypeParameterSymbol.HasNotNullConstraint.get -> bool` +* [ ] `Microsoft.CodeAnalysis.ITypeParameterSymbol.ReferenceTypeConstraintNullableAnnotation.get -> Microsoft.CodeAnalysis.NullableAnnotation` +* [ ] `Microsoft.CodeAnalysis.ITypeSymbol.ToDisplayParts(Microsoft.CodeAnalysis.NullableFlowState topLevelNullability, Microsoft.CodeAnalysis.SymbolDisplayFormat format = null) -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.ITypeSymbol.ToDisplayString(Microsoft.CodeAnalysis.NullableFlowState topLevelNullability, Microsoft.CodeAnalysis.SymbolDisplayFormat format = null) -> string` +* [ ] `Microsoft.CodeAnalysis.ITypeSymbol.ToMinimalDisplayParts(Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.NullableFlowState topLevelNullability, int position, Microsoft.CodeAnalysis.SymbolDisplayFormat format = null) -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.ITypeSymbol.ToMinimalDisplayString(Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.NullableFlowState topLevelNullability, int position, Microsoft.CodeAnalysis.SymbolDisplayFormat format = null) -> string` +* [ ] `Microsoft.CodeAnalysis.NullabilityInfo` +* [ ] `Microsoft.CodeAnalysis.NullabilityInfo.Annotation.get -> Microsoft.CodeAnalysis.NullableAnnotation` +* [ ] `Microsoft.CodeAnalysis.NullabilityInfo.Equals(Microsoft.CodeAnalysis.NullabilityInfo other) -> bool` +* [ ] `Microsoft.CodeAnalysis.NullabilityInfo.FlowState.get -> Microsoft.CodeAnalysis.NullableFlowState` +* [ ] `Microsoft.CodeAnalysis.NullableAnnotation` +* [ ] `Microsoft.CodeAnalysis.NullableAnnotation.Annotated = 2 -> Microsoft.CodeAnalysis.NullableAnnotation` +* [ ] `Microsoft.CodeAnalysis.NullableAnnotation.None = 0 -> Microsoft.CodeAnalysis.NullableAnnotation` +* [ ] `Microsoft.CodeAnalysis.NullableAnnotation.NotAnnotated = 1 -> Microsoft.CodeAnalysis.NullableAnnotation` +* [ ] `Microsoft.CodeAnalysis.NullableContext` +* [ ] `Microsoft.CodeAnalysis.NullableContext.AnnotationsContextInherited = 8 -> Microsoft.CodeAnalysis.NullableContext` +* [ ] `Microsoft.CodeAnalysis.NullableContext.AnnotationsEnabled = 2 -> Microsoft.CodeAnalysis.NullableContext` +* [ ] `Microsoft.CodeAnalysis.NullableContext.ContextInherited = Microsoft.CodeAnalysis.NullableContext.WarningsContextInherited | Microsoft.CodeAnalysis.NullableContext.AnnotationsContextInherited -> Microsoft.CodeAnalysis.NullableContext` +* [ ] `Microsoft.CodeAnalysis.NullableContext.Disabled = 0 -> Microsoft.CodeAnalysis.NullableContext` +* [ ] `Microsoft.CodeAnalysis.NullableContext.Enabled = Microsoft.CodeAnalysis.NullableContext.WarningsEnabled | Microsoft.CodeAnalysis.NullableContext.AnnotationsEnabled -> Microsoft.CodeAnalysis.NullableContext` +* [ ] `Microsoft.CodeAnalysis.NullableContext.WarningsContextInherited = 4 -> Microsoft.CodeAnalysis.NullableContext` +* [ ] `Microsoft.CodeAnalysis.NullableContext.WarningsEnabled = 1 -> Microsoft.CodeAnalysis.NullableContext` +* [ ] `Microsoft.CodeAnalysis.NullableContextExtensions` +* [ ] `Microsoft.CodeAnalysis.NullableContextOptions` +* [ ] `Microsoft.CodeAnalysis.NullableContextOptions.Annotations = 2 -> Microsoft.CodeAnalysis.NullableContextOptions` +* [ ] `Microsoft.CodeAnalysis.NullableContextOptions.Disable = 0 -> Microsoft.CodeAnalysis.NullableContextOptions` +* [ ] `Microsoft.CodeAnalysis.NullableContextOptions.Enable = Microsoft.CodeAnalysis.NullableContextOptions.Warnings | Microsoft.CodeAnalysis.NullableContextOptions.Annotations -> Microsoft.CodeAnalysis.NullableContextOptions` +* [ ] `Microsoft.CodeAnalysis.NullableContextOptions.Warnings = 1 -> Microsoft.CodeAnalysis.NullableContextOptions` +* [ ] `Microsoft.CodeAnalysis.NullableContextOptionsExtensions` +* [ ] `Microsoft.CodeAnalysis.NullableFlowState` +* [ ] `Microsoft.CodeAnalysis.NullableFlowState.MaybeNull = 2 -> Microsoft.CodeAnalysis.NullableFlowState` +* [ ] `Microsoft.CodeAnalysis.NullableFlowState.None = 0 -> Microsoft.CodeAnalysis.NullableFlowState` +* [ ] `Microsoft.CodeAnalysis.NullableFlowState.NotNull = 1 -> Microsoft.CodeAnalysis.NullableFlowState` +* [ ] `Microsoft.CodeAnalysis.SuppressionDescriptor` +* [ ] `Microsoft.CodeAnalysis.SuppressionDescriptor.Equals(Microsoft.CodeAnalysis.SuppressionDescriptor other) -> bool` +* [ ] `Microsoft.CodeAnalysis.SuppressionDescriptor.Id.get -> string` +* [ ] `Microsoft.CodeAnalysis.SuppressionDescriptor.Justification.get -> Microsoft.CodeAnalysis.LocalizableString` +* [ ] `Microsoft.CodeAnalysis.SuppressionDescriptor.SuppressedDiagnosticId.get -> string` +* [ ] `Microsoft.CodeAnalysis.SuppressionDescriptor.SuppressionDescriptor(string id, string suppressedDiagnosticId, Microsoft.CodeAnalysis.LocalizableString justification) -> void` +* [ ] `Microsoft.CodeAnalysis.SuppressionDescriptor.SuppressionDescriptor(string id, string suppressedDiagnosticId, string justification) -> void` +* [ ] `Microsoft.CodeAnalysis.OperationKind.PropertySubpattern = 107 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.Operations.IPropertySubpatternOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IPropertySubpatternOperation.Member.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IPropertySubpatternOperation.Pattern.get -> Microsoft.CodeAnalysis.Operations.IPatternOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IRecursivePatternOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IRecursivePatternOperation.DeclaredSymbol.get -> Microsoft.CodeAnalysis.ISymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IRecursivePatternOperation.DeconstructSymbol.get -> Microsoft.CodeAnalysis.ISymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IRecursivePatternOperation.DeconstructionSubpatterns.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IRecursivePatternOperation.MatchedType.get -> Microsoft.CodeAnalysis.ITypeSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IRecursivePatternOperation.PropertySubpatterns.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.SymbolEqualityComparer` +* [ ] `Microsoft.CodeAnalysis.SymbolEqualityComparer.Equals(Microsoft.CodeAnalysis.ISymbol x, Microsoft.CodeAnalysis.ISymbol y) -> bool` +* [ ] `Microsoft.CodeAnalysis.SymbolEqualityComparer.GetHashCode(Microsoft.CodeAnalysis.ISymbol obj) -> int` +* [ ] `Microsoft.CodeAnalysis.TypeInfo.ConvertedNullability.get -> Microsoft.CodeAnalysis.NullabilityInfo` +* [ ] `Microsoft.CodeAnalysis.TypeInfo.Nullability.get -> Microsoft.CodeAnalysis.NullabilityInfo` +* [ ] `abstract Microsoft.CodeAnalysis.Compilation.ClassifyCommonConversion(Microsoft.CodeAnalysis.ITypeSymbol source, Microsoft.CodeAnalysis.ITypeSymbol destination) -> Microsoft.CodeAnalysis.Operations.CommonConversion` +* [ ] `abstract Microsoft.CodeAnalysis.Compilation.ContainsSymbolsWithName(string name, Microsoft.CodeAnalysis.SymbolFilter filter = Microsoft.CodeAnalysis.SymbolFilter.TypeAndMember, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> bool` +* [ ] `abstract Microsoft.CodeAnalysis.Compilation.GetSymbolsWithName(string name, Microsoft.CodeAnalysis.SymbolFilter filter = Microsoft.CodeAnalysis.SymbolFilter.TypeAndMember, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IEnumerable` +* [ ] `abstract Microsoft.CodeAnalysis.CompilationOptions.NullableContextOptions.get -> Microsoft.CodeAnalysis.NullableContextOptions` +* [ ] `abstract Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions.TryGetValue(string key, out string value) -> bool` +* [ ] `abstract Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptionsProvider.GetOptions(Microsoft.CodeAnalysis.AdditionalText textFile) -> Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions` +* [ ] `abstract Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptionsProvider.GetOptions(Microsoft.CodeAnalysis.SyntaxTree tree) -> Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions` +* [ ] `abstract Microsoft.CodeAnalysis.Diagnostics.DiagnosticSuppressor.ReportSuppressions(Microsoft.CodeAnalysis.Diagnostics.SuppressionAnalysisContext context) -> void` +* [ ] `abstract Microsoft.CodeAnalysis.Diagnostics.DiagnosticSuppressor.SupportedSuppressions.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `abstract Microsoft.CodeAnalysis.Diagnostics.SymbolStartAnalysisContext.RegisterCodeBlockAction(System.Action action) -> void` +* [ ] `abstract Microsoft.CodeAnalysis.Diagnostics.SymbolStartAnalysisContext.RegisterCodeBlockStartAction(System.Action> action) -> void` +* [ ] `abstract Microsoft.CodeAnalysis.Diagnostics.SymbolStartAnalysisContext.RegisterOperationAction(System.Action action, System.Collections.Immutable.ImmutableArray operationKinds) -> void` +* [ ] `abstract Microsoft.CodeAnalysis.Diagnostics.SymbolStartAnalysisContext.RegisterOperationBlockAction(System.Action action) -> void` +* [ ] `abstract Microsoft.CodeAnalysis.Diagnostics.SymbolStartAnalysisContext.RegisterOperationBlockStartAction(System.Action action) -> void` +* [ ] `abstract Microsoft.CodeAnalysis.Diagnostics.SymbolStartAnalysisContext.RegisterSymbolEndAction(System.Action action) -> void` +* [ ] `abstract Microsoft.CodeAnalysis.Diagnostics.SymbolStartAnalysisContext.RegisterSyntaxNodeAction(System.Action action, System.Collections.Immutable.ImmutableArray syntaxKinds) -> void` +* [ ] `abstract Microsoft.CodeAnalysis.SemanticModel.GetNullableContext(int position) -> Microsoft.CodeAnalysis.NullableContext` +* [ ] `const Microsoft.CodeAnalysis.WellKnownMemberNames.CountPropertyName = "Count" -> string` +* [ ] `const Microsoft.CodeAnalysis.WellKnownMemberNames.DisposeAsyncMethodName = "DisposeAsync" -> string` +* [ ] `const Microsoft.CodeAnalysis.WellKnownMemberNames.DisposeMethodName = "Dispose" -> string` +* [ ] `const Microsoft.CodeAnalysis.WellKnownMemberNames.GetAsyncEnumeratorMethodName = "GetAsyncEnumerator" -> string` +* [ ] `const Microsoft.CodeAnalysis.WellKnownMemberNames.LengthPropertyName = "Length" -> string` +* [ ] `const Microsoft.CodeAnalysis.WellKnownMemberNames.MoveNextAsyncMethodName = "MoveNextAsync" -> string` +* [ ] `Microsoft.CodeAnalysis.AnalyzerConfig` +* [ ] `Microsoft.CodeAnalysis.AnalyzerConfig.GlobalSection.get -> Microsoft.CodeAnalysis.AnalyzerConfig.Section` +* [ ] `Microsoft.CodeAnalysis.AnalyzerConfig.IsRoot.get -> bool` +* [ ] `Microsoft.CodeAnalysis.AnalyzerConfig.NamedSections.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.AnalyzerConfig.NormalizedDirectory.get -> string` +* [ ] `Microsoft.CodeAnalysis.AnalyzerConfig.PathToFile.get -> string` +* [ ] `Microsoft.CodeAnalysis.AnalyzerConfig.Section` +* [ ] `Microsoft.CodeAnalysis.AnalyzerConfig.Section.Name.get -> string` +* [ ] `Microsoft.CodeAnalysis.AnalyzerConfig.Section.Properties.get -> System.Collections.Immutable.ImmutableDictionary` +* [ ] `Microsoft.CodeAnalysis.AnalyzerConfig.Section.Section(string name, System.Collections.Immutable.ImmutableDictionary properties) -> void` +* [ ] `Microsoft.CodeAnalysis.AnalyzerConfig.SectionNameMatcher` +* [ ] `Microsoft.CodeAnalysis.AnalyzerConfig.SectionNameMatcher.IsMatch(string s) -> bool` +* [ ] `Microsoft.CodeAnalysis.AnalyzerConfigOptionsResult` +* [ ] `Microsoft.CodeAnalysis.AnalyzerConfigOptionsResult.AnalyzerOptions.get -> System.Collections.Immutable.ImmutableDictionary` +* [ ] `Microsoft.CodeAnalysis.AnalyzerConfigOptionsResult.Diagnostics.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.AnalyzerConfigOptionsResult.TreeOptions.get -> System.Collections.Immutable.ImmutableDictionary` +* [ ] `Microsoft.CodeAnalysis.AnalyzerConfigSet` +* [ ] `Microsoft.CodeAnalysis.AnalyzerConfigSet.GetOptionsForSourcePath(string sourcePath) -> Microsoft.CodeAnalysis.AnalyzerConfigOptionsResult` +* [ ] `Microsoft.CodeAnalysis.CommandLineArguments.AnalyzerConfigPaths.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions.AnalyzerConfigOptions() -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptionsProvider` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptionsProvider.AnalyzerConfigOptionsProvider() -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.AnalyzerOptions.AnalyzerConfigOptionsProvider.get -> Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptionsProvider` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.AnalyzerOptions.AnalyzerOptions(System.Collections.Immutable.ImmutableArray additionalFiles, Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptionsProvider optionsProvider) -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationAnalysisContext.GetControlFlowGraph() -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationBlockAnalysisContext.GetControlFlowGraph(Microsoft.CodeAnalysis.IOperation operationBlock) -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.OperationBlockStartAnalysisContext.GetControlFlowGraph(Microsoft.CodeAnalysis.IOperation operationBlock) -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.SymbolStartAnalysisContext` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.SymbolStartAnalysisContext.CancellationToken.get -> System.Threading.CancellationToken` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.SymbolStartAnalysisContext.Compilation.get -> Microsoft.CodeAnalysis.Compilation` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.SymbolStartAnalysisContext.Options.get -> Microsoft.CodeAnalysis.Diagnostics.AnalyzerOptions` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.SymbolStartAnalysisContext.RegisterOperationAction(System.Action action, params Microsoft.CodeAnalysis.OperationKind[] operationKinds) -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.SymbolStartAnalysisContext.RegisterSyntaxNodeAction(System.Action action, params TLanguageKindEnum[] syntaxKinds) -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.SymbolStartAnalysisContext.Symbol.get -> Microsoft.CodeAnalysis.ISymbol` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.SymbolStartAnalysisContext.SymbolStartAnalysisContext(Microsoft.CodeAnalysis.ISymbol symbol, Microsoft.CodeAnalysis.Compilation compilation, Microsoft.CodeAnalysis.Diagnostics.AnalyzerOptions options, System.Threading.CancellationToken cancellationToken) -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.Concurrent.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.Concurrent.set -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.SymbolEndActionsCount.get -> int` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.SymbolEndActionsCount.set -> void` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.SymbolStartActionsCount.get -> int` +* [ ] `Microsoft.CodeAnalysis.Diagnostics.Telemetry.AnalyzerTelemetryInfo.SymbolStartActionsCount.set -> void` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.BasicBlock` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.BasicBlock.BranchValue.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.BasicBlock.ConditionalSuccessor.get -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranch` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.BasicBlock.ConditionKind.get -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowConditionKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.BasicBlock.EnclosingRegion.get -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegion` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.BasicBlock.FallThroughSuccessor.get -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranch` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.BasicBlock.IsReachable.get -> bool` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.BasicBlock.Kind.get -> Microsoft.CodeAnalysis.FlowAnalysis.BasicBlockKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.BasicBlock.Operations.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.BasicBlock.Ordinal.get -> int` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.BasicBlock.Predecessors.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.BasicBlockKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.BasicBlockKind.Block = 2 -> Microsoft.CodeAnalysis.FlowAnalysis.BasicBlockKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.BasicBlockKind.Entry = 0 -> Microsoft.CodeAnalysis.FlowAnalysis.BasicBlockKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.BasicBlockKind.Exit = 1 -> Microsoft.CodeAnalysis.FlowAnalysis.BasicBlockKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.CaptureId` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.CaptureId.Equals(Microsoft.CodeAnalysis.FlowAnalysis.CaptureId other) -> bool` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranch` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranch.Destination.get -> Microsoft.CodeAnalysis.FlowAnalysis.BasicBlock` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranch.EnteringRegions.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranch.FinallyRegions.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranch.IsConditionalSuccessor.get -> bool` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranch.LeavingRegions.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranch.Semantics.get -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranchSemantics` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranch.Source.get -> Microsoft.CodeAnalysis.FlowAnalysis.BasicBlock` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranchSemantics` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranchSemantics.Error = 7 -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranchSemantics` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranchSemantics.None = 0 -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranchSemantics` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranchSemantics.ProgramTermination = 4 -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranchSemantics` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranchSemantics.Regular = 1 -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranchSemantics` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranchSemantics.Rethrow = 6 -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranchSemantics` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranchSemantics.Return = 2 -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranchSemantics` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranchSemantics.StructuredExceptionHandling = 3 -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranchSemantics` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranchSemantics.Throw = 5 -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowBranchSemantics` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowConditionKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowConditionKind.None = 0 -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowConditionKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowConditionKind.WhenFalse = 1 -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowConditionKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowConditionKind.WhenTrue = 2 -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowConditionKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph.Blocks.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph.GetAnonymousFunctionControlFlowGraph(Microsoft.CodeAnalysis.FlowAnalysis.IFlowAnonymousFunctionOperation anonymousFunction, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph.GetLocalFunctionControlFlowGraph(Microsoft.CodeAnalysis.IMethodSymbol localFunction, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph.LocalFunctions.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph.OriginalOperation.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph.Parent.get -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph.Root.get -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegion` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraphExtensions` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegion` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegion.CaptureIds.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegion.EnclosingRegion.get -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegion` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegion.ExceptionType.get -> Microsoft.CodeAnalysis.ITypeSymbol` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegion.FirstBlockOrdinal.get -> int` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegion.Kind.get -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegion.LastBlockOrdinal.get -> int` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegion.LocalFunctions.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegion.Locals.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegion.NestedRegions.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind.Catch = 4 -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind.ErroneousBody = 10 -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind.Filter = 3 -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind.FilterAndHandler = 5 -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind.Finally = 7 -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind.LocalLifetime = 1 -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind.Root = 0 -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind.StaticLocalInitializer = 9 -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind.Try = 2 -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind.TryAndCatch = 6 -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind.TryAndFinally = 8 -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowRegionKind` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.ICaughtExceptionOperation` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.IFlowAnonymousFunctionOperation` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.IFlowAnonymousFunctionOperation.Symbol.get -> Microsoft.CodeAnalysis.IMethodSymbol` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureOperation` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureOperation.Id.get -> Microsoft.CodeAnalysis.FlowAnalysis.CaptureId` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureOperation.Value.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureReferenceOperation` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureReferenceOperation.Id.get -> Microsoft.CodeAnalysis.FlowAnalysis.CaptureId` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.IIsNullOperation` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.IIsNullOperation.Operand.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.IStaticLocalInitializationSemaphoreOperation` +* [ ] `Microsoft.CodeAnalysis.FlowAnalysis.IStaticLocalInitializationSemaphoreOperation.Local.get -> Microsoft.CodeAnalysis.ILocalSymbol` +* [ ] `Microsoft.CodeAnalysis.IFieldSymbol.IsFixedSizeBuffer.get -> bool` +* [ ] `Microsoft.CodeAnalysis.ILocalSymbol.IsFixed.get -> bool` +* [ ] `Microsoft.CodeAnalysis.IMethodSymbol.IsReadOnly.get -> bool` +* [ ] `Microsoft.CodeAnalysis.IOperation.SemanticModel.get -> Microsoft.CodeAnalysis.SemanticModel` +* [ ] `Microsoft.CodeAnalysis.ITypeSymbol.IsReadOnly.get -> bool` +* [ ] `Microsoft.CodeAnalysis.ITypeSymbol.IsRefLikeType.get -> bool` +* [ ] `Microsoft.CodeAnalysis.ITypeSymbol.IsUnmanagedType.get -> bool` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Binary = 32 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.CaughtException = 94 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.CoalesceAssignment = 97 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.ConstructorBody = 89 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.DiscardPattern = 104 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.FlowAnonymousFunction = 96 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.FlowCapture = 91 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.FlowCaptureReference = 92 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.IsNull = 93 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.MethodBody = 88 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Range = 99 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.RecursivePattern = 103 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.ReDim = 101 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.ReDimClause = 102 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.StaticLocalInitializationSemaphore = 95 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.SwitchExpression = 105 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.SwitchExpressionArm = 106 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.TupleBinary = 87 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.OperationKind.Unary = 31 -> Microsoft.CodeAnalysis.OperationKind` +* [ ] `Microsoft.CodeAnalysis.Operations.CommonConversion.IsImplicit.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.ICaseClauseOperation.Label.get -> Microsoft.CodeAnalysis.ILabelSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.ICoalesceAssignmentOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ICoalesceOperation.ValueConversion.get -> Microsoft.CodeAnalysis.Operations.CommonConversion` +* [ ] `Microsoft.CodeAnalysis.Operations.IDeclarationPatternOperation.MatchedType.get -> Microsoft.CodeAnalysis.ITypeSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IDeclarationPatternOperation.MatchesNull.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.IDiscardPatternOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IEventAssignmentOperation.EventReference.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IForLoopOperation.ConditionLocals.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IForToLoopOperation.IsChecked.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.IInstanceReferenceOperation.ReferenceKind.get -> Microsoft.CodeAnalysis.Operations.InstanceReferenceKind` +* [ ] `Microsoft.CodeAnalysis.Operations.ILoopOperation.ContinueLabel.get -> Microsoft.CodeAnalysis.ILabelSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.ILoopOperation.ExitLabel.get -> Microsoft.CodeAnalysis.ILabelSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.InstanceReferenceKind` +* [ ] `Microsoft.CodeAnalysis.Operations.InstanceReferenceKind.ContainingTypeInstance = 0 -> Microsoft.CodeAnalysis.Operations.InstanceReferenceKind` +* [ ] `Microsoft.CodeAnalysis.Operations.InstanceReferenceKind.ImplicitReceiver = 1 -> Microsoft.CodeAnalysis.Operations.InstanceReferenceKind` +* [ ] `Microsoft.CodeAnalysis.Operations.InstanceReferenceKind.PatternInput = 2 -> Microsoft.CodeAnalysis.Operations.InstanceReferenceKind` +* [ ] `Microsoft.CodeAnalysis.Operations.IPatternOperation.InputType.get -> Microsoft.CodeAnalysis.ITypeSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IRangeOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IRangeOperation.IsLifted.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.IRangeOperation.LeftOperand.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IRangeOperation.Method.get -> Microsoft.CodeAnalysis.IMethodSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IRangeOperation.RightOperand.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IReDimClauseOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IReDimClauseOperation.DimensionSizes.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IReDimClauseOperation.Operand.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IReDimOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.IReDimOperation.Clauses.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IReDimOperation.Preserve.get -> bool` +* [ ] `Microsoft.CodeAnalysis.Operations.ISwitchCaseOperation.Locals.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.ISwitchExpressionArmOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ISwitchExpressionArmOperation.Guard.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ISwitchExpressionArmOperation.Locals.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.ISwitchExpressionArmOperation.Pattern.get -> Microsoft.CodeAnalysis.Operations.IPatternOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ISwitchExpressionArmOperation.Value.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ISwitchExpressionOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ISwitchExpressionOperation.Arms.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.ISwitchExpressionOperation.Value.get -> Microsoft.CodeAnalysis.IOperation` +* [ ] `Microsoft.CodeAnalysis.Operations.ISwitchOperation.ExitLabel.get -> Microsoft.CodeAnalysis.ILabelSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.ISwitchOperation.Locals.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.ITryOperation.ExitLabel.get -> Microsoft.CodeAnalysis.ILabelSymbol` +* [ ] `Microsoft.CodeAnalysis.Operations.IUsingOperation.Locals.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.IVariableDeclarationOperation.IgnoredDimensions.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `Microsoft.CodeAnalysis.Operations.UnaryOperatorKind.Hat = 7 -> Microsoft.CodeAnalysis.Operations.UnaryOperatorKind` +* [ ] `Microsoft.CodeAnalysis.SpecialType.Count = 44 -> Microsoft.CodeAnalysis.SpecialType` +* [ ] `Microsoft.CodeAnalysis.SpecialType.System_Runtime_CompilerServices_RuntimeFeature = 44 -> Microsoft.CodeAnalysis.SpecialType` +* [ ] `Microsoft.CodeAnalysis.SymbolDisplayMiscellaneousOptions.AllowDefaultLiteral = 128 -> Microsoft.CodeAnalysis.SymbolDisplayMiscellaneousOptions` +* [ ] `Microsoft.CodeAnalysis.SymbolDisplayMiscellaneousOptions.IncludeNullableReferenceTypeModifier = 64 -> Microsoft.CodeAnalysis.SymbolDisplayMiscellaneousOptions` +* [ ] `Microsoft.CodeAnalysis.SymbolDisplayPartKind.ConstantName = 30 -> Microsoft.CodeAnalysis.SymbolDisplayPartKind` +* [ ] `Microsoft.CodeAnalysis.SymbolDisplayPartKind.EnumMemberName = 28 -> Microsoft.CodeAnalysis.SymbolDisplayPartKind` +* [ ] `Microsoft.CodeAnalysis.SymbolDisplayPartKind.ExtensionMethodName = 29 -> Microsoft.CodeAnalysis.SymbolDisplayPartKind` +* [ ] `const Microsoft.CodeAnalysis.WellKnownMemberNames.SliceMethodName = "Slice" -> string` +* [ ] `override Microsoft.CodeAnalysis.FlowAnalysis.CaptureId.Equals(object obj) -> bool` +* [ ] `override Microsoft.CodeAnalysis.FlowAnalysis.CaptureId.GetHashCode() -> int` +* [ ] `override Microsoft.CodeAnalysis.SuppressionDescriptor.Equals(object obj) -> bool` +* [ ] `override Microsoft.CodeAnalysis.SuppressionDescriptor.GetHashCode() -> int` +* [ ] `override sealed Microsoft.CodeAnalysis.Diagnostics.DiagnosticSuppressor.Initialize(Microsoft.CodeAnalysis.Diagnostics.AnalysisContext context) -> void` +* [ ] `override sealed Microsoft.CodeAnalysis.Diagnostics.DiagnosticSuppressor.SupportedDiagnostics.get -> System.Collections.Immutable.ImmutableArray` +* [ ] `static Microsoft.CodeAnalysis.AnalyzerConfig.Parse(Microsoft.CodeAnalysis.Text.SourceText text, string pathToFile) -> Microsoft.CodeAnalysis.AnalyzerConfig` +* [ ] `static Microsoft.CodeAnalysis.AnalyzerConfig.Parse(string text, string pathToFile) -> Microsoft.CodeAnalysis.AnalyzerConfig` +* [ ] `static Microsoft.CodeAnalysis.AnalyzerConfig.ReservedKeys.get -> System.Collections.Immutable.ImmutableHashSet` +* [ ] `static Microsoft.CodeAnalysis.AnalyzerConfig.ReservedValues.get -> System.Collections.Immutable.ImmutableHashSet` +* [ ] `static Microsoft.CodeAnalysis.AnalyzerConfig.Section.NameComparer.get -> System.StringComparison` +* [ ] `static Microsoft.CodeAnalysis.AnalyzerConfig.Section.PropertiesKeyComparer.get -> System.StringComparer` +* [ ] `static Microsoft.CodeAnalysis.AnalyzerConfig.TryCreateSectionNameMatcher(string sectionName) -> Microsoft.CodeAnalysis.AnalyzerConfig.SectionNameMatcher?` +* [ ] `static Microsoft.CodeAnalysis.AnalyzerConfigSet.Create(TList analyzerConfigs) -> Microsoft.CodeAnalysis.AnalyzerConfigSet` +* [ ] `static Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions.KeyComparer.get -> System.StringComparer` +* [ ] `override Microsoft.CodeAnalysis.NullabilityInfo.Equals(object other) -> bool` +* [ ] `override Microsoft.CodeAnalysis.NullabilityInfo.GetHashCode() -> int` +* [ ] `static Microsoft.CodeAnalysis.Diagnostics.Suppression.Create(Microsoft.CodeAnalysis.SuppressionDescriptor descriptor, Microsoft.CodeAnalysis.Diagnostic suppressedDiagnostic) -> Microsoft.CodeAnalysis.Diagnostics.Suppression` +* [ ] `static Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph.Create(Microsoft.CodeAnalysis.Operations.IBlockOperation body, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph` +* [ ] `static Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph.Create(Microsoft.CodeAnalysis.Operations.IConstructorBodyOperation constructorBody, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph` +* [ ] `static Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph.Create(Microsoft.CodeAnalysis.Operations.IFieldInitializerOperation initializer, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph` +* [ ] `static Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph.Create(Microsoft.CodeAnalysis.Operations.IMethodBodyOperation methodBody, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph` +* [ ] `static Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph.Create(Microsoft.CodeAnalysis.Operations.IParameterInitializerOperation initializer, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph` +* [ ] `static Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph.Create(Microsoft.CodeAnalysis.Operations.IPropertyInitializerOperation initializer, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph` +* [ ] `static Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph.Create(Microsoft.CodeAnalysis.SyntaxNode node, Microsoft.CodeAnalysis.SemanticModel semanticModel, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph` +* [ ] `static Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraphExtensions.GetAnonymousFunctionControlFlowGraphInScope(this Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph controlFlowGraph, Microsoft.CodeAnalysis.FlowAnalysis.IFlowAnonymousFunctionOperation anonymousFunction, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph` +* [ ] `static Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraphExtensions.GetLocalFunctionControlFlowGraphInScope(this Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph controlFlowGraph, Microsoft.CodeAnalysis.IMethodSymbol localFunction, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph` +* [ ] `static Microsoft.CodeAnalysis.NullableContextExtensions.AnnotationsEnabled(this Microsoft.CodeAnalysis.NullableContext context) -> bool` +* [ ] `static Microsoft.CodeAnalysis.NullableContextExtensions.AnnotationsInherited(this Microsoft.CodeAnalysis.NullableContext context) -> bool` +* [ ] `static Microsoft.CodeAnalysis.NullableContextExtensions.WarningsEnabled(this Microsoft.CodeAnalysis.NullableContext context) -> bool` +* [ ] `static Microsoft.CodeAnalysis.NullableContextExtensions.WarningsInherited(this Microsoft.CodeAnalysis.NullableContext context) -> bool` +* [ ] `static Microsoft.CodeAnalysis.NullableContextOptionsExtensions.AnnotationsEnabled(this Microsoft.CodeAnalysis.NullableContextOptions context) -> bool` +* [ ] `static Microsoft.CodeAnalysis.NullableContextOptionsExtensions.WarningsEnabled(this Microsoft.CodeAnalysis.NullableContextOptions context) -> bool` +* [ ] `static Microsoft.CodeAnalysis.Operations.OperationExtensions.GetCorrespondingOperation(this Microsoft.CodeAnalysis.Operations.IBranchOperation operation) -> Microsoft.CodeAnalysis.IOperation` +* [ ] `static readonly Microsoft.CodeAnalysis.SymbolEqualityComparer.Default -> Microsoft.CodeAnalysis.SymbolEqualityComparer` +* [ ] `static readonly Microsoft.CodeAnalysis.SymbolEqualityComparer.IncludeNullability -> Microsoft.CodeAnalysis.SymbolEqualityComparer` +* [ ] `static readonly Microsoft.CodeAnalysis.SyntaxTree.EmptyDiagnosticOptions -> System.Collections.Immutable.ImmutableDictionary` +* [ ] `virtual Microsoft.CodeAnalysis.Diagnostics.AnalysisContext.RegisterSymbolStartAction(System.Action action, Microsoft.CodeAnalysis.SymbolKind symbolKind) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Diagnostics.CompilationStartAnalysisContext.RegisterSymbolStartAction(System.Action action, Microsoft.CodeAnalysis.SymbolKind symbolKind) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitCaughtException(Microsoft.CodeAnalysis.FlowAnalysis.ICaughtExceptionOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitCoalesceAssignment(Microsoft.CodeAnalysis.Operations.ICoalesceAssignmentOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDiscardPattern(Microsoft.CodeAnalysis.Operations.IDiscardPatternOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitFlowAnonymousFunction(Microsoft.CodeAnalysis.FlowAnalysis.IFlowAnonymousFunctionOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitFlowCapture(Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitFlowCaptureReference(Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureReferenceOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitIsNull(Microsoft.CodeAnalysis.FlowAnalysis.IIsNullOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitRangeOperation(Microsoft.CodeAnalysis.Operations.IRangeOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitReDim(Microsoft.CodeAnalysis.Operations.IReDimOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitReDimClause(Microsoft.CodeAnalysis.Operations.IReDimClauseOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitStaticLocalInitializationSemaphore(Microsoft.CodeAnalysis.FlowAnalysis.IStaticLocalInitializationSemaphoreOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitSwitchExpression(Microsoft.CodeAnalysis.Operations.ISwitchExpressionOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitSwitchExpressionArm(Microsoft.CodeAnalysis.Operations.ISwitchExpressionArmOperation operation) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitCaughtException(Microsoft.CodeAnalysis.FlowAnalysis.ICaughtExceptionOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitCoalesceAssignment(Microsoft.CodeAnalysis.Operations.ICoalesceAssignmentOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitDiscardPattern(Microsoft.CodeAnalysis.Operations.IDiscardPatternOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitFlowAnonymousFunction(Microsoft.CodeAnalysis.FlowAnalysis.IFlowAnonymousFunctionOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitFlowCapture(Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitFlowCaptureReference(Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureReferenceOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitIsNull(Microsoft.CodeAnalysis.FlowAnalysis.IIsNullOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitRangeOperation(Microsoft.CodeAnalysis.Operations.IRangeOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitReDim(Microsoft.CodeAnalysis.Operations.IReDimOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitReDimClause(Microsoft.CodeAnalysis.Operations.IReDimClauseOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitStaticLocalInitializationSemaphore(Microsoft.CodeAnalysis.FlowAnalysis.IStaticLocalInitializationSemaphoreOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitSwitchExpression(Microsoft.CodeAnalysis.Operations.ISwitchExpressionOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitSwitchExpressionArm(Microsoft.CodeAnalysis.Operations.ISwitchExpressionArmOperation operation, TArgument argument) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.SyntaxTree.DiagnosticOptions.get -> System.Collections.Immutable.ImmutableDictionary` +* [ ] `virtual Microsoft.CodeAnalysis.SyntaxTree.WithDiagnosticOptions(System.Collections.Immutable.ImmutableDictionary options) -> Microsoft.CodeAnalysis.SyntaxTree` + +See [Microsoft.CodeAnalysis.CSharp release/dev16.3@c955f3c99b5698c906e0700ef691b5b1571c8136](https://raw.githubusercontent.com/dotnet/roslyn/c955f3c99b5698c906e0700ef691b5b1571c8136/src/Compilers/CSharp/Portable/PublicAPI.Unshipped.txt) + +* [ ] `*REMOVED*static Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.Create(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode root, Microsoft.CodeAnalysis.CSharp.CSharpParseOptions options = null, string path = "", System.Text.Encoding encoding = null) -> Microsoft.CodeAnalysis.SyntaxTree` +* [ ] `*REMOVED*static Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.ParseText(Microsoft.CodeAnalysis.Text.SourceText text, Microsoft.CodeAnalysis.CSharp.CSharpParseOptions options = null, string path = "", System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.SyntaxTree` +* [ ] `*REMOVED*static Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.ParseText(string text, Microsoft.CodeAnalysis.CSharp.CSharpParseOptions options = null, string path = "", System.Text.Encoding encoding = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.SyntaxTree` +* [ ] `*REMOVED*static Microsoft.CodeAnalysis.CSharp.LanguageVersionFacts.TryParse(this string version, out Microsoft.CodeAnalysis.CSharp.LanguageVersion result) -> bool` +* [ ] `*REMOVED*static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ParseSyntaxTree(Microsoft.CodeAnalysis.Text.SourceText text, Microsoft.CodeAnalysis.ParseOptions options = null, string path = "", System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.SyntaxTree` +* [ ] `*REMOVED*static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ParseSyntaxTree(string text, Microsoft.CodeAnalysis.ParseOptions options = null, string path = "", System.Text.Encoding encoding = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.SyntaxTree` +* [ ] `*REMOVED*abstract Microsoft.CodeAnalysis.CSharp.Syntax.BaseFieldDeclarationSyntax.AttributeLists.get -> Microsoft.CodeAnalysis.SyntaxList` +* [ ] `*REMOVED*abstract Microsoft.CodeAnalysis.CSharp.Syntax.BaseFieldDeclarationSyntax.Modifiers.get -> Microsoft.CodeAnalysis.SyntaxTokenList` +* [ ] `*REMOVED*abstract Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax.AttributeLists.get -> Microsoft.CodeAnalysis.SyntaxList` +* [ ] `*REMOVED*abstract Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax.Modifiers.get -> Microsoft.CodeAnalysis.SyntaxTokenList` +* [ ] `*REMOVED*abstract Microsoft.CodeAnalysis.CSharp.Syntax.BasePropertyDeclarationSyntax.AttributeLists.get -> Microsoft.CodeAnalysis.SyntaxList` +* [ ] `*REMOVED*abstract Microsoft.CodeAnalysis.CSharp.Syntax.BasePropertyDeclarationSyntax.Modifiers.get -> Microsoft.CodeAnalysis.SyntaxTokenList` +* [ ] `*REMOVED*abstract Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax.AttributeLists.get -> Microsoft.CodeAnalysis.SyntaxList` +* [ ] `*REMOVED*abstract Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax.Modifiers.get -> Microsoft.CodeAnalysis.SyntaxTokenList` +* [ ] `*REMOVED*Microsoft.CodeAnalysis.CSharp.Syntax.DelegateDeclarationSyntax.AttributeLists.get -> Microsoft.CodeAnalysis.SyntaxList` +* [ ] `*REMOVED*Microsoft.CodeAnalysis.CSharp.Syntax.DelegateDeclarationSyntax.Modifiers.get -> Microsoft.CodeAnalysis.SyntaxTokenList` +* [ ] `*REMOVED*Microsoft.CodeAnalysis.CSharp.Syntax.EnumMemberDeclarationSyntax.AttributeLists.get -> Microsoft.CodeAnalysis.SyntaxList` +* [ ] `*REMOVED*Microsoft.CodeAnalysis.CSharp.Syntax.IncompleteMemberSyntax.AttributeLists.get -> Microsoft.CodeAnalysis.SyntaxList` +* [ ] `*REMOVED*Microsoft.CodeAnalysis.CSharp.Syntax.IncompleteMemberSyntax.Modifiers.get -> Microsoft.CodeAnalysis.SyntaxTokenList` +* [ ] `Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.CSharpCompilationOptions(Microsoft.CodeAnalysis.OutputKind outputKind, bool reportSuppressedDiagnostics = false, string moduleName = null, string mainTypeName = null, string scriptClassName = null, System.Collections.Generic.IEnumerable usings = null, Microsoft.CodeAnalysis.OptimizationLevel optimizationLevel = Microsoft.CodeAnalysis.OptimizationLevel.Debug, bool checkOverflow = false, bool allowUnsafe = false, string cryptoKeyContainer = null, string cryptoKeyFile = null, System.Collections.Immutable.ImmutableArray cryptoPublicKey = default(System.Collections.Immutable.ImmutableArray), bool? delaySign = null, Microsoft.CodeAnalysis.Platform platform = Microsoft.CodeAnalysis.Platform.AnyCpu, Microsoft.CodeAnalysis.ReportDiagnostic generalDiagnosticOption = Microsoft.CodeAnalysis.ReportDiagnostic.Default, int warningLevel = 4, System.Collections.Generic.IEnumerable> specificDiagnosticOptions = null, bool concurrentBuild = true, bool deterministic = false, Microsoft.CodeAnalysis.XmlReferenceResolver xmlReferenceResolver = null, Microsoft.CodeAnalysis.SourceReferenceResolver sourceReferenceResolver = null, Microsoft.CodeAnalysis.MetadataReferenceResolver metadataReferenceResolver = null, Microsoft.CodeAnalysis.AssemblyIdentityComparer assemblyIdentityComparer = null, Microsoft.CodeAnalysis.StrongNameProvider strongNameProvider = null, bool publicSign = false, Microsoft.CodeAnalysis.MetadataImportOptions metadataImportOptions = Microsoft.CodeAnalysis.MetadataImportOptions.Public, Microsoft.CodeAnalysis.NullableContextOptions nullableContextOptions = Microsoft.CodeAnalysis.NullableContextOptions.Disable) -> void` +* [ ] `Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.WithNullableContextOptions(Microsoft.CodeAnalysis.NullableContextOptions options) -> Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.EventDeclarationSyntax.SemicolonToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.EventDeclarationSyntax.Update(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken eventKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.CSharp.Syntax.ExplicitInterfaceSpecifierSyntax explicitInterfaceSpecifier, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.CSharp.Syntax.AccessorListSyntax accessorList, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.EventDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.EventDeclarationSyntax.Update(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken eventKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.CSharp.Syntax.ExplicitInterfaceSpecifierSyntax explicitInterfaceSpecifier, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.EventDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.EventDeclarationSyntax.WithSemicolonToken(Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.EventDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax.TargetToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken hashToken, Microsoft.CodeAnalysis.SyntaxToken nullableKeyword, Microsoft.CodeAnalysis.SyntaxToken settingToken, Microsoft.CodeAnalysis.SyntaxToken targetToken, Microsoft.CodeAnalysis.SyntaxToken endOfDirectiveToken, bool isActive) -> Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax.WithTargetToken(Microsoft.CodeAnalysis.SyntaxToken targetToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax.IsNotNull.get -> bool` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.AnnotationsKeyword = 8489 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.WarningsKeyword = 8488 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `abstract Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax.AwaitKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [ ] `Microsoft.CodeAnalysis.CSharp.Conversion.IsSwitchExpression.get -> bool` +* [ ] `Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.CSharpCompilationOptions(Microsoft.CodeAnalysis.OutputKind outputKind, bool reportSuppressedDiagnostics, string moduleName, string mainTypeName, string scriptClassName, System.Collections.Generic.IEnumerable usings, Microsoft.CodeAnalysis.OptimizationLevel optimizationLevel, bool checkOverflow, bool allowUnsafe, string cryptoKeyContainer, string cryptoKeyFile, System.Collections.Immutable.ImmutableArray cryptoPublicKey, bool? delaySign, Microsoft.CodeAnalysis.Platform platform, Microsoft.CodeAnalysis.ReportDiagnostic generalDiagnosticOption, int warningLevel, System.Collections.Generic.IEnumerable> specificDiagnosticOptions, bool concurrentBuild, bool deterministic, Microsoft.CodeAnalysis.XmlReferenceResolver xmlReferenceResolver, Microsoft.CodeAnalysis.SourceReferenceResolver sourceReferenceResolver, Microsoft.CodeAnalysis.MetadataReferenceResolver metadataReferenceResolver, Microsoft.CodeAnalysis.AssemblyIdentityComparer assemblyIdentityComparer, Microsoft.CodeAnalysis.StrongNameProvider strongNameProvider, bool publicSign, Microsoft.CodeAnalysis.MetadataImportOptions metadataImportOptions) -> void` +* [x] `Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp8 = 800 -> Microsoft.CodeAnalysis.CSharp.LanguageVersion` +* [x] `Microsoft.CodeAnalysis.CSharp.LanguageVersion.LatestMajor = 2147483645 -> Microsoft.CodeAnalysis.CSharp.LanguageVersion` +* [x] `Microsoft.CodeAnalysis.CSharp.LanguageVersion.Preview = 2147483646 -> Microsoft.CodeAnalysis.CSharp.LanguageVersion` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.AnonymousFunctionExpressionSyntax.WithAsyncKeyword(Microsoft.CodeAnalysis.SyntaxToken asyncKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.AnonymousFunctionExpressionSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.AnonymousFunctionExpressionSyntax.WithBody(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode body) -> Microsoft.CodeAnalysis.CSharp.Syntax.AnonymousFunctionExpressionSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseArgumentListSyntax.AddArguments(params Microsoft.CodeAnalysis.CSharp.Syntax.ArgumentSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseArgumentListSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseArgumentListSyntax.WithArguments(Microsoft.CodeAnalysis.SeparatedSyntaxList arguments) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseArgumentListSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseCrefParameterListSyntax.AddParameters(params Microsoft.CodeAnalysis.CSharp.Syntax.CrefParameterSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseCrefParameterListSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseCrefParameterListSyntax.WithParameters(Microsoft.CodeAnalysis.SeparatedSyntaxList parameters) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseCrefParameterListSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseFieldDeclarationSyntax.AddAttributeLists(params Microsoft.CodeAnalysis.CSharp.Syntax.AttributeListSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseFieldDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseFieldDeclarationSyntax.AddDeclarationVariables(params Microsoft.CodeAnalysis.CSharp.Syntax.VariableDeclaratorSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseFieldDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseFieldDeclarationSyntax.AddModifiers(params Microsoft.CodeAnalysis.SyntaxToken[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseFieldDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseFieldDeclarationSyntax.WithAttributeLists(Microsoft.CodeAnalysis.SyntaxList attributeLists) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseFieldDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseFieldDeclarationSyntax.WithDeclaration(Microsoft.CodeAnalysis.CSharp.Syntax.VariableDeclarationSyntax declaration) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseFieldDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseFieldDeclarationSyntax.WithModifiers(Microsoft.CodeAnalysis.SyntaxTokenList modifiers) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseFieldDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseFieldDeclarationSyntax.WithSemicolonToken(Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseFieldDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax.AddAttributeLists(params Microsoft.CodeAnalysis.CSharp.Syntax.AttributeListSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax.AddBodyStatements(params Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax.AddModifiers(params Microsoft.CodeAnalysis.SyntaxToken[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax.AddParameterListParameters(params Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax.WithAttributeLists(Microsoft.CodeAnalysis.SyntaxList attributeLists) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax.WithBody(Microsoft.CodeAnalysis.CSharp.Syntax.BlockSyntax body) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax.WithExpressionBody(Microsoft.CodeAnalysis.CSharp.Syntax.ArrowExpressionClauseSyntax expressionBody) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax.WithModifiers(Microsoft.CodeAnalysis.SyntaxTokenList modifiers) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax.WithParameterList(Microsoft.CodeAnalysis.CSharp.Syntax.ParameterListSyntax parameterList) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax.WithSemicolonToken(Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseParameterListSyntax.AddParameters(params Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseParameterListSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseParameterListSyntax.WithParameters(Microsoft.CodeAnalysis.SeparatedSyntaxList parameters) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseParameterListSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BasePropertyDeclarationSyntax.AddAccessorListAccessors(params Microsoft.CodeAnalysis.CSharp.Syntax.AccessorDeclarationSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.BasePropertyDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BasePropertyDeclarationSyntax.AddAttributeLists(params Microsoft.CodeAnalysis.CSharp.Syntax.AttributeListSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.BasePropertyDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BasePropertyDeclarationSyntax.AddModifiers(params Microsoft.CodeAnalysis.SyntaxToken[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.BasePropertyDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BasePropertyDeclarationSyntax.WithAccessorList(Microsoft.CodeAnalysis.CSharp.Syntax.AccessorListSyntax accessorList) -> Microsoft.CodeAnalysis.CSharp.Syntax.BasePropertyDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BasePropertyDeclarationSyntax.WithAttributeLists(Microsoft.CodeAnalysis.SyntaxList attributeLists) -> Microsoft.CodeAnalysis.CSharp.Syntax.BasePropertyDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BasePropertyDeclarationSyntax.WithExplicitInterfaceSpecifier(Microsoft.CodeAnalysis.CSharp.Syntax.ExplicitInterfaceSpecifierSyntax explicitInterfaceSpecifier) -> Microsoft.CodeAnalysis.CSharp.Syntax.BasePropertyDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BasePropertyDeclarationSyntax.WithModifiers(Microsoft.CodeAnalysis.SyntaxTokenList modifiers) -> Microsoft.CodeAnalysis.CSharp.Syntax.BasePropertyDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BasePropertyDeclarationSyntax.WithType(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.BasePropertyDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax.AddAttributeLists(params Microsoft.CodeAnalysis.CSharp.Syntax.AttributeListSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax.AddBaseListTypes(params Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax.AddModifiers(params Microsoft.CodeAnalysis.SyntaxToken[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax.WithAttributeLists(Microsoft.CodeAnalysis.SyntaxList attributeLists) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax.WithBaseList(Microsoft.CodeAnalysis.CSharp.Syntax.BaseListSyntax baseList) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax.WithCloseBraceToken(Microsoft.CodeAnalysis.SyntaxToken closeBraceToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax.WithIdentifier(Microsoft.CodeAnalysis.SyntaxToken identifier) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax.WithModifiers(Microsoft.CodeAnalysis.SyntaxTokenList modifiers) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax.WithOpenBraceToken(Microsoft.CodeAnalysis.SyntaxToken openBraceToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax.WithSemicolonToken(Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeSyntax.WithType(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BranchingDirectiveTriviaSyntax.WithEndOfDirectiveToken(Microsoft.CodeAnalysis.SyntaxToken endOfDirectiveToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.BranchingDirectiveTriviaSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.BranchingDirectiveTriviaSyntax.WithHashToken(Microsoft.CodeAnalysis.SyntaxToken hashToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.BranchingDirectiveTriviaSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ClassOrStructConstraintSyntax.QuestionToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.ClassOrStructConstraintSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken classOrStructKeyword, Microsoft.CodeAnalysis.SyntaxToken questionToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.ClassOrStructConstraintSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ClassOrStructConstraintSyntax.WithQuestionToken(Microsoft.CodeAnalysis.SyntaxToken questionToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.ClassOrStructConstraintSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax.WithAwaitKeyword(Microsoft.CodeAnalysis.SyntaxToken awaitKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax.WithCloseParenToken(Microsoft.CodeAnalysis.SyntaxToken closeParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax.WithExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax.WithForEachKeyword(Microsoft.CodeAnalysis.SyntaxToken forEachKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax.WithInKeyword(Microsoft.CodeAnalysis.SyntaxToken inKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax.WithOpenParenToken(Microsoft.CodeAnalysis.SyntaxToken openParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax.WithStatement(Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax statement) -> Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.ConditionalDirectiveTriviaSyntax.WithCondition(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax condition) -> Microsoft.CodeAnalysis.CSharp.Syntax.ConditionalDirectiveTriviaSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.DirectiveTriviaSyntax.WithEndOfDirectiveToken(Microsoft.CodeAnalysis.SyntaxToken endOfDirectiveToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.DirectiveTriviaSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.DirectiveTriviaSyntax.WithHashToken(Microsoft.CodeAnalysis.SyntaxToken hashToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.DirectiveTriviaSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.DiscardPatternSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.DiscardPatternSyntax.UnderscoreToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.DiscardPatternSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken underscoreToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.DiscardPatternSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.DiscardPatternSyntax.WithUnderscoreToken(Microsoft.CodeAnalysis.SyntaxToken underscoreToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.DiscardPatternSyntax` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.ForEachStatementSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken awaitKeyword, Microsoft.CodeAnalysis.SyntaxToken forEachKeyword, Microsoft.CodeAnalysis.SyntaxToken openParenToken, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.SyntaxToken inKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression, Microsoft.CodeAnalysis.SyntaxToken closeParenToken, Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax statement) -> Microsoft.CodeAnalysis.CSharp.Syntax.ForEachStatementSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ForEachStatementSyntax.WithAwaitKeyword(Microsoft.CodeAnalysis.SyntaxToken awaitKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.ForEachStatementSyntax` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken awaitKeyword, Microsoft.CodeAnalysis.SyntaxToken forEachKeyword, Microsoft.CodeAnalysis.SyntaxToken openParenToken, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax variable, Microsoft.CodeAnalysis.SyntaxToken inKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression, Microsoft.CodeAnalysis.SyntaxToken closeParenToken, Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax statement) -> Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax.WithAwaitKeyword(Microsoft.CodeAnalysis.SyntaxToken awaitKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.LambdaExpressionSyntax.WithArrowToken(Microsoft.CodeAnalysis.SyntaxToken arrowToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.LambdaExpressionSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.LambdaExpressionSyntax.WithAsyncKeyword(Microsoft.CodeAnalysis.SyntaxToken asyncKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.LambdaExpressionSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.LambdaExpressionSyntax.WithBody(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode body) -> Microsoft.CodeAnalysis.CSharp.Syntax.LambdaExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalDeclarationStatementSyntax.AwaitKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.LocalDeclarationStatementSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken awaitKeyword, Microsoft.CodeAnalysis.SyntaxToken usingKeyword, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.CSharp.Syntax.VariableDeclarationSyntax declaration, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalDeclarationStatementSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalDeclarationStatementSyntax.UsingKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalDeclarationStatementSyntax.WithAwaitKeyword(Microsoft.CodeAnalysis.SyntaxToken awaitKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalDeclarationStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.LocalDeclarationStatementSyntax.WithUsingKeyword(Microsoft.CodeAnalysis.SyntaxToken usingKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalDeclarationStatementSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax.NullableKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax.SettingToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax.WithEndOfDirectiveToken(Microsoft.CodeAnalysis.SyntaxToken endOfDirectiveToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax.WithHashToken(Microsoft.CodeAnalysis.SyntaxToken hashToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax.WithIsActive(bool isActive) -> Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax.WithNullableKeyword(Microsoft.CodeAnalysis.SyntaxToken nullableKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax.WithSettingToken(Microsoft.CodeAnalysis.SyntaxToken settingToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax.AddSubpatterns(params Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax.CloseParenToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax.OpenParenToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax.Subpatterns.get -> Microsoft.CodeAnalysis.SeparatedSyntaxList` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken openParenToken, Microsoft.CodeAnalysis.SeparatedSyntaxList subpatterns, Microsoft.CodeAnalysis.SyntaxToken closeParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax.WithCloseParenToken(Microsoft.CodeAnalysis.SyntaxToken closeParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax.WithOpenParenToken(Microsoft.CodeAnalysis.SyntaxToken openParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax.WithSubpatterns(Microsoft.CodeAnalysis.SeparatedSyntaxList subpatterns) -> Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax.AddSubpatterns(params Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax.CloseBraceToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax.OpenBraceToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax.Subpatterns.get -> Microsoft.CodeAnalysis.SeparatedSyntaxList` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken openBraceToken, Microsoft.CodeAnalysis.SeparatedSyntaxList subpatterns, Microsoft.CodeAnalysis.SyntaxToken closeBraceToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax.WithCloseBraceToken(Microsoft.CodeAnalysis.SyntaxToken closeBraceToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax.WithOpenBraceToken(Microsoft.CodeAnalysis.SyntaxToken openBraceToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax.WithSubpatterns(Microsoft.CodeAnalysis.SeparatedSyntaxList subpatterns) -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RangeExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RangeExpressionSyntax.LeftOperand.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RangeExpressionSyntax.OperatorToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RangeExpressionSyntax.RightOperand.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.RangeExpressionSyntax.Update(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax leftOperand, Microsoft.CodeAnalysis.SyntaxToken operatorToken, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax rightOperand) -> Microsoft.CodeAnalysis.CSharp.Syntax.RangeExpressionSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RangeExpressionSyntax.WithLeftOperand(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax leftOperand) -> Microsoft.CodeAnalysis.CSharp.Syntax.RangeExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RangeExpressionSyntax.WithOperatorToken(Microsoft.CodeAnalysis.SyntaxToken operatorToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.RangeExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RangeExpressionSyntax.WithRightOperand(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax rightOperand) -> Microsoft.CodeAnalysis.CSharp.Syntax.RangeExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax.AddPositionalPatternClauseSubpatterns(params Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax.AddPropertyPatternClauseSubpatterns(params Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax.Designation.get -> Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax.PositionalPatternClause.get -> Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax.PropertyPatternClause.get -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax.Type.get -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax.Update(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax positionalPatternClause, Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax propertyPatternClause, Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax designation) -> Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax.WithDesignation(Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax designation) -> Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax.WithPositionalPatternClause(Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax positionalPatternClause) -> Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax.WithPropertyPatternClause(Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax propertyPatternClause) -> Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax.WithType(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type) -> Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.SimpleNameSyntax.WithIdentifier(Microsoft.CodeAnalysis.SyntaxToken identifier) -> Microsoft.CodeAnalysis.CSharp.Syntax.SimpleNameSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternSyntax.NameColon.get -> Microsoft.CodeAnalysis.CSharp.Syntax.NameColonSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternSyntax.Pattern.get -> Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternSyntax.Update(Microsoft.CodeAnalysis.CSharp.Syntax.NameColonSyntax nameColon, Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax pattern) -> Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternSyntax.WithNameColon(Microsoft.CodeAnalysis.CSharp.Syntax.NameColonSyntax nameColon) -> Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternSyntax.WithPattern(Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax pattern) -> Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax.EqualsGreaterThanToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax.Expression.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax.Pattern.get -> Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax.Update(Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax pattern, Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax whenClause, Microsoft.CodeAnalysis.SyntaxToken equalsGreaterThanToken, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax.WhenClause.get -> Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax.WithEqualsGreaterThanToken(Microsoft.CodeAnalysis.SyntaxToken equalsGreaterThanToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax.WithExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax.WithPattern(Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax pattern) -> Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax.WithWhenClause(Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax whenClause) -> Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax.AddArms(params Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax.Arms.get -> Microsoft.CodeAnalysis.SeparatedSyntaxList` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax.CloseBraceToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax.GoverningExpression.get -> Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax.OpenBraceToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax.SwitchKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax.Update(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax governingExpression, Microsoft.CodeAnalysis.SyntaxToken switchKeyword, Microsoft.CodeAnalysis.SyntaxToken openBraceToken, Microsoft.CodeAnalysis.SeparatedSyntaxList arms, Microsoft.CodeAnalysis.SyntaxToken closeBraceToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax.WithArms(Microsoft.CodeAnalysis.SeparatedSyntaxList arms) -> Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax.WithCloseBraceToken(Microsoft.CodeAnalysis.SyntaxToken closeBraceToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax.WithGoverningExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax governingExpression) -> Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax.WithOpenBraceToken(Microsoft.CodeAnalysis.SyntaxToken openBraceToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax.WithSwitchKeyword(Microsoft.CodeAnalysis.SyntaxToken switchKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchLabelSyntax.WithColonToken(Microsoft.CodeAnalysis.SyntaxToken colonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.SwitchLabelSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.SwitchLabelSyntax.WithKeyword(Microsoft.CodeAnalysis.SyntaxToken keyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.SwitchLabelSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax.AddAttributeLists(params Microsoft.CodeAnalysis.CSharp.Syntax.AttributeListSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax.AddBaseListTypes(params Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.BaseTypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax.AddConstraintClauses(params Microsoft.CodeAnalysis.CSharp.Syntax.TypeParameterConstraintClauseSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax.AddMembers(params Microsoft.CodeAnalysis.CSharp.Syntax.MemberDeclarationSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax.AddModifiers(params Microsoft.CodeAnalysis.SyntaxToken[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax.AddTypeParameterListParameters(params Microsoft.CodeAnalysis.CSharp.Syntax.TypeParameterSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax.WithAttributeLists(Microsoft.CodeAnalysis.SyntaxList attributeLists) -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax.WithBaseList(Microsoft.CodeAnalysis.CSharp.Syntax.BaseListSyntax baseList) -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax.WithCloseBraceToken(Microsoft.CodeAnalysis.SyntaxToken closeBraceToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax.WithConstraintClauses(Microsoft.CodeAnalysis.SyntaxList constraintClauses) -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax.WithIdentifier(Microsoft.CodeAnalysis.SyntaxToken identifier) -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax.WithKeyword(Microsoft.CodeAnalysis.SyntaxToken keyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax.WithMembers(Microsoft.CodeAnalysis.SyntaxList members) -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax.WithModifiers(Microsoft.CodeAnalysis.SyntaxTokenList modifiers) -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax.WithOpenBraceToken(Microsoft.CodeAnalysis.SyntaxToken openBraceToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax.WithSemicolonToken(Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax.WithTypeParameterList(Microsoft.CodeAnalysis.CSharp.Syntax.TypeParameterListSyntax typeParameterList) -> Microsoft.CodeAnalysis.CSharp.Syntax.TypeDeclarationSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.UsingStatementSyntax.AwaitKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.UsingStatementSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken awaitKeyword, Microsoft.CodeAnalysis.SyntaxToken usingKeyword, Microsoft.CodeAnalysis.SyntaxToken openParenToken, Microsoft.CodeAnalysis.CSharp.Syntax.VariableDeclarationSyntax declaration, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression, Microsoft.CodeAnalysis.SyntaxToken closeParenToken, Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax statement) -> Microsoft.CodeAnalysis.CSharp.Syntax.UsingStatementSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.UsingStatementSyntax.WithAwaitKeyword(Microsoft.CodeAnalysis.SyntaxToken awaitKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.UsingStatementSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.VarPatternSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.VarPatternSyntax.Designation.get -> Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax` +* [x] ~~`Microsoft.CodeAnalysis.CSharp.Syntax.VarPatternSyntax.Update(Microsoft.CodeAnalysis.SyntaxToken varKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax designation) -> Microsoft.CodeAnalysis.CSharp.Syntax.VarPatternSyntax`~~ +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.VarPatternSyntax.VarKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.VarPatternSyntax.WithDesignation(Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax designation) -> Microsoft.CodeAnalysis.CSharp.Syntax.VarPatternSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.Syntax.VarPatternSyntax.WithVarKeyword(Microsoft.CodeAnalysis.SyntaxToken varKeyword) -> Microsoft.CodeAnalysis.CSharp.Syntax.VarPatternSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.XmlAttributeSyntax.WithEndQuoteToken(Microsoft.CodeAnalysis.SyntaxToken endQuoteToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.XmlAttributeSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.XmlAttributeSyntax.WithEqualsToken(Microsoft.CodeAnalysis.SyntaxToken equalsToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.XmlAttributeSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.XmlAttributeSyntax.WithName(Microsoft.CodeAnalysis.CSharp.Syntax.XmlNameSyntax name) -> Microsoft.CodeAnalysis.CSharp.Syntax.XmlAttributeSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.XmlAttributeSyntax.WithStartQuoteToken(Microsoft.CodeAnalysis.SyntaxToken startQuoteToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.XmlAttributeSyntax` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.CoalesceAssignmentExpression = 8725 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.DiscardPattern = 9024 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.DotDotToken = 8222 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.EnableKeyword = 8487 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.IndexExpression = 8741 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.NullableDirectiveTrivia = 9055 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.NullableKeyword = 8486 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.PositionalPatternClause = 9023 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.PropertyPatternClause = 9021 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.QuestionQuestionEqualsToken = 8284 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.RangeExpression = 8658 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.RecursivePattern = 9020 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.Subpattern = 9022 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.SuppressNullableWarningExpression = 9054 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.SwitchExpression = 9025 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.SwitchExpressionArm = 9026 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.VarKeyword = 8490 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [x] `Microsoft.CodeAnalysis.CSharp.SyntaxKind.VarPattern = 9027 -> Microsoft.CodeAnalysis.CSharp.SyntaxKind` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpCompilation.ClassifyCommonConversion(Microsoft.CodeAnalysis.ITypeSymbol source, Microsoft.CodeAnalysis.ITypeSymbol destination) -> Microsoft.CodeAnalysis.Operations.CommonConversion` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpCompilation.ContainsSymbolsWithName(string name, Microsoft.CodeAnalysis.SymbolFilter filter = Microsoft.CodeAnalysis.SymbolFilter.TypeAndMember, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> bool` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpCompilation.GetSymbolsWithName(string name, Microsoft.CodeAnalysis.SymbolFilter filter = Microsoft.CodeAnalysis.SymbolFilter.TypeAndMember, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Collections.Generic.IEnumerable` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.NullableContextOptions.get -> Microsoft.CodeAnalysis.NullableContextOptions` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitDiscardPattern(Microsoft.CodeAnalysis.CSharp.Syntax.DiscardPatternSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitNullableDirectiveTrivia(Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitPositionalPatternClause(Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitPropertyPatternClause(Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitRangeExpression(Microsoft.CodeAnalysis.CSharp.Syntax.RangeExpressionSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitRecursivePattern(Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitSubpattern(Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitSwitchExpression(Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitSwitchExpressionArm(Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.CSharpSyntaxRewriter.VisitVarPattern(Microsoft.CodeAnalysis.CSharp.Syntax.VarPatternSyntax node) -> Microsoft.CodeAnalysis.SyntaxNode` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.DiscardPatternSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.DiscardPatternSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [x] `override Microsoft.CodeAnalysis.CSharp.Syntax.ForEachStatementSyntax.AwaitKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [x] `override Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax.AwaitKeyword.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax.EndOfDirectiveToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax.HashToken.get -> Microsoft.CodeAnalysis.SyntaxToken` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax.IsActive.get -> bool` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.RangeExpressionSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.RangeExpressionSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.VarPatternSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> void` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.VarPatternSyntax.Accept(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor visitor) -> TResult` +* [ ] `static Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.Create(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode root, Microsoft.CodeAnalysis.CSharp.CSharpParseOptions options = null, string path = "", System.Text.Encoding encoding = null, System.Collections.Immutable.ImmutableDictionary diagnosticOptions = null) -> Microsoft.CodeAnalysis.SyntaxTree` +* [ ] `static Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.Create(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode root, Microsoft.CodeAnalysis.CSharp.CSharpParseOptions options, string path, System.Text.Encoding encoding) -> Microsoft.CodeAnalysis.SyntaxTree` +* [ ] `static Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.ParseText(Microsoft.CodeAnalysis.Text.SourceText text, Microsoft.CodeAnalysis.CSharp.CSharpParseOptions options = null, string path = "", System.Collections.Immutable.ImmutableDictionary diagnosticOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.SyntaxTree` +* [ ] `static Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.ParseText(Microsoft.CodeAnalysis.Text.SourceText text, Microsoft.CodeAnalysis.CSharp.CSharpParseOptions options, string path, System.Threading.CancellationToken cancellationToken) -> Microsoft.CodeAnalysis.SyntaxTree` +* [ ] `static Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.ParseText(string text, Microsoft.CodeAnalysis.CSharp.CSharpParseOptions options, string path, System.Text.Encoding encoding, System.Threading.CancellationToken cancellationToken) -> Microsoft.CodeAnalysis.SyntaxTree` +* [ ] `static Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.ParseText(string text, Microsoft.CodeAnalysis.CSharp.CSharpParseOptions options = null, string path = "", System.Text.Encoding encoding = null, System.Collections.Immutable.ImmutableDictionary diagnosticOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.SyntaxTree` +* [ ] `static Microsoft.CodeAnalysis.CSharp.LanguageVersionFacts.TryParse(string version, out Microsoft.CodeAnalysis.CSharp.LanguageVersion result) -> bool` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SymbolDisplay.ToDisplayParts(Microsoft.CodeAnalysis.ITypeSymbol symbol, Microsoft.CodeAnalysis.NullableAnnotation nullableAnnotation, Microsoft.CodeAnalysis.SymbolDisplayFormat format = null) -> System.Collections.Immutable.ImmutableArray` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SymbolDisplay.ToDisplayParts(Microsoft.CodeAnalysis.ITypeSymbol symbol, Microsoft.CodeAnalysis.NullableFlowState nullableFlowState, Microsoft.CodeAnalysis.SymbolDisplayFormat format = null) -> System.Collections.Immutable.ImmutableArray` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SymbolDisplay.ToDisplayString(Microsoft.CodeAnalysis.ITypeSymbol symbol, Microsoft.CodeAnalysis.NullableAnnotation nullableAnnotation, Microsoft.CodeAnalysis.SymbolDisplayFormat format = null) -> string` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SymbolDisplay.ToDisplayString(Microsoft.CodeAnalysis.ITypeSymbol symbol, Microsoft.CodeAnalysis.NullableFlowState nullableFlowState, Microsoft.CodeAnalysis.SymbolDisplayFormat format = null) -> string` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SymbolDisplay.ToMinimalDisplayParts(Microsoft.CodeAnalysis.ITypeSymbol symbol, Microsoft.CodeAnalysis.NullableAnnotation nullableAnnotation, Microsoft.CodeAnalysis.SemanticModel semanticModel, int position, Microsoft.CodeAnalysis.SymbolDisplayFormat format = null) -> System.Collections.Immutable.ImmutableArray` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SymbolDisplay.ToMinimalDisplayParts(Microsoft.CodeAnalysis.ITypeSymbol symbol, Microsoft.CodeAnalysis.NullableFlowState nullableFlowState, Microsoft.CodeAnalysis.SemanticModel semanticModel, int position, Microsoft.CodeAnalysis.SymbolDisplayFormat format = null) -> System.Collections.Immutable.ImmutableArray` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SymbolDisplay.ToMinimalDisplayString(Microsoft.CodeAnalysis.ITypeSymbol symbol, Microsoft.CodeAnalysis.NullableAnnotation nullableAnnotation, Microsoft.CodeAnalysis.SemanticModel semanticModel, int position, Microsoft.CodeAnalysis.SymbolDisplayFormat format = null) -> string` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SymbolDisplay.ToMinimalDisplayString(Microsoft.CodeAnalysis.ITypeSymbol symbol, Microsoft.CodeAnalysis.NullableFlowState nullableFlowState, Microsoft.CodeAnalysis.SemanticModel semanticModel, int position, Microsoft.CodeAnalysis.SymbolDisplayFormat format = null) -> string` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ClassOrStructConstraint(Microsoft.CodeAnalysis.CSharp.SyntaxKind kind, Microsoft.CodeAnalysis.SyntaxToken classOrStructKeyword, Microsoft.CodeAnalysis.SyntaxToken questionToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.ClassOrStructConstraintSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.DiscardPattern() -> Microsoft.CodeAnalysis.CSharp.Syntax.DiscardPatternSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.DiscardPattern(Microsoft.CodeAnalysis.SyntaxToken underscoreToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.DiscardPatternSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.EventDeclaration(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken eventKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.CSharp.Syntax.ExplicitInterfaceSpecifierSyntax explicitInterfaceSpecifier, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.CSharp.Syntax.AccessorListSyntax accessorList, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.EventDeclarationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.EventDeclaration(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken eventKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.CSharp.Syntax.ExplicitInterfaceSpecifierSyntax explicitInterfaceSpecifier, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.EventDeclarationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ForEachStatement(Microsoft.CodeAnalysis.SyntaxToken awaitKeyword, Microsoft.CodeAnalysis.SyntaxToken forEachKeyword, Microsoft.CodeAnalysis.SyntaxToken openParenToken, Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.SyntaxToken inKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression, Microsoft.CodeAnalysis.SyntaxToken closeParenToken, Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax statement) -> Microsoft.CodeAnalysis.CSharp.Syntax.ForEachStatementSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ForEachVariableStatement(Microsoft.CodeAnalysis.SyntaxToken awaitKeyword, Microsoft.CodeAnalysis.SyntaxToken forEachKeyword, Microsoft.CodeAnalysis.SyntaxToken openParenToken, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax variable, Microsoft.CodeAnalysis.SyntaxToken inKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression, Microsoft.CodeAnalysis.SyntaxToken closeParenToken, Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax statement) -> Microsoft.CodeAnalysis.CSharp.Syntax.ForEachVariableStatementSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.LocalDeclarationStatement(Microsoft.CodeAnalysis.SyntaxToken awaitKeyword, Microsoft.CodeAnalysis.SyntaxToken usingKeyword, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.CSharp.Syntax.VariableDeclarationSyntax declaration, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.LocalDeclarationStatementSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.NullableDirectiveTrivia(Microsoft.CodeAnalysis.SyntaxToken hashToken, Microsoft.CodeAnalysis.SyntaxToken nullableKeyword, Microsoft.CodeAnalysis.SyntaxToken settingToken, Microsoft.CodeAnalysis.SyntaxToken targetToken, Microsoft.CodeAnalysis.SyntaxToken endOfDirectiveToken, bool isActive) -> Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.NullableDirectiveTrivia(Microsoft.CodeAnalysis.SyntaxToken settingToken, Microsoft.CodeAnalysis.SyntaxToken targetToken, bool isActive) -> Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.NullableDirectiveTrivia(Microsoft.CodeAnalysis.SyntaxToken settingToken, bool isActive) -> Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ParseMemberDeclaration(string text, int offset = 0, Microsoft.CodeAnalysis.ParseOptions options = null, bool consumeFullText = true) -> Microsoft.CodeAnalysis.CSharp.Syntax.MemberDeclarationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ParseSyntaxTree(Microsoft.CodeAnalysis.Text.SourceText text, Microsoft.CodeAnalysis.ParseOptions options = null, string path = "", System.Collections.Immutable.ImmutableDictionary diagnosticOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.SyntaxTree` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ParseSyntaxTree(Microsoft.CodeAnalysis.Text.SourceText text, Microsoft.CodeAnalysis.ParseOptions options, string path, System.Threading.CancellationToken cancellationToken) -> Microsoft.CodeAnalysis.SyntaxTree` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ParseSyntaxTree(string text, Microsoft.CodeAnalysis.ParseOptions options = null, string path = "", System.Text.Encoding encoding = null, System.Collections.Immutable.ImmutableDictionary diagnosticOptions = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.SyntaxTree` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ParseSyntaxTree(string text, Microsoft.CodeAnalysis.ParseOptions options, string path, System.Text.Encoding encoding, System.Threading.CancellationToken cancellationToken) -> Microsoft.CodeAnalysis.SyntaxTree` +* [x] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.PositionalPatternClause(Microsoft.CodeAnalysis.SeparatedSyntaxList subpatterns = default(Microsoft.CodeAnalysis.SeparatedSyntaxList)) -> Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax` +* [x] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.PositionalPatternClause(Microsoft.CodeAnalysis.SyntaxToken openParenToken, Microsoft.CodeAnalysis.SeparatedSyntaxList subpatterns, Microsoft.CodeAnalysis.SyntaxToken closeParenToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax` +* [x] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.PropertyPatternClause(Microsoft.CodeAnalysis.SeparatedSyntaxList subpatterns = default(Microsoft.CodeAnalysis.SeparatedSyntaxList)) -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax` +* [x] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.PropertyPatternClause(Microsoft.CodeAnalysis.SyntaxToken openBraceToken, Microsoft.CodeAnalysis.SeparatedSyntaxList subpatterns, Microsoft.CodeAnalysis.SyntaxToken closeBraceToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RangeExpression() -> Microsoft.CodeAnalysis.CSharp.Syntax.RangeExpressionSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RangeExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax leftOperand, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax rightOperand) -> Microsoft.CodeAnalysis.CSharp.Syntax.RangeExpressionSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RangeExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax leftOperand, Microsoft.CodeAnalysis.SyntaxToken operatorToken, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax rightOperand) -> Microsoft.CodeAnalysis.CSharp.Syntax.RangeExpressionSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RecursivePattern() -> Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.RecursivePattern(Microsoft.CodeAnalysis.CSharp.Syntax.TypeSyntax type, Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax positionalPatternClause, Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax propertyPatternClause, Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax designation) -> Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.Subpattern(Microsoft.CodeAnalysis.CSharp.Syntax.NameColonSyntax nameColon, Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax pattern) -> Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.Subpattern(Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax pattern) -> Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.SwitchExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax governingExpression) -> Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.SwitchExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax governingExpression, Microsoft.CodeAnalysis.SeparatedSyntaxList arms) -> Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.SwitchExpression(Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax governingExpression, Microsoft.CodeAnalysis.SyntaxToken switchKeyword, Microsoft.CodeAnalysis.SyntaxToken openBraceToken, Microsoft.CodeAnalysis.SeparatedSyntaxList arms, Microsoft.CodeAnalysis.SyntaxToken closeBraceToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.SwitchExpressionArm(Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax pattern, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.SwitchExpressionArm(Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax pattern, Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax whenClause, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.SwitchExpressionArm(Microsoft.CodeAnalysis.CSharp.Syntax.PatternSyntax pattern, Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax whenClause, Microsoft.CodeAnalysis.SyntaxToken equalsGreaterThanToken, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression) -> Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.UsingStatement(Microsoft.CodeAnalysis.SyntaxToken awaitKeyword, Microsoft.CodeAnalysis.SyntaxToken usingKeyword, Microsoft.CodeAnalysis.SyntaxToken openParenToken, Microsoft.CodeAnalysis.CSharp.Syntax.VariableDeclarationSyntax declaration, Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionSyntax expression, Microsoft.CodeAnalysis.SyntaxToken closeParenToken, Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax statement) -> Microsoft.CodeAnalysis.CSharp.Syntax.UsingStatementSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.VarPattern(Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax designation) -> Microsoft.CodeAnalysis.CSharp.Syntax.VarPatternSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.VarPattern(Microsoft.CodeAnalysis.SyntaxToken varKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.VariableDesignationSyntax designation) -> Microsoft.CodeAnalysis.CSharp.Syntax.VarPatternSyntax` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitDiscardPattern(Microsoft.CodeAnalysis.CSharp.Syntax.DiscardPatternSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitNullableDirectiveTrivia(Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitPositionalPatternClause(Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitPropertyPatternClause(Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitRangeExpression(Microsoft.CodeAnalysis.CSharp.Syntax.RangeExpressionSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitRecursivePattern(Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitSubpattern(Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitSwitchExpression(Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitSwitchExpressionArm(Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitVarPattern(Microsoft.CodeAnalysis.CSharp.Syntax.VarPatternSyntax node) -> void` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitDiscardPattern(Microsoft.CodeAnalysis.CSharp.Syntax.DiscardPatternSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitNullableDirectiveTrivia(Microsoft.CodeAnalysis.CSharp.Syntax.NullableDirectiveTriviaSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitPositionalPatternClause(Microsoft.CodeAnalysis.CSharp.Syntax.PositionalPatternClauseSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitPropertyPatternClause(Microsoft.CodeAnalysis.CSharp.Syntax.PropertyPatternClauseSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitRangeExpression(Microsoft.CodeAnalysis.CSharp.Syntax.RangeExpressionSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitRecursivePattern(Microsoft.CodeAnalysis.CSharp.Syntax.RecursivePatternSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitSubpattern(Microsoft.CodeAnalysis.CSharp.Syntax.SubpatternSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitSwitchExpression(Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitSwitchExpressionArm(Microsoft.CodeAnalysis.CSharp.Syntax.SwitchExpressionArmSyntax node) -> TResult` +* [ ] `virtual Microsoft.CodeAnalysis.CSharp.CSharpSyntaxVisitor.VisitVarPattern(Microsoft.CodeAnalysis.CSharp.Syntax.VarPatternSyntax node) -> TResult` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.EnumMemberDeclarationSyntax.AddModifiers(params Microsoft.CodeAnalysis.SyntaxToken[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.EnumMemberDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.EnumMemberDeclarationSyntax.Update(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.CSharp.Syntax.EqualsValueClauseSyntax equalsValue) -> Microsoft.CodeAnalysis.CSharp.Syntax.EnumMemberDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.EnumMemberDeclarationSyntax.WithModifiers(Microsoft.CodeAnalysis.SyntaxTokenList modifiers) -> Microsoft.CodeAnalysis.CSharp.Syntax.EnumMemberDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.GlobalStatementSyntax.AddAttributeLists(params Microsoft.CodeAnalysis.CSharp.Syntax.AttributeListSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.GlobalStatementSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.GlobalStatementSyntax.AddModifiers(params Microsoft.CodeAnalysis.SyntaxToken[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.GlobalStatementSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.GlobalStatementSyntax.Update(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax statement) -> Microsoft.CodeAnalysis.CSharp.Syntax.GlobalStatementSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.GlobalStatementSyntax.WithAttributeLists(Microsoft.CodeAnalysis.SyntaxList attributeLists) -> Microsoft.CodeAnalysis.CSharp.Syntax.GlobalStatementSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.GlobalStatementSyntax.WithModifiers(Microsoft.CodeAnalysis.SyntaxTokenList modifiers) -> Microsoft.CodeAnalysis.CSharp.Syntax.GlobalStatementSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.MemberDeclarationSyntax.AddAttributeLists(params Microsoft.CodeAnalysis.CSharp.Syntax.AttributeListSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.MemberDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.MemberDeclarationSyntax.AddModifiers(params Microsoft.CodeAnalysis.SyntaxToken[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.MemberDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.MemberDeclarationSyntax.WithAttributeLists(Microsoft.CodeAnalysis.SyntaxList attributeLists) -> Microsoft.CodeAnalysis.CSharp.Syntax.MemberDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.MemberDeclarationSyntax.WithModifiers(Microsoft.CodeAnalysis.SyntaxTokenList modifiers) -> Microsoft.CodeAnalysis.CSharp.Syntax.MemberDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.NamespaceDeclarationSyntax.AddAttributeLists(params Microsoft.CodeAnalysis.CSharp.Syntax.AttributeListSyntax[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.NamespaceDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.NamespaceDeclarationSyntax.AddModifiers(params Microsoft.CodeAnalysis.SyntaxToken[] items) -> Microsoft.CodeAnalysis.CSharp.Syntax.NamespaceDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.NamespaceDeclarationSyntax.Update(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken namespaceKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.NameSyntax name, Microsoft.CodeAnalysis.SyntaxToken openBraceToken, Microsoft.CodeAnalysis.SyntaxList externs, Microsoft.CodeAnalysis.SyntaxList usings, Microsoft.CodeAnalysis.SyntaxList members, Microsoft.CodeAnalysis.SyntaxToken closeBraceToken, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.NamespaceDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.NamespaceDeclarationSyntax.WithAttributeLists(Microsoft.CodeAnalysis.SyntaxList attributeLists) -> Microsoft.CodeAnalysis.CSharp.Syntax.NamespaceDeclarationSyntax` +* [ ] `Microsoft.CodeAnalysis.CSharp.Syntax.NamespaceDeclarationSyntax.WithModifiers(Microsoft.CodeAnalysis.SyntaxTokenList modifiers) -> Microsoft.CodeAnalysis.CSharp.Syntax.NamespaceDeclarationSyntax` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.DelegateDeclarationSyntax.AttributeLists.get -> Microsoft.CodeAnalysis.SyntaxList` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.DelegateDeclarationSyntax.Modifiers.get -> Microsoft.CodeAnalysis.SyntaxTokenList` +* [ ] `abstract Microsoft.CodeAnalysis.CSharp.Syntax.MemberDeclarationSyntax.AttributeLists.get -> Microsoft.CodeAnalysis.SyntaxList` +* [ ] `abstract Microsoft.CodeAnalysis.CSharp.Syntax.MemberDeclarationSyntax.Modifiers.get -> Microsoft.CodeAnalysis.SyntaxTokenList` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.GlobalStatementSyntax.AttributeLists.get -> Microsoft.CodeAnalysis.SyntaxList` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.GlobalStatementSyntax.Modifiers.get -> Microsoft.CodeAnalysis.SyntaxTokenList` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.IncompleteMemberSyntax.AttributeLists.get -> Microsoft.CodeAnalysis.SyntaxList` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.IncompleteMemberSyntax.Modifiers.get -> Microsoft.CodeAnalysis.SyntaxTokenList` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.NamespaceDeclarationSyntax.AttributeLists.get -> Microsoft.CodeAnalysis.SyntaxList` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.NamespaceDeclarationSyntax.Modifiers.get -> Microsoft.CodeAnalysis.SyntaxTokenList` +* [ ] `override abstract Microsoft.CodeAnalysis.CSharp.Syntax.BaseFieldDeclarationSyntax.AttributeLists.get -> Microsoft.CodeAnalysis.SyntaxList` +* [ ] `override abstract Microsoft.CodeAnalysis.CSharp.Syntax.BaseFieldDeclarationSyntax.Modifiers.get -> Microsoft.CodeAnalysis.SyntaxTokenList` +* [ ] `override abstract Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax.AttributeLists.get -> Microsoft.CodeAnalysis.SyntaxList` +* [ ] `override abstract Microsoft.CodeAnalysis.CSharp.Syntax.BaseMethodDeclarationSyntax.Modifiers.get -> Microsoft.CodeAnalysis.SyntaxTokenList` +* [ ] `override abstract Microsoft.CodeAnalysis.CSharp.Syntax.BasePropertyDeclarationSyntax.AttributeLists.get -> Microsoft.CodeAnalysis.SyntaxList` +* [ ] `override abstract Microsoft.CodeAnalysis.CSharp.Syntax.BasePropertyDeclarationSyntax.Modifiers.get -> Microsoft.CodeAnalysis.SyntaxTokenList` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.EnumMemberDeclaration(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken identifier, Microsoft.CodeAnalysis.CSharp.Syntax.EqualsValueClauseSyntax equalsValue) -> Microsoft.CodeAnalysis.CSharp.Syntax.EnumMemberDeclarationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.GlobalStatement(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.CSharp.Syntax.StatementSyntax statement) -> Microsoft.CodeAnalysis.CSharp.Syntax.GlobalStatementSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.NamespaceDeclaration(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.CSharp.Syntax.NameSyntax name, Microsoft.CodeAnalysis.SyntaxList externs, Microsoft.CodeAnalysis.SyntaxList usings, Microsoft.CodeAnalysis.SyntaxList members) -> Microsoft.CodeAnalysis.CSharp.Syntax.NamespaceDeclarationSyntax` +* [ ] `static Microsoft.CodeAnalysis.CSharp.SyntaxFactory.NamespaceDeclaration(Microsoft.CodeAnalysis.SyntaxList attributeLists, Microsoft.CodeAnalysis.SyntaxTokenList modifiers, Microsoft.CodeAnalysis.SyntaxToken namespaceKeyword, Microsoft.CodeAnalysis.CSharp.Syntax.NameSyntax name, Microsoft.CodeAnalysis.SyntaxToken openBraceToken, Microsoft.CodeAnalysis.SyntaxList externs, Microsoft.CodeAnalysis.SyntaxList usings, Microsoft.CodeAnalysis.SyntaxList members, Microsoft.CodeAnalysis.SyntaxToken closeBraceToken, Microsoft.CodeAnalysis.SyntaxToken semicolonToken) -> Microsoft.CodeAnalysis.CSharp.Syntax.NamespaceDeclarationSyntax` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.EnumMemberDeclarationSyntax.AttributeLists.get -> Microsoft.CodeAnalysis.SyntaxList` +* [ ] `override Microsoft.CodeAnalysis.CSharp.Syntax.EnumMemberDeclarationSyntax.Modifiers.get -> Microsoft.CodeAnalysis.SyntaxTokenList` diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ClassOrStructConstraintSyntaxExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ClassOrStructConstraintSyntaxExtensions.cs new file mode 100644 index 000000000..519eac253 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ClassOrStructConstraintSyntaxExtensions.cs @@ -0,0 +1,33 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal static class ClassOrStructConstraintSyntaxExtensions + { + private static readonly Func QuestionTokenAccessor; + private static readonly Func WithQuestionTokenAccessor; + + static ClassOrStructConstraintSyntaxExtensions() + { + QuestionTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(typeof(ClassOrStructConstraintSyntax), nameof(QuestionToken)); + WithQuestionTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(typeof(ClassOrStructConstraintSyntax), nameof(QuestionToken)); + } + + public static SyntaxToken QuestionToken(this ClassOrStructConstraintSyntax syntax) + { + return QuestionTokenAccessor(syntax); + } + + public static ClassOrStructConstraintSyntax WithQuestionToken(this ClassOrStructConstraintSyntax syntax, SyntaxToken questionToken) + { + return WithQuestionTokenAccessor(syntax, questionToken); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CommonForEachStatementSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CommonForEachStatementSyntaxWrapper.cs index 4bb3641d4..d2d5411fc 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CommonForEachStatementSyntaxWrapper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CommonForEachStatementSyntaxWrapper.cs @@ -1,126 +1,19 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Lightup { - using System; - using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; - internal struct CommonForEachStatementSyntaxWrapper : ISyntaxWrapper + internal partial struct CommonForEachStatementSyntaxWrapper : ISyntaxWrapper { - internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax"; internal const string FallbackWrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.ForEachStatementSyntax"; - private static readonly Type WrappedType; - - private static readonly Func ForEachKeywordAccessor; - private static readonly Func OpenParenTokenAccessor; - private static readonly Func InKeywordAccessor; - private static readonly Func ExpressionAccessor; - private static readonly Func CloseParenTokenAccessor; - private static readonly Func StatementAccessor; - - private readonly StatementSyntax node; - - static CommonForEachStatementSyntaxWrapper() - { - WrappedType = WrapperHelper.GetWrappedType(typeof(CommonForEachStatementSyntaxWrapper)); - ForEachKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(ForEachKeyword)); - OpenParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(OpenParenToken)); - InKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(InKeyword)); - ExpressionAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Expression)); - CloseParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(CloseParenToken)); - StatementAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Statement)); - } - - private CommonForEachStatementSyntaxWrapper(StatementSyntax node) - { - this.node = node; - } - - public StatementSyntax SyntaxNode => this.node; - - public SyntaxToken ForEachKeyword - { - get - { - return ForEachKeywordAccessor(this.SyntaxNode); - } - } - - public SyntaxToken OpenParenToken - { - get - { - return OpenParenTokenAccessor(this.SyntaxNode); - } - } - - public SyntaxToken InKeyword - { - get - { - return InKeywordAccessor(this.SyntaxNode); - } - } - - public ExpressionSyntax Expression - { - get - { - return ExpressionAccessor(this.SyntaxNode); - } - } - - public SyntaxToken CloseParenToken - { - get - { - return CloseParenTokenAccessor(this.SyntaxNode); - } - } - - public StatementSyntax Statement - { - get - { - return StatementAccessor(this.SyntaxNode); - } - } public static implicit operator CommonForEachStatementSyntaxWrapper(ForEachStatementSyntax node) { return new CommonForEachStatementSyntaxWrapper(node); } - - public static explicit operator CommonForEachStatementSyntaxWrapper(SyntaxNode node) - { - if (node == null) - { - return default(CommonForEachStatementSyntaxWrapper); - } - - if (!IsInstance(node)) - { - throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); - } - - return new CommonForEachStatementSyntaxWrapper((StatementSyntax)node); - } - - public static implicit operator StatementSyntax(CommonForEachStatementSyntaxWrapper wrapper) - { - return wrapper.node; - } - - public static bool IsInstance(SyntaxNode node) - { - return node != null && LightupHelpers.CanWrapNode(node, WrappedType); - } - - internal static CommonForEachStatementSyntaxWrapper FromUpcast(StatementSyntax node) - { - return new CommonForEachStatementSyntaxWrapper(node); - } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ConstructorDeclarationSyntaxExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ConstructorDeclarationSyntaxExtensions.cs index 0f6d8f579..cb7a254ec 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ConstructorDeclarationSyntaxExtensions.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ConstructorDeclarationSyntaxExtensions.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CrefParameterSyntaxExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CrefParameterSyntaxExtensions.cs new file mode 100644 index 000000000..5c2dd6c1a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/CrefParameterSyntaxExtensions.cs @@ -0,0 +1,33 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal static class CrefParameterSyntaxExtensions + { + private static readonly Func RefKindKeywordAccessor; + private static readonly Func WithRefKindKeywordAccessor; + + static CrefParameterSyntaxExtensions() + { + RefKindKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(typeof(CrefParameterSyntax), nameof(RefKindKeyword)); + WithRefKindKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(typeof(CrefParameterSyntax), nameof(RefKindKeyword)); + } + + public static SyntaxToken RefKindKeyword(this CrefParameterSyntax syntax) + { + return RefKindKeywordAccessor(syntax); + } + + public static CrefParameterSyntax WithRefKindKeyword(this CrefParameterSyntax syntax, SyntaxToken refKindKeyword) + { + return WithRefKindKeywordAccessor(syntax, refKindKeyword); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DestructorDeclarationSyntaxExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DestructorDeclarationSyntaxExtensions.cs index 91d67109f..79fb6fc1f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DestructorDeclarationSyntaxExtensions.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/DestructorDeclarationSyntaxExtensions.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ForEachStatementSyntaxExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ForEachStatementSyntaxExtensions.cs new file mode 100644 index 000000000..e49f06455 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ForEachStatementSyntaxExtensions.cs @@ -0,0 +1,33 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal static class ForEachStatementSyntaxExtensions + { + private static readonly Func AwaitKeywordAccessor; + private static readonly Func WithAwaitKeywordAccessor; + + static ForEachStatementSyntaxExtensions() + { + AwaitKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(typeof(ForEachStatementSyntax), nameof(AwaitKeyword)); + WithAwaitKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(typeof(ForEachStatementSyntax), nameof(AwaitKeyword)); + } + + public static SyntaxToken AwaitKeyword(this ForEachStatementSyntax syntax) + { + return AwaitKeywordAccessor(syntax); + } + + public static ForEachStatementSyntax WithAwaitKeyword(this ForEachStatementSyntax syntax, SyntaxToken awaitKeyword) + { + return WithAwaitKeywordAccessor(syntax, awaitKeyword); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/IFieldSymbolExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/IFieldSymbolExtensions.cs new file mode 100644 index 000000000..abcf1f539 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/IFieldSymbolExtensions.cs @@ -0,0 +1,25 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + + internal static class IFieldSymbolExtensions + { + private static readonly Func CorrespondingTupleFieldAccessor; + + static IFieldSymbolExtensions() + { + CorrespondingTupleFieldAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(typeof(IFieldSymbol), nameof(CorrespondingTupleField)); + } + + public static IFieldSymbol CorrespondingTupleField(this IFieldSymbol symbol) + { + return CorrespondingTupleFieldAccessor(symbol); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/INamedTypeSymbolExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/INamedTypeSymbolExtensions.cs index 59217a148..26d0cb4a9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/INamedTypeSymbolExtensions.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/INamedTypeSymbolExtensions.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Lightup { @@ -11,11 +13,13 @@ internal static class INamedTypeSymbolExtensions { private static readonly Func TupleUnderlyingTypeAccessor; private static readonly Func> TupleElementsAccessor; + private static readonly Func IsSerializableAccessor; static INamedTypeSymbolExtensions() { TupleUnderlyingTypeAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(typeof(INamedTypeSymbol), nameof(TupleUnderlyingType)); TupleElementsAccessor = LightupHelpers.CreateSyntaxPropertyAccessor>(typeof(INamedTypeSymbol), nameof(TupleElements)); + IsSerializableAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(typeof(INamedTypeSymbol), nameof(IsSerializable)); } public static INamedTypeSymbol TupleUnderlyingType(this INamedTypeSymbol symbol) @@ -27,5 +31,10 @@ public static ImmutableArray TupleElements(this INamedTypeSymbol s { return TupleElementsAccessor(symbol); } + + public static bool IsSerializable(this INamedTypeSymbol symbol) + { + return IsSerializableAccessor(symbol); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ISyntaxWrapper`1.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ISyntaxWrapper`1.cs index 77991cd3b..5a6d46483 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ISyntaxWrapper`1.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ISyntaxWrapper`1.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ITypeParameterSymbolExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ITypeParameterSymbolExtensions.cs new file mode 100644 index 000000000..30e8c3d18 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ITypeParameterSymbolExtensions.cs @@ -0,0 +1,25 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + + internal static class ITypeParameterSymbolExtensions + { + private static readonly Func HasUnmanagedTypeConstraintAccessor; + + static ITypeParameterSymbolExtensions() + { + HasUnmanagedTypeConstraintAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(typeof(ITypeParameterSymbol), nameof(HasUnmanagedTypeConstraint)); + } + + public static bool HasUnmanagedTypeConstraint(this ITypeParameterSymbol symbol) + { + return HasUnmanagedTypeConstraintAccessor(symbol); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ITypeSymbolExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ITypeSymbolExtensions.cs index f0c4315b9..94e506af5 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ITypeSymbolExtensions.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ITypeSymbolExtensions.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapper.cs new file mode 100644 index 000000000..0c9abbaf5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ImplicitStackAllocArrayCreationExpressionSyntaxWrapper.cs @@ -0,0 +1,17 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal partial struct ImplicitStackAllocArrayCreationExpressionSyntaxWrapper : ISyntaxWrapper + { + public ImplicitStackAllocArrayCreationExpressionSyntaxWrapper AddInitializerExpressions(params ExpressionSyntax[] items) + { + return new ImplicitStackAllocArrayCreationExpressionSyntaxWrapper(this.WithInitializer(this.Initializer.AddExpressions(items))); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LanguageVersionEx.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LanguageVersionEx.cs index 3c30145b5..7060401e8 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LanguageVersionEx.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LanguageVersionEx.cs @@ -1,5 +1,9 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +#pragma warning disable SA1310 // Field names should not contain underscore - Following roslyn naming conventions namespace StyleCop.Analyzers.Lightup { @@ -9,6 +13,18 @@ internal static class LanguageVersionEx { public const LanguageVersion Default = 0; public const LanguageVersion CSharp7 = (LanguageVersion)7; + public const LanguageVersion CSharp7_1 = (LanguageVersion)701; + public const LanguageVersion CSharp7_2 = (LanguageVersion)702; + public const LanguageVersion CSharp7_3 = (LanguageVersion)703; + public const LanguageVersion CSharp8 = (LanguageVersion)800; + public const LanguageVersion CSharp9 = (LanguageVersion)900; + public const LanguageVersion CSharp10 = (LanguageVersion)1000; + public const LanguageVersion CSharp11 = (LanguageVersion)1100; + public const LanguageVersion CSharp12 = (LanguageVersion)1200; + public const LanguageVersion LatestMajor = (LanguageVersion)int.MaxValue - 2; + public const LanguageVersion Preview = (LanguageVersion)int.MaxValue - 1; public const LanguageVersion Latest = (LanguageVersion)int.MaxValue; } } + +#pragma warning restore SA1310 // Field names should not contain underscore diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LightupHelpers.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LightupHelpers.cs index bbeb7315c..6e4dabe10 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LightupHelpers.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LightupHelpers.cs @@ -1,10 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Lightup { using System; using System.Collections.Concurrent; + using System.Collections.Immutable; using System.Linq; using System.Linq.Expressions; using System.Reflection; @@ -13,11 +16,69 @@ namespace StyleCop.Analyzers.Lightup internal static class LightupHelpers { - private static readonly ConcurrentDictionary> SupportedWrappers + private static readonly ConcurrentDictionary> SupportedObjectWrappers + = new ConcurrentDictionary>(); + + private static readonly ConcurrentDictionary> SupportedSyntaxWrappers = new ConcurrentDictionary>(); + private static readonly ConcurrentDictionary> SupportedOperationWrappers + = new ConcurrentDictionary>(); + public static bool SupportsCSharp7 { get; } - = Enum.GetNames(typeof(SyntaxKind)).Contains(nameof(SyntaxKindEx.IsPatternExpression)); + = Enum.GetNames(typeof(LanguageVersion)).Contains(nameof(LanguageVersionEx.CSharp7)); + + public static bool SupportsCSharp71 { get; } + = Enum.GetNames(typeof(LanguageVersion)).Contains(nameof(LanguageVersionEx.CSharp7_1)); + + public static bool SupportsCSharp72 { get; } + = Enum.GetNames(typeof(LanguageVersion)).Contains(nameof(LanguageVersionEx.CSharp7_2)); + + public static bool SupportsCSharp73 { get; } + = Enum.GetNames(typeof(LanguageVersion)).Contains(nameof(LanguageVersionEx.CSharp7_3)); + + public static bool SupportsCSharp8 { get; } + = Enum.GetNames(typeof(LanguageVersion)).Contains(nameof(LanguageVersionEx.CSharp8)); + + public static bool SupportsCSharp9 { get; } + = Enum.GetNames(typeof(LanguageVersion)).Contains(nameof(LanguageVersionEx.CSharp9)); + + public static bool SupportsCSharp10 { get; } + = Enum.GetNames(typeof(LanguageVersion)).Contains(nameof(LanguageVersionEx.CSharp10)); + + public static bool SupportsCSharp11 { get; } + = Enum.GetNames(typeof(LanguageVersion)).Contains(nameof(LanguageVersionEx.CSharp11)); + + public static bool SupportsCSharp12 { get; } + = Enum.GetNames(typeof(LanguageVersion)).Contains(nameof(LanguageVersionEx.CSharp12)); + + public static bool SupportsIOperation => SupportsCSharp73; + + internal static bool CanWrapObject(object obj, Type underlyingType) + { + if (obj == null) + { + // The wrappers support a null instance + return true; + } + + if (underlyingType == null) + { + // The current runtime doesn't define the target type of the conversion, so no instance of it can exist + return false; + } + + ConcurrentDictionary wrappedObject = SupportedObjectWrappers.GetOrAdd(underlyingType, static _ => new ConcurrentDictionary()); + + // Avoid creating a delegate and capture class + if (!wrappedObject.TryGetValue(obj.GetType(), out var canCast)) + { + canCast = underlyingType.GetTypeInfo().IsAssignableFrom(obj.GetType().GetTypeInfo()); + wrappedObject.TryAdd(obj.GetType(), canCast); + } + + return canCast; + } internal static bool CanWrapNode(SyntaxNode node, Type underlyingType) { @@ -33,38 +94,197 @@ internal static bool CanWrapNode(SyntaxNode node, Type underlyingType) return false; } - ConcurrentDictionary wrappedSyntax = SupportedWrappers.GetOrAdd(underlyingType, _ => new ConcurrentDictionary()); + ConcurrentDictionary wrappedSyntax = SupportedSyntaxWrappers.GetOrAdd(underlyingType, static _ => new ConcurrentDictionary()); - // Avoid creating the delegate if the value already exists - bool canCast; - if (!wrappedSyntax.TryGetValue(node.Kind(), out canCast)) + // Avoid creating a delegate and capture class + if (!wrappedSyntax.TryGetValue(node.Kind(), out var canCast)) { - canCast = wrappedSyntax.GetOrAdd( - node.Kind(), - kind => underlyingType.GetTypeInfo().IsAssignableFrom(node.GetType().GetTypeInfo())); + canCast = underlyingType.GetTypeInfo().IsAssignableFrom(node.GetType().GetTypeInfo()); + wrappedSyntax.TryAdd(node.Kind(), canCast); } return canCast; } + internal static bool CanWrapOperation(IOperation operation, Type underlyingType) + { + if (operation == null) + { + // The wrappers support a null instance + return true; + } + + if (underlyingType == null) + { + // The current runtime doesn't define the target type of the conversion, so no instance of it can exist + return false; + } + + ConcurrentDictionary wrappedSyntax = SupportedOperationWrappers.GetOrAdd(underlyingType, static _ => new ConcurrentDictionary()); + + // Avoid creating a delegate and capture class + if (!wrappedSyntax.TryGetValue(operation.Kind, out var canCast)) + { + canCast = underlyingType.GetTypeInfo().IsAssignableFrom(operation.GetType().GetTypeInfo()); + wrappedSyntax.TryAdd(operation.Kind, canCast); + } + + return canCast; + } + + internal static Func CreateOperationPropertyAccessor(Type type, string propertyName) + { + TProperty FallbackAccessor(TOperation syntax) + { + if (syntax == null) + { + // Unlike an extension method which would throw ArgumentNullException here, the light-up + // behavior needs to match behavior of the underlying property. + throw new NullReferenceException(); + } + + return default; + } + + if (type == null) + { + return FallbackAccessor; + } + + if (!typeof(TOperation).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) + { + throw new InvalidOperationException(); + } + + var property = type.GetTypeInfo().GetDeclaredProperty(propertyName); + if (property == null) + { + return FallbackAccessor; + } + + if (!typeof(TProperty).GetTypeInfo().IsAssignableFrom(property.PropertyType.GetTypeInfo())) + { + throw new InvalidOperationException(); + } + + var operationParameter = Expression.Parameter(typeof(TOperation), "operation"); + Expression instance = + type.GetTypeInfo().IsAssignableFrom(typeof(TOperation).GetTypeInfo()) + ? (Expression)operationParameter + : Expression.Convert(operationParameter, type); + + Expression> expression = + Expression.Lambda>( + Expression.Call(instance, property.GetMethod), + operationParameter); + return expression.Compile(); + } + + internal static Func> CreateOperationListPropertyAccessor(Type type, string propertyName) + { + ImmutableArray FallbackAccessor(TOperation syntax) + { + if (syntax == null) + { + // Unlike an extension method which would throw ArgumentNullException here, the light-up + // behavior needs to match behavior of the underlying property. + throw new NullReferenceException(); + } + + return ImmutableArray.Empty; + } + + if (type == null) + { + return FallbackAccessor; + } + + if (!typeof(TOperation).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) + { + throw new InvalidOperationException(); + } + + var property = type.GetTypeInfo().GetDeclaredProperty(propertyName); + if (property == null) + { + return FallbackAccessor; + } + + if (property.PropertyType.GetGenericTypeDefinition() != typeof(ImmutableArray<>)) + { + throw new InvalidOperationException(); + } + + var propertyOperationType = property.PropertyType.GenericTypeArguments[0]; + + if (!typeof(IOperation).GetTypeInfo().IsAssignableFrom(propertyOperationType.GetTypeInfo())) + { + throw new InvalidOperationException(); + } + + var syntaxParameter = Expression.Parameter(typeof(TOperation), "syntax"); + Expression instance = + type.GetTypeInfo().IsAssignableFrom(typeof(TOperation).GetTypeInfo()) + ? (Expression)syntaxParameter + : Expression.Convert(syntaxParameter, type); + Expression propertyAccess = Expression.Call(instance, property.GetMethod); + + var unboundCastUpMethod = typeof(ImmutableArray).GetTypeInfo().GetDeclaredMethod(nameof(ImmutableArray.CastUp)); + var boundCastUpMethod = unboundCastUpMethod.MakeGenericMethod(propertyOperationType); + + Expression>> expression = + Expression.Lambda>>( + Expression.Call(boundCastUpMethod, propertyAccess), + syntaxParameter); + return expression.Compile(); + } + + internal static Func CreateStaticPropertyAccessor(Type type, string propertyName) + { + static TProperty FallbackAccessor() + { + return default; + } + + if (type == null) + { + return FallbackAccessor; + } + + var property = type.GetTypeInfo().GetDeclaredProperty(propertyName); + if (property == null) + { + return FallbackAccessor; + } + + if (!typeof(TProperty).GetTypeInfo().IsAssignableFrom(property.PropertyType.GetTypeInfo())) + { + throw new InvalidOperationException(); + } + + Expression> expression = + Expression.Lambda>( + Expression.Call(null, property.GetMethod)); + return expression.Compile(); + } + internal static Func CreateSyntaxPropertyAccessor(Type type, string propertyName) { - Func fallbackAccessor = - syntax => + TProperty FallbackAccessor(TSyntax syntax) + { + if (syntax == null) { - if (syntax == null) - { - // Unlike an extension method which would throw ArgumentNullException here, the light-up - // behavior needs to match behavior of the underlying property. - throw new NullReferenceException(); - } + // Unlike an extension method which would throw ArgumentNullException here, the light-up + // behavior needs to match behavior of the underlying property. + throw new NullReferenceException(); + } - return default(TProperty); - }; + return default; + } if (type == null) { - return fallbackAccessor; + return FallbackAccessor; } if (!typeof(TSyntax).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) @@ -75,7 +295,7 @@ internal static Func CreateSyntaxPropertyAccessor CreateSyntaxPropertyAccessor CreateSyntaxPropertyAccessor(Type type, Type argumentType, string accessorMethodName) + { + static TProperty FallbackAccessor(TSyntax syntax, TArg argument) + { + if (syntax == null) + { + // Unlike an extension method which would throw ArgumentNullException here, the light-up + // behavior needs to match behavior of the underlying property. + throw new NullReferenceException(); + } + + return default; + } + + if (type == null) + { + return FallbackAccessor; + } + + if (!typeof(TSyntax).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) + { + throw new InvalidOperationException(); + } + + if (!typeof(TArg).GetTypeInfo().IsAssignableFrom(argumentType.GetTypeInfo())) + { + throw new InvalidOperationException(); + } + + var methods = type.GetTypeInfo().GetDeclaredMethods(accessorMethodName); + MethodInfo method = null; + foreach (var candidate in methods) + { + var parameters = candidate.GetParameters(); + if (parameters.Length != 1) + { + continue; + } + + if (Equals(argumentType, parameters[0].ParameterType)) + { + method = candidate; + break; + } + } + + if (method == null) + { + return FallbackAccessor; + } + + if (!typeof(TProperty).GetTypeInfo().IsAssignableFrom(method.ReturnType.GetTypeInfo())) + { + throw new InvalidOperationException(); + } + + var syntaxParameter = Expression.Parameter(typeof(TSyntax), "syntax"); + var argParameter = Expression.Parameter(typeof(TArg), "arg"); + Expression instance = + type.GetTypeInfo().IsAssignableFrom(typeof(TSyntax).GetTypeInfo()) + ? (Expression)syntaxParameter + : Expression.Convert(syntaxParameter, type); + Expression argument = + argumentType.GetTypeInfo().IsAssignableFrom(typeof(TArg).GetTypeInfo()) + ? (Expression)argParameter + : Expression.Convert(argParameter, argumentType); + + Expression> expression = + Expression.Lambda>( + Expression.Call(instance, method, argument), + syntaxParameter, + argParameter); + return expression.Compile(); + } + + internal static TryGetValueAccessor CreateTryGetValueAccessor(Type type, Type keyType, string methodName) + { + static bool FallbackAccessor(TSyntax syntax, TKey key, out TValue value) + { + if (syntax == null) + { + // Unlike an extension method which would throw ArgumentNullException here, the light-up + // behavior needs to match behavior of the underlying property. + throw new NullReferenceException(); + } + + value = default; + return false; + } + + if (type == null) + { + return FallbackAccessor; + } + + if (!typeof(TSyntax).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) + { + throw new InvalidOperationException(); + } + + if (!typeof(TKey).GetTypeInfo().IsAssignableFrom(keyType.GetTypeInfo())) + { + throw new InvalidOperationException(); + } + + var methods = type.GetTypeInfo().GetDeclaredMethods(methodName); + MethodInfo method = null; + foreach (var candidate in methods) + { + var parameters = candidate.GetParameters(); + if (parameters.Length != 2) + { + continue; + } + + if (Equals(keyType, parameters[0].ParameterType) + && Equals(typeof(TValue).MakeByRefType(), parameters[1].ParameterType)) + { + method = candidate; + break; + } + } + + if (method == null) + { + return FallbackAccessor; + } + + if (method.ReturnType != typeof(bool)) + { + throw new InvalidOperationException(); + } + + var syntaxParameter = Expression.Parameter(typeof(TSyntax), "syntax"); + var keyParameter = Expression.Parameter(typeof(TKey), "key"); + var valueParameter = Expression.Parameter(typeof(TValue).MakeByRefType(), "value"); + Expression instance = + type.GetTypeInfo().IsAssignableFrom(typeof(TSyntax).GetTypeInfo()) + ? (Expression)syntaxParameter + : Expression.Convert(syntaxParameter, type); + Expression key = + keyType.GetTypeInfo().IsAssignableFrom(typeof(TKey).GetTypeInfo()) + ? (Expression)keyParameter + : Expression.Convert(keyParameter, keyType); + + Expression> expression = + Expression.Lambda>( + Expression.Call(instance, method, key, valueParameter), + syntaxParameter, + keyParameter, + valueParameter); + return expression.Compile(); + } + internal static Func> CreateSeparatedSyntaxListPropertyAccessor(Type type, string propertyName) { - Func> fallbackAccessor = - syntax => + SeparatedSyntaxListWrapper FallbackAccessor(TSyntax syntax) + { + if (syntax == null) { - if (syntax == null) - { - // Unlike an extension method which would throw ArgumentNullException here, the light-up - // behavior needs to match behavior of the underlying property. - throw new NullReferenceException(); - } + // Unlike an extension method which would throw ArgumentNullException here, the light-up + // behavior needs to match behavior of the underlying property. + throw new NullReferenceException(); + } - return SeparatedSyntaxListWrapper.UnsupportedEmpty; - }; + return SeparatedSyntaxListWrapper.UnsupportedEmpty; + } if (type == null) { - return fallbackAccessor; + return FallbackAccessor; } if (!typeof(TSyntax).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) @@ -124,7 +497,7 @@ internal static Func> CreateSepar var property = type.GetTypeInfo().GetDeclaredProperty(propertyName); if (property == null) { - return fallbackAccessor; + return FallbackAccessor; } if (property.PropertyType.GetGenericTypeDefinition() != typeof(SeparatedSyntaxList<>)) @@ -148,7 +521,7 @@ internal static Func> CreateSepar var unboundWrapperType = typeof(SeparatedSyntaxListWrapper<>.AutoWrapSeparatedSyntaxList<>); var boundWrapperType = unboundWrapperType.MakeGenericType(typeof(TProperty), propertySyntaxType); - var constructorInfo = boundWrapperType.GetTypeInfo().DeclaredConstructors.Single(); + var constructorInfo = boundWrapperType.GetTypeInfo().DeclaredConstructors.Single(constructor => constructor.GetParameters().Length == 1); Expression>> expression = Expression.Lambda>>( @@ -159,27 +532,26 @@ internal static Func> CreateSepar internal static Func CreateSyntaxWithPropertyAccessor(Type type, string propertyName) { - Func fallbackAccessor = - (syntax, newValue) => + TSyntax FallbackAccessor(TSyntax syntax, TProperty newValue) + { + if (syntax == null) { - if (syntax == null) - { - // Unlike an extension method which would throw ArgumentNullException here, the light-up - // behavior needs to match behavior of the underlying property. - throw new NullReferenceException(); - } + // Unlike an extension method which would throw ArgumentNullException here, the light-up + // behavior needs to match behavior of the underlying property. + throw new NullReferenceException(); + } - if (Equals(newValue, default(TProperty))) - { - return syntax; - } + if (Equals(newValue, default(TProperty))) + { + return syntax; + } - throw new NotSupportedException(); - }; + throw new NotSupportedException(); + } if (type == null) { - return fallbackAccessor; + return FallbackAccessor; } if (!typeof(TSyntax).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) @@ -190,7 +562,7 @@ internal static Func CreateSyntaxWithPropertyAccess var property = type.GetTypeInfo().GetDeclaredProperty(propertyName); if (property == null) { - return fallbackAccessor; + return FallbackAccessor; } if (!typeof(TProperty).GetTypeInfo().IsAssignableFrom(property.PropertyType.GetTypeInfo())) @@ -199,7 +571,11 @@ internal static Func CreateSyntaxWithPropertyAccess } var methodInfo = type.GetTypeInfo().GetDeclaredMethods("With" + propertyName) - .Single(m => !m.IsStatic && m.GetParameters().Length == 1 && m.GetParameters()[0].ParameterType.Equals(property.PropertyType)); + .SingleOrDefault(m => !m.IsStatic && m.GetParameters().Length == 1 && m.GetParameters()[0].ParameterType.Equals(property.PropertyType)); + if (methodInfo is null) + { + return FallbackAccessor; + } var syntaxParameter = Expression.Parameter(typeof(TSyntax), "syntax"); var valueParameter = Expression.Parameter(typeof(TProperty), methodInfo.GetParameters()[0].Name); @@ -222,27 +598,26 @@ internal static Func CreateSyntaxWithPropertyAccess internal static Func, TSyntax> CreateSeparatedSyntaxListWithPropertyAccessor(Type type, string propertyName) { - Func, TSyntax> fallbackAccessor = - (syntax, newValue) => + TSyntax FallbackAccessor(TSyntax syntax, SeparatedSyntaxListWrapper newValue) + { + if (syntax == null) { - if (syntax == null) - { - // Unlike an extension method which would throw ArgumentNullException here, the light-up - // behavior needs to match behavior of the underlying property. - throw new NullReferenceException(); - } + // Unlike an extension method which would throw ArgumentNullException here, the light-up + // behavior needs to match behavior of the underlying property. + throw new NullReferenceException(); + } - if (newValue is null) - { - return syntax; - } + if (newValue is null) + { + return syntax; + } - throw new NotSupportedException(); - }; + throw new NotSupportedException(); + } if (type == null) { - return fallbackAccessor; + return FallbackAccessor; } if (!typeof(TSyntax).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo())) @@ -253,7 +628,7 @@ internal static Func, TSyntax> Cr var property = type.GetTypeInfo().GetDeclaredProperty(propertyName); if (property == null) { - return fallbackAccessor; + return FallbackAccessor; } if (property.PropertyType.GetGenericTypeDefinition() != typeof(SeparatedSyntaxList<>)) @@ -293,7 +668,7 @@ internal static Func, TSyntax> Cr private static bool ValidatePropertyType(Type returnType, Type actualType) { - var requiredType = WrapperHelper.GetWrappedType(returnType) ?? returnType; + var requiredType = SyntaxWrapperHelper.GetWrappedType(returnType) ?? returnType; return requiredType == actualType; } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LocalDeclarationStatementSyntaxExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LocalDeclarationStatementSyntaxExtensions.cs new file mode 100644 index 000000000..55a131439 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LocalDeclarationStatementSyntaxExtensions.cs @@ -0,0 +1,49 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal static class LocalDeclarationStatementSyntaxExtensions + { + private static readonly Func AwaitKeywordAccessor; + private static readonly Func UsingKeywordAccessor; + + private static readonly Func WithAwaitKeywordAccessor; + private static readonly Func WithUsingKeywordAccessor; + + static LocalDeclarationStatementSyntaxExtensions() + { + AwaitKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(typeof(LocalDeclarationStatementSyntax), nameof(AwaitKeyword)); + UsingKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(typeof(LocalDeclarationStatementSyntax), nameof(UsingKeyword)); + + WithAwaitKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(typeof(LocalDeclarationStatementSyntax), nameof(AwaitKeyword)); + WithUsingKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(typeof(LocalDeclarationStatementSyntax), nameof(UsingKeyword)); + } + + public static SyntaxToken AwaitKeyword(this LocalDeclarationStatementSyntax syntax) + { + return AwaitKeywordAccessor(syntax); + } + + public static SyntaxToken UsingKeyword(this LocalDeclarationStatementSyntax syntax) + { + return UsingKeywordAccessor(syntax); + } + + public static LocalDeclarationStatementSyntax WithAwaitKeyword(this LocalDeclarationStatementSyntax syntax, SyntaxToken awaitKeyword) + { + return WithAwaitKeywordAccessor(syntax, awaitKeyword); + } + + public static LocalDeclarationStatementSyntax WithUsingKeyword(this LocalDeclarationStatementSyntax syntax, SyntaxToken usingKeyword) + { + return WithUsingKeywordAccessor(syntax, usingKeyword); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LocalFunctionStatementSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LocalFunctionStatementSyntaxWrapper.cs index 4df1bbe3e..c0dda879e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LocalFunctionStatementSyntaxWrapper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LocalFunctionStatementSyntaxWrapper.cs @@ -1,211 +1,16 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Lightup { - using System; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; - internal struct LocalFunctionStatementSyntaxWrapper : ISyntaxWrapper + internal partial struct LocalFunctionStatementSyntaxWrapper : ISyntaxWrapper { - internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.LocalFunctionStatementSyntax"; - private static readonly Type WrappedType; - - private static readonly Func ModifiersAccessor; - private static readonly Func ReturnTypeAccessor; - private static readonly Func IdentifierAccessor; - private static readonly Func TypeParameterListAccessor; - private static readonly Func ParameterListAccessor; - private static readonly Func> ConstraintClausesAccessor; - private static readonly Func BodyAccessor; - private static readonly Func ExpressionBodyAccessor; - private static readonly Func SemicolonTokenAccessor; - private static readonly Func WithModifiersAccessor; - private static readonly Func WithReturnTypeAccessor; - private static readonly Func WithIdentifierAccessor; - private static readonly Func WithTypeParameterListAccessor; - private static readonly Func WithParameterListAccessor; - private static readonly Func, StatementSyntax> WithConstraintClausesAccessor; - private static readonly Func WithBodyAccessor; - private static readonly Func WithExpressionBodyAccessor; - private static readonly Func WithSemicolonTokenAccessor; - - private readonly StatementSyntax node; - - static LocalFunctionStatementSyntaxWrapper() - { - WrappedType = WrapperHelper.GetWrappedType(typeof(LocalFunctionStatementSyntaxWrapper)); - ModifiersAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Modifiers)); - ReturnTypeAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(ReturnType)); - IdentifierAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Identifier)); - TypeParameterListAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(TypeParameterList)); - ParameterListAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(ParameterList)); - ConstraintClausesAccessor = LightupHelpers.CreateSyntaxPropertyAccessor>(WrappedType, nameof(ConstraintClauses)); - BodyAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(Body)); - ExpressionBodyAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(ExpressionBody)); - SemicolonTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(SemicolonToken)); - WithModifiersAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Modifiers)); - WithReturnTypeAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(ReturnType)); - WithIdentifierAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Identifier)); - WithTypeParameterListAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(TypeParameterList)); - WithParameterListAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(ParameterList)); - WithConstraintClausesAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor>(WrappedType, nameof(ConstraintClauses)); - WithBodyAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(Body)); - WithExpressionBodyAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(ExpressionBody)); - WithSemicolonTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(SemicolonToken)); - } - - private LocalFunctionStatementSyntaxWrapper(StatementSyntax node) - { - this.node = node; - } - - public StatementSyntax SyntaxNode => this.node; - - public SyntaxTokenList Modifiers - { - get - { - return ModifiersAccessor(this.SyntaxNode); - } - } - - public TypeSyntax ReturnType - { - get - { - return ReturnTypeAccessor(this.SyntaxNode); - } - } - - public SyntaxToken Identifier - { - get - { - return IdentifierAccessor(this.SyntaxNode); - } - } - - public TypeParameterListSyntax TypeParameterList - { - get - { - return TypeParameterListAccessor(this.SyntaxNode); - } - } - - public ParameterListSyntax ParameterList - { - get - { - return ParameterListAccessor(this.SyntaxNode); - } - } - - public SyntaxList ConstraintClauses - { - get - { - return ConstraintClausesAccessor(this.SyntaxNode); - } - } - - public BlockSyntax Body - { - get - { - return BodyAccessor(this.SyntaxNode); - } - } - - public ArrowExpressionClauseSyntax ExpressionBody - { - get - { - return ExpressionBodyAccessor(this.SyntaxNode); - } - } - - public SyntaxToken SemicolonToken - { - get - { - return SemicolonTokenAccessor(this.SyntaxNode); - } - } - - public static explicit operator LocalFunctionStatementSyntaxWrapper(SyntaxNode node) - { - if (node == null) - { - return default(LocalFunctionStatementSyntaxWrapper); - } - - if (!IsInstance(node)) - { - throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); - } - - return new LocalFunctionStatementSyntaxWrapper((StatementSyntax)node); - } - - public static implicit operator StatementSyntax(LocalFunctionStatementSyntaxWrapper wrapper) - { - return wrapper.node; - } - - public static bool IsInstance(SyntaxNode node) - { - return node != null && LightupHelpers.CanWrapNode(node, WrappedType); - } - - public LocalFunctionStatementSyntaxWrapper WithModifiers(SyntaxTokenList modifiers) - { - return new LocalFunctionStatementSyntaxWrapper(WithModifiersAccessor(this.SyntaxNode, modifiers)); - } - - public LocalFunctionStatementSyntaxWrapper WithReturnType(TypeSyntax returnType) - { - return new LocalFunctionStatementSyntaxWrapper(WithReturnTypeAccessor(this.SyntaxNode, returnType)); - } - - public LocalFunctionStatementSyntaxWrapper WithIdentifier(SyntaxToken identifier) - { - return new LocalFunctionStatementSyntaxWrapper(WithIdentifierAccessor(this.SyntaxNode, identifier)); - } - - public LocalFunctionStatementSyntaxWrapper WithTypeParameterList(TypeParameterListSyntax typeParameterList) - { - return new LocalFunctionStatementSyntaxWrapper(WithTypeParameterListAccessor(this.SyntaxNode, typeParameterList)); - } - - public LocalFunctionStatementSyntaxWrapper WithParameterList(ParameterListSyntax parameterList) - { - return new LocalFunctionStatementSyntaxWrapper(WithParameterListAccessor(this.SyntaxNode, parameterList)); - } - - public LocalFunctionStatementSyntaxWrapper WithConstraintClauses(SyntaxList constraintClauses) - { - return new LocalFunctionStatementSyntaxWrapper(WithConstraintClausesAccessor(this.SyntaxNode, constraintClauses)); - } - - public LocalFunctionStatementSyntaxWrapper WithBody(BlockSyntax body) - { - return new LocalFunctionStatementSyntaxWrapper(WithBodyAccessor(this.SyntaxNode, body)); - } - - public LocalFunctionStatementSyntaxWrapper WithExpressionBody(ArrowExpressionClauseSyntax expressionBody) - { - return new LocalFunctionStatementSyntaxWrapper(WithExpressionBodyAccessor(this.SyntaxNode, expressionBody)); - } - - public LocalFunctionStatementSyntaxWrapper WithSemicolonToken(SyntaxToken semicolonToken) - { - return new LocalFunctionStatementSyntaxWrapper(WithSemicolonTokenAccessor(this.SyntaxNode, semicolonToken)); - } - public LocalFunctionStatementSyntaxWrapper AddModifiers(params SyntaxToken[] items) { return this.WithModifiers(this.Modifiers.AddRange(items)); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/MemberDeclarationSyntaxExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/MemberDeclarationSyntaxExtensions.cs new file mode 100644 index 000000000..e38c55069 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/MemberDeclarationSyntaxExtensions.cs @@ -0,0 +1,57 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal static class MemberDeclarationSyntaxExtensions + { + private static readonly Func> AttributeListsAccessor; + private static readonly Func ModifiersAccessor; + private static readonly Func, MemberDeclarationSyntax> WithAttributeListsAccessor; + private static readonly Func WithModifiersAccessor; + + static MemberDeclarationSyntaxExtensions() + { + AttributeListsAccessor = LightupHelpers.CreateSyntaxPropertyAccessor>(typeof(MemberDeclarationSyntax), nameof(AttributeLists)); + ModifiersAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(typeof(MemberDeclarationSyntax), nameof(Modifiers)); + WithAttributeListsAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor>(typeof(MemberDeclarationSyntax), nameof(AttributeLists)); + WithModifiersAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(typeof(MemberDeclarationSyntax), nameof(Modifiers)); + } + + public static SyntaxList AttributeLists(this MemberDeclarationSyntax syntax) + { + return AttributeListsAccessor(syntax); + } + + public static SyntaxTokenList Modifiers(this MemberDeclarationSyntax syntax) + { + return ModifiersAccessor(syntax); + } + + public static MemberDeclarationSyntax WithAttributeLists(this MemberDeclarationSyntax syntax, SyntaxList attributeLists) + { + return WithAttributeListsAccessor(syntax, attributeLists); + } + + public static MemberDeclarationSyntax WithModifiers(this MemberDeclarationSyntax syntax, SyntaxTokenList modifiers) + { + return WithModifiersAccessor(syntax, modifiers); + } + + public static MemberDeclarationSyntax AddAttributeLists(this MemberDeclarationSyntax syntax, params AttributeListSyntax[] items) + { + return syntax.WithAttributeLists(syntax.AttributeLists().AddRange(items)); + } + + public static MemberDeclarationSyntax AddModifiers(this MemberDeclarationSyntax syntax, params SyntaxToken[] items) + { + return syntax.WithModifiers(syntax.Modifiers().AddRange(items)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/MethodKindEx.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/MethodKindEx.cs index 4449b3531..7aa7b460f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/MethodKindEx.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/MethodKindEx.cs @@ -1,5 +1,5 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/OperationInterfaces.xml b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/OperationInterfaces.xml new file mode 100644 index 000000000..146c9cf42 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/OperationInterfaces.xml @@ -0,0 +1,3051 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + Represents an invalid operation with one or more child operations. + + Current usage: + (1) C# invalid expression or invalid statement. + (2) VB invalid expression or invalid statement. + + + + + + + + Represents a block containing a sequence of operations and local declarations. + + Current usage: + (1) C# "{ ... }" block statement. + (2) VB implicit block statement for method bodies and other block scoped statements. + + + + + + Operations contained within the block. + + + + + Local declarations contained within the block. + + + + + + Represents a variable declaration statement. + + Current Usage: + (1) C# local declaration statement + (2) C# fixed statement + (3) C# using statement + (4) C# using declaration + (5) VB Dim statement + (6) VB Using statement + + + + + Variable declaration in the statement. + + In C#, this will always be a single declaration, with all variables in . + + + + + + + + Represents a switch operation with a value to be switched upon and switch cases. + + Current usage: + (1) C# switch statement. + (2) VB Select Case statement. + + + + + + + Locals declared within the switch operation with scope spanning across all . + + + + + + Value to be switched upon. + + + + + Cases of the switch. + + + + + Exit label for the switch statement. + + + + + + + + Represents a loop operation. + + Current usage: + (1) C# 'while', 'for', 'foreach' and 'do' loop statements + (2) VB 'While', 'ForTo', 'ForEach', 'Do While' and 'Do Until' loop statements + + + + + + Kind of the loop. + + + + + Body of the loop. + + + + + Declared locals. + + + + + Loop continue label. + + + + + Loop exit/break label. + + + + + + + + Represents a for each loop. + + Current usage: + (1) C# 'foreach' loop statement + (2) VB 'For Each' loop statement + + + + + + Refers to the operation for declaring a new local variable or reference an existing variable or an expression. + + + + + Collection value over which the loop iterates. + + + + + + Optional list of comma separated next variables at loop bottom in VB. + This list is always empty for C#. + + + + + + + + Whether this for each loop is asynchronous. + Always false for VB. + + + + + + + + + Represents a for loop. + + Current usage: + (1) C# 'for' loop statement + + + + + + List of operations to execute before entry to the loop. For C#, this comes from the first clause of the for statement. + + + + + + Locals declared within the loop Condition and are in scope throughout the , + and . + They are considered to be declared per iteration. + + + + + + Condition of the loop. For C#, this comes from the second clause of the for statement. + + + + + List of operations to execute at the bottom of the loop. For C#, this comes from the third clause of the for statement. + + + + + + + + Represents a for to loop with loop control variable and initial, limit and step values for the control variable. + + Current usage: + (1) VB 'For ... To ... Step' loop statement + + + + + + Refers to the operation for declaring a new local variable or reference an existing variable or an expression. + + + + + Operation for setting the initial value of the loop control variable. This comes from the expression between the 'For' and 'To' keywords. + + + + + Operation for the limit value of the loop control variable. This comes from the expression after the 'To' keyword. + + + + + + Operation for the step value of the loop control variable. This comes from the expression after the 'Step' keyword, + or inferred by the compiler if 'Step' clause is omitted. + + + + + + + true if arithmetic operations behind this loop are 'checked'. + + + + + Optional list of comma separated next variables at loop bottom. + + + + + + + + + Represents a while or do while loop. + + Current usage: + (1) C# 'while' and 'do while' loop statements. + (2) VB 'While', 'Do While' and 'Do Until' loop statements. + + + + + + Condition of the loop. + + + + + + True if the is evaluated at start of each loop iteration. + False if it is evaluated at the end of each loop iteration. + + + + + + True if the loop has 'Until' loop semantics and the loop is executed while is false. + + + + + + Additional conditional supplied for loop in error cases, which is ignored by the compiler. + For example, for VB 'Do While' or 'Do Until' loop with syntax errors where both the top and bottom conditions are provided. + The top condition is preferred and exposed as and the bottom condition is ignored and exposed by this property. + This property should be null for all non-error cases. + + + + + + + + Represents an operation with a label. + + Current usage: + (1) C# labeled statement. + (2) VB label statement. + + + + + + Label that can be the target of branches. + + + + + Operation that has been labeled. In VB, this is always null. + + + + + + + Represents a branch operation. + + Current usage: + (1) C# goto, break, or continue statement. + (2) VB GoTo, Exit ***, or Continue *** statement. + + + + + + Label that is the target of the branch. + + + + + Kind of the branch. + + + + + + + Represents an empty or no-op operation. + + Current usage: + (1) C# empty statement. + + + + + + + + + + + + + Represents a return from the method with an optional return value. + + Current usage: + (1) C# return statement and yield statement. + (2) VB Return statement. + + + + + + Value to be returned. + + + + + + + Represents a of operations that are executed while holding a lock onto the . + + Current usage: + (1) C# lock statement. + (2) VB SyncLock statement. + + + + + + Operation producing a value to be locked. + + + + + Body of the lock, to be executed while holding the lock. + + + + + + + + Represents a try operation for exception handling code with a body, catch clauses and a finally handler. + + Current usage: + (1) C# try statement. + (2) VB Try statement. + + + + + + Body of the try, over which the handlers are active. + + + + + Catch clauses of the try. + + + + + Finally handler of the try. + + + + + Exit label for the try. This will always be null for C#. + + + + + + + Represents a of operations that are executed while using disposable . + + Current usage: + (1) C# using statement. + (2) VB Using statement. + + + + + + Declaration introduced or resource held by the using. + + + + + Body of the using, over which the resources of the using are maintained. + + + + + + Locals declared within the with scope spanning across this entire . + + + + + + + Whether this using is asynchronous. + Always false for VB. + + + + + + + + Represents an operation that drops the resulting value and the type of the underlying wrapped . + + Current usage: + (1) C# expression statement. + (2) VB expression statement. + + + + + + Underlying operation with a value and type. + + + + + + + Represents a local function defined within a method. + + Current usage: + (1) C# local function statement. + + + + + + Local function symbol. + + + + + Body of the local function. + + + + + An extra body for the local function, if both a block body and expression body are specified in source. + This is only ever non-null in error situations. + + + + + + + Represents an operation to stop or suspend execution of code. + + Current usage: + (1) VB Stop statement. + + + + + + + + Represents an operation that stops the execution of code abruptly. + + Current usage: + (1) VB End Statement. + + + + + + + + Represents an operation for raising an event. + + Current usage: + (1) VB raise event statement. + + + + + + Reference to the event to be raised. + + + + + Arguments of the invocation, excluding the instance argument. Arguments are in evaluation order. + + If the invocation is in its expanded form, then params/ParamArray arguments would be collected into arrays. + Default values are supplied for optional arguments missing in source. + + + + + + + + Represents a textual literal numeric, string, etc. + + Current usage: + (1) C# literal expression. + (2) VB literal expression. + + + + + + + + Represents a type conversion. + + Current usage: + (1) C# conversion expression. + (2) VB conversion expression. + + + + + + Value to be converted. + + + + + Operator method used by the operation, null if the operation does not use an operator method. + + + + + Gets the underlying common conversion information. + + If you need conversion information that is language specific, use either + or + . + + + + + + + False if the conversion will fail with a at runtime if the cast fails. This is true for C#'s + as operator and for VB's TryCast operator. + + + + + + True if the conversion can fail at runtime with an overflow exception. This corresponds to C# checked and unchecked blocks. + + + + + + + Represents an invocation of a method. + + Current usage: + (1) C# method invocation expression. + (2) C# collection element initializer. + For example, in the following collection initializer: new C() { 1, 2, 3 }, we will have + 3 nodes, each of which will be a call to the corresponding Add method + with either 1, 2, 3 as the argument. + (3) VB method invocation expression. + (4) VB collection element initializer. + Similar to the C# example, New C() From {1, 2, 3} will have 3 + nodes with 1, 2, and 3 as their arguments, respectively. + + + + + + Method to be invoked. + + + + + 'This' or 'Me' instance to be supplied to the method, or null if the method is static. + + + + + True if the invocation uses a virtual mechanism, and false otherwise. + + + + + Arguments of the invocation, excluding the instance argument. Arguments are in evaluation order. + + If the invocation is in its expanded form, then params/ParamArray arguments would be collected into arrays. + Default values are supplied for optional arguments missing in source. + + + + + + + + Represents a reference to an array element. + + Current usage: + (1) C# array element reference expression. + (2) VB array element reference expression. + + + + + + Array to be indexed. + + + + + Indices that specify an individual element. + + + + + + + Represents a reference to a declared local variable. + + Current usage: + (1) C# local reference expression. + (2) VB local reference expression. + + + + + + Referenced local variable. + + + + + + True if this reference is also the declaration site of this variable. This is true in out variable declarations + and in deconstruction operations where a new variable is being declared. + + + + + + + + Represents a reference to a parameter. + + Current usage: + (1) C# parameter reference expression. + (2) VB parameter reference expression. + + + + + + Referenced parameter. + + + + + + + Represents a reference to a member of a class, struct, or interface. + + Current usage: + (1) C# member reference expression. + (2) VB member reference expression. + + + + + + Instance of the type. Null if the reference is to a static/shared member. + + + + + Referenced member. + + + + + + + Represents a reference to a field. + + Current usage: + (1) C# field reference expression. + (2) VB field reference expression. + + + + + + Referenced field. + + + + + If the field reference is also where the field was declared. + + This is only ever true in CSharp scripts, where a top-level statement creates a new variable + in a reference, such as an out variable declaration or a deconstruction declaration. + + + + + + + + Represents a reference to a method other than as the target of an invocation. + + Current usage: + (1) C# method reference expression. + (2) VB method reference expression. + + + + + + Referenced method. + + + + + Indicates whether the reference uses virtual semantics. + + + + + + + Represents a reference to a property. + + Current usage: + (1) C# property reference expression. + (2) VB property reference expression. + + + + + + Referenced property. + + + + + Arguments of the indexer property reference, excluding the instance argument. Arguments are in evaluation order. + + If the invocation is in its expanded form, then params/ParamArray arguments would be collected into arrays. + Default values are supplied for optional arguments missing in source. + + + + + + + + Represents a reference to an event. + + Current usage: + (1) C# event reference expression. + (2) VB event reference expression. + + + + + + Referenced event. + + + + + + + + + + + Represents an operation with one operand and a unary operator. + + Current usage: + (1) C# unary operation expression. + (2) VB unary operation expression. + + + + + + Kind of unary operation. + + + + + Operand. + + + + + + if this is a 'lifted' unary operator. When there is an + operator that is defined to work on a value type, 'lifted' operators are + created to work on the versions of those + value types. + + + + + + + if overflow checking is performed for the arithmetic operation. + + + + + + Operator method used by the operation, null if the operation does not use an operator method. + + + + + + + + + + + Represents an operation with two operands and a binary operator that produces a result with a non-null type. + + Current usage: + (1) C# binary operator expression. + (2) VB binary operator expression. + + + + + + Kind of binary operation. + + + + + Left operand. + + + + + Right operand. + + + + + + if this is a 'lifted' binary operator. When there is an + operator that is defined to work on a value type, 'lifted' operators are + created to work on the versions of those + value types. + + + + + + + if this is a 'checked' binary operator. + + + + + + + if the comparison is text based for string or object comparison in VB. + + + + + + Operator method used by the operation, null if the operation does not use an operator method. + + + + + + True/False operator method used for short circuiting. + https://github.com/dotnet/roslyn/issues/27598 tracks exposing this information through public API + + + + + + + + Represents a conditional operation with: + (1) to be tested, + (2) operation to be executed when is true and + (3) operation to be executed when the is false. + + Current usage: + (1) C# ternary expression "a ? b : c" and if statement. + (2) VB ternary expression "If(a, b, c)" and If Else statement. + + + + + + Condition to be tested. + + + + + + Operation to be executed if the is true. + + + + + + + Operation to be executed if the is false. + + + + + + Is result a managed reference + + + + + + + Represents a coalesce operation with two operands: + (1) , which is the first operand that is unconditionally evaluated and is the result of the operation if non null. + (2) , which is the second operand that is conditionally evaluated and is the result of the operation if is null. + + Current usage: + (1) C# null-coalescing expression "Value ?? WhenNull". + (2) VB binary conditional expression "If(Value, WhenNull)". + + + + + + Operation to be unconditionally evaluated. + + + + + + Operation to be conditionally evaluated if evaluates to null/Nothing. + + + + + + + Conversion associated with when it is not null/Nothing. + + Identity if result type of the operation is the same as type of . + Otherwise, if type of is nullable, then conversion is applied to an + unwrapped , otherwise to the itself. + + + + + + + + Represents an anonymous function operation. + + Current usage: + (1) C# lambda expression. + (2) VB anonymous delegate expression. + + + + + + Symbol of the anonymous function. + + + + + Body of the anonymous function. + + + + + + + Represents creation of an object instance. + + Current usage: + (1) C# new expression. + (2) VB New expression. + + + + + + Constructor to be invoked on the created instance. + + + + + Object or collection initializer, if any. + + + + + Arguments of the object creation, excluding the instance argument. Arguments are in evaluation order. + + If the invocation is in its expanded form, then params/ParamArray arguments would be collected into arrays. + Default values are supplied for optional arguments missing in source. + + + + + + + + Represents a creation of a type parameter object, i.e. new T(), where T is a type parameter with new constraint. + + Current usage: + (1) C# type parameter object creation expression. + (2) VB type parameter object creation expression. + + + + + + Object or collection initializer, if any. + + + + + + + Represents the creation of an array instance. + + Current usage: + (1) C# array creation expression. + (2) VB array creation expression. + + + + + + Sizes of the dimensions of the created array instance. + + + + + Values of elements of the created array instance. + + + + + + + Represents an implicit/explicit reference to an instance. + + Current usage: + (1) C# this or base expression. + (2) VB Me, MyClass, or MyBase expression. + (3) C# object or collection or 'with' expression initializers. + (4) VB With statements, object or collection initializers. + + + + + + The kind of reference that is being made. + + + + + + + Represents an operation that tests if a value is of a specific type. + + Current usage: + (1) C# "is" operator expression. + (2) VB "TypeOf" and "TypeOf IsNot" expression. + + + + + + Value to test. + + + + + Type for which to test. + + + + + + Flag indicating if this is an "is not" type expression. + True for VB "TypeOf ... IsNot ..." expression. + False, otherwise. + + + + + + + + Represents an await operation. + + Current usage: + (1) C# await expression. + (2) VB await expression. + + + + + + Awaited operation. + + + + + + + Represents a base interface for assignments. + + Current usage: + (1) C# simple, compound and deconstruction assignment expressions. + (2) VB simple and compound assignment expressions. + + + + + + Target of the assignment. + + + + + Value to be assigned to the target of the assignment. + + + + + + + Represents a simple assignment operation. + + Current usage: + (1) C# simple assignment expression. + (2) VB simple assignment expression. + + + + + + Is this a ref assignment + + + + + + + Represents a compound assignment that mutates the target with the result of a binary operation. + + Current usage: + (1) C# compound assignment expression. + (2) VB compound assignment expression. + + + + + + + Conversion applied to before the operation occurs. + + + + + + + Conversion applied to the result of the binary operation, before it is assigned back to + . + + + + + + Kind of binary operation. + + + + + + if this assignment contains a 'lifted' binary operation. + + + + + + + if overflow checking is performed for the arithmetic operation. + + + + + + Operator method used by the operation, null if the operation does not use an operator method. + + + + + + + Represents a parenthesized operation. + + Current usage: + (1) VB parenthesized expression. + + + + + + Operand enclosed in parentheses. + + + + + + + Represents a binding of an event. + + Current usage: + (1) C# event assignment expression. + (2) VB Add/Remove handler statement. + + + + + + Reference to the event being bound. + + + + + Handler supplied for the event. + + + + + True for adding a binding, false for removing one. + + + + + + + Represents a conditionally accessed operation. Note that is used to refer to the value + of within . + + Current usage: + (1) C# conditional access expression (? or ?. operator). + (2) VB conditional access expression (? or ?. operator). + + + + + + Operation that will be evaluated and accessed if non null. + + + + + + Operation to be evaluated if is non null. + + + + + + + + Represents the value of a conditionally-accessed operation within . + For a conditional access operation of the form someExpr?.Member, this operation is used as the InstanceReceiver for the right operation Member. + See https://github.com/dotnet/roslyn/issues/21279#issuecomment-323153041 for more details. + + Current usage: + (1) C# conditional access instance expression. + (2) VB conditional access instance expression. + + + + + + + + Represents an interpolated string. + + Current usage: + (1) C# interpolated string expression. + (2) VB interpolated string expression. + + + + + + + Constituent parts of interpolated string, each of which is an . + + + + + + + + Represents a creation of anonymous object. + + Current usage: + (1) C# "new { ... }" expression + (2) VB "New With { ... }" expression + + + + + + + Property initializers. + Each initializer is an , with an + as the target whose Instance is an with kind. + + + + + + + + Represents an initialization for an object or collection creation. + + Current usage: + (1) C# object or collection initializer expression. + (2) VB object or collection initializer expression. + For example, object initializer "{ X = x }" within object creation "new Class() { X = x }" and + collection initializer "{ x, y, 3 }" within collection creation "new MyList() { x, y, 3 }". + + + + + + Object member or collection initializers. + + + + + + + Represents an initialization of member within an object initializer with a nested object or collection initializer. + + Current usage: + (1) C# nested member initializer expression. + For example, given an object creation with initializer "new Class() { X = x, Y = { x, y, 3 }, Z = { X = z } }", + member initializers for Y and Z, i.e. "Y = { x, y, 3 }", and "Z = { X = z }" are nested member initializers represented by this operation. + + + + + + + Initialized member reference or an invalid operation for error cases. + + + + + + Member initializer. + + + + + "ICollectionElementInitializerOperation has been replaced with " + nameof(IInvocationOperation) + " and " + nameof(IDynamicInvocationOperation) + + + Obsolete interface that used to represent a collection element initializer. It has been replaced by + and , as appropriate. + + Current usage: + None. This API has been obsoleted in favor of and . + + + + + + + + + + + Represents an operation that gets a string value for the name. + + Current usage: + (1) C# nameof expression. + (2) VB NameOf expression. + + + + + + Argument to the name of operation. + + + + + + + Represents a tuple with one or more elements. + + Current usage: + (1) C# tuple expression. + (2) VB tuple expression. + + + + + + Tuple elements. + + + + + + Natural type of the tuple, or null if tuple doesn't have a natural type. + Natural type can be different from depending on the + conversion context, in which the tuple is used. + + + + + + + + Represents an object creation with a dynamically bound constructor. + + Current usage: + (1) C# "new" expression with dynamic argument(s). + (2) VB late bound "New" expression. + + + + + + Object or collection initializer, if any. + + + + + Dynamically bound arguments, excluding the instance argument. + + + + + + + Represents a reference to a member of a class, struct, or module that is dynamically bound. + + Current usage: + (1) C# dynamic member reference expression. + (2) VB late bound member reference expression. + + + + + + Instance receiver. In VB, this can be null. + + + + + Referenced member. + + + + + Type arguments. + + + + + + The containing type of the referenced member, if different from type of the . + + + + + + + + Represents a invocation that is dynamically bound. + + Current usage: + (1) C# dynamic invocation expression. + (2) C# dynamic collection element initializer. + For example, in the following collection initializer: new C() { do1, do2, do3 } where + the doX objects are of type dynamic, we'll have 3 with do1, do2, and + do3 as their arguments. + (3) VB late bound invocation expression. + (4) VB dynamic collection element initializer. + Similar to the C# example, New C() From {do1, do2, do3} will generate 3 + nodes with do1, do2, and do3 as their arguments, respectively. + + + + + + Dynamically or late bound operation. + + + + + Dynamically bound arguments, excluding the instance argument. + + + + + + + Represents an indexer access that is dynamically bound. + + Current usage: + (1) C# dynamic indexer access expression. + + + + + + Dynamically indexed operation. + + + + + Dynamically bound arguments, excluding the instance argument. + + + + + + + Represents an unrolled/lowered query operation. + For example, for a C# query expression "from x in set where x.Name != null select x.Name", the Operation tree has the following shape: + ITranslatedQueryExpression + IInvocationExpression ('Select' invocation for "select x.Name") + IInvocationExpression ('Where' invocation for "where x.Name != null") + IInvocationExpression ('From' invocation for "from x in set") + + Current usage: + (1) C# query expression. + (2) VB query expression. + + + + + + Underlying unrolled operation. + + + + + + + Represents a delegate creation. This is created whenever a new delegate is created. + + Current usage: + (1) C# delegate creation expression. + (2) VB delegate creation expression. + + + + + + The lambda or method binding that this delegate is created from. + + + + + + + Represents a default value operation. + + Current usage: + (1) C# default value expression. + + + + + + + + Represents an operation that gets for the given . + + Current usage: + (1) C# typeof expression. + (2) VB GetType expression. + + + + + + Type operand. + + + + + + + Represents an operation to compute the size of a given type. + + Current usage: + (1) C# sizeof expression. + + + + + + Type operand. + + + + + + + Represents an operation that creates a pointer value by taking the address of a reference. + + Current usage: + (1) C# address of expression + + + + + + Addressed reference. + + + + + + + Represents an operation that tests if a value matches a specific pattern. + + Current usage: + (1) C# is pattern expression. For example, "x is int i". + + + + + + Underlying operation to test. + + + + + Pattern. + + + + + + + + + + + Represents an or operation. + Note that this operation is different from an as it mutates the , + while unary operator expression does not mutate it's operand. + + Current usage: + (1) C# increment expression or decrement expression. + + + + + + + if this is a postfix expression. if this is a prefix expression. + + + + + + + if this is a 'lifted' increment operator. When there + is an operator that is defined to work on a value type, 'lifted' operators are + created to work on the versions of those + value types. + + + + + + + if overflow checking is performed for the arithmetic operation. + + + + + + Target of the assignment. + + + + + Operator method used by the operation, null if the operation does not use an operator method. + + + + + + + Represents an operation to throw an exception. + + Current usage: + (1) C# throw expression. + (2) C# throw statement. + (2) VB Throw statement. + + + + + + Instance of an exception being thrown. + + + + + + + Represents a assignment with a deconstruction. + + Current usage: + (1) C# deconstruction assignment expression. + + + + + + + + Represents a declaration expression operation. Unlike a regular variable declaration and , this operation represents an "expression" declaring a variable. + + Current usage: + (1) C# declaration expression. For example, + (a) "var (x, y)" is a deconstruction declaration expression with variables x and y. + (b) "(var x, var y)" is a tuple expression with two declaration expressions. + (c) "M(out var x);" is an invocation expression with an out "var x" declaration expression. + + + + + + Underlying expression. + + + + + + + Represents an argument value that has been omitted in an invocation. + + Current usage: + (1) VB omitted argument in an invocation expression. + + + + + + + + Represents an initializer for a field, property, parameter or a local variable declaration. + + Current usage: + (1) C# field, property, parameter or local variable initializer. + (2) VB field(s), property, parameter or local variable initializer. + + + + + + + Local declared in and scoped to the . + + + + + + Underlying initializer value. + + + + + + + Represents an initialization of a field. + + Current usage: + (1) C# field initializer with equals value clause. + (2) VB field(s) initializer with equals value clause or AsNew clause. Multiple fields can be initialized with AsNew clause in VB. + + + + + + Initialized fields. There can be multiple fields for Visual Basic fields declared with AsNew clause. + + + + + + + Represents an initialization of a local variable. + + Current usage: + (1) C# local variable initializer with equals value clause. + (2) VB local variable initializer with equals value clause or AsNew clause. + + + + + + + + Represents an initialization of a property. + + Current usage: + (1) C# property initializer with equals value clause. + (2) VB property initializer with equals value clause or AsNew clause. Multiple properties can be initialized with 'WithEvents' declaration with AsNew clause in VB. + + + + + + Initialized properties. There can be multiple properties for Visual Basic 'WithEvents' declaration with AsNew clause. + + + + + + + Represents an initialization of a parameter at the point of declaration. + + Current usage: + (1) C# parameter initializer with equals value clause. + (2) VB parameter initializer with equals value clause. + + + + + + Initialized parameter. + + + + + + + Represents the initialization of an array instance. + + Current usage: + (1) C# array initializer. + (2) VB array initializer. + + + + + + Values to initialize array elements. + + + + + + Represents a single variable declarator and initializer. + + Current Usage: + (1) C# variable declarator + (2) C# catch variable declaration + (3) VB single variable declaration + (4) VB catch variable declaration + + + In VB, the initializer for this node is only ever used for explicit array bounds initializers. This node corresponds to + the VariableDeclaratorSyntax in C# and the ModifiedIdentifierSyntax in VB. + + + + + Symbol declared by this variable declaration + + + + + Optional initializer of the variable. + + If this variable is in an , the initializer may be located + in the parent operation. Call + to check in all locations. It is only possible to have initializers in both locations in VB invalid code scenarios. + + + + + + + Additional arguments supplied to the declarator in error cases, ignored by the compiler. This only used for the C# case of + DeclaredArgumentSyntax nodes on a VariableDeclaratorSyntax. + + + + + + + Represents a declarator that declares multiple individual variables. + + Current Usage: + (1) C# VariableDeclaration + (2) C# fixed declarations + (3) VB Dim statement declaration groups + (4) VB Using statement variable declarations + + + The initializer of this node is applied to all individual declarations in . There cannot + be initializers in both locations except in invalid code scenarios. + In C#, this node will never have an initializer. + This corresponds to the VariableDeclarationSyntax in C#, and the VariableDeclaratorSyntax in Visual Basic. + + + + + Individual variable declarations declared by this multiple declaration. + + All will have at least 1 , + even if the declaration group only declares 1 variable. + + + + + + Optional initializer of the variable. + In C#, this will always be null. + + + + + + Array dimensions supplied to an array declaration in error cases, ignored by the compiler. This is only used for the C# case of + RankSpecifierSyntax nodes on an ArrayTypeSyntax. + + + + + + + + Represents an argument to a method invocation. + + Current usage: + (1) C# argument to an invocation expression, object creation expression, etc. + (2) VB argument to an invocation expression, object creation expression, etc. + + + + + + Kind of argument. + + + + + Parameter the argument matches. + + + + + Value supplied for the argument. + + + + + Information of the conversion applied to the argument value passing it into the target method. Applicable only to VB Reference arguments. + + + + + Information of the conversion applied to the argument value after the invocation. Applicable only to VB Reference arguments. + + + + + + + Represents a catch clause. + + Current usage: + (1) C# catch clause. + (2) VB Catch clause. + + + + + + + Optional source for exception. This could be any of the following operation: + 1. Declaration for the local catch variable bound to the caught exception (C# and VB) OR + 2. Null, indicating no declaration or expression (C# and VB) + 3. Reference to an existing local or parameter (VB) OR + 4. Other expression for error scenarios (VB) + + + + + + Type of the exception handled by the catch clause. + + + + + + Locals declared by the and/or clause. + + + + + + Filter operation to be executed to determine whether to handle the exception. + + + + + Body of the exception handler. + + + + + + + Represents a switch case section with one or more case clauses to match and one or more operations to execute within the section. + + Current usage: + (1) C# switch section for one or more case clause and set of statements to execute. + (2) VB case block with a case statement for one or more case clause and set of statements to execute. + + + + + + Clauses of the case. + + + + + One or more operations to execute within the switch section. + + + + + Locals declared within the switch case section scoped to the section. + + + + + + Optional combined logical condition that accounts for all . + An instance of with kind + is used to refer to the in context of this expression. + It is not part of list and likely contains duplicate nodes for + nodes exposed by , like , + etc. + Never set for C# at the moment. + + + + + + + + + Represents a case clause. + + Current usage: + (1) C# case clause. + (2) VB Case clause. + + + + + + Kind of the clause. + + + + + Label associated with the case clause, if any. + + + + + + + + Represents a default case clause. + + Current usage: + (1) C# default clause. + (2) VB Case Else clause. + + + + + + + + + Represents a case clause with a pattern and an optional guard operation. + + Current usage: + (1) C# pattern case clause. + + + + + + + Label associated with the case clause. + https://github.com/dotnet/roslyn/issues/27602: Similar property was added to the base interface, consider if we can remove this one. + + + + + + Pattern associated with case clause. + + + + + Guard associated with the pattern case clause. + + + + + + + + Represents a case clause with range of values for comparison. + + Current usage: + (1) VB range case clause of the form "Case x To y". + + + + + + Minimum value of the case range. + + + + + Maximum value of the case range. + + + + + + + + Represents a case clause with custom relational operator for comparison. + + Current usage: + (1) VB relational case clause of the form "Case Is op x". + + + + + + Case value. + + + + + Relational operator used to compare the switch value with the case value. + + + + + + + + Represents a case clause with a single value for comparison. + + Current usage: + (1) C# case clause of the form "case x" + (2) VB case clause of the form "Case x". + + + + + + Case value. + + + + + + + Represents a constituent part of an interpolated string. + + Current usage: + (1) C# interpolated string content. + (2) VB interpolated string content. + + + + + + + + Represents a constituent string literal part of an interpolated string operation. + + Current usage: + (1) C# interpolated string text. + (2) VB interpolated string text. + + + + + + Text content. + + + + + + + Represents a constituent interpolation part of an interpolated string operation. + + Current usage: + (1) C# interpolation part. + (2) VB interpolation part. + + + + + + Expression of the interpolation. + + + + + Optional alignment of the interpolation. + + + + + Optional format string of the interpolation. + + + + + + + Represents a pattern matching operation. + + Current usage: + (1) C# pattern. + + + + + + The input type to the pattern-matching operation. + + + + + The narrowed type of the pattern-matching operation. + + + + + + + Represents a pattern with a constant value. + + Current usage: + (1) C# constant pattern. + + + + + + Constant value of the pattern operation. + + + + + + + Represents a pattern that declares a symbol. + + Current usage: + (1) C# declaration pattern. + + + + + + + The type explicitly specified, or null if it was inferred (e.g. using var in C#). + + + + + + + True if the pattern is of a form that accepts null. + For example, in C# the pattern `var x` will match a null input, + while the pattern `string x` will not. + + + + + + Symbol declared by the pattern, if any. + + + + + + + + + + + Represents a comparison of two operands that returns a bool type. + + Current usage: + (1) C# tuple binary operator expression. + + + + + + Kind of binary operation. + + + + + Left operand. + + + + + Right operand. + + + + + + + Represents a method body operation. + + Current usage: + (1) C# method body + + + + + + Method body corresponding to BaseMethodDeclarationSyntax.Body or AccessorDeclarationSyntax.Body + + + + + Method body corresponding to BaseMethodDeclarationSyntax.ExpressionBody or AccessorDeclarationSyntax.ExpressionBody + + + + + + + + + + + Represents a method body operation. + + Current usage: + (1) C# method body for non-constructor + + + + + + + + + + + + Represents a constructor method body operation. + + Current usage: + (1) C# method body for constructor declaration + + + + + + Local declarations contained within the . + + + + + Constructor initializer, if any. + + + + + + + Represents a discard operation. + + Current usage: C# discard expressions + + + + + + The symbol of the discard operation. + + + + + + + Represents that an intermediate result is being captured. + This node is produced only as part of a . + + + + + An id used to match references to the same intermediate result. + + + + + Value to be captured. + + + + + + + Represents a point of use of an intermediate result captured earlier. + The fact of capturing the result is represented by . + This node is produced only as part of a . + + + + + An id used to match references to the same intermediate result. + + + + + + + Represents result of checking whether the is null. + For reference types this checks if the is a null reference, + for nullable types this checks if the doesn’t have a value. + The node is produced as part of a flow graph during rewrite of + and nodes. + + + + + Value to check. + + + + + + + Represents a exception instance passed by an execution environment to an exception filter or handler. + This node is produced only as part of a . + + + + + + + Represents the check during initialization of a VB static local that is initialized on the first call of the function, and never again. + If the semaphore operation returns true, the static local has not yet been initialized, and the initializer will be run. If it returns + false, then the local has already been initialized, and the static local initializer region will be skipped. + This node is produced only as part of a . + + + + + The static local variable that is possibly initialized. + + + + + + + Represents an anonymous function operation in context of a . + + Current usage: + (1) C# lambda expression. + (2) VB anonymous delegate expression. + + A for the body of the anonymous function is available from + the enclosing . + + + + + Symbol of the anonymous function. + + + + + + + Represents a coalesce assignment operation with a target and a conditionally-evaluated value: + (1) is evaluated for null. If it is null, is evaluated and assigned to target. + (2) is conditionally evaluated if is null, and the result is assigned into . + The result of the entire expression is, which is only evaluated once. + + Current usage: + (1) C# null-coalescing assignment operation Target ??= Value. + + + + + + + + Represents a range operation. + + Current usage: + (1) C# range expressions + + + + + + Left operand. + + + + + Right operand. + + + + + + true if this is a 'lifted' range operation. When there is an + operator that is defined to work on a value type, 'lifted' operators are + created to work on the versions of those + value types. + + + + + + + Factory method used to create this Range value. Can be null if appropriate + symbol was not found. + + + + + + + + Represents the ReDim operation to re-allocate storage space for array variables. + + Current usage: + (1) VB ReDim statement. + + + + + + Individual clauses of the ReDim operation. + + + + + Modifier used to preserve the data in the existing array when you change the size of only the last dimension. + + + + + + + Represents an individual clause of an to re-allocate storage space for a single array variable. + + Current usage: + (1) VB ReDim clause. + + + + + + Operand whose storage space needs to be re-allocated. + + + + + Sizes of the dimensions of the created array instance. + + + + + + Represents a C# recursive pattern. + + + + The type accepted for the recursive pattern. + + + + + + The symbol, if any, used for the fetching values for subpatterns. This is either a Deconstruct + method, the type System.Runtime.CompilerServices.ITuple, or null (for example, in + error cases or when matching a tuple type). + + + + + + This contains the patterns contained within a deconstruction or positional subpattern. + + + + + This contains the (symbol, property) pairs within a property subpattern. + + + + + Symbol declared by the pattern. + + + + + + + Represents a discard pattern. + + Current usage: C# discard pattern + + + + + + + + Represents a switch expression. + + Current usage: + (1) C# switch expression. + + + + + + Value to be switched upon. + + + + + Arms of the switch expression. + + + + + + Represents one arm of a switch expression. + + + + The pattern to match. + + + + + Guard (when clause expression) associated with the switch arm, if any. + + + + + Result value of the enclosing switch expression when this arm matches. + + + + + Locals declared within the switch arm (e.g. pattern locals and locals declared in the guard) scoped to the arm. + + + + + + + Represents an element of a property subpattern, which identifies a member to be matched and the + pattern to match it against. + + + + + + The member being matched in a property subpattern. This can be a + in non-error cases, or an in error cases. + + + + + + The pattern to which the member is matched in a property subpattern. + + + + + + Represents a standalone VB query Aggregate operation with more than one item in Into clause. + + + + + + + Represents a C# fixed statement. + + + + Locals declared. + + + + + Variables to be fixed. + + + + + Body of the fixed, over which the variables are fixed. + + + + + + + Represents a creation of an instance of a NoPia interface, i.e. new I(), where I is an embedded NoPia interface. + + Current usage: + (1) C# NoPia interface instance creation expression. + (2) VB NoPia interface instance creation expression. + + + + + + Object or collection initializer, if any. + + + + + + + Represents a general placeholder when no more specific kind of placeholder is available. + A placeholder is an expression whose meaning is inferred from context. + + + + + + + + Represents a reference through a pointer. + + Current usage: + (1) C# pointer indirection reference expression. + + + + + + Pointer to be dereferenced. + + + + + + + Represents a of operations that are executed with implicit reference to the for member references. + + Current usage: + (1) VB With statement. + + + + + + Body of the with. + + + + + Value to whose members leading-dot-qualified references within the with body bind. + + + + + + + Represents using variable declaration, with scope spanning across the parent . + + Current Usage: + (1) C# using declaration + (1) C# asynchronous using declaration + + + + + + The variables declared by this using declaration. + + + + + True if this is an asynchronous using declaration. + + + + + + + Represents a negated pattern. + + Current usage: + (1) C# negated pattern. + + + + + + The negated pattern. + + + + + + + Represents a binary ("and" or "or") pattern. + + Current usage: + (1) C# "and" and "or" patterns. + + + + + + Kind of binary pattern; either or . + + + + + The pattern on the left. + + + + + The pattern on the right. + + + + + + + Represents a pattern comparing the input with a given type. + + Current usage: + (1) C# type pattern. + + + + + + + The type explicitly specified, or null if it was inferred (e.g. using var in C#). + + + + + + + + Represents a pattern comparing the input with a constant value using a relational operator. + + Current usage: + (1) C# relational pattern. + + + + + + The kind of the relational operator. + + + + + Constant value of the pattern operation. + + + + + + + Represents cloning of an object instance. + + Current usage: + (1) C# with expression. + + + + + + Operand to be cloned. + + + + + Clone method to be invoked on the value. + + + + + With collection initializer. + + + + diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ParenthesizedVariableDesignationSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ParenthesizedVariableDesignationSyntaxWrapper.cs index fc3d04895..2ebd16050 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ParenthesizedVariableDesignationSyntaxWrapper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ParenthesizedVariableDesignationSyntaxWrapper.cs @@ -1,121 +1,17 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Lightup { - using System; - using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; - internal struct ParenthesizedVariableDesignationSyntaxWrapper : ISyntaxWrapper + internal partial struct ParenthesizedVariableDesignationSyntaxWrapper : ISyntaxWrapper { - internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.ParenthesizedVariableDesignationSyntax"; - private static readonly Type WrappedType; - - private static readonly Func OpenParenTokenAccessor; - private static readonly Func> VariablesAccessor; - private static readonly Func CloseParenTokenAccessor; - private static readonly Func WithOpenParenTokenAccessor; - private static readonly Func, CSharpSyntaxNode> WithVariablesAccessor; - private static readonly Func WithCloseParenTokenAccessor; - - private readonly CSharpSyntaxNode node; - - static ParenthesizedVariableDesignationSyntaxWrapper() - { - WrappedType = WrapperHelper.GetWrappedType(typeof(ParenthesizedVariableDesignationSyntaxWrapper)); - OpenParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(OpenParenToken)); - VariablesAccessor = LightupHelpers.CreateSeparatedSyntaxListPropertyAccessor(WrappedType, nameof(Variables)); - CloseParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(CloseParenToken)); - WithOpenParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(OpenParenToken)); - WithVariablesAccessor = LightupHelpers.CreateSeparatedSyntaxListWithPropertyAccessor(WrappedType, nameof(Variables)); - WithCloseParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(CloseParenToken)); - } - - private ParenthesizedVariableDesignationSyntaxWrapper(CSharpSyntaxNode node) - { - this.node = node; - } - - public CSharpSyntaxNode SyntaxNode => this.node; - - public SyntaxToken OpenParenToken - { - get - { - return OpenParenTokenAccessor(this.SyntaxNode); - } - } - - public SeparatedSyntaxListWrapper Variables - { - get - { - return VariablesAccessor(this.SyntaxNode); - } - } - - public SyntaxToken CloseParenToken - { - get - { - return CloseParenTokenAccessor(this.SyntaxNode); - } - } - - public static explicit operator ParenthesizedVariableDesignationSyntaxWrapper(VariableDesignationSyntaxWrapper node) - { - return (ParenthesizedVariableDesignationSyntaxWrapper)node.SyntaxNode; - } - - public static explicit operator ParenthesizedVariableDesignationSyntaxWrapper(SyntaxNode node) - { - if (node == null) - { - return default(ParenthesizedVariableDesignationSyntaxWrapper); - } - - if (!IsInstance(node)) - { - throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); - } - - return new ParenthesizedVariableDesignationSyntaxWrapper((CSharpSyntaxNode)node); - } - - public static implicit operator VariableDesignationSyntaxWrapper(ParenthesizedVariableDesignationSyntaxWrapper wrapper) - { - return VariableDesignationSyntaxWrapper.FromUpcast(wrapper.node); - } - - public static implicit operator CSharpSyntaxNode(ParenthesizedVariableDesignationSyntaxWrapper wrapper) - { - return wrapper.node; - } - - public static bool IsInstance(SyntaxNode node) - { - return node != null && LightupHelpers.CanWrapNode(node, WrappedType); - } - public ParenthesizedVariableDesignationSyntaxWrapper AddVariables(params VariableDesignationSyntaxWrapper[] items) { return new ParenthesizedVariableDesignationSyntaxWrapper(this.WithVariables(this.Variables.AddRange(items))); } - - public ParenthesizedVariableDesignationSyntaxWrapper WithOpenParenToken(SyntaxToken identifier) - { - return new ParenthesizedVariableDesignationSyntaxWrapper(WithOpenParenTokenAccessor(this.SyntaxNode, identifier)); - } - - public ParenthesizedVariableDesignationSyntaxWrapper WithVariables(SeparatedSyntaxListWrapper variables) - { - return new ParenthesizedVariableDesignationSyntaxWrapper(WithVariablesAccessor(this.SyntaxNode, variables)); - } - - public ParenthesizedVariableDesignationSyntaxWrapper WithCloseParenToken(SyntaxToken identifier) - { - return new ParenthesizedVariableDesignationSyntaxWrapper(WithCloseParenTokenAccessor(this.SyntaxNode, identifier)); - } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/PositionalPatternClauseSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/PositionalPatternClauseSyntaxWrapper.cs new file mode 100644 index 000000000..bcff14ca5 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/PositionalPatternClauseSyntaxWrapper.cs @@ -0,0 +1,17 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using Microsoft.CodeAnalysis.CSharp; + + internal partial struct PositionalPatternClauseSyntaxWrapper : ISyntaxWrapper + { + public PositionalPatternClauseSyntaxWrapper AddSubpatterns(params SubpatternSyntaxWrapper[] items) + { + return new PositionalPatternClauseSyntaxWrapper(this.WithSubpatterns(this.Subpatterns.AddRange(items))); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/PropertyPatternClauseSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/PropertyPatternClauseSyntaxWrapper.cs new file mode 100644 index 000000000..6128729e6 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/PropertyPatternClauseSyntaxWrapper.cs @@ -0,0 +1,17 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using Microsoft.CodeAnalysis.CSharp; + + internal partial struct PropertyPatternClauseSyntaxWrapper : ISyntaxWrapper + { + public PropertyPatternClauseSyntaxWrapper AddSubpatterns(params SubpatternSyntaxWrapper[] items) + { + return new PropertyPatternClauseSyntaxWrapper(this.WithSubpatterns(this.Subpatterns.AddRange(items))); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/RecursivePatternSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/RecursivePatternSyntaxWrapper.cs new file mode 100644 index 000000000..75d4b6719 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/RecursivePatternSyntaxWrapper.cs @@ -0,0 +1,34 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using Microsoft.CodeAnalysis.CSharp; + + internal partial struct RecursivePatternSyntaxWrapper : ISyntaxWrapper + { + public RecursivePatternSyntaxWrapper AddPositionalPatternClauseSubpatterns(params SubpatternSyntaxWrapper[] items) + { + var positionalPatternClause = this.PositionalPatternClause; + if (positionalPatternClause.SyntaxNode is null) + { + positionalPatternClause = SyntaxFactoryEx.PositionalPatternClause(); + } + + return this.WithPositionalPatternClause(positionalPatternClause.WithSubpatterns(positionalPatternClause.Subpatterns.AddRange(items))); + } + + public RecursivePatternSyntaxWrapper AddPropertyPatternClauseSubpatterns(params SubpatternSyntaxWrapper[] items) + { + var propertyPatternClause = this.PropertyPatternClause; + if (propertyPatternClause.SyntaxNode is null) + { + propertyPatternClause = SyntaxFactoryEx.PropertyPatternClause(); + } + + return this.WithPropertyPatternClause(propertyPatternClause.WithSubpatterns(propertyPatternClause.Subpatterns.AddRange(items))); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SeparatedSyntaxListWrapper`1.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SeparatedSyntaxListWrapper`1.cs index 18be917f2..3e7f2f000 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SeparatedSyntaxListWrapper`1.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SeparatedSyntaxListWrapper`1.cs @@ -1,11 +1,14 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Lightup { using System; using System.Collections; using System.Collections.Generic; + using System.Collections.Immutable; using System.ComponentModel; using System.Linq; using Microsoft.CodeAnalysis; @@ -51,11 +54,19 @@ public abstract TNode this[int index] public static bool operator ==(SeparatedSyntaxListWrapper left, SeparatedSyntaxListWrapper right) { + // Currently unused + _ = left; + _ = right; + throw new NotImplementedException(); } public static bool operator !=(SeparatedSyntaxListWrapper left, SeparatedSyntaxListWrapper right) { + // Currently unused + _ = left; + _ = right; + throw new NotImplementedException(); } @@ -158,7 +169,7 @@ public Enumerator(SeparatedSyntaxListWrapper wrapper) { this.wrapper = wrapper; this.index = -1; - this.current = default(TNode); + this.current = default; } public TNode Current => this.current; @@ -213,7 +224,7 @@ public bool MoveNext() public void Reset() { this.index = -1; - this.current = default(TNode); + this.current = default; } } @@ -222,6 +233,11 @@ internal sealed class AutoWrapSeparatedSyntaxList : SeparatedSyntaxList { private readonly SeparatedSyntaxList syntaxList; + public AutoWrapSeparatedSyntaxList() + : this(default) + { + } + public AutoWrapSeparatedSyntaxList(SeparatedSyntaxList syntaxList) { this.syntaxList = syntaxList; @@ -317,7 +333,7 @@ public override string ToString() private sealed class UnsupportedSyntaxList : SeparatedSyntaxListWrapper { - private static readonly SeparatedSyntaxList SyntaxList = default(SeparatedSyntaxList); + private static readonly SeparatedSyntaxList SyntaxList = default; public UnsupportedSyntaxList() { @@ -351,7 +367,7 @@ public override TNode First() => SyntaxWrapper.Wrap(SyntaxList.First()); public override TNode FirstOrDefault() - => SyntaxWrapper.Wrap(default(SyntaxNode)); + => SyntaxWrapper.Wrap(default); public override int GetHashCode() => SyntaxList.GetHashCode(); @@ -391,7 +407,7 @@ public override int LastIndexOf(Func predicate) => SyntaxList.LastIndexOf(node => predicate(SyntaxWrapper.Wrap(node))); public override TNode LastOrDefault() - => SyntaxWrapper.Wrap(default(SyntaxNode)); + => SyntaxWrapper.Wrap(default); public override SeparatedSyntaxListWrapper Remove(TNode node) { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/StackAllocArrayCreationExpressionSyntaxExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/StackAllocArrayCreationExpressionSyntaxExtensions.cs new file mode 100644 index 000000000..e27a81787 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/StackAllocArrayCreationExpressionSyntaxExtensions.cs @@ -0,0 +1,32 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal static class StackAllocArrayCreationExpressionSyntaxExtensions + { + private static readonly Func InitializerAccessor; + private static readonly Func WithInitializerAccessor; + + static StackAllocArrayCreationExpressionSyntaxExtensions() + { + InitializerAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(typeof(StackAllocArrayCreationExpressionSyntax), nameof(Initializer)); + WithInitializerAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(typeof(StackAllocArrayCreationExpressionSyntax), nameof(Initializer)); + } + + public static InitializerExpressionSyntax Initializer(this StackAllocArrayCreationExpressionSyntax syntax) + { + return InitializerAccessor(syntax); + } + + public static StackAllocArrayCreationExpressionSyntax WithInitializer(this StackAllocArrayCreationExpressionSyntax syntax, InitializerExpressionSyntax initializer) + { + return WithInitializerAccessor(syntax, initializer); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/StatementSyntaxExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/StatementSyntaxExtensions.cs new file mode 100644 index 000000000..8312e725b --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/StatementSyntaxExtensions.cs @@ -0,0 +1,38 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal static class StatementSyntaxExtensions + { + private static readonly Func> AttributeListsAccessor; + private static readonly Func, StatementSyntax> WithAttributeListsAccessor; + + static StatementSyntaxExtensions() + { + AttributeListsAccessor = LightupHelpers.CreateSyntaxPropertyAccessor>(typeof(StatementSyntax), nameof(AttributeLists)); + WithAttributeListsAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor>(typeof(StatementSyntax), nameof(AttributeLists)); + } + + public static SyntaxList AttributeLists(this StatementSyntax syntax) + { + return AttributeListsAccessor(syntax); + } + + public static StatementSyntax WithAttributeLists(this StatementSyntax syntax, SyntaxList attributeLists) + { + return WithAttributeListsAccessor(syntax, attributeLists); + } + + public static StatementSyntax AddAttributeLists(this StatementSyntax syntax, params AttributeListSyntax[] items) + { + return syntax.WithAttributeLists(syntax.AttributeLists().AddRange(items)); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SwitchExpressionSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SwitchExpressionSyntaxWrapper.cs new file mode 100644 index 000000000..ba364c904 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SwitchExpressionSyntaxWrapper.cs @@ -0,0 +1,17 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal partial struct SwitchExpressionSyntaxWrapper : ISyntaxWrapper + { + public SwitchExpressionSyntaxWrapper AddArms(params SwitchExpressionArmSyntaxWrapper[] arms) + { + return new SwitchExpressionSyntaxWrapper(this.WithArms(this.Arms.AddRange(arms))); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SymbolDisplayLocalOptionsEx.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SymbolDisplayLocalOptionsEx.cs index 010008d05..e7ce1e16a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SymbolDisplayLocalOptionsEx.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SymbolDisplayLocalOptionsEx.cs @@ -1,5 +1,5 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SymbolDisplayMemberOptionsEx.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SymbolDisplayMemberOptionsEx.cs index bf111a3f0..cc10f078a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SymbolDisplayMemberOptionsEx.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SymbolDisplayMemberOptionsEx.cs @@ -1,5 +1,5 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SymbolKindEx.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SymbolKindEx.cs index defc2a50f..83d683b17 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SymbolKindEx.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SymbolKindEx.cs @@ -1,5 +1,5 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/Syntax.xml b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/Syntax.xml new file mode 100644 index 000000000..452c34af0 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/Syntax.xml @@ -0,0 +1,4942 @@ + + + + + + + + + + + + + Provides the base class from which the classes that represent name syntax nodes are derived. This is an abstract class. + + + + + + SyntaxToken representing the identifier of the simple name. + + + + + Provides the base class from which the classes that represent simple name syntax nodes are derived. This is an abstract class. + + + + + + + + + SyntaxToken representing the keyword for the kind of the identifier name. + + + + Class which represents the syntax node for identifier name. + + + Creates an IdentifierNameSyntax node. + + + + + + + NameSyntax node representing the name on the left side of the dot token of the qualified name. + + + + + + SyntaxToken representing the dot. + + + + + SimpleNameSyntax node representing the name on the right side of the dot token of the qualified name. + + + + Class which represents the syntax node for qualified name. + + + Creates a QualifiedNameSyntax node. + + + + + + + + SyntaxToken representing the name of the identifier of the generic name. + + + + + TypeArgumentListSyntax node representing the list of type arguments of the generic name. + + + + Class which represents the syntax node for generic name. + + + Creates a GenericNameSyntax node. + + + + + + + + SyntaxToken representing less than. + + + + + SeparatedSyntaxList of TypeSyntax node representing the type arguments. + + + + + + SyntaxToken representing greater than. + + + + Class which represents the syntax node for type argument list. + + + Creates a TypeArgumentListSyntax node. + + + + + + + IdentifierNameSyntax node representing the name of the alias + + + + + + SyntaxToken representing colon colon. + + + + + SimpleNameSyntax node representing the name that is being alias qualified. + + + + Class which represents the syntax node for alias qualified name. + + + Creates an AliasQualifiedNameSyntax node. + + + + + + Provides the base class from which the classes that represent type syntax nodes are derived. This is an abstract class. + + + + + + + + + + + + + + + + + + + + + + + SyntaxToken which represents the keyword corresponding to the predefined type. + + + + Class which represents the syntax node for predefined types. + + + Creates a PredefinedTypeSyntax node. + + + + + + + TypeSyntax node representing the type of the element of the array. + + + + + SyntaxList of ArrayRankSpecifierSyntax nodes representing the list of rank specifiers for the array. + + + + Class which represents the syntax node for the array type. + + + Creates an ArrayTypeSyntax node. + + + + + + + + + + + + + + + + + TypeSyntax node that represents the element type of the pointer. + + + + + + SyntaxToken representing the asterisk. + + + + Class which represents the syntax node for pointer type. + + + Creates a PointerTypeSyntax node. + + + + + + + + SyntaxToken representing the delegate keyword. + + + + + + SyntaxToken representing the asterisk. + + + + + Node representing the optional calling convention. + + + + + List of the parameter types and return type of the function pointer. + + + + + + Function pointer parameter list syntax. + + + + + + SyntaxToken representing the less than token. + + + + + SeparatedSyntaxList of ParameterSyntaxes representing the list of parameters and return type. + + + + + + SyntaxToken representing the greater than token. + + + + + + Function pointer calling convention syntax. + + + + + + + SyntaxToken representing whether the calling convention is managed or unmanaged. + + + + + Optional list of identifiers that will contribute to an unmanaged calling convention. + + + + + + Function pointer calling convention syntax. + + + + + + SyntaxToken representing open bracket. + + + + + SeparatedSyntaxList of calling convention identifiers. + + + + + + SyntaxToken representing close bracket. + + + + + + Individual function pointer unmanaged calling convention. + + + + + + SyntaxToken representing the calling convention identifier. + + + + + + + + TypeSyntax node representing the type of the element. + + + + + + SyntaxToken representing the question mark. + + + + Class which represents the syntax node for a nullable type. + + + Creates a NullableTypeSyntax node. + + + + + + + + SyntaxToken representing the open parenthesis. + + + + + + + SyntaxToken representing the close parenthesis. + + + + Class which represents the syntax node for tuple type. + + + Creates a TupleTypeSyntax node. + + + + + Tuple type element. + + + + + Gets the type of the tuple element. + + + + + Gets the name of the tuple element. + + + + + + + + + + SyntaxToken representing the omitted type argument. + + + + Class which represents a placeholder in the type argument list of an unbound generic type. + + + Creates an OmittedTypeArgumentSyntax node. + + + + + The ref modifier of a method's return value or a local. + + + + + + + + + Gets the optional "readonly" keyword. + + + + + + + + + Provides the base class from which the classes that represent expression syntax nodes are derived. This is an abstract class. + + + + + + + + SyntaxToken representing the open parenthesis. + + + + + ExpressionSyntax node representing the expression enclosed within the parenthesis. + + + + + + SyntaxToken representing the close parenthesis. + + + + Class which represents the syntax node for parenthesized expression. + + + Creates a ParenthesizedExpressionSyntax node. + + + + + + + + SyntaxToken representing the open parenthesis. + + + + + SeparatedSyntaxList of ArgumentSyntax representing the list of arguments. + + + + + + SyntaxToken representing the close parenthesis. + + + + Class which represents the syntax node for tuple expression. + + + Creates a TupleExpressionSyntax node. + + + + + + + + + + + + + + + + + + + + + + " + + SyntaxToken representing the kind of the operator of the prefix unary expression. + + + + + ExpressionSyntax representing the operand of the prefix unary expression. + + + + Class which represents the syntax node for prefix unary expression. + + + Creates a PrefixUnaryExpressionSyntax node. + + + + + + + + SyntaxToken representing the kind "await" keyword. + + + + + ExpressionSyntax representing the operand of the "await" operator. + + + + Class which represents the syntax node for an "await" expression. + + + Creates an AwaitExpressionSyntax node. + + + + + + + + + ExpressionSyntax representing the operand of the postfix unary expression. + + + + + + + + SyntaxToken representing the kind of the operator of the postfix unary expression. + + + + Class which represents the syntax node for postfix unary expression. + + + Creates a PostfixUnaryExpressionSyntax node. + + + + + + + + ExpressionSyntax node representing the object that the member belongs to. + + + + + + + SyntaxToken representing the kind of the operator in the member access expression. + + + + + SimpleNameSyntax node representing the member being accessed. + + + + Class which represents the syntax node for member access expression. + + + Creates a MemberAccessExpressionSyntax node. + + + + + + + ExpressionSyntax node representing the object conditionally accessed. + + + + + + SyntaxToken representing the question mark. + + + + + ExpressionSyntax node representing the access expression to be executed when the object is not null. + + + + Class which represents the syntax node for conditional access expression. + + + Creates a ConditionalAccessExpressionSyntax node. + + + + + + + + SyntaxToken representing dot. + + + + + SimpleNameSyntax node representing the member being bound to. + + + + Class which represents the syntax node for member binding expression. + + + Creates a MemberBindingExpressionSyntax node. + + + + + + + BracketedArgumentListSyntax node representing the list of arguments of the element binding expression. + + + + Class which represents the syntax node for element binding expression. + + + Creates an ElementBindingExpressionSyntax node. + + + + + + + ExpressionSyntax node representing the expression on the left of the range operator. + + + + + + SyntaxToken representing the operator of the range expression. + + + + + ExpressionSyntax node representing the expression on the right of the range operator. + + + + Class which represents the syntax node for a range expression. + + + Creates an RangeExpressionSyntax node. + + + + + + + BracketedArgumentListSyntax node representing the list of arguments of the implicit element access expression. + + + + Class which represents the syntax node for implicit element access expression. + + + Creates an ImplicitElementAccessSyntax node. + + + + + + + + + + + + + + + + + + + + + + + + + + + ExpressionSyntax node representing the expression on the left of the binary operator. + + + + + + + + + + + + + + + + + + + + + + + + + + SyntaxToken representing the operator of the binary expression. + + + + + ExpressionSyntax node representing the expression on the right of the binary operator. + + + + Class which represents an expression that has a binary operator. + + + Creates a BinaryExpressionSyntax node. + + + + + + + + + + + + + + + + + + ExpressionSyntax node representing the expression on the left of the assignment operator. + + + + + + + + + + + + + + + + + SyntaxToken representing the operator of the assignment expression. + + + + + ExpressionSyntax node representing the expression on the right of the assignment operator. + + + + Class which represents an expression that has an assignment operator. + + + Creates an AssignmentExpressionSyntax node. + + + + + + + ExpressionSyntax node representing the condition of the conditional expression. + + + + + + SyntaxToken representing the question mark. + + + + + ExpressionSyntax node representing the expression to be executed when the condition is true. + + + + + + SyntaxToken representing the colon. + + + + + ExpressionSyntax node representing the expression to be executed when the condition is false. + + + + Class which represents the syntax node for conditional expression. + + + Creates a ConditionalExpressionSyntax node. + + + + + Provides the base class from which the classes that represent instance expression syntax nodes are derived. This is an abstract class. + + + + + + + + SyntaxToken representing the this keyword. + + + + Class which represents the syntax node for a this expression. + + + Creates a ThisExpressionSyntax node. + + + + + + + + SyntaxToken representing the base keyword. + + + + Class which represents the syntax node for a base expression. + + + Creates a BaseExpressionSyntax node. + + + + + + + + + + + + + + + + + + + + + + SyntaxToken representing the keyword corresponding to the kind of the literal expression. + + + + Class which represents the syntax node for a literal expression. + + + Creates a LiteralExpressionSyntax node. + + + + + + + + SyntaxToken representing the MakeRefKeyword. + + + + + + SyntaxToken representing open parenthesis. + + + + + Argument of the primary function. + + + + + + SyntaxToken representing close parenthesis. + + + + Class which represents the syntax node for MakeRef expression. + + + Creates a MakeRefExpressionSyntax node. + + + + + + + + SyntaxToken representing the RefTypeKeyword. + + + + + + SyntaxToken representing open parenthesis. + + + + + Argument of the primary function. + + + + + + SyntaxToken representing close parenthesis. + + + + Class which represents the syntax node for RefType expression. + + + Creates a RefTypeExpressionSyntax node. + + + + + + + + SyntaxToken representing the RefValueKeyword. + + + + + + SyntaxToken representing open parenthesis. + + + + + Typed reference expression. + + + + + + Comma separating the arguments. + + + + + The type of the value. + + + + + + SyntaxToken representing close parenthesis. + + + + Class which represents the syntax node for RefValue expression. + + + Creates a RefValueExpressionSyntax node. + + + + + + + + + + SyntaxToken representing the checked or unchecked keyword. + + + + + + SyntaxToken representing open parenthesis. + + + + + Argument of the primary function. + + + + + + SyntaxToken representing close parenthesis. + + + + Class which represents the syntax node for Checked or Unchecked expression. + + + Creates a CheckedExpressionSyntax node. + + + + + + + + SyntaxToken representing the DefaultKeyword. + + + + + + SyntaxToken representing open parenthesis. + + + + + Argument of the primary function. + + + + + + SyntaxToken representing close parenthesis. + + + + Class which represents the syntax node for Default expression. + + + Creates a DefaultExpressionSyntax node. + + + + + + + + SyntaxToken representing the TypeOfKeyword. + + + + + + SyntaxToken representing open parenthesis. + + + + + The expression to return type of. + + + + + + SyntaxToken representing close parenthesis. + + + + Class which represents the syntax node for TypeOf expression. + + + Creates a TypeOfExpressionSyntax node. + + + + + + + + SyntaxToken representing the SizeOfKeyword. + + + + + + SyntaxToken representing open parenthesis. + + + + + Argument of the primary function. + + + + + + SyntaxToken representing close parenthesis. + + + + Class which represents the syntax node for SizeOf expression. + + + Creates a SizeOfExpressionSyntax node. + + + + + + + ExpressionSyntax node representing the expression part of the invocation. + + + + + ArgumentListSyntax node representing the list of arguments of the invocation expression. + + + + Class which represents the syntax node for invocation expression. + + + Creates an InvocationExpressionSyntax node. + + + + + + + ExpressionSyntax node representing the expression which is accessing the element. + + + + + BracketedArgumentListSyntax node representing the list of arguments of the element access expression. + + + + Class which represents the syntax node for element access expression. + + + Creates an ElementAccessExpressionSyntax node. + + + + + + SeparatedSyntaxList of ArgumentSyntax nodes representing the list of arguments. + + + + Provides the base class from which the classes that represent argument list syntax nodes are derived. This is an abstract class. + + + + + + + + SyntaxToken representing open parenthesis. + + + + + SeparatedSyntaxList of ArgumentSyntax representing the list of arguments. + + + + + + SyntaxToken representing close parenthesis. + + + + Class which represents the syntax node for the list of arguments. + + + Creates an ArgumentListSyntax node. + + + + + + + + SyntaxToken representing open bracket. + + + + + SeparatedSyntaxList of ArgumentSyntax representing the list of arguments. + + + + + + SyntaxToken representing close bracket. + + + + Class which represents the syntax node for bracketed argument list. + + + Creates a BracketedArgumentListSyntax node. + + + + + + + NameColonSyntax node representing the optional name arguments. + + + + + + + + SyntaxToken representing the optional ref or out keyword. + + + + + ExpressionSyntax node representing the argument. + + + + Class which represents the syntax node for argument. + + + Creates an ArgumentSyntax node. + + + + + + + + + + + + + + + + + + + IdentifierNameSyntax representing the identifier name. + + + + + SyntaxToken representing colon. + + + + Class which represents the syntax node for name colon syntax. + + + Creates a NameColonSyntax node. + + + + + + + + Declaration representing the variable declared in an out parameter or deconstruction. + + + + Class which represents the syntax node for the variable declaration in an out var declaration or a deconstruction declaration. + + + Creates a DeclarationExpression node. + + + + + + + + SyntaxToken representing the open parenthesis. + + + + + TypeSyntax node representing the type to which the expression is being cast. + + + + + + SyntaxToken representing the close parenthesis. + + + + + ExpressionSyntax node representing the expression that is being casted. + + + + Class which represents the syntax node for cast expression. + + + Creates a CastExpressionSyntax node. + + + + + Provides the base class from which the classes that represent anonymous function expressions are derived. + + + + + + + BlockSyntax node representing the body of the anonymous function. + Only one of Block or ExpressionBody will be non-null. + + + + + + + ExpressionSyntax node representing the body of the anonymous function. + Only one of Block or ExpressionBody will be non-null. + + + + + + + + + + + + SyntaxToken representing the delegate keyword. + + + + + List of parameters of the anonymous method expression, or null if there no parameters are specified. + + + + + + BlockSyntax node representing the body of the anonymous function. + This will never be null. + + + + + + + Inherited from AnonymousFunctionExpressionSyntax, but not used for + AnonymousMethodExpressionSyntax. This will always be null. + + + + + Class which represents the syntax node for anonymous method expression. + + + Creates an AnonymousMethodExpressionSyntax node. + + + + + Provides the base class from which the classes that represent lambda expressions are derived. + + + + + + + SyntaxToken representing equals greater than. + + + + + + + + + + + ParameterSyntax node representing the parameter of the lambda expression. + + + + + + + SyntaxToken representing equals greater than. + + + + + + + BlockSyntax node representing the body of the lambda. + Only one of Block or ExpressionBody will be non-null. + + + + + + + ExpressionSyntax node representing the body of the lambda. + Only one of Block or ExpressionBody will be non-null. + + + + + + Class which represents the syntax node for a simple lambda expression. + + + Creates a SimpleLambdaExpressionSyntax node. + + + + + + + + + + + + + + + + + ParameterListSyntax node representing the list of parameters for the lambda expression. + + + + + + + SyntaxToken representing equals greater than. + + + + + + + BlockSyntax node representing the body of the lambda. + Only one of Block or ExpressionBody will be non-null. + + + + + + + ExpressionSyntax node representing the body of the lambda. + Only one of Block or ExpressionBody will be non-null. + + + + + + Class which represents the syntax node for parenthesized lambda expression. + + + Creates a ParenthesizedLambdaExpressionSyntax node. + + + + + + + + + + + + SyntaxToken representing the open brace. + + + + + SeparatedSyntaxList of ExpressionSyntax representing the list of expressions in the initializer expression. + + + + + + SyntaxToken representing the close brace. + + + + Class which represents the syntax node for initializer expression. + + + Creates an InitializerExpressionSyntax node. + + + + + + + SyntaxToken representing the new keyword. + + + + + ArgumentListSyntax representing the list of arguments passed as part of the object creation expression. + + + + + InitializerExpressionSyntax representing the initializer expression for the object being created. + + + + + + + + + SyntaxToken representing the new keyword. + + + + + ArgumentListSyntax representing the list of arguments passed as part of the object creation expression. + + + + + InitializerExpressionSyntax representing the initializer expression for the object being created. + + + + Class which represents the syntax node for implicit object creation expression. + + + Creates an ImplicitObjectCreationExpressionSyntax node. + + + + + + + + SyntaxToken representing the new keyword. + + + + + TypeSyntax representing the type of the object being created. + + + + + ArgumentListSyntax representing the list of arguments passed as part of the object creation expression. + + + + + InitializerExpressionSyntax representing the initializer expression for the object being created. + + + + Class which represents the syntax node for object creation expression. + + + Creates an ObjectCreationExpressionSyntax node. + + + + + + + + + + + InitializerExpressionSyntax representing the initializer expression for the with expression. + + + + + + + + NameEqualsSyntax representing the optional name of the member being initialized. + + + + + ExpressionSyntax representing the value the member is initialized with. + + + + Creates an AnonymousObjectMemberDeclaratorSyntax node. + + + + + + + + SyntaxToken representing the new keyword. + + + + + + SyntaxToken representing the open brace. + + + + + SeparatedSyntaxList of AnonymousObjectMemberDeclaratorSyntax representing the list of object member initializers. + + + + + + SyntaxToken representing the close brace. + + + + Class which represents the syntax node for anonymous object creation expression. + + + Creates an AnonymousObjectCreationExpressionSyntax node. + + + + + + + + SyntaxToken representing the new keyword. + + + + + ArrayTypeSyntax node representing the type of the array. + + + + + InitializerExpressionSyntax node representing the initializer of the array creation expression. + + + + Class which represents the syntax node for array creation expression. + + + Creates an ArrayCreationExpressionSyntax node. + + + + + + + + SyntaxToken representing the new keyword. + + + + + + SyntaxToken representing the open bracket. + + + + + SyntaxList of SyntaxToken representing the commas in the implicit array creation expression. + + + + + + SyntaxToken representing the close bracket. + + + + + InitializerExpressionSyntax representing the initializer expression of the implicit array creation expression. + + + + Class which represents the syntax node for implicit array creation expression. + + + Creates an ImplicitArrayCreationExpressionSyntax node. + + + + + + + + SyntaxToken representing the stackalloc keyword. + + + + + TypeSyntax node representing the type of the stackalloc array. + + + + + InitializerExpressionSyntax node representing the initializer of the stackalloc array creation expression. + + + + Class which represents the syntax node for stackalloc array creation expression. + + + Creates a StackAllocArrayCreationExpressionSyntax node. + + + + + + + + SyntaxToken representing the stackalloc keyword. + + + + + + SyntaxToken representing the open bracket. + + + + + + SyntaxToken representing the close bracket. + + + + + InitializerExpressionSyntax representing the initializer expression of the implicit stackalloc array creation expression. + + + + Class which represents the syntax node for implicit stackalloc array creation expression. + + + Creates an ImplicitStackAllocArrayCreationExpressionSyntax node. + + + + + + + + + + + + + + + + + + + + + + + + + + Gets the identifier. + + + + + + + + + + + + + + + + Gets the identifier. + + + + + + + + + + + + + + + + + Gets the identifier. + + + + + + + + + + + + + + + + + + + + + + + + + Gets the identifier. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gets the identifier. + + + + + + + + + + + SyntaxToken representing the omitted array size expression. + + + + Class which represents a placeholder in an array size list. + + + Creates an OmittedArraySizeExpressionSyntax node. + + + + + + + + + The first part of an interpolated string, $" or $@" + + + + + List of parts of the interpolated string, each one is either a literal part or an interpolation. + + + + + + The closing quote of the interpolated string. + + + + + + + + ExpressionSyntax node representing the expression on the left of the "is" operator. + + + + + + + + PatternSyntax node representing the pattern on the right of the "is" operator. + + + + Class which represents a simple pattern-matching expression using the "is" keyword. + + + Creates an IsPatternExpressionSyntax node. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ExpressionSyntax node representing the constant expression. + + + + + + + + + + + + + + + + + + + + + + + + + + SyntaxToken representing the operator of the relational pattern. + + + + + + + + + The type for the type pattern. + + + + + + + + + + + + + + + + + + + + + + + + + + + + The text contents of a part of the interpolated string. + + + + + + + + + + + + + + + + + + + + + + + + + + + The text contents of the format specifier for an interpolation. + + + + + + + + Always empty on a global statement. + + + Always empty on a global statement. + + + + + + Represents the base class for all statements syntax classes. + + + + + + + + + + + + + + + + + + + + + + Gets the identifier. + + + + + + + + + + + + + Gets the optional semicolon token. + + + + + + + + + + + + + + + + + + + Gets the modifier list. + + + + + + + + + + + + + + + + + + + Gets the identifier. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gets the identifier. + + + + + + + Gets a SyntaxToken that represents the colon following the statement's label. + + + + + Represents a labeled statement syntax. + + + Creates a LabeledStatementSyntax node + + + + + + + + + + + + Gets a SyntaxToken that represents the goto keyword. + + + + + + + + + Gets a SyntaxToken that represents the case or default keywords if any exists. + + + + + + + Gets a constant expression for a goto case statement. + + + + + + + + Gets a SyntaxToken that represents the semi-colon at the end of the statement. + + + + + + Represents a goto statement syntax + + + + + Creates a GotoStatementSyntax node. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gets the identifier. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The variable(s) of the loop. In correct code this is a tuple + literal, declaration expression with a tuple designator, or + a discard syntax in the form of a simple identifier. In broken + code it could be something else. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gets a SyntaxToken that represents the if keyword. + + + + + + + + Gets a SyntaxToken that represents the open parenthesis before the if statement's condition expression. + + + + + + + Gets an ExpressionSyntax that represents the condition of the if statement. + + + + + + + + Gets a SyntaxToken that represents the close parenthesis after the if statement's condition expression. + + + + + + + Gets a StatementSyntax the represents the statement to be executed when the condition is true. + + + + + + + Gets an ElseClauseSyntax that represents the statement to be executed when the condition is false if such statement exists. + + + + + + Represents an if statement syntax. + + + + Creates an IfStatementSyntax node + + + + + + + + + Gets a syntax token + + + + + + Represents an else statement syntax. + + + Creates a ElseClauseSyntax node + + + + + + + + + + + Gets a SyntaxToken that represents the switch keyword. + + + + + + + + Gets a SyntaxToken that represents the open parenthesis preceding the switch governing expression. + + + + + + + Gets an ExpressionSyntax representing the expression of the switch statement. + + + + + + + + Gets a SyntaxToken that represents the close parenthesis following the switch governing expression. + + + + + + + + Gets a SyntaxToken that represents the open braces preceding the switch sections. + + + + + + + Gets a SyntaxList of SwitchSectionSyntax's that represents the switch sections of the switch statement. + + + + + + + + Gets a SyntaxToken that represents the open braces following the switch sections. + + + + + Represents a switch statement syntax. + + + Creates a SwitchStatementSyntax node. + + + + + + + + Gets a SyntaxList of SwitchLabelSyntax's the represents the possible labels that control can transfer to within the section. + + + + + + + Gets a SyntaxList of StatementSyntax's the represents the statements to be executed when control transfer to a label the belongs to the section. + + + + + Represents a switch section syntax of a switch statement. + + + Creates a SwitchSectionSyntax node. + + + + + + + Gets a SyntaxToken that represents a case or default keyword that belongs to a switch label. + + + + + + + + Gets a SyntaxToken that represents the colon that terminates the switch label. + + + + + Represents a switch label within a switch statement. + + + + + + + + Gets the case keyword token. + + + + + + Gets a PatternSyntax that represents the pattern that gets matched for the case label. + + + + + + + Represents a case label within a switch statement. + + + Creates a CaseMatchLabelSyntax node. + + + + + + + + Gets the case keyword token. + + + + + + Gets an ExpressionSyntax that represents the constant expression that gets matched for the case label. + + + + + + Represents a case label within a switch statement. + + + Creates a CaseSwitchLabelSyntax node. + + + + + + + + Gets the default keyword token. + + + + + Represents a default label within a switch statement. + + + Creates a DefaultSwitchLabelSyntax node. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gets the attribute declaration list. + + + + + + + + + + + + + SyntaxToken representing the extern keyword. + + + + + + SyntaxToken representing the alias keyword. + + + + + Gets the identifier. + + + + + + + SyntaxToken representing the semicolon token. + + + + + Represents an ExternAlias directive syntax, e.g. "extern alias MyAlias;" with specifying "/r:MyAlias=SomeAssembly.dll " on the compiler command line. + + + + Creates an ExternAliasDirectiveSyntax node + + + + + + + + + + + + + + + + + + + + + + Member declaration syntax. + + + + Gets the attribute declaration list. + + + + + Gets the modifier list. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gets the optional semicolon token. + + + + + + + + + + + + + + + + + + + + + + Class representing one or more attributes applied to a language construct. + + + + + + Gets the open bracket token. + + + + + Gets the optional construct targeted by the attribute. + + + + + Gets the attribute declaration list. + + + + + + Gets the close bracket token. + + + + + + Class representing what language construct an attribute targets. + + + + + Gets the identifier. + + + + + + Gets the colon token. + + + + + + Attribute syntax. + + + + + Gets the name. + + + + + + + Attribute argument list syntax. + + + + + Gets the open paren token. + + + + + + Gets the arguments syntax list. + + + + + Gets the close paren token. + + + + + + + Attribute argument syntax. + + + + + + + + + Gets the expression. + + + + + + Class representing an identifier name followed by an equals token. + + + + + Gets the identifier name. + + + + + + + + + + Type parameter list syntax. + + + + + Gets the < token. + + + + + + Gets the parameter list. + + + + + Gets the > token. + + + + + + + Type parameter syntax. + + + + + Gets the attribute declaration list. + + + + + + + + + Gets the identifier. + + + + + + + Base class for type declaration syntax. + + + + Gets the identifier. + + + + + + Gets the base type list. + + + + + Gets the open brace token. + + + + + + Gets the close brace token. + + + + + + Gets the optional semicolon token. + + + + + + + Base class for type declaration syntax (class, struct, interface, record). + + + + Gets the type keyword token ("class", "struct", "interface", "record"). + + + + + + Gets the type constraint list. + + + + + Gets the member declarations. + + + + + + Class type declaration syntax. + + + + + + + Gets the class keyword token. + + + + + + + + + + + + + + + + + + + + + + + Struct type declaration syntax. + + + + + + + Gets the struct keyword token. + + + + + + + + + + + + + + + + + + + + + + + Interface type declaration syntax. + + + + + + + Gets the interface keyword token. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Enum type declaration syntax. + + + + + + + Gets the enum keyword token. + + + + + + + + + + + + + + Gets the members declaration list. + + + + + + + + Gets the optional semicolon token. + + + + + + + Delegate declaration syntax. + + + + + + + Gets the "delegate" keyword. + + + + + + Gets the return type. + + + + + Gets the identifier. + + + + + + + Gets the parameter list. + + + + + Gets the constraint clause list. + + + + + Gets the semicolon token. + + + + + + + + + + + Gets the identifier. + + + + + + + + Base list syntax. + + + + + Gets the colon token. + + + + + + Gets the base type references. + + + + + + + Provides the base class from which the classes that represent base type syntax nodes are derived. This is an abstract class. + + + + + + + + + + + + + + + + + + + + Type parameter constraint clause. + + + + + + + + Gets the identifier. + + + + + + Gets the colon token. + + + + + + Gets the constraints list. + + + + + + Base type for type parameter constraint syntax. + + + + + Constructor constraint syntax. + + + + + Gets the "new" keyword. + + + + + + Gets the open paren keyword. + + + + + + Gets the close paren keyword. + + + + + + + Class or struct constraint syntax. + + + + + + Gets the constraint keyword ("class" or "struct"). + + + + + + + + SyntaxToken representing the question mark. + + + + + + Type constraint syntax. + + + + + Gets the type syntax. + + + + + + Default constraint syntax. + + + + + Gets the "default" keyword. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Base type for method declaration syntax. + + + + Gets the parameter list. + + + + + + + + + Gets the optional semicolon token. + + + + + + + + + Method declaration syntax. + + + + + + + Gets the return type syntax. + + + + + + Gets the identifier. + + + + + + + + Gets the constraint clause list. + + + + + + + + + Gets the optional semicolon token. + + + + + + + + + + Operator declaration syntax. + + + + + + + Gets the return type. + + + + + + Gets the "operator" keyword. + + + + + + Gets the operator token. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gets the optional semicolon token. + + + + + + + + + + Conversion operator declaration syntax. + + + + + + + Gets the "implicit" or "explicit" token. + + + + + + + + Gets the "operator" token. + + + + + + Gets the type. + + + + + + + + + + Gets the optional semicolon token. + + + + + + + + + Constructor declaration syntax. + + + + + + + Gets the identifier. + + + + + + + + + + + + Gets the optional semicolon token. + + + + + + + + + Constructor initializer syntax. + + + + + + Gets the colon token. + + + + + + Gets the "this" or "base" keyword. + + + + + + + + + Destructor declaration syntax. + + + + + + + Gets the tilde token. + + + + + + Gets the identifier. + + + + + + + + + + + Gets the optional semicolon token. + + + + + + + + + Base type for property declaration syntax. + + + + Gets the type syntax. + + + + + Gets the optional explicit interface specifier. + + + + + + + + + + + + + Gets the identifier. + + + + + + + + + + + + + + + + + + + The syntax for the expression body of an expression-bodied member. + + + + + + + + + + + + + + + + + + + Gets the identifier. + + + + + + + + + + + + + + + + + + + + + + Gets the parameter list. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Gets the attribute declaration list. + + + + + Gets the modifier list. + + + + + + + + + + + Gets the keyword token, or identifier if an erroneous accessor declaration. + + + + + + Gets the optional body block which may be empty, but it is null if there are no braces. + + + + + + Gets the optional expression body. + + + + + Gets the optional semicolon token. + + + + + + + + + Base type for parameter list syntax. + + + + Gets the parameter list. + + + + + + Parameter list syntax. + + + + + Gets the open paren token. + + + + + + + Gets the close paren token. + + + + + + + Parameter list syntax with surrounding brackets. + + + + + Gets the open bracket token. + + + + + + + Gets the close bracket token. + + + + + + + Base parameter syntax. + + + + Gets the attribute declaration list. + + + + + Gets the modifier list. + + + + + + + Parameter syntax. + + + + + Gets the attribute declaration list. + + + + + Gets the modifier list. + + + + + + Gets the identifier. + + + + + + + + + Parameter syntax. + + + + + Gets the attribute declaration list. + + + + + Gets the modifier list. + + + + + + n + + + + + + + + + + + + + + + + + + + + + + + A symbol referenced by a cref attribute (e.g. in a <see> or <seealso> documentation comment tag). + For example, the M in <see cref="M" />. + + + + + + + A symbol reference that definitely refers to a type. + For example, "int", "A::B", "A.B", "A<T>", but not "M()" (has parameter list) or "this" (indexer). + NOTE: TypeCrefSyntax, QualifiedCrefSyntax, and MemberCrefSyntax overlap. The syntax in a TypeCrefSyntax + will always be bound as type, so it's safer to use QualifiedCrefSyntax or MemberCrefSyntax if the symbol + might be a non-type member. + + + + + + + + + A symbol reference to a type or non-type member that is qualified by an enclosing type or namespace. + For example, cref="System.String.ToString()". + NOTE: TypeCrefSyntax, QualifiedCrefSyntax, and MemberCrefSyntax overlap. The syntax in a TypeCrefSyntax + will always be bound as type, so it's safer to use QualifiedCrefSyntax or MemberCrefSyntax if the symbol + might be a non-type member. + + + + + + + + + + + + + The unqualified part of a CrefSyntax. + For example, "ToString()" in "object.ToString()". + NOTE: TypeCrefSyntax, QualifiedCrefSyntax, and MemberCrefSyntax overlap. The syntax in a TypeCrefSyntax + will always be bound as type, so it's safer to use QualifiedCrefSyntax or MemberCrefSyntax if the symbol + might be a non-type member. + + + + + + + A MemberCrefSyntax specified by a name (an identifier, predefined type keyword, or an alias-qualified name, + with an optional type parameter list) and an optional parameter list. + For example, "M", "M<T>" or "M(int)". + Also, "A::B()" or "string()". + + + + + + + + + + A MemberCrefSyntax specified by a this keyword and an optional parameter list. + For example, "this" or "this[int]". + + + + + + + + + + + + A MemberCrefSyntax specified by an operator keyword, an operator symbol and an optional parameter list. + For example, "operator +" or "operator -[int]". + NOTE: the operator must be overloadable. + + + + + + + + + Gets the operator token. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A MemberCrefSyntax specified by an implicit or explicit keyword, an operator keyword, a destination type, and an optional parameter list. + For example, "implicit operator int" or "explicit operator MyType(int)". + + + + + + + + + + + + + + + + + A list of cref parameters with surrounding punctuation. + Unlike regular parameters, cref parameters do not have names. + + + + + Gets the parameter list. + + + + + + + A parenthesized list of cref parameters. + + + + + + Gets the open paren token. + + + + + + + Gets the close paren token. + + + + + + + + A bracketed list of cref parameters. + + + + + + Gets the open bracket token. + + + + + + + Gets the close bracket token. + + + + + + + + An element of a BaseCrefParameterListSyntax. + Unlike a regular parameter, a cref parameter has only an optional ref or out keyword and a type - + there is no name and there are no attributes or other modifiers. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxFactoryEx.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxFactoryEx.cs new file mode 100644 index 000000000..fbcfcfa90 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxFactoryEx.cs @@ -0,0 +1,324 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Linq; + using System.Linq.Expressions; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal static class SyntaxFactoryEx + { + private static readonly Func, CSharpSyntaxNode> PositionalPatternClauseAccessor1; + private static readonly Func, SyntaxToken, CSharpSyntaxNode> PositionalPatternClauseAccessor2; + private static readonly Func, CSharpSyntaxNode> PropertyPatternClauseAccessor1; + private static readonly Func, SyntaxToken, CSharpSyntaxNode> PropertyPatternClauseAccessor2; + private static readonly Func TupleElementAccessor1; + private static readonly Func TupleElementAccessor2; + private static readonly Func, ExpressionSyntax> TupleExpressionAccessor1; + private static readonly Func, SyntaxToken, ExpressionSyntax> TupleExpressionAccessor2; + private static readonly Func, TypeSyntax> TupleTypeAccessor1; + private static readonly Func, SyntaxToken, TypeSyntax> TupleTypeAccessor2; + + static SyntaxFactoryEx() + { + var positionalPatternClauseMethods = typeof(SyntaxFactory).GetTypeInfo().GetDeclaredMethods(nameof(PositionalPatternClause)); + var positionalPatternClauseMethod = positionalPatternClauseMethods.FirstOrDefault(method => method.GetParameters().Length == 1 && method.GetParameters()[0].ParameterType == typeof(SeparatedSyntaxList<>).MakeGenericType(SyntaxWrapperHelper.GetWrappedType(typeof(SubpatternSyntaxWrapper)))); + if (positionalPatternClauseMethod is object) + { + var subpatternsParameter = Expression.Parameter(typeof(SeparatedSyntaxListWrapper), "subpatterns"); + var underlyingListProperty = typeof(SeparatedSyntaxListWrapper).GetTypeInfo().GetDeclaredProperty(nameof(SeparatedSyntaxListWrapper.UnderlyingList)); + Expression, CSharpSyntaxNode>> expression = + Expression.Lambda, CSharpSyntaxNode>>( + Expression.Call( + positionalPatternClauseMethod, + Expression.Convert( + Expression.Call(subpatternsParameter, underlyingListProperty.GetMethod), + positionalPatternClauseMethod.GetParameters()[0].ParameterType)), + subpatternsParameter); + PositionalPatternClauseAccessor1 = expression.Compile(); + } + else + { + PositionalPatternClauseAccessor1 = ThrowNotSupportedOnFallback, CSharpSyntaxNode>(nameof(SyntaxFactory), nameof(PositionalPatternClause)); + } + + positionalPatternClauseMethod = positionalPatternClauseMethods.FirstOrDefault(method => method.GetParameters().Length == 3 + && method.GetParameters()[0].ParameterType == typeof(SyntaxToken) + && method.GetParameters()[1].ParameterType == typeof(SeparatedSyntaxList<>).MakeGenericType(SyntaxWrapperHelper.GetWrappedType(typeof(SubpatternSyntaxWrapper))) + && method.GetParameters()[2].ParameterType == typeof(SyntaxToken)); + if (positionalPatternClauseMethod is object) + { + var openParenTokenParameter = Expression.Parameter(typeof(SyntaxToken), "openParenToken"); + var subpatternsParameter = Expression.Parameter(typeof(SeparatedSyntaxListWrapper), "subpatterns"); + var closeParenTokenParameter = Expression.Parameter(typeof(SyntaxToken), "closeParenToken"); + + var underlyingListProperty = typeof(SeparatedSyntaxListWrapper).GetTypeInfo().GetDeclaredProperty(nameof(SeparatedSyntaxListWrapper.UnderlyingList)); + + Expression, SyntaxToken, CSharpSyntaxNode>> expression = + Expression.Lambda, SyntaxToken, CSharpSyntaxNode>>( + Expression.Call( + positionalPatternClauseMethod, + openParenTokenParameter, + Expression.Convert( + Expression.Call(subpatternsParameter, underlyingListProperty.GetMethod), + positionalPatternClauseMethod.GetParameters()[1].ParameterType), + closeParenTokenParameter), + openParenTokenParameter, + subpatternsParameter, + closeParenTokenParameter); + PositionalPatternClauseAccessor2 = expression.Compile(); + } + else + { + PositionalPatternClauseAccessor2 = ThrowNotSupportedOnFallback, SyntaxToken, TypeSyntax>(nameof(SyntaxFactory), nameof(PositionalPatternClause)); + } + + var propertyPatternClauseMethods = typeof(SyntaxFactory).GetTypeInfo().GetDeclaredMethods(nameof(PropertyPatternClause)); + var propertyPatternClauseMethod = propertyPatternClauseMethods.FirstOrDefault(method => method.GetParameters().Length == 1 && method.GetParameters()[0].ParameterType == typeof(SeparatedSyntaxList<>).MakeGenericType(SyntaxWrapperHelper.GetWrappedType(typeof(SubpatternSyntaxWrapper)))); + if (propertyPatternClauseMethod is object) + { + var subpatternsParameter = Expression.Parameter(typeof(SeparatedSyntaxListWrapper), "subpatterns"); + var underlyingListProperty = typeof(SeparatedSyntaxListWrapper).GetTypeInfo().GetDeclaredProperty(nameof(SeparatedSyntaxListWrapper.UnderlyingList)); + Expression, CSharpSyntaxNode>> expression = + Expression.Lambda, CSharpSyntaxNode>>( + Expression.Call( + propertyPatternClauseMethod, + Expression.Convert( + Expression.Call(subpatternsParameter, underlyingListProperty.GetMethod), + propertyPatternClauseMethod.GetParameters()[0].ParameterType)), + subpatternsParameter); + PropertyPatternClauseAccessor1 = expression.Compile(); + } + else + { + PropertyPatternClauseAccessor1 = ThrowNotSupportedOnFallback, CSharpSyntaxNode>(nameof(SyntaxFactory), nameof(PropertyPatternClause)); + } + + propertyPatternClauseMethod = propertyPatternClauseMethods.FirstOrDefault(method => method.GetParameters().Length == 3 + && method.GetParameters()[0].ParameterType == typeof(SyntaxToken) + && method.GetParameters()[1].ParameterType == typeof(SeparatedSyntaxList<>).MakeGenericType(SyntaxWrapperHelper.GetWrappedType(typeof(SubpatternSyntaxWrapper))) + && method.GetParameters()[2].ParameterType == typeof(SyntaxToken)); + if (propertyPatternClauseMethod is object) + { + var openBraceTokenParameter = Expression.Parameter(typeof(SyntaxToken), "openBraceToken"); + var subpatternsParameter = Expression.Parameter(typeof(SeparatedSyntaxListWrapper), "subpatterns"); + var closeBraceTokenParameter = Expression.Parameter(typeof(SyntaxToken), "closeBraceToken"); + + var underlyingListProperty = typeof(SeparatedSyntaxListWrapper).GetTypeInfo().GetDeclaredProperty(nameof(SeparatedSyntaxListWrapper.UnderlyingList)); + + Expression, SyntaxToken, CSharpSyntaxNode>> expression = + Expression.Lambda, SyntaxToken, CSharpSyntaxNode>>( + Expression.Call( + propertyPatternClauseMethod, + openBraceTokenParameter, + Expression.Convert( + Expression.Call(subpatternsParameter, underlyingListProperty.GetMethod), + propertyPatternClauseMethod.GetParameters()[1].ParameterType), + closeBraceTokenParameter), + openBraceTokenParameter, + subpatternsParameter, + closeBraceTokenParameter); + PropertyPatternClauseAccessor2 = expression.Compile(); + } + else + { + PropertyPatternClauseAccessor2 = ThrowNotSupportedOnFallback, SyntaxToken, TypeSyntax>(nameof(SyntaxFactory), nameof(PropertyPatternClause)); + } + + var tupleElementMethods = typeof(SyntaxFactory).GetTypeInfo().GetDeclaredMethods(nameof(TupleElement)); + var tupleElementMethod = tupleElementMethods.FirstOrDefault(method => method.GetParameters().Length == 1 && method.GetParameters()[0].ParameterType == typeof(TypeSyntax)); + if (tupleElementMethod is object) + { + var typeParameter = Expression.Parameter(typeof(TypeSyntax), "type"); + Expression> expression = + Expression.Lambda>( + Expression.Call(tupleElementMethod, typeParameter), + typeParameter); + TupleElementAccessor1 = expression.Compile(); + } + else + { + TupleElementAccessor1 = ThrowNotSupportedOnFallback(nameof(SyntaxFactory), nameof(TupleElement)); + } + + tupleElementMethod = tupleElementMethods.FirstOrDefault(method => method.GetParameters().Length == 2 && method.GetParameters()[0].ParameterType == typeof(TypeSyntax) && method.GetParameters()[1].ParameterType == typeof(SyntaxToken)); + if (tupleElementMethod is object) + { + var typeParameter = Expression.Parameter(typeof(TypeSyntax), "type"); + var identifierParameter = Expression.Parameter(typeof(SyntaxToken), "identifier"); + Expression> expression = + Expression.Lambda>( + Expression.Call(tupleElementMethod, typeParameter, identifierParameter), + typeParameter, + identifierParameter); + TupleElementAccessor2 = expression.Compile(); + } + else + { + TupleElementAccessor2 = ThrowNotSupportedOnFallback(nameof(SyntaxFactory), nameof(TupleElement)); + } + + var tupleExpressionMethods = typeof(SyntaxFactory).GetTypeInfo().GetDeclaredMethods(nameof(TupleExpression)); + var tupleExpressionMethod = tupleExpressionMethods.FirstOrDefault(method => method.GetParameters().Length == 1 && method.GetParameters()[0].ParameterType == typeof(SeparatedSyntaxList)); + if (tupleExpressionMethod is object) + { + var argumentsParameter = Expression.Parameter(typeof(SeparatedSyntaxList), "arguments"); + Expression, ExpressionSyntax>> expression = + Expression.Lambda, ExpressionSyntax>>( + Expression.Call(tupleExpressionMethod, argumentsParameter), + argumentsParameter); + TupleExpressionAccessor1 = expression.Compile(); + } + else + { + TupleExpressionAccessor1 = ThrowNotSupportedOnFallback, ExpressionSyntax>(nameof(SyntaxFactory), nameof(TupleExpression)); + } + + tupleExpressionMethod = tupleExpressionMethods.FirstOrDefault(method => method.GetParameters().Length == 3 + && method.GetParameters()[0].ParameterType == typeof(SyntaxToken) + && method.GetParameters()[1].ParameterType == typeof(SeparatedSyntaxList) + && method.GetParameters()[2].ParameterType == typeof(SyntaxToken)); + if (tupleExpressionMethod is object) + { + var openParenTokenParameter = Expression.Parameter(typeof(SyntaxToken), "openParenToken"); + var argumentsParameter = Expression.Parameter(typeof(SeparatedSyntaxList), "arguments"); + var closeParenTokenParameter = Expression.Parameter(typeof(SyntaxToken), "closeParenToken"); + Expression, SyntaxToken, ExpressionSyntax>> expression = + Expression.Lambda, SyntaxToken, ExpressionSyntax>>( + Expression.Call(tupleExpressionMethod, openParenTokenParameter, argumentsParameter, closeParenTokenParameter), + openParenTokenParameter, + argumentsParameter, + closeParenTokenParameter); + TupleExpressionAccessor2 = expression.Compile(); + } + else + { + TupleExpressionAccessor2 = ThrowNotSupportedOnFallback, SyntaxToken, ExpressionSyntax>(nameof(SyntaxFactory), nameof(TupleExpression)); + } + + var tupleTypeMethods = typeof(SyntaxFactory).GetTypeInfo().GetDeclaredMethods(nameof(TupleType)); + var tupleTypeMethod = tupleTypeMethods.FirstOrDefault(method => method.GetParameters().Length == 1 && method.GetParameters()[0].ParameterType == typeof(SeparatedSyntaxList<>).MakeGenericType(SyntaxWrapperHelper.GetWrappedType(typeof(TupleElementSyntaxWrapper)))); + if (tupleTypeMethod is object) + { + var elementsParameter = Expression.Parameter(typeof(SeparatedSyntaxListWrapper), "elements"); + var underlyingListProperty = typeof(SeparatedSyntaxListWrapper).GetTypeInfo().GetDeclaredProperty(nameof(SeparatedSyntaxListWrapper.UnderlyingList)); + Expression, TypeSyntax>> expression = + Expression.Lambda, TypeSyntax>>( + Expression.Call( + tupleTypeMethod, + Expression.Convert( + Expression.Call(elementsParameter, underlyingListProperty.GetMethod), + tupleTypeMethod.GetParameters()[0].ParameterType)), + elementsParameter); + TupleTypeAccessor1 = expression.Compile(); + } + else + { + TupleTypeAccessor1 = ThrowNotSupportedOnFallback, TypeSyntax>(nameof(SyntaxFactory), nameof(TupleType)); + } + + tupleTypeMethod = tupleTypeMethods.FirstOrDefault(method => method.GetParameters().Length == 3 + && method.GetParameters()[0].ParameterType == typeof(SyntaxToken) + && method.GetParameters()[1].ParameterType == typeof(SeparatedSyntaxList<>).MakeGenericType(SyntaxWrapperHelper.GetWrappedType(typeof(TupleElementSyntaxWrapper))) + && method.GetParameters()[2].ParameterType == typeof(SyntaxToken)); + if (tupleTypeMethod is object) + { + var openParenTokenParameter = Expression.Parameter(typeof(SyntaxToken), "openParenToken"); + var elementsParameter = Expression.Parameter(typeof(SeparatedSyntaxListWrapper), "elements"); + var closeParenTokenParameter = Expression.Parameter(typeof(SyntaxToken), "closeParenToken"); + + var underlyingListProperty = typeof(SeparatedSyntaxListWrapper).GetTypeInfo().GetDeclaredProperty(nameof(SeparatedSyntaxListWrapper.UnderlyingList)); + + Expression, SyntaxToken, TypeSyntax>> expression = + Expression.Lambda, SyntaxToken, TypeSyntax>>( + Expression.Call( + tupleTypeMethod, + openParenTokenParameter, + Expression.Convert( + Expression.Call(elementsParameter, underlyingListProperty.GetMethod), + tupleTypeMethod.GetParameters()[1].ParameterType), + closeParenTokenParameter), + openParenTokenParameter, + elementsParameter, + closeParenTokenParameter); + TupleTypeAccessor2 = expression.Compile(); + } + else + { + TupleTypeAccessor2 = ThrowNotSupportedOnFallback, SyntaxToken, TypeSyntax>(nameof(SyntaxFactory), nameof(TupleType)); + } + } + + public static PositionalPatternClauseSyntaxWrapper PositionalPatternClause(SeparatedSyntaxListWrapper subpatterns = default) + { + return (PositionalPatternClauseSyntaxWrapper)PositionalPatternClauseAccessor1(subpatterns); + } + + public static PositionalPatternClauseSyntaxWrapper PositionalPatternClause(SyntaxToken openParenToken, SeparatedSyntaxListWrapper subpatterns, SyntaxToken closeParenToken) + { + return (PositionalPatternClauseSyntaxWrapper)PositionalPatternClauseAccessor2(openParenToken, subpatterns, closeParenToken); + } + + public static PropertyPatternClauseSyntaxWrapper PropertyPatternClause(SeparatedSyntaxListWrapper subpatterns = default) + { + return (PropertyPatternClauseSyntaxWrapper)PropertyPatternClauseAccessor1(subpatterns); + } + + public static PropertyPatternClauseSyntaxWrapper PropertyPatternClause(SyntaxToken openBraceToken, SeparatedSyntaxListWrapper subpatterns, SyntaxToken closeBraceToken) + { + return (PropertyPatternClauseSyntaxWrapper)PropertyPatternClauseAccessor2(openBraceToken, subpatterns, closeBraceToken); + } + + public static TupleElementSyntaxWrapper TupleElement(TypeSyntax type) + { + return (TupleElementSyntaxWrapper)TupleElementAccessor1(type); + } + + public static TupleElementSyntaxWrapper TupleElement(TypeSyntax type, SyntaxToken identifier) + { + return (TupleElementSyntaxWrapper)TupleElementAccessor2(type, identifier); + } + + public static TupleExpressionSyntaxWrapper TupleExpression(SeparatedSyntaxList arguments = default) + { + return (TupleExpressionSyntaxWrapper)TupleExpressionAccessor1(arguments); + } + + public static TupleExpressionSyntaxWrapper TupleExpression(SyntaxToken openParenToken, SeparatedSyntaxList arguments, SyntaxToken closeParenToken) + { + return (TupleExpressionSyntaxWrapper)TupleExpressionAccessor2(openParenToken, arguments, closeParenToken); + } + + public static TupleTypeSyntaxWrapper TupleType(SeparatedSyntaxListWrapper elements = default) + { + return (TupleTypeSyntaxWrapper)TupleTypeAccessor1(elements); + } + + public static TupleTypeSyntaxWrapper TupleType(SyntaxToken openParenToken, SeparatedSyntaxListWrapper elements, SyntaxToken closeParenToken) + { + return (TupleTypeSyntaxWrapper)TupleTypeAccessor2(openParenToken, elements, closeParenToken); + } + + private static Func ThrowNotSupportedOnFallback(string typeName, string methodName) + { + return _ => throw new NotSupportedException($"{typeName}.{methodName} is not supported in this version"); + } + + private static Func ThrowNotSupportedOnFallback(string typeName, string methodName) + { + return (_, __) => throw new NotSupportedException($"{typeName}.{methodName} is not supported in this version"); + } + + private static Func ThrowNotSupportedOnFallback(string typeName, string methodName) + { + return (arg1, arg2, arg3) => throw new NotSupportedException($"{typeName}.{methodName} is not supported in this version"); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxFactsEx.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxFactsEx.cs new file mode 100644 index 000000000..88483d6ef --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxFactsEx.cs @@ -0,0 +1,74 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using System.Linq.Expressions; + using System.Reflection; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + + internal static class SyntaxFactsEx + { + private static readonly Func TryGetInferredMemberNameAccessor; + private static readonly Func IsReservedTupleElementNameAccessor; + + static SyntaxFactsEx() + { + string FallbackAccessor(SyntaxNode syntax) + { + if (syntax == null) + { + // Unlike an extension method which would throw ArgumentNullException here, the light-up + // behavior needs to match behavior of the underlying property. + throw new NullReferenceException(); + } + + return null; + } + + var tryGetInferredMemberNameMethod = typeof(SyntaxFacts).GetTypeInfo().GetDeclaredMethod(nameof(TryGetInferredMemberName)); + if (tryGetInferredMemberNameMethod is object) + { + var syntaxParameter = Expression.Parameter(typeof(SyntaxNode), "syntax"); + Expression> expression = + Expression.Lambda>( + Expression.Call(tryGetInferredMemberNameMethod, syntaxParameter), + syntaxParameter); + TryGetInferredMemberNameAccessor = expression.Compile(); + } + else + { + TryGetInferredMemberNameAccessor = FallbackAccessor; + } + + var isReservedTupleElementNameMethod = typeof(SyntaxFacts).GetTypeInfo().GetDeclaredMethod(nameof(IsReservedTupleElementName)); + if (isReservedTupleElementNameMethod is object) + { + var elementNameParameter = Expression.Parameter(typeof(string), "elementName"); + Expression> expression = + Expression.Lambda>( + Expression.Call(isReservedTupleElementNameMethod, elementNameParameter), + elementNameParameter); + IsReservedTupleElementNameAccessor = expression.Compile(); + } + else + { + IsReservedTupleElementNameAccessor = _ => false; + } + } + + public static string TryGetInferredMemberName(this SyntaxNode syntax) + { + return TryGetInferredMemberNameAccessor(syntax); + } + + public static bool IsReservedTupleElementName(string elementName) + { + return IsReservedTupleElementNameAccessor(elementName); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxKindEx.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxKindEx.cs index e020e4fb3..b3c2d27c6 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxKindEx.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxKindEx.cs @@ -1,5 +1,5 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Lightup { @@ -7,10 +7,31 @@ namespace StyleCop.Analyzers.Lightup internal static class SyntaxKindEx { + public const SyntaxKind DotDotToken = (SyntaxKind)8222; + public const SyntaxKind QuestionQuestionEqualsToken = (SyntaxKind)8284; + public const SyntaxKind OrKeyword = (SyntaxKind)8438; + public const SyntaxKind AndKeyword = (SyntaxKind)8439; + public const SyntaxKind NotKeyword = (SyntaxKind)8440; + public const SyntaxKind InitKeyword = (SyntaxKind)8443; + public const SyntaxKind ManagedKeyword = (SyntaxKind)8445; + public const SyntaxKind UnmanagedKeyword = (SyntaxKind)8446; + public const SyntaxKind RequiredKeyword = (SyntaxKind)8447; + public const SyntaxKind FileKeyword = (SyntaxKind)8449; + public const SyntaxKind NullableKeyword = (SyntaxKind)8486; + public const SyntaxKind EnableKeyword = (SyntaxKind)8487; + public const SyntaxKind WarningsKeyword = (SyntaxKind)8488; + public const SyntaxKind AnnotationsKeyword = (SyntaxKind)8489; + public const SyntaxKind VarKeyword = (SyntaxKind)8490; public const SyntaxKind UnderscoreToken = (SyntaxKind)8491; + public const SyntaxKind ConflictMarkerTrivia = (SyntaxKind)8564; public const SyntaxKind IsPatternExpression = (SyntaxKind)8657; + public const SyntaxKind RangeExpression = (SyntaxKind)8658; + public const SyntaxKind ImplicitObjectCreationExpression = (SyntaxKind)8659; + public const SyntaxKind CoalesceAssignmentExpression = (SyntaxKind)8725; + public const SyntaxKind IndexExpression = (SyntaxKind)8741; public const SyntaxKind DefaultLiteralExpression = (SyntaxKind)8755; public const SyntaxKind LocalFunctionStatement = (SyntaxKind)8830; + public const SyntaxKind FileScopedNamespaceDeclaration = (SyntaxKind)8845; public const SyntaxKind TupleType = (SyntaxKind)8924; public const SyntaxKind TupleElement = (SyntaxKind)8925; public const SyntaxKind TupleExpression = (SyntaxKind)8926; @@ -22,9 +43,32 @@ internal static class SyntaxKindEx public const SyntaxKind CasePatternSwitchLabel = (SyntaxKind)9009; public const SyntaxKind WhenClause = (SyntaxKind)9013; public const SyntaxKind DiscardDesignation = (SyntaxKind)9014; + public const SyntaxKind RecursivePattern = (SyntaxKind)9020; + public const SyntaxKind PropertyPatternClause = (SyntaxKind)9021; + public const SyntaxKind Subpattern = (SyntaxKind)9022; + public const SyntaxKind PositionalPatternClause = (SyntaxKind)9023; + public const SyntaxKind DiscardPattern = (SyntaxKind)9024; + public const SyntaxKind SwitchExpression = (SyntaxKind)9025; + public const SyntaxKind SwitchExpressionArm = (SyntaxKind)9026; + public const SyntaxKind VarPattern = (SyntaxKind)9027; + public const SyntaxKind ParenthesizedPattern = (SyntaxKind)9028; + public const SyntaxKind SlicePattern = (SyntaxKind)9034; + public const SyntaxKind ListPattern = (SyntaxKind)9035; public const SyntaxKind DeclarationExpression = (SyntaxKind)9040; public const SyntaxKind RefExpression = (SyntaxKind)9050; public const SyntaxKind RefType = (SyntaxKind)9051; public const SyntaxKind ThrowExpression = (SyntaxKind)9052; + public const SyntaxKind ImplicitStackAllocArrayCreationExpression = (SyntaxKind)9053; + public const SyntaxKind SuppressNullableWarningExpression = (SyntaxKind)9054; + public const SyntaxKind NullableDirectiveTrivia = (SyntaxKind)9055; + public const SyntaxKind FunctionPointerType = (SyntaxKind)9056; + public const SyntaxKind FunctionPointerParameter = (SyntaxKind)9057; + public const SyntaxKind InitAccessorDeclaration = (SyntaxKind)9060; + public const SyntaxKind WithExpression = (SyntaxKind)9061; + public const SyntaxKind WithInitializerExpression = (SyntaxKind)9062; + public const SyntaxKind RecordDeclaration = (SyntaxKind)9063; + public const SyntaxKind FunctionPointerUnmanagedCallingConventionList = (SyntaxKind)9066; + public const SyntaxKind RecordStructDeclaration = (SyntaxKind)9068; + public const SyntaxKind CollectionExpression = (SyntaxKind)9076; } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxWrapper`1.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxWrapper`1.cs index 29a001a27..24f2a3926 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxWrapper`1.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/SyntaxWrapper`1.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Lightup { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TryGetValueAccessor`3.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TryGetValueAccessor`3.cs new file mode 100644 index 000000000..b6ae18db2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TryGetValueAccessor`3.cs @@ -0,0 +1,9 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + internal delegate bool TryGetValueAccessor(T instance, TKey key, out TValue value); +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TupleExpressionSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TupleExpressionSyntaxWrapper.cs index 7f92f01d7..7e1fa3524 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TupleExpressionSyntaxWrapper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TupleExpressionSyntaxWrapper.cs @@ -1,111 +1,17 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Lightup { - using System; - using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; - internal struct TupleExpressionSyntaxWrapper : ISyntaxWrapper + internal partial struct TupleExpressionSyntaxWrapper : ISyntaxWrapper { - internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.TupleExpressionSyntax"; - private static readonly Type WrappedType; - - private static readonly Func OpenParenTokenAccessor; - private static readonly Func> ArgumentsAccessor; - private static readonly Func CloseParenTokenAccessor; - private static readonly Func WithOpenParenTokenAccessor; - private static readonly Func, ExpressionSyntax> WithArgumentsAccessor; - private static readonly Func WithCloseParenTokenAccessor; - - private readonly ExpressionSyntax node; - - static TupleExpressionSyntaxWrapper() - { - WrappedType = WrapperHelper.GetWrappedType(typeof(TupleExpressionSyntaxWrapper)); - OpenParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(OpenParenToken)); - ArgumentsAccessor = LightupHelpers.CreateSyntaxPropertyAccessor>(WrappedType, nameof(Arguments)); - CloseParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(CloseParenToken)); - WithOpenParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(OpenParenToken)); - WithArgumentsAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor>(WrappedType, nameof(Arguments)); - WithCloseParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(CloseParenToken)); - } - - private TupleExpressionSyntaxWrapper(ExpressionSyntax node) - { - this.node = node; - } - - public ExpressionSyntax SyntaxNode => this.node; - - public SyntaxToken OpenParenToken - { - get - { - return OpenParenTokenAccessor(this.SyntaxNode); - } - } - - public SeparatedSyntaxList Arguments - { - get - { - return ArgumentsAccessor(this.SyntaxNode); - } - } - - public SyntaxToken CloseParenToken - { - get - { - return CloseParenTokenAccessor(this.SyntaxNode); - } - } - - public static explicit operator TupleExpressionSyntaxWrapper(SyntaxNode node) - { - if (node == null) - { - return default(TupleExpressionSyntaxWrapper); - } - - if (!IsInstance(node)) - { - throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); - } - - return new TupleExpressionSyntaxWrapper((ExpressionSyntax)node); - } - - public static implicit operator ExpressionSyntax(TupleExpressionSyntaxWrapper wrapper) - { - return wrapper.node; - } - - public static bool IsInstance(SyntaxNode node) - { - return node != null && LightupHelpers.CanWrapNode(node, WrappedType); - } - public TupleExpressionSyntaxWrapper AddArguments(params ArgumentSyntax[] items) { return new TupleExpressionSyntaxWrapper(this.WithArguments(this.Arguments.AddRange(items))); } - - public TupleExpressionSyntaxWrapper WithOpenParenToken(SyntaxToken openParenToken) - { - return new TupleExpressionSyntaxWrapper(WithOpenParenTokenAccessor(this.SyntaxNode, openParenToken)); - } - - public TupleExpressionSyntaxWrapper WithArguments(SeparatedSyntaxList arguments) - { - return new TupleExpressionSyntaxWrapper(WithArgumentsAccessor(this.SyntaxNode, arguments)); - } - - public TupleExpressionSyntaxWrapper WithCloseParenToken(SyntaxToken closeParenToken) - { - return new TupleExpressionSyntaxWrapper(WithCloseParenTokenAccessor(this.SyntaxNode, closeParenToken)); - } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TupleTypeSyntaxWrapper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TupleTypeSyntaxWrapper.cs index a1075b15b..6dfa8da08 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TupleTypeSyntaxWrapper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/TupleTypeSyntaxWrapper.cs @@ -1,111 +1,17 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Lightup { - using System; - using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; - internal struct TupleTypeSyntaxWrapper : ISyntaxWrapper + internal partial struct TupleTypeSyntaxWrapper : ISyntaxWrapper { - internal const string WrappedTypeName = "Microsoft.CodeAnalysis.CSharp.Syntax.TupleTypeSyntax"; - private static readonly Type WrappedType; - - private static readonly Func OpenParenTokenAccessor; - private static readonly Func> ElementsAccessor; - private static readonly Func CloseParenTokenAccessor; - private static readonly Func WithOpenParenTokenAccessor; - private static readonly Func, TypeSyntax> WithElementsAccessor; - private static readonly Func WithCloseParenTokenAccessor; - - private readonly TypeSyntax node; - - static TupleTypeSyntaxWrapper() - { - WrappedType = WrapperHelper.GetWrappedType(typeof(TupleTypeSyntaxWrapper)); - OpenParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(OpenParenToken)); - ElementsAccessor = LightupHelpers.CreateSeparatedSyntaxListPropertyAccessor(WrappedType, nameof(Elements)); - CloseParenTokenAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(WrappedType, nameof(CloseParenToken)); - WithOpenParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(OpenParenToken)); - WithElementsAccessor = LightupHelpers.CreateSeparatedSyntaxListWithPropertyAccessor(WrappedType, nameof(Elements)); - WithCloseParenTokenAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(WrappedType, nameof(CloseParenToken)); - } - - private TupleTypeSyntaxWrapper(TypeSyntax node) - { - this.node = node; - } - - public TypeSyntax SyntaxNode => this.node; - - public SyntaxToken OpenParenToken - { - get - { - return OpenParenTokenAccessor(this.SyntaxNode); - } - } - - public SeparatedSyntaxListWrapper Elements - { - get - { - return ElementsAccessor(this.SyntaxNode); - } - } - - public SyntaxToken CloseParenToken - { - get - { - return CloseParenTokenAccessor(this.SyntaxNode); - } - } - - public static explicit operator TupleTypeSyntaxWrapper(SyntaxNode node) - { - if (node == null) - { - return default(TupleTypeSyntaxWrapper); - } - - if (!IsInstance(node)) - { - throw new InvalidCastException($"Cannot cast '{node.GetType().FullName}' to '{WrappedTypeName}'"); - } - - return new TupleTypeSyntaxWrapper((TypeSyntax)node); - } - - public static implicit operator TypeSyntax(TupleTypeSyntaxWrapper wrapper) - { - return wrapper.node; - } - - public static bool IsInstance(SyntaxNode node) - { - return node != null && LightupHelpers.CanWrapNode(node, WrappedType); - } - public TupleTypeSyntaxWrapper AddElements(params TupleElementSyntaxWrapper[] items) { return new TupleTypeSyntaxWrapper(this.WithElements(this.Elements.AddRange(items))); } - - public TupleTypeSyntaxWrapper WithOpenParenToken(SyntaxToken openParenToken) - { - return new TupleTypeSyntaxWrapper(WithOpenParenTokenAccessor(this.SyntaxNode, openParenToken)); - } - - public TupleTypeSyntaxWrapper WithElements(SeparatedSyntaxListWrapper elements) - { - return new TupleTypeSyntaxWrapper(WithElementsAccessor(this.SyntaxNode, elements)); - } - - public TupleTypeSyntaxWrapper WithCloseParenToken(SyntaxToken closeParenToken) - { - return new TupleTypeSyntaxWrapper(WithCloseParenTokenAccessor(this.SyntaxNode, closeParenToken)); - } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/UsingStatementSyntaxExtensions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/UsingStatementSyntaxExtensions.cs new file mode 100644 index 000000000..ef8180ec2 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/UsingStatementSyntaxExtensions.cs @@ -0,0 +1,33 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Lightup +{ + using System; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp.Syntax; + + internal static class UsingStatementSyntaxExtensions + { + private static readonly Func AwaitKeywordAccessor; + private static readonly Func WithAwaitKeywordAccessor; + + static UsingStatementSyntaxExtensions() + { + AwaitKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor(typeof(UsingStatementSyntax), nameof(AwaitKeyword)); + WithAwaitKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor(typeof(UsingStatementSyntax), nameof(AwaitKeyword)); + } + + public static SyntaxToken AwaitKeyword(this UsingStatementSyntax syntax) + { + return AwaitKeywordAccessor(syntax); + } + + public static UsingStatementSyntax WithAwaitKeyword(this UsingStatementSyntax syntax, SyntaxToken awaitKeyword) + { + return WithAwaitKeywordAccessor(syntax, awaitKeyword); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/WrapperHelper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/WrapperHelper.cs index b59d5d217..b7927c89a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/WrapperHelper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/WrapperHelper.cs @@ -1,11 +1,14 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Lightup { using System; using System.Collections.Immutable; using System.Reflection; + using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; internal static class WrapperHelper @@ -14,35 +17,11 @@ internal static class WrapperHelper static WrapperHelper() { - var codeAnalysisAssembly = typeof(CSharpSyntaxNode).GetTypeInfo().Assembly; + var codeAnalysisAssembly = typeof(SyntaxNode).GetTypeInfo().Assembly; var builder = ImmutableDictionary.CreateBuilder(); - builder.Add(typeof(CasePatternSwitchLabelSyntaxWrapper), codeAnalysisAssembly.GetType(CasePatternSwitchLabelSyntaxWrapper.WrappedTypeName)); - - // Prior to C# 7, ForEachStatementSyntax was the base type for all foreach statements. If - // the CommonForEachStatementSyntax type isn't found at runtime, we fall back to using this type instead. - var forEachStatementSyntaxType = codeAnalysisAssembly.GetType(CommonForEachStatementSyntaxWrapper.WrappedTypeName) - ?? codeAnalysisAssembly.GetType(CommonForEachStatementSyntaxWrapper.FallbackWrappedTypeName); - builder.Add(typeof(CommonForEachStatementSyntaxWrapper), forEachStatementSyntaxType); - - builder.Add(typeof(ConstantPatternSyntaxWrapper), codeAnalysisAssembly.GetType(ConstantPatternSyntaxWrapper.WrappedTypeName)); - builder.Add(typeof(DeclarationExpressionSyntaxWrapper), codeAnalysisAssembly.GetType(DeclarationExpressionSyntaxWrapper.WrappedTypeName)); - builder.Add(typeof(DeclarationPatternSyntaxWrapper), codeAnalysisAssembly.GetType(DeclarationPatternSyntaxWrapper.WrappedTypeName)); - builder.Add(typeof(DiscardDesignationSyntaxWrapper), codeAnalysisAssembly.GetType(DiscardDesignationSyntaxWrapper.WrappedTypeName)); - builder.Add(typeof(ForEachVariableStatementSyntaxWrapper), codeAnalysisAssembly.GetType(ForEachVariableStatementSyntaxWrapper.WrappedTypeName)); - builder.Add(typeof(IsPatternExpressionSyntaxWrapper), codeAnalysisAssembly.GetType(IsPatternExpressionSyntaxWrapper.WrappedTypeName)); - builder.Add(typeof(LocalFunctionStatementSyntaxWrapper), codeAnalysisAssembly.GetType(LocalFunctionStatementSyntaxWrapper.WrappedTypeName)); - builder.Add(typeof(ParenthesizedVariableDesignationSyntaxWrapper), codeAnalysisAssembly.GetType(ParenthesizedVariableDesignationSyntaxWrapper.WrappedTypeName)); - builder.Add(typeof(PatternSyntaxWrapper), codeAnalysisAssembly.GetType(PatternSyntaxWrapper.WrappedTypeName)); - builder.Add(typeof(RefExpressionSyntaxWrapper), codeAnalysisAssembly.GetType(RefExpressionSyntaxWrapper.WrappedTypeName)); - builder.Add(typeof(RefTypeSyntaxWrapper), codeAnalysisAssembly.GetType(RefTypeSyntaxWrapper.WrappedTypeName)); - builder.Add(typeof(SingleVariableDesignationSyntaxWrapper), codeAnalysisAssembly.GetType(SingleVariableDesignationSyntaxWrapper.WrappedTypeName)); - builder.Add(typeof(ThrowExpressionSyntaxWrapper), codeAnalysisAssembly.GetType(ThrowExpressionSyntaxWrapper.WrappedTypeName)); - builder.Add(typeof(TupleElementSyntaxWrapper), codeAnalysisAssembly.GetType(TupleElementSyntaxWrapper.WrappedTypeName)); - builder.Add(typeof(TupleExpressionSyntaxWrapper), codeAnalysisAssembly.GetType(TupleExpressionSyntaxWrapper.WrappedTypeName)); - builder.Add(typeof(TupleTypeSyntaxWrapper), codeAnalysisAssembly.GetType(TupleTypeSyntaxWrapper.WrappedTypeName)); - builder.Add(typeof(VariableDesignationSyntaxWrapper), codeAnalysisAssembly.GetType(VariableDesignationSyntaxWrapper.WrappedTypeName)); - builder.Add(typeof(WhenClauseSyntaxWrapper), codeAnalysisAssembly.GetType(WhenClauseSyntaxWrapper.WrappedTypeName)); + builder.Add(typeof(AnalyzerConfigOptionsProviderWrapper), codeAnalysisAssembly.GetType(AnalyzerConfigOptionsProviderWrapper.WrappedTypeName)); + builder.Add(typeof(AnalyzerConfigOptionsWrapper), codeAnalysisAssembly.GetType(AnalyzerConfigOptionsWrapper.WrappedTypeName)); WrappedTypes = builder.ToImmutable(); } @@ -50,12 +29,11 @@ static WrapperHelper() /// /// Gets the type that is wrapped by the given wrapper. /// - /// Type of the wrapper for which the wrapped type should be retrieved. + /// Type of the wrapper for which the wrapped type should be retrieved. /// The wrapped type, or null if there is no info. internal static Type GetWrappedType(Type wrapperType) { - Type wrappedType; - if (WrappedTypes.TryGetValue(wrapperType, out wrappedType)) + if (WrappedTypes.TryGetValue(wrapperType, out Type wrappedType)) { return wrappedType; } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/LinqHelpers/SyntaxTriviaListEnumerable.cs b/StyleCop.Analyzers/StyleCop.Analyzers/LinqHelpers/SyntaxTriviaListEnumerable.cs index 11f63ded8..37febc3b5 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/LinqHelpers/SyntaxTriviaListEnumerable.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/LinqHelpers/SyntaxTriviaListEnumerable.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace System.Linq { @@ -113,7 +115,7 @@ internal static SyntaxTrivia LastOrDefault(this SyntaxTriviaList list, SyntaxKin } } - return default(SyntaxTrivia); + return default; } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/MaintainabilityResources.Designer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/MaintainabilityResources.Designer.cs deleted file mode 100644 index 7b3cdfdaf..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/MaintainabilityResources.Designer.cs +++ /dev/null @@ -1,163 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace StyleCop.Analyzers.MaintainabilityRules { - using System; - using System.Reflection; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class MaintainabilityResources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal MaintainabilityResources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StyleCop.Analyzers.MaintainabilityRules.MaintainabilityResources", typeof(MaintainabilityResources).GetTypeInfo().Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Remove parentheses. - /// - internal static string SA1119CodeFix { - get { - return ResourceManager.GetString("SA1119CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Declare accessibility. - /// - internal static string SA1400CodeFix { - get { - return ResourceManager.GetString("SA1400CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Move type to new file. - /// - internal static string SA1402CodeFix { - get { - return ResourceManager.GetString("SA1402CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Fix justification. - /// - internal static string SA1404CodeFix { - get { - return ResourceManager.GetString("SA1404CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Add parentheses. - /// - internal static string SA1407SA1408CodeFix { - get { - return ResourceManager.GetString("SA1407SA1408CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove parentheses. - /// - internal static string SA1410SA1411CodeFix { - get { - return ResourceManager.GetString("SA1410SA1411CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Change encoding from '{0}' to UTF-8 with byte order mark. - /// - internal static string SA1412CodeFix { - get { - return ResourceManager.GetString("SA1412CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Add trailing comma. - /// - internal static string SA1413CodeFix { - get { - return ResourceManager.GetString("SA1413CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A multi-line initializer in a C# code file should use a comma on the last line.. - /// - internal static string SA1413Description { - get { - return ResourceManager.GetString("SA1413Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use trailing comma in multi-line initializers. - /// - internal static string SA1413MessageFormat { - get { - return ResourceManager.GetString("SA1413MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use trailing comma in multi-line initializers. - /// - internal static string SA1413Title { - get { - return ResourceManager.GetString("SA1413Title", resourceCulture); - } - } - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/MaintainabilityResources.resx b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/MaintainabilityResources.resx index 0018b3434..2c5ee67a5 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/MaintainabilityResources.resx +++ b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/MaintainabilityResources.resx @@ -120,24 +120,150 @@ Remove parentheses + + A C# statement contains parenthesis which are unnecessary and should be removed. + + + Statement should not use unnecessary parenthesis + + + Statement should not use unnecessary parenthesis + Declare accessibility + + The access modifier for a C# element has not been explicitly defined. + + + Element '{0}' should declare an access modifier + + + Access modifier should be declared + + + A field within a C# class has an access modifier other than private. + + + Field should be private + + + Fields should be private + Move type to new file + + A C# code file contains more than one unique type. + + + File may only contain a single type + + + File may only contain a single type + + + A C# code file contains more than one namespace. + + + File may only contain a single namespace + + + File may only contain a single namespace + Fix justification + + A Code Analysis SuppressMessage attribute does not include a justification. + + + Code analysis suppression should have justification + + + Code analysis suppression should have justification + + + A call to Debug.Assert in C# code does not include a descriptive message. + + + Debug.Assert should provide message text + + + Debug.Assert should provide message text + + + A call to Debug.Fail in C# code does not include a descriptive message. + + + Debug.Fail should provide message text + + + Debug.Fail should provide message text + + + A C# statement contains a complex arithmetic expression which omits parenthesis around operators. + + + Arithmetic expressions should declare precedence + Add parentheses + + Arithmetic expressions should declare precedence + + + A C# statement contains a complex conditional expression which omits parenthesis around operators. + + + Conditional expressions should declare precedence + + + Conditional expressions should declare precedence + + + A C# file contains code which is unnecessary and can be removed without changing the overall logic of the code. + + + TODO: Message format + + + Remove unnecessary code + + + A call to a C# anonymous method does not contain any method parameters, yet the statement still includes parenthesis. + + + Remove delegate parenthesis when possible + Remove parentheses + + Remove delegate parenthesis when possible + + + TODO. + + + Attribute constructor should not use unnecessary parenthesis + + + Attribute constructor should not use unnecessary parenthesis + Change encoding from '{0}' to UTF-8 with byte order mark + + Source files should be saved using the UTF-8 encoding with a byte order mark. + + + Store files as UTF-8 with byte order mark + + + Store files as UTF-8 with byte order mark + Add trailing comma @@ -150,4 +276,13 @@ Use trailing comma in multi-line initializers + + Tuple types appearing in member declarations should have explicitly named tuple elements. + + + Tuple types in signatures should have element names + + + Tuple types in signatures should have element names + \ No newline at end of file diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1119StatementMustNotUseUnnecessaryParenthesis.cs b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1119StatementMustNotUseUnnecessaryParenthesis.cs index 17359234d..db8e25992 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1119StatementMustNotUseUnnecessaryParenthesis.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1119StatementMustNotUseUnnecessaryParenthesis.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { @@ -10,6 +12,7 @@ namespace StyleCop.Analyzers.MaintainabilityRules using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; + using StyleCop.Analyzers.Helpers; using StyleCop.Analyzers.Lightup; /// @@ -54,16 +57,18 @@ internal class SA1119StatementMustNotUseUnnecessaryParenthesis : DiagnosticAnaly /// . /// public const string ParenthesesDiagnosticId = DiagnosticId + "_p"; - private const string Title = "Statement should not use unnecessary parenthesis"; - private const string MessageFormat = "Statement should not use unnecessary parenthesis"; - private const string Description = "A C# statement contains parenthesis which are unnecessary and should be removed."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1119.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(MaintainabilityResources.SA1119Title), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(MaintainabilityResources.SA1119MessageFormat), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(MaintainabilityResources.SA1119Description), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.MaintainabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); private static readonly DiagnosticDescriptor ParenthesisDescriptor = +#pragma warning disable RS2000 // Add analyzer diagnostic IDs to analyzer release. new DiagnosticDescriptor(ParenthesesDiagnosticId, Title, MessageFormat, AnalyzerCategory.MaintainabilityRules, DiagnosticSeverity.Hidden, AnalyzerConstants.EnabledByDefault, Description, HelpLink, customTags: new[] { WellKnownDiagnosticTags.Unnecessary, WellKnownDiagnosticTags.NotConfigurable }); +#pragma warning restore RS2000 // Add analyzer diagnostic IDs to analyzer release. private static readonly Action CompilationStartAction = HandleCompilationStart; private static readonly Action ParenthesizedExpressionAction = HandleParenthesizedExpression; @@ -88,7 +93,7 @@ private static void HandleCompilationStart(CompilationStartAnalysisContext conte // Only register the syntax node action if the diagnostic is enabled. This is important because // otherwise the diagnostic for fading out the parenthesis is still active, even if the main diagnostic // is disabled - if (context.Compilation.Options.SpecificDiagnosticOptions.GetValueOrDefault(Descriptor.Id) != Microsoft.CodeAnalysis.ReportDiagnostic.Suppress) + if (!context.IsAnalyzerSuppressed(Descriptor)) { context.RegisterSyntaxNodeAction(ParenthesizedExpressionAction, SyntaxKind.ParenthesizedExpression); } @@ -114,6 +119,7 @@ private static void HandleParenthesizedExpression(SyntaxNodeAnalysisContext cont && !node.Expression.IsKind(SyntaxKind.CoalesceExpression) && !node.Expression.IsKind(SyntaxKind.QueryExpression) && !node.Expression.IsKind(SyntaxKind.AwaitExpression) + && !node.Expression.IsKind(SyntaxKindEx.RangeExpression) && !node.IsKind(SyntaxKind.ConstructorDeclaration)) { if (node.Expression.IsKind(SyntaxKind.ConditionalAccessExpression) @@ -124,6 +130,18 @@ private static void HandleParenthesizedExpression(SyntaxNodeAnalysisContext cont return; } + if (IsSwitchOrWithExpressionWithRequiredParentheses(node)) + { + return; + } + + if ((node.Expression.IsKind(SyntaxKind.StackAllocArrayCreationExpression) + || node.Expression.IsKind(SyntaxKindEx.ImplicitStackAllocArrayCreationExpression)) + && node.Parent.IsKind(SyntaxKind.EqualsValueClause)) + { + return; + } + ReportDiagnostic(context, node); } else @@ -135,6 +153,15 @@ private static void HandleParenthesizedExpression(SyntaxNodeAnalysisContext cont return; } + if (node.Parent is AssignmentExpressionSyntax assignmentExpression + && node.Expression.IsKind(SyntaxKind.ConditionalExpression) + && assignmentExpression.Left == node) + { + // NOTE: This is only valid syntax if the conditional expression is a ref expression + // Parenthesis can't be removed here + return; + } + if (!(node.Parent is ExpressionSyntax) || node.Parent is CheckedExpressionSyntax || node.Parent is MemberAccessExpressionSyntax) @@ -160,7 +187,7 @@ private static void HandleParenthesizedExpression(SyntaxNodeAnalysisContext cont } else { - if (node.Parent is AssignmentExpressionSyntax assignValue) + if (node.Parent is AssignmentExpressionSyntax) { ReportDiagnostic(context, node); } @@ -196,6 +223,27 @@ private static bool IsConditionalAccessInInterpolation(ExpressionSyntax node) return false; } + private static bool IsSwitchOrWithExpressionWithRequiredParentheses(ParenthesizedExpressionSyntax node) + { + if (!node.Expression.IsKind(SyntaxKindEx.SwitchExpression) + && !node.Expression.IsKind(SyntaxKindEx.WithExpression)) + { + return false; + } + + var outerExpression = node.WalkUpParentheses(); + return outerExpression.Parent switch + { + AwaitExpressionSyntax awaitExpression => awaitExpression.Expression == outerExpression, + CastExpressionSyntax castExpression => castExpression.Expression == outerExpression, + MemberAccessExpressionSyntax memberAccessExpression => memberAccessExpression.Expression == outerExpression, + ConditionalAccessExpressionSyntax conditionalAccessExpression => conditionalAccessExpression.Expression == outerExpression, + ElementAccessExpressionSyntax elementAccessExpression => elementAccessExpression.Expression == outerExpression, + InvocationExpressionSyntax invocationExpression => invocationExpression.Expression == outerExpression, + _ => false, + }; + } + private static void ReportDiagnostic(SyntaxNodeAnalysisContext context, ParenthesizedExpressionSyntax node) { context.ReportDiagnostic(Diagnostic.Create(Descriptor, node.GetLocation())); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1400AccessModifierMustBeDeclared.cs b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1400AccessModifierMustBeDeclared.cs index 184ed3c53..860ec3449 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1400AccessModifierMustBeDeclared.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1400AccessModifierMustBeDeclared.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { @@ -11,6 +13,7 @@ namespace StyleCop.Analyzers.MaintainabilityRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; /// /// The access modifier for a C# element has not been explicitly defined. @@ -29,10 +32,10 @@ internal class SA1400AccessModifierMustBeDeclared : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1400"; - private const string Title = "Access modifier should be declared"; - private const string MessageFormat = "Element '{0}' should declare an access modifier"; - private const string Description = "The access modifier for a C# element has not been explicitly defined."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1400.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(MaintainabilityResources.SA1400Title), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(MaintainabilityResources.SA1400MessageFormat), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(MaintainabilityResources.SA1400Description), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.MaintainabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -187,6 +190,7 @@ private static void CheckAccessModifiers(SyntaxNodeAnalysisContext context, Synt case SyntaxKind.ProtectedKeyword: case SyntaxKind.InternalKeyword: case SyntaxKind.PrivateKeyword: + case SyntaxKindEx.FileKeyword: return; case SyntaxKind.StaticKeyword: diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1401FieldsMustBePrivate.cs b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1401FieldsMustBePrivate.cs index 5fe8af6db..175262aa4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1401FieldsMustBePrivate.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1401FieldsMustBePrivate.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { @@ -27,10 +29,10 @@ internal class SA1401FieldsMustBePrivate : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1401"; - private const string Title = "Fields should be private"; - private const string MessageFormat = "Field should be private"; - private const string Description = "A field within a C# class has an access modifier other than private."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1401.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(MaintainabilityResources.SA1401Title), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(MaintainabilityResources.SA1401MessageFormat), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(MaintainabilityResources.SA1401Description), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.MaintainabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1402FileMayOnlyContainASingleType.cs b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1402FileMayOnlyContainASingleType.cs index c1b5ba2ee..b9ca8c9e2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1402FileMayOnlyContainASingleType.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1402FileMayOnlyContainASingleType.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { @@ -12,6 +14,7 @@ namespace StyleCop.Analyzers.MaintainabilityRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.Settings.ObjectModel; /// @@ -34,10 +37,10 @@ internal class SA1402FileMayOnlyContainASingleType : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1402"; - private const string Title = "File may only contain a single type"; - private const string MessageFormat = "File may only contain a single type"; - private const string Description = "A C# code file contains more than one unique type."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1402.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(MaintainabilityResources.SA1402Title), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(MaintainabilityResources.SA1402MessageFormat), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(MaintainabilityResources.SA1402Description), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.MaintainabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -54,7 +57,10 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxTreeAction(SyntaxTreeAction); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxTreeAction(SyntaxTreeAction); + }); } private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context, StyleCopSettings settings) @@ -99,7 +105,7 @@ private static IEnumerable GetTopLevelTypeDeclarations( private static bool ContainsTopLevelTypeDeclarations(SyntaxNode node) { - return node.IsKind(SyntaxKind.CompilationUnit) || node.IsKind(SyntaxKind.NamespaceDeclaration); + return node.IsKind(SyntaxKind.CompilationUnit) || node.IsKind(SyntaxKind.NamespaceDeclaration) || node.IsKind(SyntaxKindEx.FileScopedNamespaceDeclaration); } private static bool IsRelevantType(SyntaxNode node, StyleCopSettings settings) @@ -110,12 +116,14 @@ private static bool IsRelevantType(SyntaxNode node, StyleCopSettings settings) switch (node.Kind()) { case SyntaxKind.ClassDeclaration: + case SyntaxKindEx.RecordDeclaration: isRelevant = topLevelTypes.Contains(TopLevelType.Class); break; case SyntaxKind.InterfaceDeclaration: isRelevant = topLevelTypes.Contains(TopLevelType.Interface); break; case SyntaxKind.StructDeclaration: + case SyntaxKindEx.RecordStructDeclaration: isRelevant = topLevelTypes.Contains(TopLevelType.Struct); break; case SyntaxKind.EnumDeclaration: diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1403FileMayOnlyContainASingleNamespace.cs b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1403FileMayOnlyContainASingleNamespace.cs index 5855fed27..9aa2d05a0 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1403FileMayOnlyContainASingleNamespace.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1403FileMayOnlyContainASingleNamespace.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { @@ -24,10 +26,10 @@ internal class SA1403FileMayOnlyContainASingleNamespace : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1403"; - private const string Title = "File may only contain a single namespace"; - private const string MessageFormat = "File may only contain a single namespace"; - private const string Description = "A C# code file contains more than one namespace."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1403.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(MaintainabilityResources.SA1403Title), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(MaintainabilityResources.SA1403MessageFormat), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(MaintainabilityResources.SA1403Description), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.MaintainabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -51,7 +53,8 @@ private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context) { var syntaxRoot = context.Tree.GetRoot(context.CancellationToken); - var descentNodes = syntaxRoot.DescendantNodes(descendIntoChildren: node => node != null && !node.IsKind(SyntaxKind.ClassDeclaration)); + // No need to check file-scoped namespaces because the compiler only allows one per file + var descentNodes = syntaxRoot.DescendantNodes(descendIntoChildren: node => node.IsKind(SyntaxKind.CompilationUnit) || node.IsKind(SyntaxKind.NamespaceDeclaration)); bool foundNode = false; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1404CodeAnalysisSuppressionMustHaveJustification.cs b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1404CodeAnalysisSuppressionMustHaveJustification.cs index 1d96dece4..10b7e65d2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1404CodeAnalysisSuppressionMustHaveJustification.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1404CodeAnalysisSuppressionMustHaveJustification.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { @@ -42,10 +44,10 @@ internal class SA1404CodeAnalysisSuppressionMustHaveJustification : DiagnosticAn /// analyzer. /// public const string DiagnosticId = "SA1404"; - private const string Title = "Code analysis suppression should have justification"; - private const string MessageFormat = "Code analysis suppression should have justification"; - private const string Description = "A Code Analysis SuppressMessage attribute does not include a justification."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1404.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(MaintainabilityResources.SA1404Title), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(MaintainabilityResources.SA1404MessageFormat), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(MaintainabilityResources.SA1404Description), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.MaintainabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1405DebugAssertMustProvideMessageText.cs b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1405DebugAssertMustProvideMessageText.cs index a348e20d1..d661af3ac 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1405DebugAssertMustProvideMessageText.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1405DebugAssertMustProvideMessageText.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { @@ -29,10 +31,10 @@ internal class SA1405DebugAssertMustProvideMessageText : SystemDiagnosticsDebugD /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1405"; - private const string Title = "Debug.Assert should provide message text"; - private const string MessageFormat = "Debug.Assert should provide message text"; - private const string Description = "A call to Debug.Assert in C# code does not include a descriptive message."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1405.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(MaintainabilityResources.SA1405Title), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(MaintainabilityResources.SA1405MessageFormat), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(MaintainabilityResources.SA1405Description), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.MaintainabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1406DebugFailMustProvideMessageText.cs b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1406DebugFailMustProvideMessageText.cs index a30b386a0..fe40d639d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1406DebugFailMustProvideMessageText.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1406DebugFailMustProvideMessageText.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { @@ -29,10 +31,10 @@ internal class SA1406DebugFailMustProvideMessageText : SystemDiagnosticsDebugDia /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1406"; - private const string Title = "Debug.Fail should provide message text"; - private const string MessageFormat = "Debug.Fail should provide message text"; - private const string Description = "A call to Debug.Fail in C# code does not include a descriptive message."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1406.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(MaintainabilityResources.SA1406Title), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(MaintainabilityResources.SA1406MessageFormat), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(MaintainabilityResources.SA1406Description), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.MaintainabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1407ArithmeticExpressionsMustDeclarePrecedence.cs b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1407ArithmeticExpressionsMustDeclarePrecedence.cs index cb735bf70..2b7f9bf3e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1407ArithmeticExpressionsMustDeclarePrecedence.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1407ArithmeticExpressionsMustDeclarePrecedence.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { @@ -46,10 +48,10 @@ internal class SA1407ArithmeticExpressionsMustDeclarePrecedence : DiagnosticAnal /// analyzer. /// public const string DiagnosticId = "SA1407"; - private const string Title = "Arithmetic expressions should declare precedence"; - private const string MessageFormat = "Arithmetic expressions should declare precedence"; - private const string Description = "A C# statement contains a complex arithmetic expression which omits parenthesis around operators."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1407.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(MaintainabilityResources.SA1407Title), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(MaintainabilityResources.SA1407MessageFormat), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(MaintainabilityResources.SA1407Description), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.MaintainabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1408ConditionalExpressionsMustDeclarePrecedence.cs b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1408ConditionalExpressionsMustDeclarePrecedence.cs index 2d5d483ee..e5b1dc7fc 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1408ConditionalExpressionsMustDeclarePrecedence.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1408ConditionalExpressionsMustDeclarePrecedence.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { @@ -58,10 +60,10 @@ internal class SA1408ConditionalExpressionsMustDeclarePrecedence : DiagnosticAna /// analyzer. /// public const string DiagnosticId = "SA1408"; - private const string Title = "Conditional expressions should declare precedence"; - private const string MessageFormat = "Conditional expressions should declare precedence"; - private const string Description = "A C# statement contains a complex conditional expression which omits parenthesis around operators."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1408.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(MaintainabilityResources.SA1408Title), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(MaintainabilityResources.SA1408MessageFormat), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(MaintainabilityResources.SA1408Description), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.MaintainabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1409RemoveUnnecessaryCode.cs b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1409RemoveUnnecessaryCode.cs index 5573810db..d9859433e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1409RemoveUnnecessaryCode.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1409RemoveUnnecessaryCode.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { @@ -59,13 +61,15 @@ internal class SA1409RemoveUnnecessaryCode : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1409"; - private const string Title = "Remove unnecessary code"; - private const string MessageFormat = "TODO: Message format"; - private const string Description = "A C# file contains code which is unnecessary and can be removed without changing the overall logic of the code."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1409.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(MaintainabilityResources.SA1409Title), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(MaintainabilityResources.SA1409MessageFormat), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(MaintainabilityResources.SA1409Description), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); private static readonly DiagnosticDescriptor Descriptor = +#pragma warning disable RS2000 // Add analyzer diagnostic IDs to analyzer release. new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.MaintainabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.NotConfigurable); +#pragma warning restore RS2000 // Add analyzer diagnostic IDs to analyzer release. /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -73,7 +77,11 @@ internal class SA1409RemoveUnnecessaryCode : DiagnosticAnalyzer /// [ExcludeFromCodeCoverage] +#pragma warning disable RS1025 // Configure generated code analysis +#pragma warning disable RS1026 // Enable concurrent execution public override void Initialize(AnalysisContext context) +#pragma warning restore RS1026 // Enable concurrent execution +#pragma warning restore RS1025 // Configure generated code analysis { // This diagnostic is not implemented (by design) in StyleCopAnalyzers. } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1410RemoveDelegateParenthesisWhenPossible.cs b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1410RemoveDelegateParenthesisWhenPossible.cs index 9086bdf58..9cf390d48 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1410RemoveDelegateParenthesisWhenPossible.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1410RemoveDelegateParenthesisWhenPossible.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { @@ -38,10 +40,10 @@ internal class SA1410RemoveDelegateParenthesisWhenPossible : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1410"; - private const string Title = "Remove delegate parenthesis when possible"; - private const string MessageFormat = "Remove delegate parenthesis when possible"; - private const string Description = "A call to a C# anonymous method does not contain any method parameters, yet the statement still includes parenthesis."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1410.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(MaintainabilityResources.SA1410Title), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(MaintainabilityResources.SA1410MessageFormat), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(MaintainabilityResources.SA1410Description), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.MaintainabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.Unnecessary); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1411AttributeConstructorMustNotUseUnnecessaryParenthesis.cs b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1411AttributeConstructorMustNotUseUnnecessaryParenthesis.cs index 1b730cb1a..7a5db42ca 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1411AttributeConstructorMustNotUseUnnecessaryParenthesis.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1411AttributeConstructorMustNotUseUnnecessaryParenthesis.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { @@ -35,10 +37,10 @@ internal class SA1411AttributeConstructorMustNotUseUnnecessaryParenthesis : Diag /// analyzer. /// public const string DiagnosticId = "SA1411"; - private const string Title = "Attribute constructor should not use unnecessary parenthesis"; - private const string MessageFormat = "Attribute constructor should not use unnecessary parenthesis"; - private const string Description = "TODO."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1411.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(MaintainabilityResources.SA1411Title), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(MaintainabilityResources.SA1411MessageFormat), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(MaintainabilityResources.SA1411Description), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.MaintainabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.Unnecessary); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1412StoreFilesAsUtf8.cs b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1412StoreFilesAsUtf8.cs index 52ec35b82..418303ad7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1412StoreFilesAsUtf8.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1412StoreFilesAsUtf8.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { @@ -29,17 +31,17 @@ internal class SA1412StoreFilesAsUtf8 : DiagnosticAnalyzer /// analyzer. /// public const string DiagnosticId = "SA1412"; - private const string Title = "Store files as UTF-8 with byte order mark"; - private const string MessageFormat = "Store files as UTF-8 with byte order mark"; - private const string Description = "Source files should be saved using the UTF-8 encoding with a byte order mark"; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1412.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(MaintainabilityResources.SA1412Title), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(MaintainabilityResources.SA1412MessageFormat), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(MaintainabilityResources.SA1412Description), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.MaintainabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink); private static readonly Action SyntaxTreeAction = HandleSyntaxTree; - private static byte[] utf8Preamble = Encoding.UTF8.GetPreamble(); + private static readonly byte[] Utf8Preamble = Encoding.UTF8.GetPreamble(); /// /// Gets the key for the detected encoding name in the collection. @@ -81,15 +83,15 @@ private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context) private static bool IsUtf8Preamble(byte[] preamble) { - if (preamble == null || preamble.Length != utf8Preamble.Length) + if (preamble == null || preamble.Length != Utf8Preamble.Length) { return false; } else { - for (int i = 0; i < utf8Preamble.Length; i++) + for (int i = 0; i < Utf8Preamble.Length; i++) { - if (utf8Preamble[i] != preamble[i]) + if (Utf8Preamble[i] != preamble[i]) { return false; } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1413UseTrailingCommasInMultiLineInitializers.cs b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1413UseTrailingCommasInMultiLineInitializers.cs index bc2e6c130..371c4be2b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1413UseTrailingCommasInMultiLineInitializers.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1413UseTrailingCommasInMultiLineInitializers.cs @@ -1,16 +1,18 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { using System; using System.Collections.Immutable; - using System.Linq; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; /// /// A multi-line initializer should use a comma on the last item. @@ -48,20 +50,21 @@ internal class SA1413UseTrailingCommasInMultiLineInitializers : DiagnosticAnalyz /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1413"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1413.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(MaintainabilityResources.SA1413Title), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(MaintainabilityResources.SA1413MessageFormat), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(MaintainabilityResources.SA1413Description), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1413.md"; private static readonly DiagnosticDescriptor Descriptor = - new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.MaintainabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); private static readonly Action HandleObjectInitializerAction = HandleObjectInitializer; private static readonly Action HandleAnonymousObjectInitializerAction = HandleAnonymousObjectInitializer; private static readonly Action HandleEnumDeclarationAction = HandleEnumDeclaration; + private static readonly Action HandleSwitchExpressionAction = HandleSwitchExpression; private static readonly ImmutableArray ObjectInitializerKinds = - ImmutableArray.Create(SyntaxKind.ObjectInitializerExpression, SyntaxKind.ArrayInitializerExpression, SyntaxKind.CollectionInitializerExpression); + ImmutableArray.Create(SyntaxKind.ObjectInitializerExpression, SyntaxKind.ArrayInitializerExpression, SyntaxKind.CollectionInitializerExpression, SyntaxKindEx.WithInitializerExpression); /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -76,6 +79,7 @@ public override void Initialize(AnalysisContext context) context.RegisterSyntaxNodeAction(HandleObjectInitializerAction, ObjectInitializerKinds); context.RegisterSyntaxNodeAction(HandleAnonymousObjectInitializerAction, SyntaxKind.AnonymousObjectCreationExpression); context.RegisterSyntaxNodeAction(HandleEnumDeclarationAction, SyntaxKind.EnumDeclaration); + context.RegisterSyntaxNodeAction(HandleSwitchExpressionAction, SyntaxKindEx.SwitchExpression); } private static void HandleEnumDeclaration(SyntaxNodeAnalysisContext context) @@ -120,5 +124,19 @@ private static void HandleAnonymousObjectInitializer(SyntaxNodeAnalysisContext c context.ReportDiagnostic(Diagnostic.Create(Descriptor, initializer.Initializers.Last().GetLocation())); } } + + private static void HandleSwitchExpression(SyntaxNodeAnalysisContext context) + { + var switchExpression = (SwitchExpressionSyntaxWrapper)context.Node; + if (switchExpression.SyntaxNode == null || !switchExpression.SyntaxNode.SpansMultipleLines()) + { + return; + } + + if (switchExpression.Arms.SeparatorCount < switchExpression.Arms.Count) + { + context.ReportDiagnostic(Diagnostic.Create(Descriptor, switchExpression.Arms.Last().SyntaxNode.GetLocation())); + } + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1414TupleTypesInSignaturesShouldHaveElementNames.cs b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1414TupleTypesInSignaturesShouldHaveElementNames.cs new file mode 100644 index 000000000..0105c038a --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SA1414TupleTypesInSignaturesShouldHaveElementNames.cs @@ -0,0 +1,185 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.MaintainabilityRules +{ + using System; + using System.Collections.Immutable; + using System.Linq; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using Microsoft.CodeAnalysis.Diagnostics; + using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; + + [DiagnosticAnalyzer(LanguageNames.CSharp)] + [NoCodeFix("Cannot generate appropriate names.")] + internal class SA1414TupleTypesInSignaturesShouldHaveElementNames : DiagnosticAnalyzer + { + /// + /// The ID for diagnostics produced by the analyzer. + /// + public const string DiagnosticId = "SA1414"; + + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1414.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(MaintainabilityResources.SA1414Title), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(MaintainabilityResources.SA1414MessageFormat), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(MaintainabilityResources.SA1414Description), MaintainabilityResources.ResourceManager, typeof(MaintainabilityResources)); + + private static readonly Action MethodDeclarationAction = HandleMethodDeclaration; + private static readonly Action ConstructorDeclarationAction = HandleConstructorDeclaration; + private static readonly Action PropertyDeclarationAction = HandlePropertyDeclaration; + private static readonly Action IndexerDeclarationAction = HandleIndexerDeclaration; + private static readonly Action ConversionOperatorDeclarationAction = HandleConversionOperatorDeclaration; + private static readonly Action DelegateDeclarationAction = HandleDelegateDeclaration; + + private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + + /// + public override ImmutableArray SupportedDiagnostics { get; } = ImmutableArray.Create(Descriptor); + + /// + public override void Initialize(AnalysisContext context) + { + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); + context.EnableConcurrentExecution(); + + context.RegisterSyntaxNodeAction(MethodDeclarationAction, SyntaxKind.MethodDeclaration); + context.RegisterSyntaxNodeAction(ConstructorDeclarationAction, SyntaxKind.ConstructorDeclaration); + context.RegisterSyntaxNodeAction(PropertyDeclarationAction, SyntaxKind.PropertyDeclaration); + context.RegisterSyntaxNodeAction(IndexerDeclarationAction, SyntaxKind.IndexerDeclaration); + context.RegisterSyntaxNodeAction(ConversionOperatorDeclarationAction, SyntaxKind.ConversionOperatorDeclaration); + context.RegisterSyntaxNodeAction(DelegateDeclarationAction, SyntaxKind.DelegateDeclaration); + } + + private static void HandleMethodDeclaration(SyntaxNodeAnalysisContext context) + { + if (!context.SupportsTuples()) + { + return; + } + + var methodDeclaration = (MethodDeclarationSyntax)context.Node; + if (methodDeclaration.Modifiers.Any(SyntaxKind.OverrideKeyword)) + { + return; + } + + CheckType(context, methodDeclaration.ReturnType); + CheckParameterList(context, methodDeclaration.ParameterList); + } + + private static void HandleConstructorDeclaration(SyntaxNodeAnalysisContext context) + { + if (!context.SupportsTuples()) + { + return; + } + + var constructorDeclaration = (ConstructorDeclarationSyntax)context.Node; + + CheckParameterList(context, constructorDeclaration.ParameterList); + } + + private static void HandlePropertyDeclaration(SyntaxNodeAnalysisContext context) + { + if (!context.SupportsTuples()) + { + return; + } + + var propertyDeclaration = (PropertyDeclarationSyntax)context.Node; + + CheckType(context, propertyDeclaration.Type); + } + + private static void HandleIndexerDeclaration(SyntaxNodeAnalysisContext context) + { + if (!context.SupportsTuples()) + { + return; + } + + var indexerDeclaration = (IndexerDeclarationSyntax)context.Node; + + CheckType(context, indexerDeclaration.Type); + } + + private static void HandleConversionOperatorDeclaration(SyntaxNodeAnalysisContext context) + { + if (!context.SupportsTuples()) + { + return; + } + + var conversionOperatorDeclarion = (ConversionOperatorDeclarationSyntax)context.Node; + + CheckType(context, conversionOperatorDeclarion.Type); + CheckParameterList(context, conversionOperatorDeclarion.ParameterList); + } + + private static void HandleDelegateDeclaration(SyntaxNodeAnalysisContext context) + { + if (!context.SupportsTuples()) + { + return; + } + + var delegateDeclarion = (DelegateDeclarationSyntax)context.Node; + + CheckType(context, delegateDeclarion.ReturnType); + CheckParameterList(context, delegateDeclarion.ParameterList); + } + + private static void CheckParameterList(SyntaxNodeAnalysisContext context, ParameterListSyntax parameterList) + { + foreach (var parameter in parameterList.Parameters) + { + CheckType(context, parameter.Type); + } + } + + private static void CheckType(SyntaxNodeAnalysisContext context, TypeSyntax typeSyntax) + { + switch (typeSyntax.Kind()) + { + case SyntaxKindEx.TupleType: + CheckTupleType(context, (TupleTypeSyntaxWrapper)typeSyntax); + break; + + case SyntaxKind.QualifiedName: + CheckType(context, ((QualifiedNameSyntax)typeSyntax).Right); + break; + + case SyntaxKind.GenericName: + CheckGenericName(context, (GenericNameSyntax)typeSyntax); + break; + } + } + + private static void CheckTupleType(SyntaxNodeAnalysisContext context, TupleTypeSyntaxWrapper tupleTypeSyntax) + { + foreach (var tupleElementSyntax in tupleTypeSyntax.Elements) + { + CheckType(context, tupleElementSyntax.Type); + + if (tupleElementSyntax.Identifier.IsKind(SyntaxKind.None) && !NamedTypeHelpers.IsImplementingAnInterfaceMember(context.SemanticModel.GetDeclaredSymbol(context.Node))) + { + var location = tupleElementSyntax.SyntaxNode.GetLocation(); + context.ReportDiagnostic(Diagnostic.Create(Descriptor, location)); + } + } + } + + private static void CheckGenericName(SyntaxNodeAnalysisContext context, GenericNameSyntax genericNameSyntax) + { + foreach (var typeArgument in genericNameSyntax.TypeArgumentList.Arguments) + { + CheckType(context, typeArgument); + } + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SystemDiagnosticsDebugDiagnosticBase.cs b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SystemDiagnosticsDebugDiagnosticBase.cs index 52516d92b..371d09c47 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SystemDiagnosticsDebugDiagnosticBase.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/MaintainabilityRules/SystemDiagnosticsDebugDiagnosticBase.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.MaintainabilityRules { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/NamingResources.Designer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/NamingResources.Designer.cs deleted file mode 100644 index 7ac0f90d3..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/NamingResources.Designer.cs +++ /dev/null @@ -1,172 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace StyleCop.Analyzers.NamingRules { - using System; - using System.Reflection; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class NamingResources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal NamingResources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StyleCop.Analyzers.NamingRules.NamingResources", typeof(NamingResources).GetTypeInfo().Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Rename To '{0}'. - /// - internal static string RenameToCodeFix { - get { - return ResourceManager.GetString("RenameToCodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Prefix interface name with 'I'. - /// - internal static string SA1302CodeFix { - get { - return ResourceManager.GetString("SA1302CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The name of a variable in C# does not begin with a lower-case letter.. - /// - internal static string SA1312Description { - get { - return ResourceManager.GetString("SA1312Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Variable '{0}' should begin with lower-case letter. - /// - internal static string SA1312MessageFormat { - get { - return ResourceManager.GetString("SA1312MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Variable names should begin with lower-case letter. - /// - internal static string SA1312Title { - get { - return ResourceManager.GetString("SA1312Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The name of a parameter in C# does not begin with a lower-case letter.. - /// - internal static string SA1313Description { - get { - return ResourceManager.GetString("SA1313Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parameter '{0}' should begin with lower-case letter. - /// - internal static string SA1313MessageFormat { - get { - return ResourceManager.GetString("SA1313MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parameter names should begin with lower-case letter. - /// - internal static string SA1313Title { - get { - return ResourceManager.GetString("SA1313Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Prefix type parameter name with 'T'. - /// - internal static string SA1314CodeFix { - get { - return ResourceManager.GetString("SA1314CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The name of a C# type parameter does not begin with the capital letter T.. - /// - internal static string SA1314Description { - get { - return ResourceManager.GetString("SA1314Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Type parameter names should begin with T. - /// - internal static string SA1314MessageFormat { - get { - return ResourceManager.GetString("SA1314MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Type parameter names should begin with T. - /// - internal static string SA1314Title { - get { - return ResourceManager.GetString("SA1314Title", resourceCulture); - } - } - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/NamingResources.resx b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/NamingResources.resx index f41e4bb8f..80a01e537 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/NamingResources.resx +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/NamingResources.resx @@ -120,9 +120,117 @@ Rename To '{0}' + + The name of a C# element does not begin with an upper-case letter. + + + Element '{0}' should begin with an uppercase letter + + + Element should begin with upper-case letter + + + There are currently no situations in which this rule will fire. + + + Element should begin with lower-case letter + + + Element should begin with lower-case letter + Prefix interface name with 'I' + + The name of a C# interface does not begin with the capital letter I. + + + Interface names should begin with I + + + Interface names should begin with I + + + The name of a constant C# field should begin with an upper-case letter. + + + Const field names should begin with upper-case letter + + + Const field names should begin with upper-case letter + + + The name of a non-private readonly C# field should being with an upper-case letter. + + + Non-private readonly fields should begin with upper-case letter + + + Non-private readonly fields should begin with upper-case letter + + + The name of a field or variable in C# uses Hungarian notation. + + + {0} '{1}' should not use Hungarian notation + + + Field names should not use Hungarian notation + + + The name of a field in C# does not begin with a lower-case letter. + + + Field '{0}' should begin with lower-case letter + + + Field names should begin with lower-case letter + + + The name of a public or internal field in C# does not begin with an upper-case letter. + + + Field '{0}' should begin with upper-case letter + + + Accessible fields should begin with upper-case letter + + + A field name in C# is prefixed with 'm_', 's_', or 't_'. + + + Field '{0}' should not begin with the prefix '{1}' + + + Variable names should not be prefixed + + + A field name in C# begins with an underscore. + + + Field '{0}' should not begin with an underscore + + + Field names should not begin with underscore + + + A field name in C# contains an underscore. + + + Field '{0}' should not contain an underscore + + + Field names should not contain underscore + + + The name of a static readonly field does not begin with an upper-case letter. + + + Static readonly fields should begin with upper-case letter + + + Static readonly fields should begin with upper-case letter + The name of a variable in C# does not begin with a lower-case letter. @@ -153,4 +261,34 @@ Type parameter names should begin with T + + Correct tuple element name casing + + + Element names within a tuple type should have the correct casing. + + + Tuple element names should use correct casing + + + Tuple element names should use correct casing + + + A field name in C# does not begin with an underscore. + + + Field '{0}' should begin with an underscore + + + A static field name in C# does not begin with an underscore. + + + Static field '{0}' should begin with an underscore + + + Static field names should begin with underscore + + + Field names should begin with underscore + \ No newline at end of file diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1300ElementMustBeginWithUpperCaseLetter.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1300ElementMustBeginWithUpperCaseLetter.cs index 846c32944..2d2cfe2be 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1300ElementMustBeginWithUpperCaseLetter.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1300ElementMustBeginWithUpperCaseLetter.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { @@ -12,6 +14,7 @@ namespace StyleCop.Analyzers.NamingRules using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; using StyleCop.Analyzers.Lightup; + using StyleCop.Analyzers.Settings.ObjectModel; /// /// The name of a C# element does not begin with an upper-case letter. @@ -29,6 +32,9 @@ namespace StyleCop.Analyzers.NamingRules /// class. A NativeMethods class is any class which contains a name ending in NativeMethods, and is /// intended as a placeholder for Win32 or COM wrappers. StyleCop will ignore this violation if the item is placed /// within a NativeMethods class. + /// + /// For namespace components that begin with a small letter, due to branding issues or other reasons, add the + /// term to the allowedNamespaceComponents list. /// [DiagnosticAnalyzer(LanguageNames.CSharp)] internal class SA1300ElementMustBeginWithUpperCaseLetter : DiagnosticAnalyzer @@ -37,16 +43,17 @@ internal class SA1300ElementMustBeginWithUpperCaseLetter : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1300"; - private const string Title = "Element should begin with upper-case letter"; - private const string MessageFormat = "Element '{0}' should begin with an uppercase letter"; - private const string Description = "The name of a C# element does not begin with an upper-case letter."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1300.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(NamingResources.SA1300Title), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(NamingResources.SA1300MessageFormat), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(NamingResources.SA1300Description), NamingResources.ResourceManager, typeof(NamingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.NamingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); - private static readonly Action NamespaceDeclarationAction = HandleNamespaceDeclaration; + private static readonly Action BaseNamespaceDeclarationAction = HandleBaseNamespaceDeclaration; private static readonly Action ClassDeclarationAction = HandleClassDeclaration; + private static readonly Action RecordDeclarationAction = HandleRecordDeclaration; private static readonly Action EnumDeclarationAction = HandleEnumDeclaration; private static readonly Action EnumMemberDeclarationAction = HandleEnumMemberDeclaration; private static readonly Action StructDeclarationAction = HandleStructDeclaration; @@ -56,6 +63,7 @@ internal class SA1300ElementMustBeginWithUpperCaseLetter : DiagnosticAnalyzer private static readonly Action MethodDeclarationAction = HandleMethodDeclaration; private static readonly Action LocalFunctionStatementAction = HandleLocalFunctionStatement; private static readonly Action PropertyDeclarationAction = HandlePropertyDeclaration; + private static readonly Action ParameterAction = HandleParameter; /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -67,28 +75,34 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - // Note: Interfaces are handled by SA1302 - // Note: Fields are handled by SA1303 through SA1311 - context.RegisterSyntaxNodeAction(NamespaceDeclarationAction, SyntaxKind.NamespaceDeclaration); - context.RegisterSyntaxNodeAction(ClassDeclarationAction, SyntaxKind.ClassDeclaration); - context.RegisterSyntaxNodeAction(EnumDeclarationAction, SyntaxKind.EnumDeclaration); - context.RegisterSyntaxNodeAction(EnumMemberDeclarationAction, SyntaxKind.EnumMemberDeclaration); - context.RegisterSyntaxNodeAction(StructDeclarationAction, SyntaxKind.StructDeclaration); - context.RegisterSyntaxNodeAction(DelegateDeclarationAction, SyntaxKind.DelegateDeclaration); - context.RegisterSyntaxNodeAction(EventDeclarationAction, SyntaxKind.EventDeclaration); - context.RegisterSyntaxNodeAction(EventFieldDeclarationAction, SyntaxKind.EventFieldDeclaration); - context.RegisterSyntaxNodeAction(MethodDeclarationAction, SyntaxKind.MethodDeclaration); - context.RegisterSyntaxNodeAction(LocalFunctionStatementAction, SyntaxKindEx.LocalFunctionStatement); - context.RegisterSyntaxNodeAction(PropertyDeclarationAction, SyntaxKind.PropertyDeclaration); + context.RegisterCompilationStartAction(context => + { + // Note: Interfaces are handled by SA1302 + // Note: Fields are handled by SA1303 through SA1311 + context.RegisterSyntaxNodeAction(BaseNamespaceDeclarationAction, SyntaxKinds.BaseNamespaceDeclaration); + context.RegisterSyntaxNodeAction(ClassDeclarationAction, SyntaxKind.ClassDeclaration); + context.RegisterSyntaxNodeAction(RecordDeclarationAction, SyntaxKindEx.RecordDeclaration); + context.RegisterSyntaxNodeAction(RecordDeclarationAction, SyntaxKindEx.RecordStructDeclaration); + context.RegisterSyntaxNodeAction(EnumDeclarationAction, SyntaxKind.EnumDeclaration); + context.RegisterSyntaxNodeAction(EnumMemberDeclarationAction, SyntaxKind.EnumMemberDeclaration); + context.RegisterSyntaxNodeAction(StructDeclarationAction, SyntaxKind.StructDeclaration); + context.RegisterSyntaxNodeAction(DelegateDeclarationAction, SyntaxKind.DelegateDeclaration); + context.RegisterSyntaxNodeAction(EventDeclarationAction, SyntaxKind.EventDeclaration); + context.RegisterSyntaxNodeAction(EventFieldDeclarationAction, SyntaxKind.EventFieldDeclaration); + context.RegisterSyntaxNodeAction(MethodDeclarationAction, SyntaxKind.MethodDeclaration); + context.RegisterSyntaxNodeAction(LocalFunctionStatementAction, SyntaxKindEx.LocalFunctionStatement); + context.RegisterSyntaxNodeAction(PropertyDeclarationAction, SyntaxKind.PropertyDeclaration); + context.RegisterSyntaxNodeAction(ParameterAction, SyntaxKind.Parameter); + }); } - private static void HandleNamespaceDeclaration(SyntaxNodeAnalysisContext context) + private static void HandleBaseNamespaceDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) { - NameSyntax nameSyntax = ((NamespaceDeclarationSyntax)context.Node).Name; - CheckNameSyntax(context, nameSyntax); + NameSyntax nameSyntax = ((BaseNamespaceDeclarationSyntaxWrapper)context.Node).Name; + CheckNamespaceNameSyntax(context, nameSyntax, settings); } - private static void CheckNameSyntax(SyntaxNodeAnalysisContext context, NameSyntax nameSyntax) + private static void CheckNamespaceNameSyntax(SyntaxNodeAnalysisContext context, NameSyntax nameSyntax, StyleCopSettings settings) { if (nameSyntax == null || nameSyntax.IsMissing) { @@ -97,12 +111,13 @@ private static void CheckNameSyntax(SyntaxNodeAnalysisContext context, NameSynta if (nameSyntax is QualifiedNameSyntax qualifiedNameSyntax) { - CheckNameSyntax(context, qualifiedNameSyntax.Left); - CheckNameSyntax(context, qualifiedNameSyntax.Right); + CheckNamespaceNameSyntax(context, qualifiedNameSyntax.Left, settings); + CheckNamespaceNameSyntax(context, qualifiedNameSyntax.Right, settings); return; } - if (nameSyntax is SimpleNameSyntax simpleNameSyntax) + if (nameSyntax is SimpleNameSyntax simpleNameSyntax && + !settings.NamingRules.AllowedNamespaceComponents.Contains(simpleNameSyntax.Identifier.ValueText)) { CheckElementNameToken(context, simpleNameSyntax.Identifier); return; @@ -116,6 +131,11 @@ private static void HandleClassDeclaration(SyntaxNodeAnalysisContext context) CheckElementNameToken(context, ((ClassDeclarationSyntax)context.Node).Identifier); } + private static void HandleRecordDeclaration(SyntaxNodeAnalysisContext context) + { + CheckElementNameToken(context, ((TypeDeclarationSyntax)context.Node).Identifier); + } + private static void HandleEnumDeclaration(SyntaxNodeAnalysisContext context) { CheckElementNameToken(context, ((EnumDeclarationSyntax)context.Node).Identifier); @@ -198,6 +218,19 @@ private static void HandlePropertyDeclaration(SyntaxNodeAnalysisContext context) CheckElementNameToken(context, propertyDeclaration.Identifier); } + private static void HandleParameter(SyntaxNodeAnalysisContext context) + { + var parameterDeclaration = (ParameterSyntax)context.Node; + if (!parameterDeclaration.Parent.IsKind(SyntaxKind.ParameterList) + || (!parameterDeclaration.Parent.Parent.IsKind(SyntaxKindEx.RecordDeclaration) && !parameterDeclaration.Parent.Parent.IsKind(SyntaxKindEx.RecordStructDeclaration))) + { + // Only positional parameters of records are treated as properties + return; + } + + CheckElementNameToken(context, parameterDeclaration.Identifier); + } + private static void CheckElementNameToken(SyntaxNodeAnalysisContext context, SyntaxToken identifier, bool allowUnderscoreDigit = false) { if (identifier.IsMissing) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1301ElementMustBeginWithLowerCaseLetter.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1301ElementMustBeginWithLowerCaseLetter.cs index 3af7b0f37..8ef79c763 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1301ElementMustBeginWithLowerCaseLetter.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1301ElementMustBeginWithLowerCaseLetter.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { @@ -20,13 +22,15 @@ internal class SA1301ElementMustBeginWithLowerCaseLetter : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1301"; - private const string Title = "Element should begin with lower-case letter"; - private const string MessageFormat = "Element should begin with lower-case letter"; - private const string Description = "There are currently no situations in which this rule will fire."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1301.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(NamingResources.SA1301Title), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(NamingResources.SA1301MessageFormat), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(NamingResources.SA1301Description), NamingResources.ResourceManager, typeof(NamingResources)); private static readonly DiagnosticDescriptor Descriptor = +#pragma warning disable RS2000 // Add analyzer diagnostic IDs to analyzer release. new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.NamingRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.NotConfigurable); +#pragma warning restore RS2000 // Add analyzer diagnostic IDs to analyzer release. /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -36,6 +40,9 @@ internal class SA1301ElementMustBeginWithLowerCaseLetter : DiagnosticAnalyzer [ExcludeFromCodeCoverage] public override void Initialize(AnalysisContext context) { + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); + context.EnableConcurrentExecution(); + // Intentionally empty } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1302InterfaceNamesMustBeginWithI.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1302InterfaceNamesMustBeginWithI.cs index 32bb0cbbe..ad4adee7d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1302InterfaceNamesMustBeginWithI.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1302InterfaceNamesMustBeginWithI.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { @@ -31,10 +33,10 @@ internal class SA1302InterfaceNamesMustBeginWithI : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1302"; - private const string Title = "Interface names should begin with I"; - private const string MessageFormat = "Interface names should begin with I"; - private const string Description = "The name of a C# interface does not begin with the capital letter I."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1302.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(NamingResources.SA1302Title), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(NamingResources.SA1302MessageFormat), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(NamingResources.SA1302Description), NamingResources.ResourceManager, typeof(NamingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.NamingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1303ConstFieldNamesMustBeginWithUpperCaseLetter.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1303ConstFieldNamesMustBeginWithUpperCaseLetter.cs index 9f4399df9..15bd011be 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1303ConstFieldNamesMustBeginWithUpperCaseLetter.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1303ConstFieldNamesMustBeginWithUpperCaseLetter.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { @@ -31,10 +33,10 @@ internal class SA1303ConstFieldNamesMustBeginWithUpperCaseLetter : DiagnosticAna /// analyzer. /// public const string DiagnosticId = "SA1303"; - private const string Title = "Const field names should begin with upper-case letter"; - private const string MessageFormat = "Const field names should begin with upper-case letter."; - private const string Description = "The name of a constant C# field should begin with an upper-case letter."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1303.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(NamingResources.SA1303Title), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(NamingResources.SA1303MessageFormat), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(NamingResources.SA1303Description), NamingResources.ResourceManager, typeof(NamingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.NamingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -51,7 +53,7 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSymbolAction(Analyzer.HandleFieldDeclaration, SymbolKind.Field); + context.RegisterSymbolAction(FieldDeclarationAction, SymbolKind.Field); } private static class Analyzer diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1304NonPrivateReadonlyFieldsMustBeginWithUpperCaseLetter.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1304NonPrivateReadonlyFieldsMustBeginWithUpperCaseLetter.cs index 8d638b86c..5af4679ea 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1304NonPrivateReadonlyFieldsMustBeginWithUpperCaseLetter.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1304NonPrivateReadonlyFieldsMustBeginWithUpperCaseLetter.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { @@ -33,12 +35,10 @@ internal class SA1304NonPrivateReadonlyFieldsMustBeginWithUpperCaseLetter : Diag /// analyzer. /// public const string DiagnosticId = "SA1304"; - private const string Title = "Non-private readonly fields should begin with upper-case letter"; - private const string MessageFormat = "Non-private readonly fields should begin with upper-case letter"; - - private const string Description = "The name of a non-private readonly C# field should being with an upper-case letter."; - private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1304.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(NamingResources.SA1304Title), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(NamingResources.SA1304MessageFormat), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(NamingResources.SA1304Description), NamingResources.ResourceManager, typeof(NamingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.NamingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -84,8 +84,7 @@ private static void HandleFieldDeclaration(SyntaxNodeAnalysisContext context) { // SA1307 is taken precedence here. SA1307 should be reported if the field is accessible. // So if SA1307 is enabled this diagnostic will only be reported for internal fields. - if (context.SemanticModel.Compilation.Options.SpecificDiagnosticOptions - .GetValueOrDefault(SA1307AccessibleFieldsMustBeginWithUpperCaseLetter.DiagnosticId, ReportDiagnostic.Default) != ReportDiagnostic.Suppress) + if (!context.IsAnalyzerSuppressed(SA1307AccessibleFieldsMustBeginWithUpperCaseLetter.Descriptor)) { return; } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1305FieldNamesMustNotUseHungarianNotation.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1305FieldNamesMustNotUseHungarianNotation.cs index a5af96793..fec5aae33 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1305FieldNamesMustNotUseHungarianNotation.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1305FieldNamesMustNotUseHungarianNotation.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { @@ -54,10 +56,10 @@ internal class SA1305FieldNamesMustNotUseHungarianNotation : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1305"; - private const string Title = "Field names should not use Hungarian notation"; - private const string MessageFormat = "{0} '{1}' should not use Hungarian notation"; - private const string Description = "The name of a field or variable in C# uses Hungarian notation."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1305.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(NamingResources.SA1305Title), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(NamingResources.SA1305MessageFormat), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(NamingResources.SA1305Description), NamingResources.ResourceManager, typeof(NamingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.NamingRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink); @@ -88,16 +90,19 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(VariableDeclarationAction, SyntaxKind.VariableDeclaration); - context.RegisterSyntaxNodeAction(ParameterDeclarationAction, SyntaxKind.Parameter); - context.RegisterSyntaxNodeAction(CatchDeclarationAction, SyntaxKind.CatchDeclaration); - context.RegisterSyntaxNodeAction(QueryContinuationAction, SyntaxKind.QueryContinuation); - context.RegisterSyntaxNodeAction(FromClauseAction, SyntaxKind.FromClause); - context.RegisterSyntaxNodeAction(LetClauseAction, SyntaxKind.LetClause); - context.RegisterSyntaxNodeAction(JoinClauseAction, SyntaxKind.JoinClause); - context.RegisterSyntaxNodeAction(JoinIntoClauseAction, SyntaxKind.JoinIntoClause); - context.RegisterSyntaxNodeAction(ForEachStatementAction, SyntaxKind.ForEachStatement); - context.RegisterSyntaxNodeAction(SingleVariableDesignationAction, SyntaxKindEx.SingleVariableDesignation); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(VariableDeclarationAction, SyntaxKind.VariableDeclaration); + context.RegisterSyntaxNodeAction(ParameterDeclarationAction, SyntaxKind.Parameter); + context.RegisterSyntaxNodeAction(CatchDeclarationAction, SyntaxKind.CatchDeclaration); + context.RegisterSyntaxNodeAction(QueryContinuationAction, SyntaxKind.QueryContinuation); + context.RegisterSyntaxNodeAction(FromClauseAction, SyntaxKind.FromClause); + context.RegisterSyntaxNodeAction(LetClauseAction, SyntaxKind.LetClause); + context.RegisterSyntaxNodeAction(JoinClauseAction, SyntaxKind.JoinClause); + context.RegisterSyntaxNodeAction(JoinIntoClauseAction, SyntaxKind.JoinIntoClause); + context.RegisterSyntaxNodeAction(ForEachStatementAction, SyntaxKind.ForEachStatement); + context.RegisterSyntaxNodeAction(SingleVariableDesignationAction, SyntaxKindEx.SingleVariableDesignation); + }); } private static class Analyzer diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1306FieldNamesMustBeginWithLowerCaseLetter.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1306FieldNamesMustBeginWithLowerCaseLetter.cs index 26ba845ff..de652bfe7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1306FieldNamesMustBeginWithLowerCaseLetter.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1306FieldNamesMustBeginWithLowerCaseLetter.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { @@ -33,10 +35,10 @@ internal class SA1306FieldNamesMustBeginWithLowerCaseLetter : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1306"; - private const string Title = "Field names should begin with lower-case letter"; - private const string MessageFormat = "Field '{0}' should begin with lower-case letter"; - private const string Description = "The name of a field in C# does not begin with a lower-case letter."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1306.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(NamingResources.SA1306Title), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(NamingResources.SA1306MessageFormat), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(NamingResources.SA1306Description), NamingResources.ResourceManager, typeof(NamingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.NamingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1307AccessibleFieldsMustBeginWithUpperCaseLetter.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1307AccessibleFieldsMustBeginWithUpperCaseLetter.cs index 33c051f94..2794aa757 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1307AccessibleFieldsMustBeginWithUpperCaseLetter.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1307AccessibleFieldsMustBeginWithUpperCaseLetter.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { @@ -32,13 +34,15 @@ internal class SA1307AccessibleFieldsMustBeginWithUpperCaseLetter : DiagnosticAn /// analyzer. /// public const string DiagnosticId = "SA1307"; - private const string Title = "Accessible fields should begin with upper-case letter"; - private const string MessageFormat = "Field '{0}' should begin with upper-case letter"; - private const string Description = "The name of a public or internal field in C# does not begin with an upper-case letter."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1307.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(NamingResources.SA1307Title), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(NamingResources.SA1307MessageFormat), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(NamingResources.SA1307Description), NamingResources.ResourceManager, typeof(NamingResources)); - private static readonly DiagnosticDescriptor Descriptor = +#pragma warning disable SA1202 // Elements should be ordered by access + internal static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.NamingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); +#pragma warning restore SA1202 // Elements should be ordered by access private static readonly Action FieldDeclarationAction = HandleFieldDeclaration; @@ -71,7 +75,7 @@ private static void HandleFieldDeclaration(SyntaxNodeAnalysisContext context) { foreach (VariableDeclaratorSyntax declarator in declaration.Declaration.Variables) { - string name = declarator.Identifier.ToString(); + string name = declarator.Identifier.ValueText; if (!string.IsNullOrEmpty(name) && char.IsLower(name[0]) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1308VariableNamesMustNotBePrefixed.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1308VariableNamesMustNotBePrefixed.cs index 84b3cdda6..aa8b1b990 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1308VariableNamesMustNotBePrefixed.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1308VariableNamesMustNotBePrefixed.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { @@ -37,10 +39,10 @@ internal class SA1308VariableNamesMustNotBePrefixed : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1308"; - private const string Title = "Variable names should not be prefixed"; - private const string MessageFormat = "Field '{0}' should not begin with the prefix '{1}'"; - private const string Description = "A field name in C# is prefixed with 'm_', 's_', or 't_'."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1308.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(NamingResources.SA1308Title), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(NamingResources.SA1308MessageFormat), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(NamingResources.SA1308Description), NamingResources.ResourceManager, typeof(NamingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.NamingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1309FieldNamesMustNotBeginWithUnderscore.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1309FieldNamesMustNotBeginWithUnderscore.cs index 5476ae5cc..cc0c43823 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1309FieldNamesMustNotBeginWithUnderscore.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1309FieldNamesMustNotBeginWithUnderscore.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { @@ -37,10 +39,10 @@ internal class SA1309FieldNamesMustNotBeginWithUnderscore : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1309"; - private const string Title = "Field names should not begin with underscore"; - private const string MessageFormat = "Field '{0}' should not begin with an underscore"; - private const string Description = "A field name in C# begins with an underscore."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1309.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(NamingResources.SA1309Title), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(NamingResources.SA1309MessageFormat), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(NamingResources.SA1309Description), NamingResources.ResourceManager, typeof(NamingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.NamingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1310FieldNamesMustNotContainUnderscore.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1310FieldNamesMustNotContainUnderscore.cs index 1588bb645..45f502abb 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1310FieldNamesMustNotContainUnderscore.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1310FieldNamesMustNotContainUnderscore.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { @@ -33,10 +35,10 @@ internal class SA1310FieldNamesMustNotContainUnderscore : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1310"; - private const string Title = "Field names should not contain underscore"; - private const string MessageFormat = "Field '{0}' should not contain an underscore"; - private const string Description = "A field name in C# contains an underscore."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1310.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(NamingResources.SA1310Title), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(NamingResources.SA1310MessageFormat), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(NamingResources.SA1310Description), NamingResources.ResourceManager, typeof(NamingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.NamingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1311StaticReadonlyFieldsMustBeginWithUpperCaseLetter.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1311StaticReadonlyFieldsMustBeginWithUpperCaseLetter.cs index f859e4578..97e73ad2f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1311StaticReadonlyFieldsMustBeginWithUpperCaseLetter.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1311StaticReadonlyFieldsMustBeginWithUpperCaseLetter.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { @@ -25,10 +27,10 @@ internal class SA1311StaticReadonlyFieldsMustBeginWithUpperCaseLetter : Diagnost /// analyzer. /// public const string DiagnosticId = "SA1311"; - private const string Title = "Static readonly fields should begin with upper-case letter"; - private const string MessageFormat = "Static readonly fields should begin with upper-case letter"; - private const string Description = "The name of a static readonly field does not begin with an upper-case letter."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1311.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(NamingResources.SA1311Title), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(NamingResources.SA1311MessageFormat), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(NamingResources.SA1311Description), NamingResources.ResourceManager, typeof(NamingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.NamingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1312VariableNamesMustBeginWithLowerCaseLetter.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1312VariableNamesMustBeginWithLowerCaseLetter.cs index c28074dbc..4d714cbda 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1312VariableNamesMustBeginWithLowerCaseLetter.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1312VariableNamesMustBeginWithLowerCaseLetter.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { @@ -31,10 +33,10 @@ internal class SA1312VariableNamesMustBeginWithLowerCaseLetter : DiagnosticAnaly /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1312"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1312.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(NamingResources.SA1312Title), NamingResources.ResourceManager, typeof(NamingResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(NamingResources.SA1312MessageFormat), NamingResources.ResourceManager, typeof(NamingResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(NamingResources.SA1312Description), NamingResources.ResourceManager, typeof(NamingResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1312.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.NamingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1313ParameterNamesMustBeginWithLowerCaseLetter.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1313ParameterNamesMustBeginWithLowerCaseLetter.cs index 8fb041fa9..869d5a2ae 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1313ParameterNamesMustBeginWithLowerCaseLetter.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1313ParameterNamesMustBeginWithLowerCaseLetter.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { @@ -10,6 +12,7 @@ namespace StyleCop.Analyzers.NamingRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; /// /// The name of a parameter in C# does not begin with a lower-case letter. @@ -33,10 +36,10 @@ internal class SA1313ParameterNamesMustBeginWithLowerCaseLetter : DiagnosticAnal /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1313"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1313.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(NamingResources.SA1313Title), NamingResources.ResourceManager, typeof(NamingResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(NamingResources.SA1313MessageFormat), NamingResources.ResourceManager, typeof(NamingResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(NamingResources.SA1313Description), NamingResources.ResourceManager, typeof(NamingResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1313.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.NamingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -64,6 +67,13 @@ private static void HandleParameter(SyntaxNodeAnalysisContext context) return; } + if (syntax.Parent.Parent.IsKind(SyntaxKindEx.RecordDeclaration) + || syntax.Parent.Parent.IsKind(SyntaxKindEx.RecordStructDeclaration)) + { + // Positional parameters of a record are treated as properties for naming conventions + return; + } + var identifier = syntax.Identifier; if (identifier.IsMissing) { @@ -127,12 +137,23 @@ private static bool NameMatchesAbstraction(ParameterSyntax syntax, SemanticModel if (methodSymbol.IsOverride) { - // OverridenMethod can be null in case of an invalid method declaration -> exit because there is no meaningful analysis to be done. + // OverriddenMethod can be null in case of an invalid method declaration -> exit because there is no meaningful analysis to be done. if ((methodSymbol.OverriddenMethod == null) || (methodSymbol.OverriddenMethod.Parameters[index].Name == syntax.Identifier.ValueText)) { return true; } } + else if (methodSymbol.ExplicitInterfaceImplementations.Length > 0) + { + // Checking explicitly implemented interface members here because the code below will not handle them correctly + foreach (var interfaceMethod in methodSymbol.ExplicitInterfaceImplementations) + { + if (interfaceMethod.Parameters[index].Name == syntax.Identifier.ValueText) + { + return true; + } + } + } else { var containingType = methodSymbol.ContainingType; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1314TypeParameterNamesMustBeginWithT.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1314TypeParameterNamesMustBeginWithT.cs index 5ae91e810..d8fcafd8c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1314TypeParameterNamesMustBeginWithT.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1314TypeParameterNamesMustBeginWithT.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { @@ -24,10 +26,10 @@ internal class SA1314TypeParameterNamesMustBeginWithT : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1314"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1314.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(NamingResources.SA1314Title), NamingResources.ResourceManager, typeof(NamingResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(NamingResources.SA1314MessageFormat), NamingResources.ResourceManager, typeof(NamingResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(NamingResources.SA1314Description), NamingResources.ResourceManager, typeof(NamingResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1314.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.NamingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1316TupleElementNamesShouldUseCorrectCasing.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1316TupleElementNamesShouldUseCorrectCasing.cs new file mode 100644 index 000000000..cfabeb4ab --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SA1316TupleElementNamesShouldUseCorrectCasing.cs @@ -0,0 +1,146 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.NamingRules +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.Diagnostics; + using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; + using StyleCop.Analyzers.Settings.ObjectModel; + + /// + /// Field names within a tuple declaration should have the correct casing. + /// + [DiagnosticAnalyzer(LanguageNames.CSharp)] + internal class SA1316TupleElementNamesShouldUseCorrectCasing : DiagnosticAnalyzer + { + /// + /// The ID for diagnostics produced by the analyzer. + /// + public const string DiagnosticId = "SA1316"; + + /// + /// The key used to signal the fixed tuple element name to the code fix. + /// + internal const string ExpectedTupleElementNameKey = "ExpectedTupleElementName"; + + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1316.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(NamingResources.SA1316Title), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(NamingResources.SA1316MessageFormat), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(NamingResources.SA1316Description), NamingResources.ResourceManager, typeof(NamingResources)); + + private static readonly DiagnosticDescriptor Descriptor = + new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.NamingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + + private static readonly Action TupleTypeAction = HandleTupleTypeAction; + private static readonly Action TupleExpressionAction = HandleTupleExpressionAction; + + /// + public override ImmutableArray SupportedDiagnostics { get; } = + ImmutableArray.Create(Descriptor); + + /// + public override void Initialize(AnalysisContext context) + { + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); + context.EnableConcurrentExecution(); + + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(TupleTypeAction, SyntaxKindEx.TupleType); + context.RegisterSyntaxNodeAction(TupleExpressionAction, SyntaxKindEx.TupleExpression); + }); + } + + private static void HandleTupleTypeAction(SyntaxNodeAnalysisContext context, StyleCopSettings settings) + { + if (!context.SupportsTuples()) + { + return; + } + + var tupleType = (TupleTypeSyntaxWrapper)context.Node; + + foreach (var tupleElement in tupleType.Elements) + { + CheckTupleElement(context, settings, tupleElement); + } + } + + private static void HandleTupleExpressionAction(SyntaxNodeAnalysisContext context, StyleCopSettings settings) + { + if (!context.SupportsInferredTupleElementNames()) + { + return; + } + + if (!settings.NamingRules.IncludeInferredTupleElementNames) + { + return; + } + + var tupleExpression = (TupleExpressionSyntaxWrapper)context.Node; + foreach (var argument in tupleExpression.Arguments) + { + var inferredMemberName = SyntaxFactsEx.TryGetInferredMemberName(argument.NameColon?.Name ?? argument.Expression); + if (inferredMemberName != null) + { + CheckName(context, settings, inferredMemberName, argument.Expression.GetLocation(), false); + } + } + } + + private static void CheckTupleElement(SyntaxNodeAnalysisContext context, StyleCopSettings settings, TupleElementSyntaxWrapper tupleElement) + { + if (tupleElement.Identifier == default) + { + return; + } + + CheckName(context, settings, tupleElement.Identifier.ValueText, tupleElement.Identifier.GetLocation(), true); + } + + private static void CheckName(SyntaxNodeAnalysisContext context, StyleCopSettings settings, string tupleElementName, Location location, bool prepareCodeFix) + { + if (tupleElementName == "_") + { + return; + } + + var firstCharacterIsLower = char.IsLower(tupleElementName[0]); + + bool reportDiagnostic; + string fixedName; + + switch (settings.NamingRules.TupleElementNameCasing) + { + case TupleElementNameCase.PascalCase: + reportDiagnostic = firstCharacterIsLower; + fixedName = char.ToUpper(tupleElementName[0]) + tupleElementName.Substring(1); + break; + + default: + reportDiagnostic = !firstCharacterIsLower; + fixedName = char.ToLower(tupleElementName[0]) + tupleElementName.Substring(1); + break; + } + + if (reportDiagnostic) + { + var diagnosticProperties = ImmutableDictionary.CreateBuilder(); + + if (prepareCodeFix) + { + diagnosticProperties.Add(ExpectedTupleElementNameKey, fixedName); + } + + context.ReportDiagnostic(Diagnostic.Create(Descriptor, location, diagnosticProperties.ToImmutableDictionary())); + } + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SX1309FieldNamesMustBeginWithUnderscore.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SX1309FieldNamesMustBeginWithUnderscore.cs index 0b33f2282..b15fa0948 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SX1309FieldNamesMustBeginWithUnderscore.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SX1309FieldNamesMustBeginWithUnderscore.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { @@ -33,10 +35,10 @@ internal class SX1309FieldNamesMustBeginWithUnderscore : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SX1309"; - private const string Title = "Field names should begin with underscore"; - private const string MessageFormat = "Field '{0}' should begin with an underscore"; - private const string Description = "A field name in C# does not begin with an underscore."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SX1309.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(NamingResources.SX1309Title), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(NamingResources.SX1309MessageFormat), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(NamingResources.SX1309Description), NamingResources.ResourceManager, typeof(NamingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.NamingRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledAlternative, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SX1309SStaticFieldNamesMustBeginWithUnderscore.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SX1309SStaticFieldNamesMustBeginWithUnderscore.cs index 240f97583..5a27b14b2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SX1309SStaticFieldNamesMustBeginWithUnderscore.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NamingRules/SX1309SStaticFieldNamesMustBeginWithUnderscore.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.NamingRules { @@ -34,10 +36,10 @@ internal class SX1309SStaticFieldNamesMustBeginWithUnderscore : DiagnosticAnalyz /// analyzer. /// public const string DiagnosticId = "SX1309S"; - private const string Title = "Static field names should begin with underscore"; - private const string MessageFormat = "Static field '{0}' should begin with an underscore"; - private const string Description = "A static field name in C# does not begin with an underscore."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SX1309S.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(NamingResources.SX1309STitle), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(NamingResources.SX1309SMessageFormat), NamingResources.ResourceManager, typeof(NamingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(NamingResources.SX1309SDescription), NamingResources.ResourceManager, typeof(NamingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.NamingRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledAlternative, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NoCodeFixAttribute.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NoCodeFixAttribute.cs index b498d9a41..e768e63ca 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NoCodeFixAttribute.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NoCodeFixAttribute.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/NoDiagnosticAttribute.cs b/StyleCop.Analyzers/StyleCop.Analyzers/NoDiagnosticAttribute.cs index bff4bce2e..75298c92a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/NoDiagnosticAttribute.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/NoDiagnosticAttribute.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/OrderingResources.Designer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/OrderingResources.Designer.cs deleted file mode 100644 index 0835b0fba..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/OrderingResources.Designer.cs +++ /dev/null @@ -1,253 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace StyleCop.Analyzers.OrderingRules { - using System; - using System.Reflection; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class OrderingResources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal OrderingResources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StyleCop.Analyzers.OrderingRules.OrderingResources", typeof(OrderingResources).GetTypeInfo().Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Fix element order. - /// - internal static string ElementOrderCodeFix { - get { - return ResourceManager.GetString("ElementOrderCodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Fix modifier order. - /// - internal static string ModifierOrderCodeFix { - get { - return ResourceManager.GetString("ModifierOrderCodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to An element within a C# code file is out of order in relation to the other elements in the code.. - /// - internal static string SA1201Description { - get { - return ResourceManager.GetString("SA1201Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A {0} should not follow a {1}. - /// - internal static string SA1201MessageFormat { - get { - return ResourceManager.GetString("SA1201MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Elements should appear in the correct order. - /// - internal static string SA1201Title { - get { - return ResourceManager.GetString("SA1201Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to An element within a C# code file is out of order in relation to other elements in the code.. - /// - internal static string SA1202Description { - get { - return ResourceManager.GetString("SA1202Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to '{0}' members should come before '{1}' members. - /// - internal static string SA1202MessageFormat { - get { - return ResourceManager.GetString("SA1202MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Elements should be ordered by access. - /// - internal static string SA1202Title { - get { - return ResourceManager.GetString("SA1202Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A constant field is placed beneath a non-constant field.. - /// - internal static string SA1203Description { - get { - return ResourceManager.GetString("SA1203Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Constant fields should appear before non-constant fields. - /// - internal static string SA1203MessageFormat { - get { - return ResourceManager.GetString("SA1203MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Constants should appear before fields. - /// - internal static string SA1203Title { - get { - return ResourceManager.GetString("SA1203Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A static element is positioned beneath an instance element.. - /// - internal static string SA1204Description { - get { - return ResourceManager.GetString("SA1204Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Static members should appear before non-static members. - /// - internal static string SA1204MessageFormat { - get { - return ResourceManager.GetString("SA1204MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Static elements should appear before instance elements. - /// - internal static string SA1204Title { - get { - return ResourceManager.GetString("SA1204Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Add access modifier. - /// - internal static string SA1205CodeFix { - get { - return ResourceManager.GetString("SA1205CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Place keyword 'protected' before keyword 'internal'. - /// - internal static string SA1207CodeFix { - get { - return ResourceManager.GetString("SA1207CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Fix accessor order. - /// - internal static string SA1213CodeFix { - get { - return ResourceManager.GetString("SA1213CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A readonly field is positioned beneath a non-readonly field.. - /// - internal static string SA1214Description { - get { - return ResourceManager.GetString("SA1214Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Readonly fields should appear before non-readonly fields. - /// - internal static string SA1214MessageFormat { - get { - return ResourceManager.GetString("SA1214MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Readonly fields should appear before non-readonly fields. - /// - internal static string SA1214Title { - get { - return ResourceManager.GetString("SA1214Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Reorder using statements. - /// - internal static string UsingCodeFix { - get { - return ResourceManager.GetString("UsingCodeFix", resourceCulture); - } - } - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/OrderingResources.resx b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/OrderingResources.resx index 73efdf658..be6132f01 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/OrderingResources.resx +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/OrderingResources.resx @@ -120,6 +120,24 @@ Fix element order + + Fix modifier order + + + A C# using directive is placed outside of a namespace element. + + + A C# using directive is placed inside of a namespace declaration. + + + Using directive should appear within a namespace declaration + + + Using directive should appear outside a namespace declaration + + + Using directives should be placed correctly + An element within a C# code file is out of order in relation to the other elements in the code. @@ -156,18 +174,96 @@ Static elements should appear before instance elements - - Fix modifier order - Add access modifier + + The partial element does not have an access modifier defined. + + + Partial elements should declare an access modifier + + + Partial elements should declare access + + + The keywords within the declaration of an element do not follow a standard ordering scheme. + + + The '{0}' modifier should appear before '{1}' + + + Declaration keywords should follow order + Place keyword 'protected' before keyword 'internal' + + The keyword '{0}' is positioned after the keyword '{1}' within the declaration of a {0} {1} C# element. + + + The keyword '{0}' should come before '{1}' + + + Protected should come before internal + + + A using directive which declares a member of the 'System' namespace appears after a using directive which declares a member of a different namespace, within a C# code file. + + + Using directive for '{0}' should appear before directive for '{1}' + + + System using directives should be placed before other using directives + + + A using-alias directive is positioned before a regular using directive. + + + Using alias directives should be placed after all using namespace directives + + + Using alias directives should be placed after other using directives + + + The using directives within a C# code file are not sorted alphabetically by namespace. + + + Using directives should be ordered alphabetically by the namespaces + + + Using directives should be ordered alphabetically by namespace + + + The using-alias directives within a C# code file are not sorted alphabetically by alias name. + + + Using alias directive for '{0}' should appear before using alias directive for '{1}' + + + Using alias directives should be ordered alphabetically by alias name + + + A get accessor appears after a set accessor within a property or indexer. + + + A get accessor appears after a set accessor within a property or indexer + + + Property accessors should follow order + Fix accessor order + + An add accessor appears after a remove accessor within an event. + + + Event accessors should follow order + + + Event accessors should follow order + A readonly field is positioned beneath a non-readonly field. @@ -177,6 +273,24 @@ Readonly fields should appear before non-readonly fields + + A using static directive is positioned before a regular or after an alias using directive. + + + Using static directives should be placed at the correct location + + + Using static directives should be placed at the correct location + + + All using static directives should be ordered alphabetically. + + + The using static directive for '{0}' should appear after the using static directive for '{1}' + + + Using static directives should be ordered alphabetically + Reorder using statements diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1200UsingDirectivesMustBePlacedCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1200UsingDirectivesMustBePlacedCorrectly.cs index cf4ab0068..a42d217e1 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1200UsingDirectivesMustBePlacedCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1200UsingDirectivesMustBePlacedCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { @@ -10,6 +12,8 @@ namespace StyleCop.Analyzers.OrderingRules using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; + using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.Settings.ObjectModel; /// @@ -157,22 +161,26 @@ internal class SA1200UsingDirectivesMustBePlacedCorrectly : DiagnosticAnalyzer /// public const string DiagnosticId = "SA1200"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1200.md"; + + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(OrderingResources.SA1200Title), OrderingResources.ResourceManager, typeof(OrderingResources)); + + private static readonly LocalizableString MessageFormatInside = new LocalizableResourceString(nameof(OrderingResources.SA1200MessageFormatInside), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString DescriptionInside = new LocalizableResourceString(nameof(OrderingResources.SA1200DescriptionInside), OrderingResources.ResourceManager, typeof(OrderingResources)); + + private static readonly LocalizableString MessageFormatOutside = new LocalizableResourceString(nameof(OrderingResources.SA1200MessageFormatOutside), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString DescriptionOutside = new LocalizableResourceString(nameof(OrderingResources.SA1200DescriptionOutside), OrderingResources.ResourceManager, typeof(OrderingResources)); + +#pragma warning disable SA1202 // Elements should be ordered by access internal static readonly DiagnosticDescriptor DescriptorInside = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormatInside, AnalyzerCategory.OrderingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, DescriptionInside, HelpLink); internal static readonly DiagnosticDescriptor DescriptorOutside = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormatOutside, AnalyzerCategory.OrderingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, DescriptionOutside, HelpLink); - - private const string Title = "Using directives should be placed correctly"; - private const string MessageFormatInside = "Using directive should appear within a namespace declaration"; - private const string DescriptionInside = "A C# using directive is placed outside of a namespace element."; - private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1200.md"; - - private const string MessageFormatOutside = "Using directive should appear outside a namespace declaration"; - private const string DescriptionOutside = "A C# using directive is placed inside of a namespace declaration."; +#pragma warning restore SA1202 // Elements should be ordered by access private static readonly Action CompilationUnitAction = HandleCompilationUnit; - private static readonly Action NamespaceDeclarationAction = HandleNamespaceDeclaration; + private static readonly Action BaseNamespaceDeclarationAction = HandleBaseNamespaceDeclaration; /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -184,8 +192,11 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); - context.RegisterSyntaxNodeAction(NamespaceDeclarationAction, SyntaxKind.NamespaceDeclaration); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); + context.RegisterSyntaxNodeAction(BaseNamespaceDeclarationAction, SyntaxKinds.BaseNamespaceDeclaration); + }); } /// @@ -218,7 +229,11 @@ private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context, Sty return; case SyntaxKind.AttributeList: - // suppress SA1200 if file contains an attribute in the global namespace + // Suppress SA1200 if file contains an attribute in the global namespace + return; + + case SyntaxKind.GlobalStatement: + // Suppress SA1200 if file contains top-level statements return; case SyntaxKind.UsingDirective: @@ -227,6 +242,7 @@ private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context, Sty case SyntaxKind.ExternAliasDirective: case SyntaxKind.NamespaceDeclaration: + case SyntaxKindEx.FileScopedNamespaceDeclaration: default: continue; } @@ -246,18 +262,20 @@ private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context, Sty /// /// The analysis context. /// The effective StyleCop analysis settings. - private static void HandleNamespaceDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) + private static void HandleBaseNamespaceDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) { if (settings.OrderingRules.UsingDirectivesPlacement != UsingDirectivesPlacement.OutsideNamespace) { return; } - NamespaceDeclarationSyntax syntax = (NamespaceDeclarationSyntax)context.Node; + BaseNamespaceDeclarationSyntaxWrapper syntax = (BaseNamespaceDeclarationSyntaxWrapper)context.Node; foreach (UsingDirectiveSyntax directive in syntax.Usings) { // Using directive should appear outside a namespace declaration +#pragma warning disable RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor (https://github.com/dotnet/roslyn-analyzers/issues/4103) context.ReportDiagnostic(Diagnostic.Create(DescriptorOutside, directive.GetLocation())); +#pragma warning restore RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1201ElementsMustAppearInTheCorrectOrder.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1201ElementsMustAppearInTheCorrectOrder.cs index ceb953553..e67d398ed 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1201ElementsMustAppearInTheCorrectOrder.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1201ElementsMustAppearInTheCorrectOrder.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { @@ -11,6 +13,7 @@ namespace StyleCop.Analyzers.OrderingRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.Settings.ObjectModel; /// @@ -112,19 +115,17 @@ internal class SA1201ElementsMustAppearInTheCorrectOrder : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1201"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1201.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(OrderingResources.SA1201Title), OrderingResources.ResourceManager, typeof(OrderingResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(OrderingResources.SA1201MessageFormat), OrderingResources.ResourceManager, typeof(OrderingResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(OrderingResources.SA1201Description), OrderingResources.ResourceManager, typeof(OrderingResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1201.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.OrderingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); - private static readonly ImmutableArray TypeDeclarationKinds = - ImmutableArray.Create(SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.InterfaceDeclaration); - // extern alias and usings are missing here because the compiler itself is enforcing the right order. private static readonly ImmutableArray OuterOrder = ImmutableArray.Create( + SyntaxKindEx.FileScopedNamespaceDeclaration, SyntaxKind.NamespaceDeclaration, SyntaxKind.DelegateDeclaration, SyntaxKind.EnumDeclaration, @@ -151,18 +152,19 @@ internal class SA1201ElementsMustAppearInTheCorrectOrder : DiagnosticAnalyzer private static readonly Dictionary MemberNames = new Dictionary { [SyntaxKind.NamespaceDeclaration] = "namespace", + [SyntaxKindEx.FileScopedNamespaceDeclaration] = "namespace", [SyntaxKind.DelegateDeclaration] = "delegate", [SyntaxKind.EnumDeclaration] = "enum", [SyntaxKind.InterfaceDeclaration] = "interface", [SyntaxKind.StructDeclaration] = "struct", [SyntaxKind.ClassDeclaration] = "class", + [SyntaxKindEx.RecordDeclaration] = "record", + [SyntaxKindEx.RecordStructDeclaration] = "record struct", [SyntaxKind.FieldDeclaration] = "field", [SyntaxKind.ConstructorDeclaration] = "constructor", [SyntaxKind.DestructorDeclaration] = "destructor", - [SyntaxKind.DelegateDeclaration] = "delegate", [SyntaxKind.EventDeclaration] = "event", - [SyntaxKind.EnumDeclaration] = "enum", - [SyntaxKind.InterfaceDeclaration] = "interface", + [SyntaxKind.EventFieldDeclaration] = "event", [SyntaxKind.PropertyDeclaration] = "property", [SyntaxKind.IndexerDeclaration] = "indexer", [SyntaxKind.MethodDeclaration] = "method", @@ -171,7 +173,7 @@ internal class SA1201ElementsMustAppearInTheCorrectOrder : DiagnosticAnalyzer }; private static readonly Action CompilationUnitAction = HandleCompilationUnit; - private static readonly Action NamespaceDeclarationAction = HandleNamespaceDeclaration; + private static readonly Action BaseNamespaceDeclarationAction = HandleBaseNamespaceDeclaration; private static readonly Action TypeDeclarationAction = HandleTypeDeclaration; /// @@ -184,9 +186,12 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); - context.RegisterSyntaxNodeAction(NamespaceDeclarationAction, SyntaxKind.NamespaceDeclaration); - context.RegisterSyntaxNodeAction(TypeDeclarationAction, TypeDeclarationKinds); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); + context.RegisterSyntaxNodeAction(BaseNamespaceDeclarationAction, SyntaxKinds.BaseNamespaceDeclaration); + context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKinds.TypeDeclaration); + }); } private static void HandleTypeDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) @@ -217,7 +222,7 @@ private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context, Sty HandleMemberList(context, elementOrder, kindIndex, compilationUnit.Members, OuterOrder); } - private static void HandleNamespaceDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) + private static void HandleBaseNamespaceDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) { var elementOrder = settings.OrderingRules.ElementOrder; int kindIndex = elementOrder.IndexOf(OrderingTrait.Kind); @@ -226,9 +231,9 @@ private static void HandleNamespaceDeclaration(SyntaxNodeAnalysisContext context return; } - var compilationUnit = (NamespaceDeclarationSyntax)context.Node; + var baseNamespaceDeclaration = (BaseNamespaceDeclarationSyntaxWrapper)context.Node; - HandleMemberList(context, elementOrder, kindIndex, compilationUnit.Members, OuterOrder); + HandleMemberList(context, elementOrder, kindIndex, baseNamespaceDeclaration.Members, OuterOrder); } private static void HandleMemberList(SyntaxNodeAnalysisContext context, ImmutableArray elementOrder, int kindIndex, SyntaxList members, ImmutableArray order) @@ -287,18 +292,31 @@ private static void HandleMemberList(SyntaxNodeAnalysisContext context, Immutabl } var elementSyntaxKind = members[i].Kind(); - elementSyntaxKind = elementSyntaxKind == SyntaxKind.EventFieldDeclaration ? SyntaxKind.EventDeclaration : elementSyntaxKind; - int index = order.IndexOf(elementSyntaxKind); + int index = order.IndexOf(GetSyntaxKindForOrdering(elementSyntaxKind)); var nextElementSyntaxKind = members[i + 1].Kind(); - nextElementSyntaxKind = nextElementSyntaxKind == SyntaxKind.EventFieldDeclaration ? SyntaxKind.EventDeclaration : nextElementSyntaxKind; - int nextIndex = order.IndexOf(nextElementSyntaxKind); + int nextIndex = order.IndexOf(GetSyntaxKindForOrdering(nextElementSyntaxKind)); if (index > nextIndex) { - context.ReportDiagnostic(Diagnostic.Create(Descriptor, NamedTypeHelpers.GetNameOrIdentifierLocation(members[i + 1]), MemberNames[nextElementSyntaxKind], MemberNames[elementSyntaxKind])); + // [Issue #3160] Added hardening here to make sure that this won't crash when working with invalid code. + var nextElementMemberName = MemberNames.GetValueOrDefault(nextElementSyntaxKind, ""); + var elementMemberName = MemberNames.GetValueOrDefault(elementSyntaxKind, ""); + + context.ReportDiagnostic(Diagnostic.Create(Descriptor, NamedTypeHelpers.GetNameOrIdentifierLocation(members[i + 1]), nextElementMemberName, elementMemberName)); } } } + + private static SyntaxKind GetSyntaxKindForOrdering(SyntaxKind syntaxKind) + { + return syntaxKind switch + { + SyntaxKind.EventFieldDeclaration => SyntaxKind.EventDeclaration, + SyntaxKindEx.RecordDeclaration => SyntaxKind.ClassDeclaration, + SyntaxKindEx.RecordStructDeclaration => SyntaxKind.StructDeclaration, + _ => syntaxKind, + }; + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1202ElementsMustBeOrderedByAccess.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1202ElementsMustBeOrderedByAccess.cs index 6ab2c7b26..2a94c3572 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1202ElementsMustBeOrderedByAccess.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1202ElementsMustBeOrderedByAccess.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { @@ -10,6 +12,7 @@ namespace StyleCop.Analyzers.OrderingRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.Settings.ObjectModel; /// @@ -42,17 +45,14 @@ internal class SA1202ElementsMustBeOrderedByAccess : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1202"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1202.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(OrderingResources.SA1202Title), OrderingResources.ResourceManager, typeof(OrderingResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(OrderingResources.SA1202MessageFormat), OrderingResources.ResourceManager, typeof(OrderingResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(OrderingResources.SA1202Description), OrderingResources.ResourceManager, typeof(OrderingResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1202.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.OrderingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); - private static readonly ImmutableArray TypeDeclarationKinds = - ImmutableArray.Create(SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration); - private static readonly ImmutableHashSet MemberKinds = ImmutableHashSet.Create( SyntaxKind.DelegateDeclaration, SyntaxKind.EnumDeclaration, @@ -66,10 +66,12 @@ internal class SA1202ElementsMustBeOrderedByAccess : DiagnosticAnalyzer SyntaxKind.IndexerDeclaration, SyntaxKind.MethodDeclaration, SyntaxKind.ConversionOperatorDeclaration, - SyntaxKind.OperatorDeclaration); + SyntaxKind.OperatorDeclaration, + SyntaxKindEx.RecordDeclaration, + SyntaxKindEx.RecordStructDeclaration); private static readonly Action CompilationUnitAction = HandleCompilationUnit; - private static readonly Action NamespaceDeclarationAction = HandleNamespaceDeclaration; + private static readonly Action BaseNamespaceDeclarationAction = HandleBaseNamespaceDeclaration; private static readonly Action TypeDeclarationAction = HandleTypeDeclaration; /// @@ -82,9 +84,12 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); - context.RegisterSyntaxNodeAction(NamespaceDeclarationAction, SyntaxKind.NamespaceDeclaration); - context.RegisterSyntaxNodeAction(TypeDeclarationAction, TypeDeclarationKinds); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); + context.RegisterSyntaxNodeAction(BaseNamespaceDeclarationAction, SyntaxKinds.BaseNamespaceDeclaration); + context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKinds.TypeDeclaration); + }); } private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context, StyleCopSettings settings) @@ -98,10 +103,10 @@ private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context, Sty var compilationUnit = (CompilationUnitSyntax)context.Node; - HandleMemberList(context, elementOrder, accessibilityIndex, compilationUnit.Members, AccessLevel.Internal); + HandleMemberList(context, elementOrder, accessibilityIndex, compilationUnit.Members); } - private static void HandleNamespaceDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) + private static void HandleBaseNamespaceDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) { var elementOrder = settings.OrderingRules.ElementOrder; int accessibilityIndex = elementOrder.IndexOf(OrderingTrait.Accessibility); @@ -110,9 +115,9 @@ private static void HandleNamespaceDeclaration(SyntaxNodeAnalysisContext context return; } - var compilationUnit = (NamespaceDeclarationSyntax)context.Node; + var baseNamespaceDeclaration = (BaseNamespaceDeclarationSyntaxWrapper)context.Node; - HandleMemberList(context, elementOrder, accessibilityIndex, compilationUnit.Members, AccessLevel.Internal); + HandleMemberList(context, elementOrder, accessibilityIndex, baseNamespaceDeclaration.Members); } private static void HandleTypeDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) @@ -126,12 +131,11 @@ private static void HandleTypeDeclaration(SyntaxNodeAnalysisContext context, Sty var typeDeclaration = (TypeDeclarationSyntax)context.Node; - HandleMemberList(context, elementOrder, accessibilityIndex, typeDeclaration.Members, AccessLevel.Private); + HandleMemberList(context, elementOrder, accessibilityIndex, typeDeclaration.Members); } - private static void HandleMemberList(SyntaxNodeAnalysisContext context, ImmutableArray elementOrder, int accessibilityIndex, SyntaxList members, AccessLevel defaultAccessLevel) + private static void HandleMemberList(SyntaxNodeAnalysisContext context, ImmutableArray elementOrder, int accessibilityIndex, SyntaxList members) { - MemberDeclarationSyntax previousMember = null; var previousSyntaxKind = SyntaxKind.None; var previousAccessLevel = AccessLevel.NotSpecified; bool previousIsConst = false; @@ -212,7 +216,6 @@ private static void HandleMemberList(SyntaxNodeAnalysisContext context, Immutabl } } - previousMember = member; previousSyntaxKind = currentSyntaxKind; previousAccessLevel = currentAccessLevel; previousIsConst = currentIsConst; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1203ConstantsMustAppearBeforeFields.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1203ConstantsMustAppearBeforeFields.cs index 141020d5f..c1782d003 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1203ConstantsMustAppearBeforeFields.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1203ConstantsMustAppearBeforeFields.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { @@ -27,10 +29,10 @@ internal class SA1203ConstantsMustAppearBeforeFields : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1203"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1203.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(OrderingResources.SA1203Title), OrderingResources.ResourceManager, typeof(OrderingResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(OrderingResources.SA1203MessageFormat), OrderingResources.ResourceManager, typeof(OrderingResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(OrderingResources.SA1203Description), OrderingResources.ResourceManager, typeof(OrderingResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1203.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.OrderingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -50,7 +52,10 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(TypeDeclarationAction, TypeDeclarationKinds); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(TypeDeclarationAction, TypeDeclarationKinds); + }); } private static void HandleTypeDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1204StaticElementsMustAppearBeforeInstanceElements.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1204StaticElementsMustAppearBeforeInstanceElements.cs index 8ca569534..5cfcc8a4e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1204StaticElementsMustAppearBeforeInstanceElements.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1204StaticElementsMustAppearBeforeInstanceElements.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { @@ -11,6 +13,7 @@ namespace StyleCop.Analyzers.OrderingRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.Settings.ObjectModel; /// @@ -29,10 +32,10 @@ internal class SA1204StaticElementsMustAppearBeforeInstanceElements : Diagnostic /// analyzer. /// public const string DiagnosticId = "SA1204"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1204.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(OrderingResources.SA1204Title), OrderingResources.ResourceManager, typeof(OrderingResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(OrderingResources.SA1204MessageFormat), OrderingResources.ResourceManager, typeof(OrderingResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(OrderingResources.SA1204Description), OrderingResources.ResourceManager, typeof(OrderingResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1204.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.OrderingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -41,7 +44,7 @@ internal class SA1204StaticElementsMustAppearBeforeInstanceElements : Diagnostic ImmutableArray.Create(SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration); private static readonly Action CompilationUnitAction = HandleCompilationUnit; - private static readonly Action NamespaceDeclarationAction = HandleNamespaceDeclaration; + private static readonly Action BaseNamespaceDeclarationAction = HandleBaseNamespaceDeclaration; private static readonly Action TypeDeclarationAction = HandleTypeDeclaration; /// @@ -54,9 +57,12 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); - context.RegisterSyntaxNodeAction(NamespaceDeclarationAction, SyntaxKind.NamespaceDeclaration); - context.RegisterSyntaxNodeAction(TypeDeclarationAction, TypeDeclarationKinds); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); + context.RegisterSyntaxNodeAction(BaseNamespaceDeclarationAction, SyntaxKinds.BaseNamespaceDeclaration); + context.RegisterSyntaxNodeAction(TypeDeclarationAction, TypeDeclarationKinds); + }); } private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context, StyleCopSettings settings) @@ -73,7 +79,7 @@ private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context, Sty HandleMemberList(context, elementOrder, staticIndex, compilationUnit.Members); } - private static void HandleNamespaceDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) + private static void HandleBaseNamespaceDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) { var elementOrder = settings.OrderingRules.ElementOrder; int staticIndex = elementOrder.IndexOf(OrderingTrait.Static); @@ -82,9 +88,9 @@ private static void HandleNamespaceDeclaration(SyntaxNodeAnalysisContext context return; } - var compilationUnit = (NamespaceDeclarationSyntax)context.Node; + var baseNamespaceDeclaration = (BaseNamespaceDeclarationSyntaxWrapper)context.Node; - HandleMemberList(context, elementOrder, staticIndex, compilationUnit.Members); + HandleMemberList(context, elementOrder, staticIndex, baseNamespaceDeclaration.Members); } private static void HandleTypeDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1205PartialElementsMustDeclareAccess.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1205PartialElementsMustDeclareAccess.cs index 131ff96cc..fb2effabc 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1205PartialElementsMustDeclareAccess.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1205PartialElementsMustDeclareAccess.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { @@ -25,10 +27,10 @@ internal class SA1205PartialElementsMustDeclareAccess : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1205"; - private const string Title = "Partial elements should declare access"; - private const string MessageFormat = "Partial elements should declare an access modifier"; - private const string Description = "The partial element does not have an access modifier defined."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1205.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(OrderingResources.SA1205Title), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(OrderingResources.SA1205MessageFormat), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(OrderingResources.SA1205Description), OrderingResources.ResourceManager, typeof(OrderingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.OrderingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1206DeclarationKeywordsMustFollowOrder.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1206DeclarationKeywordsMustFollowOrder.cs index da8e99571..5b2141ceb 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1206DeclarationKeywordsMustFollowOrder.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1206DeclarationKeywordsMustFollowOrder.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { @@ -38,10 +40,10 @@ internal class SA1206DeclarationKeywordsMustFollowOrder : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1206"; - private const string Title = "Declaration keywords should follow order"; - private const string MessageFormat = "The '{0}' modifier should appear before '{1}'"; - private const string Description = "The keywords within the declaration of an element do not follow a standard ordering scheme."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1206.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(OrderingResources.SA1206Title), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(OrderingResources.SA1206MessageFormat), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(OrderingResources.SA1206Description), OrderingResources.ResourceManager, typeof(OrderingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.OrderingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -88,21 +90,33 @@ private static void CheckModifiersOrderAndReportDiagnostics(SyntaxNodeAnalysisCo { var previousModifierType = ModifierType.None; var otherModifiersAppearEarlier = false; - SyntaxToken previousModifier = default(SyntaxToken); - SyntaxToken previousOtherModifier = default(SyntaxToken); + SyntaxToken previousModifier = default; + SyntaxToken previousOtherModifier = default; foreach (var modifier in modifiers) { var currentModifierType = GetModifierType(modifier); + bool reportPreviousModifier = false; + bool reportPreviousOtherModifier = false; if (CompareModifiersType(currentModifierType, previousModifierType) < 0) { - context.ReportDiagnostic(Diagnostic.Create(Descriptor, modifier.GetLocation(), modifier.ValueText, previousModifier.ValueText)); + reportPreviousModifier = true; } if (AccessOrStaticModifierNotFollowingOtherModifier(currentModifierType, previousModifierType) && otherModifiersAppearEarlier) { - context.ReportDiagnostic(Diagnostic.Create(Descriptor, modifier.GetLocation(), modifier.ValueText, previousOtherModifier.ValueText)); + reportPreviousOtherModifier = true; + } + + if (reportPreviousModifier || reportPreviousOtherModifier) + { + // Note: Only report one diagnostic per modifier. If both diagnostics apply, report the diagnostic + // relative to the earlier modifier. + var reportedModifier = reportPreviousModifier && (!reportPreviousOtherModifier || previousModifier.SpanStart < previousOtherModifier.SpanStart) + ? previousModifier.ValueText + : previousOtherModifier.ValueText; + context.ReportDiagnostic(Diagnostic.Create(Descriptor, modifier.GetLocation(), modifier.ValueText, reportedModifier)); } if (!otherModifiersAppearEarlier && currentModifierType == ModifierType.Other) @@ -155,28 +169,6 @@ private static int CompareModifiersType(ModifierType first, ModifierType second) return result; } - private static string GetModifierTypeText(ModifierType modifierType) - { - var result = string.Empty; - - switch (modifierType) - { - case ModifierType.Access: - result = "access modifier"; - break; - - case ModifierType.Static: - result = "static"; - break; - - case ModifierType.Other: - result = "other"; - break; - } - - return result; - } - private static bool AccessOrStaticModifierNotFollowingOtherModifier(ModifierType current, ModifierType previous) => (current == ModifierType.Access || current == ModifierType.Static) && previous != ModifierType.Other; } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1207ProtectedMustComeBeforeInternal.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1207ProtectedMustComeBeforeInternal.cs index 34efaae90..1e04fd92b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1207ProtectedMustComeBeforeInternal.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1207ProtectedMustComeBeforeInternal.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { @@ -11,11 +13,12 @@ namespace StyleCop.Analyzers.OrderingRules /// /// The keyword protected is positioned after the keyword internal within the declaration of a - /// protected internal C# element. + /// protected internal C# element, or the keyword private is positioned after the keyword protected. /// /// /// A violation of this rule occurs when a protected internal element's access modifiers are written as - /// internal protected. In reality, an element with the keywords protected internal will have the same + /// internal protected, or when a private protected element's access modifiers are written as + /// protected private. In reality, an element with the keywords protected internal will have the same /// access level as an element with the keywords internal protected. To make the code easier to read and more /// consistent, StyleCop standardizes the ordering of these keywords, so that a protected internal element will /// always be described as such, and never as internal protected. This can help to reduce confusion about whether @@ -28,10 +31,10 @@ internal class SA1207ProtectedMustComeBeforeInternal : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1207"; - private const string Title = "Protected should come before internal"; - private const string MessageFormat = "The keyword 'protected' should come before 'internal'."; - private const string Description = "The keyword 'protected' is positioned after the keyword 'internal' within the declaration of a protected internal C# element."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1207.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(OrderingResources.SA1207Title), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(OrderingResources.SA1207MessageFormat), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(OrderingResources.SA1207Description), OrderingResources.ResourceManager, typeof(OrderingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.OrderingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -72,6 +75,7 @@ private static void HandleDeclaration(SyntaxNodeAnalysisContext context) return; } + bool protectedKeywordFound = false; bool internalKeywordFound = false; foreach (var childToken in childTokens) { @@ -80,10 +84,22 @@ private static void HandleDeclaration(SyntaxNodeAnalysisContext context) internalKeywordFound = true; continue; } - - if (internalKeywordFound && childToken.IsKind(SyntaxKind.ProtectedKeyword)) + else if (childToken.IsKind(SyntaxKind.ProtectedKeyword)) + { + if (internalKeywordFound) + { + context.ReportDiagnostic(Diagnostic.Create(Descriptor, childToken.GetLocation(), "protected", "internal")); + break; + } + else + { + protectedKeywordFound = true; + continue; + } + } + else if (protectedKeywordFound && childToken.IsKind(SyntaxKind.PrivateKeyword)) { - context.ReportDiagnostic(Diagnostic.Create(Descriptor, childToken.GetLocation())); + context.ReportDiagnostic(Diagnostic.Create(Descriptor, childToken.GetLocation(), "private", "protected")); break; } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1208SystemUsingDirectivesMustBePlacedBeforeOtherUsingDirectives.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1208SystemUsingDirectivesMustBePlacedBeforeOtherUsingDirectives.cs index 2309e0efd..0e53ce59d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1208SystemUsingDirectivesMustBePlacedBeforeOtherUsingDirectives.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1208SystemUsingDirectivesMustBePlacedBeforeOtherUsingDirectives.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { @@ -10,6 +12,7 @@ namespace StyleCop.Analyzers.OrderingRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.Settings.ObjectModel; /// @@ -30,16 +33,16 @@ internal class SA1208SystemUsingDirectivesMustBePlacedBeforeOtherUsingDirectives /// analyzer. /// public const string DiagnosticId = "SA1208"; - private const string Title = "System using directives should be placed before other using directives"; - private const string MessageFormat = "Using directive for '{0}' should appear before directive for '{1}'"; - private const string Description = "A using directive which declares a member of the 'System' namespace appears after a using directive which declares a member of a different namespace, within a C# code file."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1208.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(OrderingResources.SA1208Title), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(OrderingResources.SA1208MessageFormat), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(OrderingResources.SA1208Description), OrderingResources.ResourceManager, typeof(OrderingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.OrderingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); private static readonly Action CompilationUnitAction = HandleCompilationUnit; - private static readonly Action NamespaceDeclarationAction = HandleNamespaceDeclaration; + private static readonly Action BaseNamespaceDeclarationAction = HandleBaseNamespaceDeclaration; /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -51,8 +54,11 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); - context.RegisterSyntaxNodeAction(NamespaceDeclarationAction, SyntaxKind.NamespaceDeclaration); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); + context.RegisterSyntaxNodeAction(BaseNamespaceDeclarationAction, SyntaxKinds.BaseNamespaceDeclaration); + }); } private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context, StyleCopSettings settings) @@ -69,17 +75,15 @@ private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context, Sty ProcessUsingsAndReportDiagnostic(usings, context); } - private static void HandleNamespaceDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) + private static void HandleBaseNamespaceDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) { if (!settings.OrderingRules.SystemUsingDirectivesFirst) { return; } - var namespaceDeclaration = (NamespaceDeclarationSyntax)context.Node; - + var namespaceDeclaration = (BaseNamespaceDeclarationSyntaxWrapper)context.Node; var usings = namespaceDeclaration.Usings; - ProcessUsingsAndReportDiagnostic(usings, context); } @@ -107,7 +111,7 @@ private static void ProcessUsingsAndReportDiagnostic(SyntaxList /// A using-alias directive is positioned before a regular using directive. @@ -28,16 +31,16 @@ internal class SA1209UsingAliasDirectivesMustBePlacedAfterOtherUsingDirectives : /// analyzer. /// public const string DiagnosticId = "SA1209"; - private const string Title = "Using alias directives should be placed after other using directives"; - private const string MessageFormat = "Using alias directives should be placed after all using namespace directives."; - private const string Description = "A using-alias directive is positioned before a regular using directive."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1209.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(OrderingResources.SA1209Title), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(OrderingResources.SA1209MessageFormat), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(OrderingResources.SA1209Description), OrderingResources.ResourceManager, typeof(OrderingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.OrderingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); private static readonly Action CompilationUnitAction = HandleCompilationUnit; - private static readonly Action NamespaceDeclarationAction = HandleNamespaceDeclaration; + private static readonly Action BaseNamespaceDeclarationAction = HandleBaseNamespaceDeclaration; /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -50,7 +53,7 @@ public override void Initialize(AnalysisContext context) context.EnableConcurrentExecution(); context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); - context.RegisterSyntaxNodeAction(NamespaceDeclarationAction, SyntaxKind.NamespaceDeclaration); + context.RegisterSyntaxNodeAction(BaseNamespaceDeclarationAction, SyntaxKinds.BaseNamespaceDeclaration); } private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context) @@ -60,9 +63,9 @@ private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context) ProcessUsingsAndReportDiagnostic(compilationUnit.Usings, context); } - private static void HandleNamespaceDeclaration(SyntaxNodeAnalysisContext context) + private static void HandleBaseNamespaceDeclaration(SyntaxNodeAnalysisContext context) { - var namespaceDeclaration = (NamespaceDeclarationSyntax)context.Node; + var namespaceDeclaration = (BaseNamespaceDeclarationSyntaxWrapper)context.Node; ProcessUsingsAndReportDiagnostic(namespaceDeclaration.Usings, context); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1210UsingDirectivesMustBeOrderedAlphabeticallyByNamespace.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1210UsingDirectivesMustBeOrderedAlphabeticallyByNamespace.cs index 90d40691d..9ef3af50e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1210UsingDirectivesMustBeOrderedAlphabeticallyByNamespace.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1210UsingDirectivesMustBeOrderedAlphabeticallyByNamespace.cs @@ -1,17 +1,19 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { using System; using System.Collections.Generic; using System.Collections.Immutable; - using System.Globalization; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.Settings.ObjectModel; /// @@ -32,16 +34,16 @@ internal class SA1210UsingDirectivesMustBeOrderedAlphabeticallyByNamespace : Dia /// analyzer. /// public const string DiagnosticId = "SA1210"; - private const string Title = "Using directives should be ordered alphabetically by namespace"; - private const string MessageFormat = "Using directives should be ordered alphabetically by the namespaces."; - private const string Description = "The using directives within a C# code file are not sorted alphabetically by namespace."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1210.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(OrderingResources.SA1210Title), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(OrderingResources.SA1210MessageFormat), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(OrderingResources.SA1210Description), OrderingResources.ResourceManager, typeof(OrderingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.OrderingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); private static readonly Action CompilationUnitAction = HandleCompilationUnit; - private static readonly Action NamespaceDeclarationAction = HandleNamespaceDeclaration; + private static readonly Action BaseNamespaceDeclarationAction = HandleBaseNamespaceDeclaration; /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -53,8 +55,11 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); - context.RegisterSyntaxNodeAction(NamespaceDeclarationAction, SyntaxKind.NamespaceDeclaration); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); + context.RegisterSyntaxNodeAction(BaseNamespaceDeclarationAction, SyntaxKinds.BaseNamespaceDeclaration); + }); } private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context, StyleCopSettings settings) @@ -64,9 +69,9 @@ private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context, Sty ProcessUsings(context, settings.OrderingRules, compilationUnit.Usings); } - private static void HandleNamespaceDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) + private static void HandleBaseNamespaceDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) { - var namespaceDeclaration = (NamespaceDeclarationSyntax)context.Node; + var namespaceDeclaration = (BaseNamespaceDeclarationSyntaxWrapper)context.Node; ProcessUsings(context, settings.OrderingRules, namespaceDeclaration.Usings); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1211UsingAliasDirectivesMustBeOrderedAlphabeticallyByAliasName.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1211UsingAliasDirectivesMustBeOrderedAlphabeticallyByAliasName.cs index 90ea48536..04374b26c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1211UsingAliasDirectivesMustBeOrderedAlphabeticallyByAliasName.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1211UsingAliasDirectivesMustBeOrderedAlphabeticallyByAliasName.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { @@ -11,6 +13,7 @@ namespace StyleCop.Analyzers.OrderingRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; /// /// The using-alias directives within a C# code file are not sorted alphabetically by alias name. @@ -28,16 +31,16 @@ internal class SA1211UsingAliasDirectivesMustBeOrderedAlphabeticallyByAliasName /// analyzer. /// public const string DiagnosticId = "SA1211"; - private const string Title = "Using alias directives should be ordered alphabetically by alias name"; - private const string MessageFormat = "Using alias directive for '{0}' should appear before using alias directive for '{1}'"; - private const string Description = "The using-alias directives within a C# code file are not sorted alphabetically by alias name."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1211.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(OrderingResources.SA1211Title), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(OrderingResources.SA1211MessageFormat), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(OrderingResources.SA1211Description), OrderingResources.ResourceManager, typeof(OrderingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.OrderingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); private static readonly Action CompilationUnitAction = HandleCompilationUnit; - private static readonly Action NamespaceDeclarationAction = HandleNamespaceDeclaration; + private static readonly Action BaseNamespaceDeclarationAction = HandleBaseNamespaceDeclaration; /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -50,7 +53,7 @@ public override void Initialize(AnalysisContext context) context.EnableConcurrentExecution(); context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); - context.RegisterSyntaxNodeAction(NamespaceDeclarationAction, SyntaxKind.NamespaceDeclaration); + context.RegisterSyntaxNodeAction(BaseNamespaceDeclarationAction, SyntaxKinds.BaseNamespaceDeclaration); } private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context) @@ -59,9 +62,9 @@ private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context) HandleUsingDirectives(context, compilationUnit.Usings); } - private static void HandleNamespaceDeclaration(SyntaxNodeAnalysisContext context) + private static void HandleBaseNamespaceDeclaration(SyntaxNodeAnalysisContext context) { - var namespaceDeclaration = (NamespaceDeclarationSyntax)context.Node; + var namespaceDeclaration = (BaseNamespaceDeclarationSyntaxWrapper)context.Node; HandleUsingDirectives(context, namespaceDeclaration.Usings); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1212PropertyAccessorsMustFollowOrder.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1212PropertyAccessorsMustFollowOrder.cs index 034fcb996..a2285c411 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1212PropertyAccessorsMustFollowOrder.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1212PropertyAccessorsMustFollowOrder.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { @@ -9,6 +11,7 @@ namespace StyleCop.Analyzers.OrderingRules using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; + using StyleCop.Analyzers.Lightup; /// /// A get accessor appears after a set accessor within a property or indexer. @@ -44,10 +47,10 @@ internal class SA1212PropertyAccessorsMustFollowOrder : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1212"; - private const string Title = "Property accessors should follow order"; - private const string MessageFormat = "A get accessor appears after a set accessor within a property or indexer."; - private const string Description = "A get accessor appears after a set accessor within a property or indexer."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1212.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(OrderingResources.SA1212Title), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(OrderingResources.SA1212MessageFormat), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(OrderingResources.SA1212Description), OrderingResources.ResourceManager, typeof(OrderingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.OrderingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -97,7 +100,7 @@ private static void AnalyzeProperty(SyntaxNodeAnalysisContext context, BasePrope return; } - if (accessors[0].Kind() == SyntaxKind.SetAccessorDeclaration && + if ((accessors[0].Kind() is SyntaxKind.SetAccessorDeclaration or SyntaxKindEx.InitAccessorDeclaration) && accessors[1].Kind() == SyntaxKind.GetAccessorDeclaration) { context.ReportDiagnostic(Diagnostic.Create(Descriptor, accessors[0].GetLocation())); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1213EventAccessorsMustFollowOrder.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1213EventAccessorsMustFollowOrder.cs index cf198f93e..a6265e490 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1213EventAccessorsMustFollowOrder.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1213EventAccessorsMustFollowOrder.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { @@ -44,10 +46,10 @@ internal class SA1213EventAccessorsMustFollowOrder : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1213"; - private const string Title = "Event accessors should follow order"; - private const string MessageFormat = "Event accessors should follow order."; - private const string Description = "An add accessor appears after a remove accessor within an event."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1213.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(OrderingResources.SA1213Title), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(OrderingResources.SA1213MessageFormat), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(OrderingResources.SA1213Description), OrderingResources.ResourceManager, typeof(OrderingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.OrderingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1214ReadonlyElementsMustAppearBeforeNonReadonlyElements.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1214ReadonlyElementsMustAppearBeforeNonReadonlyElements.cs index a61f1e29b..a732a62f9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1214ReadonlyElementsMustAppearBeforeNonReadonlyElements.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1214ReadonlyElementsMustAppearBeforeNonReadonlyElements.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { @@ -23,10 +25,10 @@ internal class SA1214ReadonlyElementsMustAppearBeforeNonReadonlyElements : Diagn /// analyzer. /// public const string DiagnosticId = "SA1214"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1214.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(OrderingResources.SA1214Title), OrderingResources.ResourceManager, typeof(OrderingResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(OrderingResources.SA1214MessageFormat), OrderingResources.ResourceManager, typeof(OrderingResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(OrderingResources.SA1214Description), OrderingResources.ResourceManager, typeof(OrderingResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1214.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.OrderingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -46,7 +48,10 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(TypeDeclarationAction, TypeDeclarationKinds); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(TypeDeclarationAction, TypeDeclarationKinds); + }); } private static void HandleTypeDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1216UsingStaticDirectivesMustBePlacedAtTheCorrectLocation.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1216UsingStaticDirectivesMustBePlacedAtTheCorrectLocation.cs index f9704d7e8..01bb78822 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1216UsingStaticDirectivesMustBePlacedAtTheCorrectLocation.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1216UsingStaticDirectivesMustBePlacedAtTheCorrectLocation.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { @@ -10,6 +12,7 @@ namespace StyleCop.Analyzers.OrderingRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; /// /// A static using directive is positioned at the wrong location. @@ -28,16 +31,16 @@ internal class SA1216UsingStaticDirectivesMustBePlacedAtTheCorrectLocation : Dia /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1216"; - private const string Title = "Using static directives should be placed at the correct location."; - private const string MessageFormat = "Using static directives should be placed at the correct location."; - private const string Description = "A using static directive is positioned before a regular or after an alias using directive."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1216.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(OrderingResources.SA1216Title), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(OrderingResources.SA1216MessageFormat), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(OrderingResources.SA1216Description), OrderingResources.ResourceManager, typeof(OrderingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.OrderingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); private static readonly Action CompilationUnitAction = HandleCompilationUnit; - private static readonly Action NamespaceDeclarationAction = HandleNamespaceDeclaration; + private static readonly Action BaseNamespaceDeclarationAction = HandleBaseNamespaceDeclaration; /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -50,7 +53,7 @@ public override void Initialize(AnalysisContext context) context.EnableConcurrentExecution(); context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); - context.RegisterSyntaxNodeAction(NamespaceDeclarationAction, SyntaxKind.NamespaceDeclaration); + context.RegisterSyntaxNodeAction(BaseNamespaceDeclarationAction, SyntaxKinds.BaseNamespaceDeclaration); } private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context) @@ -59,9 +62,9 @@ private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context) CheckUsingDeclarations(context, compilationUnit.Usings); } - private static void HandleNamespaceDeclaration(SyntaxNodeAnalysisContext context) + private static void HandleBaseNamespaceDeclaration(SyntaxNodeAnalysisContext context) { - var namespaceDirective = (NamespaceDeclarationSyntax)context.Node; + var namespaceDirective = (BaseNamespaceDeclarationSyntaxWrapper)context.Node; CheckUsingDeclarations(context, namespaceDirective.Usings); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1217UsingStaticDirectivesMustBeOrderedAlphabetically.cs b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1217UsingStaticDirectivesMustBeOrderedAlphabetically.cs index 751b56047..a7d98312e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1217UsingStaticDirectivesMustBeOrderedAlphabetically.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/OrderingRules/SA1217UsingStaticDirectivesMustBeOrderedAlphabetically.cs @@ -1,16 +1,19 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.OrderingRules { using System; using System.Collections.Immutable; - using System.Globalization; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; + using StyleCop.Analyzers.Settings.ObjectModel; /// /// A static using directive is positioned at the wrong location. @@ -29,16 +32,16 @@ internal class SA1217UsingStaticDirectivesMustBeOrderedAlphabetically : Diagnost /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1217"; - private const string Title = "Using static directives should be ordered alphabetically"; - private const string MessageFormat = "The using static directive for '{0}' should appear after the using static directive for '{1}'"; - private const string Description = "All using static directives should be ordered alphabetically."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1217.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(OrderingResources.SA1217Title), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(OrderingResources.SA1217MessageFormat), OrderingResources.ResourceManager, typeof(OrderingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(OrderingResources.SA1217Description), OrderingResources.ResourceManager, typeof(OrderingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.OrderingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); - private static readonly Action CompilationUnitAction = HandleCompilationUnit; - private static readonly Action NamespaceDeclarationAction = HandleNamespaceDeclaration; + private static readonly Action CompilationUnitAction = HandleCompilationUnit; + private static readonly Action BaseNamespaceDeclarationAction = HandleBaseNamespaceDeclaration; /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -50,51 +53,90 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); - context.RegisterSyntaxNodeAction(NamespaceDeclarationAction, SyntaxKind.NamespaceDeclaration); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); + context.RegisterSyntaxNodeAction(BaseNamespaceDeclarationAction, SyntaxKinds.BaseNamespaceDeclaration); + }); } - private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context) + private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context, StyleCopSettings settings) { var compilationUnit = (CompilationUnitSyntax)context.Node; - CheckUsingDeclarations(context, compilationUnit.Usings); + CheckUsingDeclarations(context, settings.OrderingRules, compilationUnit.Usings); } - private static void HandleNamespaceDeclaration(SyntaxNodeAnalysisContext context) + private static void HandleBaseNamespaceDeclaration(SyntaxNodeAnalysisContext context, StyleCopSettings settings) { - var namespaceDirective = (NamespaceDeclarationSyntax)context.Node; - CheckUsingDeclarations(context, namespaceDirective.Usings); + var namespaceDirective = (BaseNamespaceDeclarationSyntaxWrapper)context.Node; + CheckUsingDeclarations(context, settings.OrderingRules, namespaceDirective.Usings); } - private static void CheckUsingDeclarations(SyntaxNodeAnalysisContext context, SyntaxList usingDirectives) + private static void CheckUsingDeclarations(SyntaxNodeAnalysisContext context, OrderingSettings orderingSettings, SyntaxList usingDirectives) { UsingDirectiveSyntax lastStaticUsingDirective = null; + UsingDirectiveSyntax lastSystemStaticUsingDirective = null; + UsingDirectiveSyntax firstNonSystemUsing = null; foreach (var usingDirective in usingDirectives) { if (usingDirective.IsPrecededByPreprocessorDirective()) { lastStaticUsingDirective = null; + lastSystemStaticUsingDirective = null; + firstNonSystemUsing = null; } if (usingDirective.StaticKeyword.IsKind(SyntaxKind.StaticKeyword)) { - if (lastStaticUsingDirective != null) + if (orderingSettings.SystemUsingDirectivesFirst && usingDirective.IsSystemUsingDirective()) { - var firstName = lastStaticUsingDirective.Name; - var secondName = usingDirective.Name; - - if (NameSyntaxHelpers.Compare(firstName, secondName) > 0) + if (firstNonSystemUsing != null) { context.ReportDiagnostic(Diagnostic.Create( Descriptor, - lastStaticUsingDirective.GetLocation(), - new[] { firstName.ToNormalizedString(), secondName.ToNormalizedString() })); + firstNonSystemUsing.GetLocation(), + new[] { firstNonSystemUsing.Name.ToNormalizedString(), usingDirective.Name.ToNormalizedString() })); return; } + + if (lastSystemStaticUsingDirective != null) + { + var firstName = lastSystemStaticUsingDirective.Name; + var secondName = usingDirective.Name; + + if (NameSyntaxHelpers.Compare(firstName, secondName) > 0) + { + context.ReportDiagnostic(Diagnostic.Create( + Descriptor, + lastSystemStaticUsingDirective.GetLocation(), + new[] { firstName.ToNormalizedString(), secondName.ToNormalizedString() })); + return; + } + } + + lastSystemStaticUsingDirective = usingDirective; } + else + { + if (lastStaticUsingDirective != null) + { + var firstName = lastStaticUsingDirective.Name; + var secondName = usingDirective.Name; - lastStaticUsingDirective = usingDirective; + if (NameSyntaxHelpers.Compare(firstName, secondName) > 0) + { + context.ReportDiagnostic(Diagnostic.Create( + Descriptor, + lastStaticUsingDirective.GetLocation(), + new[] { firstName.ToNormalizedString(), secondName.ToNormalizedString() })); + return; + } + } + + lastStaticUsingDirective = usingDirective; + firstNonSystemUsing = firstNonSystemUsing ?? usingDirective; + } } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Properties/AssemblyInfo.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Properties/AssemblyInfo.cs index 05133adc5..11c7e48bd 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Properties/AssemblyInfo.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Properties/AssemblyInfo.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable using System; using System.Runtime.CompilerServices; @@ -15,11 +17,12 @@ // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] -#if DEVELOPMENT_KEY -[assembly: InternalsVisibleTo("StyleCop.Analyzers.CodeFixes, PublicKey=0024000004800000940000000602000000240000525341310004000001000100fbe8bc154d11de9907c4e19600890ebef9cf9c8456c9a8ee05f0a8c9e69bd4f66c038ff4ea769c8864e6c5a38a1aad538876d6b2549962856f1b39e10d33bb13940c6538d2e863542ae15bc6e251946ca18094b6902690866d514f1fcd9395756732f927f9aeab1d6e1af5190816a251ad29db9c5b4cb86de7d909fc6c3d18a0")] -#else [assembly: InternalsVisibleTo("StyleCop.Analyzers.CodeFixes, PublicKey=0024000004800000940000000602000000240000525341310004000001000100ad62a4e5529344c07fe1455f270d61b205bdc8b0a94bcbe80b8506f28061073e4ed750b7e3d344f23213f671397a05e8c59b1434555f78edc091c0cf7b603011cf126aaa10116d890354f97f369ff56e24df17ee7f22cc3dd4d4b841d027d6d3d3b52a9a4462b8acf0f4bb9f400256ae18eed71070692e4cdd051498d04a66ed")] -#endif [assembly: InternalsVisibleTo("StyleCop.Analyzers.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] [assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp7, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp8, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp9, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp10, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp11, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] +[assembly: InternalsVisibleTo("StyleCop.Analyzers.Test.CSharp12, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] [assembly: InternalsVisibleTo("StyleCopTester, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c36d40d996fcc95fb6a89754728616758f459026e31478ce93633b3e27a4af416f103aa3d7a9e7998f829f8715cc1240d30724fd662042550fa71357b19562622424267e9e4640c403edbe64709a9ca5918128a9b9020b0db6e770d0dd1eac888869c23a835b74bde00e171984b1d1c24636cf030f0b23106e73035a2be145a6")] diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/PublicAPI.Shipped.txt b/StyleCop.Analyzers/StyleCop.Analyzers/PublicAPI.Shipped.txt new file mode 100644 index 000000000..e69de29bb diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/PublicAPI.Unshipped.txt b/StyleCop.Analyzers/StyleCop.Analyzers/PublicAPI.Unshipped.txt new file mode 100644 index 000000000..e69de29bb diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/ReadabilityResources.Designer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/ReadabilityResources.Designer.cs deleted file mode 100644 index 3948e9921..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/ReadabilityResources.Designer.cs +++ /dev/null @@ -1,1360 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace StyleCop.Analyzers.ReadabilityRules { - using System; - using System.Reflection; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class ReadabilityResources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal ReadabilityResources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StyleCop.Analyzers.ReadabilityRules.ReadabilityResources", typeof(ReadabilityResources).GetTypeInfo().Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Fix indentation. - /// - internal static string IndentationCodeFix { - get { - return ResourceManager.GetString("IndentationCodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove region. - /// - internal static string RemoveRegionCodeFix { - get { - return ResourceManager.GetString("RemoveRegionCodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Replace 'base.' with 'this.'. - /// - internal static string SA1100CodeFix { - get { - return ResourceManager.GetString("SA1100CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A call to a member from an inherited class begins with 'base.', and the local class does not contain an override or implementation of the member.. - /// - internal static string SA1100Description { - get { - return ResourceManager.GetString("SA1100Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Do not prefix calls with base unless local implementation exists. - /// - internal static string SA1100MessageFormat { - get { - return ResourceManager.GetString("SA1100MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Do not prefix calls with base unless local implementation exists. - /// - internal static string SA1100Title { - get { - return ResourceManager.GetString("SA1100Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Prefix reference with 'this.'. - /// - internal static string SA1101CodeFix { - get { - return ResourceManager.GetString("SA1101CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A call to an instance member of the local class or a base class is not prefixed with 'this.', within a C# code file.. - /// - internal static string SA1101Description { - get { - return ResourceManager.GetString("SA1101Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Prefix local calls with this. - /// - internal static string SA1101MessageFormat { - get { - return ResourceManager.GetString("SA1101MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Prefix local calls with this. - /// - internal static string SA1101Title { - get { - return ResourceManager.GetString("SA1101Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove separating lines. - /// - internal static string SA1102CodeFix { - get { - return ResourceManager.GetString("SA1102CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A C# query clause does not begin on the same line as the previous clause, or on the next line.. - /// - internal static string SA1102Description { - get { - return ResourceManager.GetString("SA1102Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Query clause should follow previous clause.. - /// - internal static string SA1102MessageFormat { - get { - return ResourceManager.GetString("SA1102MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Query clause should follow previous clause. - /// - internal static string SA1102Title { - get { - return ResourceManager.GetString("SA1102Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Place on multiple lines. - /// - internal static string SA1103CodeFixMultipleLines { - get { - return ResourceManager.GetString("SA1103CodeFixMultipleLines", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Place on single line. - /// - internal static string SA1103CodeFixSingleLine { - get { - return ResourceManager.GetString("SA1103CodeFixSingleLine", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The clauses within a C# query expression are not all placed on the same line, and each clause is not placed on its own line.. - /// - internal static string SA1103Description { - get { - return ResourceManager.GetString("SA1103Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Query clauses should be on separate lines or all on one line. - /// - internal static string SA1103MessageFormat { - get { - return ResourceManager.GetString("SA1103MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Query clauses should be on separate lines or all on one line. - /// - internal static string SA1103Title { - get { - return ResourceManager.GetString("SA1103Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A clause within a C# query expression begins on the same line as the previous clause, when the previous clause spans across multiple lines.. - /// - internal static string SA1104Description { - get { - return ResourceManager.GetString("SA1104Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Query clause should begin on new line when previous clause spans multiple lines. - /// - internal static string SA1104MessageFormat { - get { - return ResourceManager.GetString("SA1104MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Insert new line. - /// - internal static string SA1104SA1105CodeFix { - get { - return ResourceManager.GetString("SA1104SA1105CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Query clause should begin on new line when previous clause spans multiple lines. - /// - internal static string SA1104Title { - get { - return ResourceManager.GetString("SA1104Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A clause within a C# query expression spans across multiple lines, and does not begin on its own line.. - /// - internal static string SA1105Description { - get { - return ResourceManager.GetString("SA1105Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Query clauses spanning multiple lines should begin on own line. - /// - internal static string SA1105MessageFormat { - get { - return ResourceManager.GetString("SA1105MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Query clauses spanning multiple lines should begin on own line. - /// - internal static string SA1105Title { - get { - return ResourceManager.GetString("SA1105Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove empty statement. - /// - internal static string SA1106CodeFix { - get { - return ResourceManager.GetString("SA1106CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The C# code contains an extra semicolon.. - /// - internal static string SA1106Description { - get { - return ResourceManager.GetString("SA1106Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Code should not contain empty statements. - /// - internal static string SA1106MessageFormat { - get { - return ResourceManager.GetString("SA1106MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Code should not contain empty statements. - /// - internal static string SA1106Title { - get { - return ResourceManager.GetString("SA1106Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Enter new line. - /// - internal static string SA1107CodeFix { - get { - return ResourceManager.GetString("SA1107CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The C# code contains more than one statement on a single line.. - /// - internal static string SA1107Description { - get { - return ResourceManager.GetString("SA1107Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Code should not contain multiple statements on one line. - /// - internal static string SA1107MessageFormat { - get { - return ResourceManager.GetString("SA1107MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Code should not contain multiple statements on one line. - /// - internal static string SA1107Title { - get { - return ResourceManager.GetString("SA1107Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A C# statement contains a comment between the declaration of the statement and the opening brace of the statement.. - /// - internal static string SA1108Description { - get { - return ResourceManager.GetString("SA1108Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Block statements should not contain embedded comments. - /// - internal static string SA1108MessageFormat { - get { - return ResourceManager.GetString("SA1108MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Block statements should not contain embedded comments. - /// - internal static string SA1108Title { - get { - return ResourceManager.GetString("SA1108Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A C# statement contains a region tag between the declaration of the statement and the opening brace of the statement.. - /// - internal static string SA1109Description { - get { - return ResourceManager.GetString("SA1109Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to . - /// - internal static string SA1109MessageFormat { - get { - return ResourceManager.GetString("SA1109MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Block statements should not contain embedded regions. - /// - internal static string SA1109Title { - get { - return ResourceManager.GetString("SA1109Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The opening parenthesis or bracket is not placed on the same line as the method/indexer/attribute/array name.. - /// - internal static string SA1110Description { - get { - return ResourceManager.GetString("SA1110Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Opening parenthesis or bracket should be on declaration line.. - /// - internal static string SA1110MessageFormat { - get { - return ResourceManager.GetString("SA1110MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Opening parenthesis or bracket should be on declaration line. - /// - internal static string SA1110Title { - get { - return ResourceManager.GetString("SA1110Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The closing parenthesis or bracket in a call to or declaration of a C# method/indexer/attribute/array/constructor/delegate is not placed on the same line as the last parameter.. - /// - internal static string SA1111Description { - get { - return ResourceManager.GetString("SA1111Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Closing parenthesis should be on line of last parameter. - /// - internal static string SA1111MessageFormat { - get { - return ResourceManager.GetString("SA1111MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Closing parenthesis should be on line of last parameter. - /// - internal static string SA1111Title { - get { - return ResourceManager.GetString("SA1111Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The closing parenthesis or bracket in a call to a C# method or indexer, or the declaration of a method or indexer, is not placed on the same line as the opening bracket when the element does not take any parameters.. - /// - internal static string SA1112Description { - get { - return ResourceManager.GetString("SA1112Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Closing parenthesis should be on line of opening parenthesis. - /// - internal static string SA1112MessageFormat { - get { - return ResourceManager.GetString("SA1112MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Closing parenthesis should be on line of opening parenthesis. - /// - internal static string SA1112Title { - get { - return ResourceManager.GetString("SA1112Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A comma between two parameters in a call to a C# method or indexer, or in the declaration of a method or indexer, is not placed on the same line as the previous parameter.. - /// - internal static string SA1113Description { - get { - return ResourceManager.GetString("SA1113Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Comma should be on the same line as previous parameter.. - /// - internal static string SA1113MessageFormat { - get { - return ResourceManager.GetString("SA1113MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Comma should be on the same line as previous parameter. - /// - internal static string SA1113Title { - get { - return ResourceManager.GetString("SA1113Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The start of the parameter list for a method/constructor/indexer/array/operator call or declaration does not begin on the same line as the opening bracket, or on the line after the opening bracket.. - /// - internal static string SA1114Description { - get { - return ResourceManager.GetString("SA1114Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parameter list should follow declaration. - /// - internal static string SA1114MessageFormat { - get { - return ResourceManager.GetString("SA1114MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parameter list should follow declaration. - /// - internal static string SA1114Title { - get { - return ResourceManager.GetString("SA1114Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A parameter within a C# method or indexer call or declaration does not begin on the same line as the previous parameter, or on the next line.. - /// - internal static string SA1115Description { - get { - return ResourceManager.GetString("SA1115Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The parameter should begin on the line after the previous parameter.. - /// - internal static string SA1115MessageFormat { - get { - return ResourceManager.GetString("SA1115MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parameter should follow comma. - /// - internal static string SA1115Title { - get { - return ResourceManager.GetString("SA1115Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Move first argument to next line. - /// - internal static string SA1116CodeFix { - get { - return ResourceManager.GetString("SA1116CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The parameters to a C# method or indexer call or declaration span across multiple lines, but the first parameter does not start on the line after the opening bracket.. - /// - internal static string SA1116Description { - get { - return ResourceManager.GetString("SA1116Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The parameters should begin on the line after the declaration, whenever the parameter span across multiple lines. - /// - internal static string SA1116MessageFormat { - get { - return ResourceManager.GetString("SA1116MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Split parameters should start on line after declaration. - /// - internal static string SA1116Title { - get { - return ResourceManager.GetString("SA1116Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The parameters to a C# method or indexer call or declaration are not all on the same line or each on a separate line.. - /// - internal static string SA1117Description { - get { - return ResourceManager.GetString("SA1117Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The parameters should all be placed on the same line or each parameter should be placed on its own line.. - /// - internal static string SA1117MessageFormat { - get { - return ResourceManager.GetString("SA1117MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parameters should be on same line or separate lines. - /// - internal static string SA1117Title { - get { - return ResourceManager.GetString("SA1117Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A parameter to a C# method/indexer/attribute/array, other than the first parameter, spans across multiple lines. If the parameter is short, place the entire parameter on a single line. Otherwise, save the contents of the parameter in a temporary variable and pass the temporary variable as a parameter.. - /// - internal static string SA1118Description { - get { - return ResourceManager.GetString("SA1118Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The parameter spans multiple lines. - /// - internal static string SA1118MessageFormat { - get { - return ResourceManager.GetString("SA1118MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Parameter should not span multiple lines. - /// - internal static string SA1118Title { - get { - return ResourceManager.GetString("SA1118Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove empty comment. - /// - internal static string SA1120CodeFix { - get { - return ResourceManager.GetString("SA1120CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The C# comment does not contain any comment text.. - /// - internal static string SA1120Description { - get { - return ResourceManager.GetString("SA1120Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Comments should contain text. - /// - internal static string SA1120MessageFormat { - get { - return ResourceManager.GetString("SA1120MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Comments should contain text. - /// - internal static string SA1120Title { - get { - return ResourceManager.GetString("SA1120Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Replace with built-in type. - /// - internal static string SA1121CodeFix { - get { - return ResourceManager.GetString("SA1121CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The code uses one of the basic C# types, but does not use the built-in alias for the type.. - /// - internal static string SA1121Description { - get { - return ResourceManager.GetString("SA1121Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use built-in type alias. - /// - internal static string SA1121MessageFormat { - get { - return ResourceManager.GetString("SA1121MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use built-in type alias. - /// - internal static string SA1121Title { - get { - return ResourceManager.GetString("SA1121Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Replace with string.Empty. - /// - internal static string SA1122CodeFix { - get { - return ResourceManager.GetString("SA1122CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The C# code includes an empty string, written as "".. - /// - internal static string SA1122Description { - get { - return ResourceManager.GetString("SA1122Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use string.Empty for empty strings. - /// - internal static string SA1122MessageFormat { - get { - return ResourceManager.GetString("SA1122MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use string.Empty for empty strings. - /// - internal static string SA1122Title { - get { - return ResourceManager.GetString("SA1122Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The C# code contains a region within the body of a code element.. - /// - internal static string SA1123Description { - get { - return ResourceManager.GetString("SA1123Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Region should not be located within a code element.. - /// - internal static string SA1123MessageFormat { - get { - return ResourceManager.GetString("SA1123MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Do not place regions within elements. - /// - internal static string SA1123Title { - get { - return ResourceManager.GetString("SA1123Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The C# code contains a region.. - /// - internal static string SA1124Description { - get { - return ResourceManager.GetString("SA1124Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Do not use regions. - /// - internal static string SA1124MessageFormat { - get { - return ResourceManager.GetString("SA1124MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Do not use regions. - /// - internal static string SA1124Title { - get { - return ResourceManager.GetString("SA1124Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The Nullable<T> type has been defined not using the C# shorthand. For example, Nullable<DateTime> has been used instead of the preferred DateTime?. - /// - internal static string SA1125Description { - get { - return ResourceManager.GetString("SA1125Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use shorthand for nullable types. - /// - internal static string SA1125MessageFormat { - get { - return ResourceManager.GetString("SA1125MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use shorthand for nullable types. - /// - internal static string SA1125Title { - get { - return ResourceManager.GetString("SA1125Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A call to a member is not prefixed with the 'this.', 'base.', 'object.' or 'typename.' prefix to indicate the intended method call, within a C# code file.. - /// - internal static string SA1126Description { - get { - return ResourceManager.GetString("SA1126Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to . - /// - internal static string SA1126MessageFormat { - get { - return ResourceManager.GetString("SA1126MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Prefix calls correctly. - /// - internal static string SA1126Title { - get { - return ResourceManager.GetString("SA1126Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Place each type constraint on a new line. - /// - internal static string SA1127CodeFix { - get { - return ResourceManager.GetString("SA1127CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Each type constraint clause for a generic type parameter should be listed on a line of code by itself.. - /// - internal static string SA1127Description { - get { - return ResourceManager.GetString("SA1127Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Generic type constraints should be on their own line. - /// - internal static string SA1127MessageFormat { - get { - return ResourceManager.GetString("SA1127MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Generic type constraints should be on their own line. - /// - internal static string SA1127Title { - get { - return ResourceManager.GetString("SA1127Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Place constructor initializer on own line. - /// - internal static string SA1128CodeFix { - get { - return ResourceManager.GetString("SA1128CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A constructor initializer, including the colon character, should be on its own line.. - /// - internal static string SA1128Description { - get { - return ResourceManager.GetString("SA1128Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Put constructor initializers on their own line. - /// - internal static string SA1128MessageFormat { - get { - return ResourceManager.GetString("SA1128MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Put constructor initializers on their own line. - /// - internal static string SA1128Title { - get { - return ResourceManager.GetString("SA1128Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Replace with default(T). - /// - internal static string SA1129CodeFix { - get { - return ResourceManager.GetString("SA1129CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to When creating a new instance of a value type T, the syntax 'default(T)' is functionally equivalent to the syntax 'new T()'. To avoid confusion regarding the behavior of the resulting instance, the first form is preferred.. - /// - internal static string SA1129Description { - get { - return ResourceManager.GetString("SA1129Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Do not use default value type constructor. - /// - internal static string SA1129MessageFormat { - get { - return ResourceManager.GetString("SA1129MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Do not use default value type constructor. - /// - internal static string SA1129Title { - get { - return ResourceManager.GetString("SA1129Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Replace with lambda.. - /// - internal static string SA1130CodeFix { - get { - return ResourceManager.GetString("SA1130CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Lambda expressions are more succinct and easier to read than anonymous methods, so they should are preferred whenever the two are functionally equivalent.. - /// - internal static string SA1130Description { - get { - return ResourceManager.GetString("SA1130Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use lambda syntax. - /// - internal static string SA1130MessageFormat { - get { - return ResourceManager.GetString("SA1130MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use lambda syntax. - /// - internal static string SA1130Title { - get { - return ResourceManager.GetString("SA1130Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Swap operands. - /// - internal static string SA1131CodeFix { - get { - return ResourceManager.GetString("SA1131CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to When a comparison is made between a variable and a literal, the variable should be placed on the left-hand-side to maximize readability.. - /// - internal static string SA1131Description { - get { - return ResourceManager.GetString("SA1131Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Constant values should appear on the right-hand side of comparisons. - /// - internal static string SA1131MessageFormat { - get { - return ResourceManager.GetString("SA1131MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use readable conditions. - /// - internal static string SA1131Title { - get { - return ResourceManager.GetString("SA1131Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Place each field on a new line. - /// - internal static string SA1132CodeFix { - get { - return ResourceManager.GetString("SA1132CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Each field should be declared on its own line, in order to clearly see each field of a type and allow for proper documentation of the behavior of each field.. - /// - internal static string SA1132Description { - get { - return ResourceManager.GetString("SA1132Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Each field should be declared on its own line. - /// - internal static string SA1132MessageFormat { - get { - return ResourceManager.GetString("SA1132MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Do not combine fields. - /// - internal static string SA1132Title { - get { - return ResourceManager.GetString("SA1132Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Give each attribute its own square brackets. - /// - internal static string SA1133CodeFix { - get { - return ResourceManager.GetString("SA1133CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Each attribute usage should be placed in its own set of square brackets for maximum readability.. - /// - internal static string SA1133Description { - get { - return ResourceManager.GetString("SA1133Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Each attribute should be placed in its own set of square brackets.. - /// - internal static string SA1133MessageFormat { - get { - return ResourceManager.GetString("SA1133MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Do not combine attributes. - /// - internal static string SA1133Title { - get { - return ResourceManager.GetString("SA1133Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Place attribute on own line.. - /// - internal static string SA1134CodeFix { - get { - return ResourceManager.GetString("SA1134CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Each attribute should be placed on its own line of code.. - /// - internal static string SA1134Description { - get { - return ResourceManager.GetString("SA1134Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Each attribute should be placed on its own line of code.. - /// - internal static string SA1134MessageFormat { - get { - return ResourceManager.GetString("SA1134MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Attributes should not share line. - /// - internal static string SA1134Title { - get { - return ResourceManager.GetString("SA1134Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Qualify using directive. - /// - internal static string SA1135CodeFix { - get { - return ResourceManager.GetString("SA1135CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to All using directives should be qualified.. - /// - internal static string SA1135Description { - get { - return ResourceManager.GetString("SA1135Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Using directive for namespace '{0}' should be qualified. - /// - internal static string SA1135MessageFormatNamespace { - get { - return ResourceManager.GetString("SA1135MessageFormatNamespace", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Using directive for type '{0}' should be qualified. - /// - internal static string SA1135MessageFormatType { - get { - return ResourceManager.GetString("SA1135MessageFormatType", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Using directives should be qualified. - /// - internal static string SA1135Title { - get { - return ResourceManager.GetString("SA1135Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Place enum values own their own lines. - /// - internal static string SA1136CodeFix { - get { - return ResourceManager.GetString("SA1136CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Enum values should be placed on their own lines for maximum readability.. - /// - internal static string SA1136Description { - get { - return ResourceManager.GetString("SA1136Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Enum values should be on separate lines. - /// - internal static string SA1136MessageFormat { - get { - return ResourceManager.GetString("SA1136MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Enum values should be on separate lines. - /// - internal static string SA1136Title { - get { - return ResourceManager.GetString("SA1136Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Elements at the same level in the syntax tree should have the same indentation.. - /// - internal static string SA1137Description { - get { - return ResourceManager.GetString("SA1137Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Elements should have the same indentation. - /// - internal static string SA1137MessageFormat { - get { - return ResourceManager.GetString("SA1137MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Elements should have the same indentation. - /// - internal static string SA1137Title { - get { - return ResourceManager.GetString("SA1137Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use literal suffix notation instead of casting. - /// - internal static string SA1139CodeFix { - get { - return ResourceManager.GetString("SA1139CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use literal suffix notation instead of casting, in order to improve readability, avoid bugs related to illegal casts and ensure that optimal IL is produced.. - /// - internal static string SA1139Description { - get { - return ResourceManager.GetString("SA1139Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use literal suffix notation instead of casting. - /// - internal static string SA1139MessageFormat { - get { - return ResourceManager.GetString("SA1139MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use literal suffix notation instead of casting. - /// - internal static string SA1139Title { - get { - return ResourceManager.GetString("SA1139Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove 'this.' prefix. - /// - internal static string SX1101CodeFix { - get { - return ResourceManager.GetString("SX1101CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A call to an instance member of the local class or a base class is prefixed with `this.`.. - /// - internal static string SX1101Description { - get { - return ResourceManager.GetString("SX1101Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Do not prefix local calls with 'this.'. - /// - internal static string SX1101MessageFormat { - get { - return ResourceManager.GetString("SX1101MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Do not prefix local calls with 'this.'. - /// - internal static string SX1101Title { - get { - return ResourceManager.GetString("SX1101Title", resourceCulture); - } - } - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/ReadabilityResources.resx b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/ReadabilityResources.resx index fafe5b0af..5c0605a09 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/ReadabilityResources.resx +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/ReadabilityResources.resx @@ -241,7 +241,7 @@ The opening parenthesis or bracket is not placed on the same line as the method/indexer/attribute/array name. - Opening parenthesis or bracket should be on declaration line. + Opening parenthesis or bracket should be on declaration line Opening parenthesis or bracket should be on declaration line @@ -268,7 +268,7 @@ A comma between two parameters in a call to a C# method or indexer, or in the declaration of a method or indexer, is not placed on the same line as the previous parameter. - Comma should be on the same line as previous parameter. + Comma should be on the same line as previous parameter Comma should be on the same line as previous parameter @@ -286,7 +286,7 @@ A parameter within a C# method or indexer call or declaration does not begin on the same line as the previous parameter, or on the next line. - The parameter should begin on the line after the previous parameter. + The parameter should begin on the line after the previous parameter Parameter should follow comma @@ -307,7 +307,7 @@ The parameters to a C# method or indexer call or declaration are not all on the same line or each on a separate line. - The parameters should all be placed on the same line or each parameter should be placed on its own line. + The parameters should all be placed on the same line or each parameter should be placed on its own line Parameters should be on same line or separate lines @@ -361,7 +361,7 @@ The C# code contains a region within the body of a code element. - Region should not be located within a code element. + Region should not be located within a code element Do not place regions within elements @@ -472,7 +472,7 @@ Each attribute usage should be placed in its own set of square brackets for maximum readability. - Each attribute should be placed in its own set of square brackets. + Each attribute should be placed in its own set of square brackets Do not combine attributes @@ -484,11 +484,26 @@ Each attribute should be placed on its own line of code. - Each attribute should be placed on its own line of code. + Each attribute should be placed on its own line of code Attributes should not share line + + Qualify using directive + + + All using directives should be qualified. + + + Using directive for namespace '{0}' should be qualified + + + Using directive for type '{0}' should be qualified + + + Using directives should be qualified + Place enum values own their own lines @@ -510,6 +525,9 @@ Elements should have the same indentation + + Use literal suffix notation instead of casting + Use literal suffix notation instead of casting, in order to improve readability, avoid bugs related to illegal casts and ensure that optimal IL is produced. @@ -519,23 +537,29 @@ Use literal suffix notation instead of casting - - Use literal suffix notation instead of casting + + Replace with tuple syntax - - Qualify using directive + + Use tuple syntax instead of the underlying ValueTuple implementation type. - - All using directives should be qualified. + + Use tuple syntax - - Using directive for namespace '{0}' should be qualified + + Use tuple syntax - - Using directive for type '{0}' should be qualified + + Use tuple field name - - Using directives should be qualified + + A field of a tuple was referenced by its metadata name when a field name is available. + + + Refer to tuple fields by name + + + Refer to tuple fields by name Remove 'this.' prefix diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists.cs index 670e84bd3..ebf459834 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -58,10 +60,10 @@ internal class SA1100DoNotPrefixCallsWithBaseUnlessLocalImplementationExists : D /// analyzer. /// public const string DiagnosticId = "SA1100"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1100.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1100Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1100MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1100Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1100.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1101PrefixLocalCallsWithThis.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1101PrefixLocalCallsWithThis.cs index 1040f489c..6cfcfa023 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1101PrefixLocalCallsWithThis.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1101PrefixLocalCallsWithThis.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -10,6 +12,7 @@ namespace StyleCop.Analyzers.ReadabilityRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; /// /// A call to an instance member of the local class or a base class is not prefixed with ‘this.’, within a C# code @@ -38,10 +41,10 @@ internal class SA1101PrefixLocalCallsWithThis : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1101"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1101.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1101Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1101MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1101Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1101.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -95,13 +98,23 @@ private static void HandleSimpleName(SyntaxNodeAnalysisContext context) return; case SyntaxKind.SimpleAssignmentExpression: - if (((AssignmentExpressionSyntax)context.Node.Parent).Left == context.Node - && (context.Node.Parent.Parent?.IsKind(SyntaxKind.ObjectInitializerExpression) ?? true)) + if (((AssignmentExpressionSyntax)context.Node.Parent).Left == context.Node) { - /* Handle 'X' in: - * new TypeName() { X = 3 } - */ - return; + if (context.Node.Parent.Parent.IsKind(SyntaxKind.ObjectInitializerExpression)) + { + /* Handle 'X' in: + * new TypeName() { X = 3 } + */ + return; + } + + if (context.Node.Parent.Parent.IsKind(SyntaxKindEx.WithInitializerExpression)) + { + /* Handle 'X' in: + * value with { X = 3 } + */ + return; + } } break; @@ -181,10 +194,17 @@ private static void HandleIdentifierNameImpl(SyntaxNodeAnalysisContext context, return; } - if (symbol is IMethodSymbol methodSymbol - && methodSymbol.MethodKind == MethodKind.Constructor) + if (symbol is IMethodSymbol methodSymbol) { - return; + switch (methodSymbol.MethodKind) + { + case MethodKind.Constructor: + case MethodKindEx.LocalFunction: + return; + + default: + break; + } } // This is a workaround for: @@ -231,36 +251,39 @@ private static bool HasThis(SyntaxNode node) case SyntaxKind.DelegateDeclaration: case SyntaxKind.EnumDeclaration: case SyntaxKind.NamespaceDeclaration: + case SyntaxKindEx.FileScopedNamespaceDeclaration: return false; case SyntaxKind.FieldDeclaration: case SyntaxKind.EventFieldDeclaration: + return false; + case SyntaxKind.EventDeclaration: - case SyntaxKind.PropertyDeclaration: case SyntaxKind.IndexerDeclaration: - return false; + var basePropertySyntax = (BasePropertyDeclarationSyntax)node; + return !basePropertySyntax.Modifiers.Any(SyntaxKind.StaticKeyword); + + case SyntaxKind.PropertyDeclaration: + var propertySyntax = (PropertyDeclarationSyntax)node; + return !propertySyntax.Modifiers.Any(SyntaxKind.StaticKeyword) + && propertySyntax.Initializer == null; case SyntaxKind.MultiLineDocumentationCommentTrivia: case SyntaxKind.SingleLineDocumentationCommentTrivia: return false; - case SyntaxKind.GetAccessorDeclaration: - case SyntaxKind.SetAccessorDeclaration: - case SyntaxKind.AddAccessorDeclaration: - case SyntaxKind.RemoveAccessorDeclaration: - case SyntaxKind.UnknownAccessorDeclaration: - BasePropertyDeclarationSyntax basePropertySyntax = (BasePropertyDeclarationSyntax)node.Parent.Parent; - return !basePropertySyntax.Modifiers.Any(SyntaxKind.StaticKeyword); - case SyntaxKind.ConstructorDeclaration: case SyntaxKind.DestructorDeclaration: case SyntaxKind.MethodDeclaration: - BaseMethodDeclarationSyntax baseMethodSyntax = (BaseMethodDeclarationSyntax)node; + var baseMethodSyntax = (BaseMethodDeclarationSyntax)node; return !baseMethodSyntax.Modifiers.Any(SyntaxKind.StaticKeyword); case SyntaxKind.Attribute: return false; + case SyntaxKindEx.RecursivePattern: + return false; + default: continue; } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1106CodeMustNotContainEmptyStatements.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1106CodeMustNotContainEmptyStatements.cs index b4580412b..e99ce7c8a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1106CodeMustNotContainEmptyStatements.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1106CodeMustNotContainEmptyStatements.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -25,10 +27,10 @@ internal class SA1106CodeMustNotContainEmptyStatements : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1106"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1106.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1106Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1106MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1106Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1106.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.Unnecessary); @@ -56,7 +58,8 @@ private static void HandleBaseTypeDeclaration(SyntaxNodeAnalysisContext context) { var declaration = (BaseTypeDeclarationSyntax)context.Node; - if (declaration.SemicolonToken.IsKind(SyntaxKind.SemicolonToken)) + if (declaration.SemicolonToken.IsKind(SyntaxKind.SemicolonToken) + && !declaration.OpenBraceToken.IsKind(SyntaxKind.None)) { context.ReportDiagnostic(Diagnostic.Create(Descriptor, declaration.SemicolonToken.GetLocation())); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1107CodeMustNotContainMultipleStatementsOnOneLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1107CodeMustNotContainMultipleStatementsOnOneLine.cs index 98d9de06a..3bd680c27 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1107CodeMustNotContainMultipleStatementsOnOneLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1107CodeMustNotContainMultipleStatementsOnOneLine.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -26,10 +28,10 @@ internal class SA1107CodeMustNotContainMultipleStatementsOnOneLine : DiagnosticA /// analyzer. /// public const string DiagnosticId = "SA1107"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1107.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1107Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1107MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1107Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1107.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1108BlockStatementsMustNotContainEmbeddedComments.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1108BlockStatementsMustNotContainEmbeddedComments.cs index 7e6f1677e..7d41a2008 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1108BlockStatementsMustNotContainEmbeddedComments.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1108BlockStatementsMustNotContainEmbeddedComments.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -53,10 +55,10 @@ internal class SA1108BlockStatementsMustNotContainEmbeddedComments : DiagnosticA /// analyzer. /// public const string DiagnosticId = "SA1108"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1108.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1108Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1108MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1108Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1108.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1109BlockStatementsMustNotContainEmbeddedRegions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1109BlockStatementsMustNotContainEmbeddedRegions.cs index 3d87c89eb..f41d836f3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1109BlockStatementsMustNotContainEmbeddedRegions.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1109BlockStatementsMustNotContainEmbeddedRegions.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -35,13 +37,15 @@ internal class SA1109BlockStatementsMustNotContainEmbeddedRegions : DiagnosticAn /// analyzer. /// public const string DiagnosticId = "SA1109"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1109.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1109Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1109MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1109Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1109.md"; private static readonly DiagnosticDescriptor Descriptor = +#pragma warning disable RS2000 // Add analyzer diagnostic IDs to analyzer release. new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.NotConfigurable); +#pragma warning restore RS2000 // Add analyzer diagnostic IDs to analyzer release. /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -49,7 +53,11 @@ internal class SA1109BlockStatementsMustNotContainEmbeddedRegions : DiagnosticAn /// [ExcludeFromCodeCoverage] +#pragma warning disable RS1025 // Configure generated code analysis +#pragma warning disable RS1026 // Enable concurrent execution public override void Initialize(AnalysisContext context) +#pragma warning restore RS1026 // Enable concurrent execution +#pragma warning restore RS1025 // Configure generated code analysis { // This diagnostic is not implemented (by design) in StyleCopAnalyzers. } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA110xQueryClauses.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA110xQueryClauses.cs index 81ee13934..11ebbebcf 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA110xQueryClauses.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA110xQueryClauses.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -103,10 +105,10 @@ private static void HandleQueryExpression(SyntaxNodeAnalysisContext context) HandleQueryClause(queryExpression.FromClause, tokensToCheck); HandleQueryBody(queryExpression.Body, tokensToCheck); - bool isEnabledSA1102 = !context.IsAnalyzerSuppressed(SA1102Identifier); - bool isEnabledSA1103 = !context.IsAnalyzerSuppressed(SA1103Identifier); - bool isEnabledSA1104 = !context.IsAnalyzerSuppressed(SA1104Identifier); - bool isEnabledSA1105 = !context.IsAnalyzerSuppressed(SA1105Identifier); + bool isEnabledSA1102 = !context.IsAnalyzerSuppressed(SA1102Descriptor); + bool isEnabledSA1103 = !context.IsAnalyzerSuppressed(SA1103Descriptor); + bool isEnabledSA1104 = !context.IsAnalyzerSuppressed(SA1104Descriptor); + bool isEnabledSA1105 = !context.IsAnalyzerSuppressed(SA1105Descriptor); bool allOnSameLine = true; bool allOnSeparateLine = true; @@ -218,7 +220,11 @@ private static void HandleSelectOrGroup(SelectOrGroupClauseSyntax selectOrGroup, { case SyntaxKind.SelectClause: var selectClause = (SelectClauseSyntax)selectOrGroup; - tokensToCheck.Add(selectClause.SelectKeyword); + if (!selectClause.IsMissing) + { + tokensToCheck.Add(selectClause.SelectKeyword); + } + break; case SyntaxKind.GroupClause: var groupClause = (GroupClauseSyntax)selectOrGroup; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1110OpeningParenthesisMustBeOnDeclarationLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1110OpeningParenthesisMustBeOnDeclarationLine.cs index 12f6eadf7..4b4477f75 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1110OpeningParenthesisMustBeOnDeclarationLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1110OpeningParenthesisMustBeOnDeclarationLine.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -43,10 +45,10 @@ internal class SA1110OpeningParenthesisMustBeOnDeclarationLine : DiagnosticAnaly /// analyzer. /// public const string DiagnosticId = "SA1110"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1110.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1110Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1110MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1110Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1110.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1111ClosingParenthesisMustBeOnLineOfLastParameter.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1111ClosingParenthesisMustBeOnLineOfLastParameter.cs index 26d521d4f..a965afcba 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1111ClosingParenthesisMustBeOnLineOfLastParameter.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1111ClosingParenthesisMustBeOnLineOfLastParameter.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -43,10 +45,10 @@ internal class SA1111ClosingParenthesisMustBeOnLineOfLastParameter : DiagnosticA /// analyzer. /// public const string DiagnosticId = "SA1111"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1111.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1111Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1111MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1111Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1111.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1112ClosingParenthesisMustBeOnLineOfOpeningParenthesis.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1112ClosingParenthesisMustBeOnLineOfOpeningParenthesis.cs index a093d7511..b484052b0 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1112ClosingParenthesisMustBeOnLineOfOpeningParenthesis.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1112ClosingParenthesisMustBeOnLineOfOpeningParenthesis.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -36,10 +38,10 @@ internal class SA1112ClosingParenthesisMustBeOnLineOfOpeningParenthesis : Diagno /// analyzer. /// public const string DiagnosticId = "SA1112"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1112.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1112Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1112MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1112Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1112.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1113CommaMustBeOnSameLineAsPreviousParameter.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1113CommaMustBeOnSameLineAsPreviousParameter.cs index 869fd5b5a..29c4d968b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1113CommaMustBeOnSameLineAsPreviousParameter.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1113CommaMustBeOnSameLineAsPreviousParameter.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -43,10 +45,10 @@ internal class SA1113CommaMustBeOnSameLineAsPreviousParameter : DiagnosticAnalyz /// analyzer. /// public const string DiagnosticId = "SA1113"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1113.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1113Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1113MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1113Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1113.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1114ParameterListMustFollowDeclaration.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1114ParameterListMustFollowDeclaration.cs index edec3a8cd..d6b936e4c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1114ParameterListMustFollowDeclaration.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1114ParameterListMustFollowDeclaration.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -47,10 +49,10 @@ internal class SA1114ParameterListMustFollowDeclaration : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1114"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1114.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1114Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1114MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1114Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1114.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1115ParameterMustFollowComma.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1115ParameterMustFollowComma.cs index cb9a90200..43ee97a59 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1115ParameterMustFollowComma.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1115ParameterMustFollowComma.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -47,10 +49,10 @@ internal class SA1115ParameterMustFollowComma : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1115"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1115.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1115Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1115MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1115Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1115.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -138,7 +140,7 @@ private static void HandleParenthesizedLambdaExpression(SyntaxNodeAnalysisContex private static void HandleAnonymousMethodExpression(SyntaxNodeAnalysisContext context) { var anonymousMethod = (AnonymousMethodExpressionSyntax)context.Node; - AnalyzeSyntaxList(context, anonymousMethod.ParameterList?.Parameters ?? default(SeparatedSyntaxList)); + AnalyzeSyntaxList(context, anonymousMethod.ParameterList?.Parameters ?? default); } private static void HandleAttributeList(SyntaxNodeAnalysisContext context) @@ -150,7 +152,7 @@ private static void HandleAttributeList(SyntaxNodeAnalysisContext context) private static void HandleAttribute(SyntaxNodeAnalysisContext context) { var attribute = (AttributeSyntax)context.Node; - AnalyzeSyntaxList(context, attribute.ArgumentList?.Arguments ?? default(SeparatedSyntaxList)); + AnalyzeSyntaxList(context, attribute.ArgumentList?.Arguments ?? default); } private static void HandleArrayCreationExpression(SyntaxNodeAnalysisContext context) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1116SplitParametersMustStartOnLineAfterDeclaration.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1116SplitParametersMustStartOnLineAfterDeclaration.cs index fc73d550a..8cb3bf866 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1116SplitParametersMustStartOnLineAfterDeclaration.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1116SplitParametersMustStartOnLineAfterDeclaration.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -43,10 +45,10 @@ internal class SA1116SplitParametersMustStartOnLineAfterDeclaration : Diagnostic /// analyzer. /// public const string DiagnosticId = "SA1116"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1116.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1116Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1116MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1116Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1116.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -61,6 +63,7 @@ internal class SA1116SplitParametersMustStartOnLineAfterDeclaration : Diagnostic private static readonly Action IndexerDeclarationAction = HandleIndexerDeclaration; private static readonly Action InvocationExpressionAction = HandleInvocationExpression; private static readonly Action ObjectCreationExpressionAction = HandleObjectCreationExpression; + private static readonly Action ImplicitObjectCreationExpressionAction = HandleImplicitObjectCreationExpression; private static readonly Action ElementAccessExpressionAction = HandleElementAccessExpression; private static readonly Action ElementBindingExpressionAction = HandleElementBindingExpression; private static readonly Action ImplicitElementAccessAction = HandleImplicitElementAccess; @@ -86,6 +89,7 @@ public override void Initialize(AnalysisContext context) context.RegisterSyntaxNodeAction(IndexerDeclarationAction, SyntaxKind.IndexerDeclaration); context.RegisterSyntaxNodeAction(InvocationExpressionAction, SyntaxKind.InvocationExpression); context.RegisterSyntaxNodeAction(ObjectCreationExpressionAction, SyntaxKind.ObjectCreationExpression); + context.RegisterSyntaxNodeAction(ImplicitObjectCreationExpressionAction, SyntaxKindEx.ImplicitObjectCreationExpression); context.RegisterSyntaxNodeAction(ElementAccessExpressionAction, SyntaxKind.ElementAccessExpression); context.RegisterSyntaxNodeAction(ElementBindingExpressionAction, SyntaxKind.ElementBindingExpression); context.RegisterSyntaxNodeAction(ImplicitElementAccessAction, SyntaxKind.ImplicitElementAccess); @@ -119,6 +123,12 @@ private static void HandleObjectCreationExpression(SyntaxNodeAnalysisContext con HandleArgumentListSyntax(context, objectCreation.ArgumentList); } + private static void HandleImplicitObjectCreationExpression(SyntaxNodeAnalysisContext context) + { + var implicitObjectCreation = (ImplicitObjectCreationExpressionSyntaxWrapper)context.Node; + HandleArgumentListSyntax(context, implicitObjectCreation.ArgumentList); + } + private static void HandleIndexerDeclaration(SyntaxNodeAnalysisContext context) { var indexerDeclaration = (IndexerDeclarationSyntax)context.Node; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1117ParametersMustBeOnSameLineOrSeparateLines.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1117ParametersMustBeOnSameLineOrSeparateLines.cs index 9e66344f2..bad69434a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1117ParametersMustBeOnSameLineOrSeparateLines.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1117ParametersMustBeOnSameLineOrSeparateLines.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -54,10 +56,10 @@ internal class SA1117ParametersMustBeOnSameLineOrSeparateLines : DiagnosticAnaly /// analyzer. /// public const string DiagnosticId = "SA1117"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1117.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1117Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1117MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1117Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1117.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -72,6 +74,7 @@ internal class SA1117ParametersMustBeOnSameLineOrSeparateLines : DiagnosticAnaly private static readonly Action IndexerDeclarationAction = HandleIndexerDeclaration; private static readonly Action InvocationExpressionAction = HandleInvocationExpression; private static readonly Action ObjectCreationExpressionAction = HandleObjectCreationExpression; + private static readonly Action ImplicitObjectCreationExpressionAction = HandleImplicitObjectCreationExpression; private static readonly Action ElementAccessExpressionAction = HandleElementAccessExpression; private static readonly Action ElementBindingExpressionAction = HandleElementBindingExpression; private static readonly Action ArrayCreationExpressionAction = HandleArrayCreationExpression; @@ -96,6 +99,7 @@ public override void Initialize(AnalysisContext context) context.RegisterSyntaxNodeAction(IndexerDeclarationAction, SyntaxKind.IndexerDeclaration); context.RegisterSyntaxNodeAction(InvocationExpressionAction, SyntaxKind.InvocationExpression); context.RegisterSyntaxNodeAction(ObjectCreationExpressionAction, SyntaxKind.ObjectCreationExpression); + context.RegisterSyntaxNodeAction(ImplicitObjectCreationExpressionAction, SyntaxKindEx.ImplicitObjectCreationExpression); context.RegisterSyntaxNodeAction(ElementAccessExpressionAction, SyntaxKind.ElementAccessExpression); context.RegisterSyntaxNodeAction(ElementBindingExpressionAction, SyntaxKind.ElementBindingExpression); context.RegisterSyntaxNodeAction(ArrayCreationExpressionAction, SyntaxKind.ArrayCreationExpression); @@ -128,16 +132,19 @@ private static void HandleObjectCreationExpression(SyntaxNodeAnalysisContext con HandleArgumentListSyntax(context, objectCreation.ArgumentList); } + private static void HandleImplicitObjectCreationExpression(SyntaxNodeAnalysisContext context) + { + var implicitObjectCreation = (ImplicitObjectCreationExpressionSyntaxWrapper)context.Node; + HandleArgumentListSyntax(context, implicitObjectCreation.ArgumentList); + } + private static void HandleIndexerDeclaration(SyntaxNodeAnalysisContext context) { var indexerDeclaration = (IndexerDeclarationSyntax)context.Node; BracketedParameterListSyntax argumentListSyntax = indexerDeclaration.ParameterList; SeparatedSyntaxList arguments = argumentListSyntax.Parameters; - if (arguments.Count > 2) - { - Analyze(context, argumentListSyntax.Parameters); - } + Analyze(context, arguments); } private static void HandleElementAccessExpression(SyntaxNodeAnalysisContext context) @@ -153,41 +160,7 @@ private static void HandleArrayCreationExpression(SyntaxNodeAnalysisContext cont foreach (var rankSpecifier in arrayCreation.Type.RankSpecifiers) { SeparatedSyntaxList sizes = rankSpecifier.Sizes; - if (sizes.Count < 3) - { - continue; - } - - ExpressionSyntax previousParameter = sizes[1]; - int firstParameterLine = sizes[0].GetLine(); - int previousLine = previousParameter.GetLine(); - Func lineCondition; - - if (firstParameterLine == previousLine) - { - // arguments should be on same line - lineCondition = (param1Line, param2Line) => param1Line == param2Line; - } - else - { - // each argument should be on its own line - lineCondition = (param1Line, param2Line) => param1Line != param2Line; - } - - for (int i = 2; i < sizes.Count; ++i) - { - ExpressionSyntax currentParameter = sizes[i]; - int currentLine = currentParameter.GetLine(); - - if (lineCondition(previousLine, currentLine)) - { - previousLine = currentLine; - continue; - } - - context.ReportDiagnostic(Diagnostic.Create(Descriptor, currentParameter.GetLocation())); - return; - } + Analyze(context, sizes); } } @@ -201,41 +174,7 @@ private static void HandleAttribute(SyntaxNodeAnalysisContext context) } SeparatedSyntaxList arguments = argumentListSyntax.Arguments; - if (arguments.Count < 3) - { - return; - } - - AttributeArgumentSyntax previousParameter = arguments[1]; - int firstParameterLine = arguments[0].GetLine(); - int previousLine = previousParameter.GetLine(); - Func lineCondition; - - if (firstParameterLine == previousLine) - { - // arguments should be on same line - lineCondition = (param1Line, param2Line) => param1Line == param2Line; - } - else - { - // each argument should be on its own line - lineCondition = (param1Line, param2Line) => param1Line != param2Line; - } - - for (int i = 2; i < arguments.Count; ++i) - { - AttributeArgumentSyntax currentParameter = arguments[i]; - int currentLine = currentParameter.GetLine(); - - if (lineCondition(previousLine, currentLine)) - { - previousLine = currentLine; - continue; - } - - context.ReportDiagnostic(Diagnostic.Create(Descriptor, currentParameter.GetLocation())); - return; - } + Analyze(context, arguments); } private static void HandleAnonymousMethodExpression(SyntaxNodeAnalysisContext context) @@ -276,10 +215,7 @@ private static void HandleArgumentListSyntax(SyntaxNodeAnalysisContext context, } SeparatedSyntaxList arguments = argumentList.Arguments; - if (arguments.Count > 2) - { - Analyze(context, arguments); - } + Analyze(context, arguments); } private static void HandleParameterListSyntax(SyntaxNodeAnalysisContext context, ParameterListSyntax parameterList) @@ -290,81 +226,45 @@ private static void HandleParameterListSyntax(SyntaxNodeAnalysisContext context, } SeparatedSyntaxList parameters = parameterList.Parameters; - if (parameters.Count > 2) - { - Analyze(context, parameters); - } + Analyze(context, parameters); } private static void HandleBracketedArgumentListSyntax(SyntaxNodeAnalysisContext context, BracketedArgumentListSyntax bracketedArgumentList) { SeparatedSyntaxList arguments = bracketedArgumentList.Arguments; - if (arguments.Count > 2) - { - Analyze(context, arguments); - } + Analyze(context, arguments); } - private static void Analyze(SyntaxNodeAnalysisContext context, SeparatedSyntaxList parameters) + private static void Analyze(SyntaxNodeAnalysisContext context, SeparatedSyntaxList arguments) + where T : SyntaxNode { - ParameterSyntax previousParameter = parameters[1]; - int firstParameterLine = parameters[0].GetLine(); - int previousLine = previousParameter.GetLine(); - Func lineCondition; - - if (firstParameterLine == previousLine) - { - // parameters should be on same line - lineCondition = (param1Line, param2Line) => param1Line == param2Line; - } - else + if (arguments.Count < 2) { - // each parameter should be on its own line - lineCondition = (param1Line, param2Line) => param1Line != param2Line; - } - - for (int i = 2; i < parameters.Count; ++i) - { - ParameterSyntax currentParameter = parameters[i]; - int currentLine = currentParameter.GetLine(); - - if (lineCondition(previousLine, currentLine)) - { - previousLine = currentLine; - continue; - } - - context.ReportDiagnostic(Diagnostic.Create(Descriptor, currentParameter.GetLocation())); return; } - } - private static void Analyze(SyntaxNodeAnalysisContext context, SeparatedSyntaxList arguments) - { - ArgumentSyntax previousParameter = arguments[1]; - int firstParameterLine = arguments[0].GetLine(); - int previousLine = previousParameter.GetLine(); - Func lineCondition; + SyntaxNode firstParameter = arguments[0]; + SyntaxNode secondParameter = arguments[1]; + Func lineCondition; - if (firstParameterLine == previousLine) + if (firstParameter.GetLine() == secondParameter.GetLine()) { // arguments should be on same line - lineCondition = (param1Line, param2Line) => param1Line == param2Line; + lineCondition = (param1, param2) => param1.GetLine() == param2.GetLine(); } else { // each argument should be on its own line - lineCondition = (param1Line, param2Line) => param1Line != param2Line; + lineCondition = (param1, param2) => param1.GetEndLine() != param2.GetLine(); } - for (int i = 2; i < arguments.Count; ++i) + SyntaxNode previousParameter = firstParameter; + for (int i = 1; i < arguments.Count; ++i) { - ArgumentSyntax currentParameter = arguments[i]; - int currentLine = currentParameter.GetLine(); - - if (lineCondition(previousLine, currentLine)) + SyntaxNode currentParameter = arguments[i]; + if (lineCondition(previousParameter, currentParameter)) { - previousLine = currentLine; + previousParameter = currentParameter; continue; } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1118ParameterMustNotSpanMultipleLines.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1118ParameterMustNotSpanMultipleLines.cs index 81135dd91..a2e9dee0f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1118ParameterMustNotSpanMultipleLines.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1118ParameterMustNotSpanMultipleLines.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -11,6 +13,7 @@ namespace StyleCop.Analyzers.ReadabilityRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; /// /// A parameter to a C# method or indexer, other than the first parameter, spans across multiple lines. @@ -61,10 +64,10 @@ internal class SA1118ParameterMustNotSpanMultipleLines : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1118"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1118.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1118Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1118MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1118Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1118.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -80,6 +83,11 @@ internal class SA1118ParameterMustNotSpanMultipleLines : DiagnosticAnalyzer SyntaxKind.InvocationExpression, SyntaxKind.ObjectCreationExpression, SyntaxKind.AnonymousObjectCreationExpression, + SyntaxKind.ArrayCreationExpression, + SyntaxKind.ImplicitArrayCreationExpression, + SyntaxKindEx.WithExpression, + SyntaxKindEx.ImplicitObjectCreationExpression, + SyntaxKindEx.CollectionExpression, }; /// @@ -131,10 +139,10 @@ private static bool CheckIfArgumentIsMultiline(CSharpSyntaxNode argument) return lineSpan.EndLinePosition.Line > lineSpan.StartLinePosition.Line; } - private static bool IsArgumentOnExceptionList(ExpressionSyntax argumentExpresson) + private static bool IsArgumentOnExceptionList(ExpressionSyntax argumentExpression) { - return argumentExpresson != null - && ArgumentExceptionSyntaxKinds.Any(argumentExpresson.IsKind); + return argumentExpression != null + && ArgumentExceptionSyntaxKinds.Any(argumentExpression.IsKind); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1120CommentsMustContainText.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1120CommentsMustContainText.cs index 77c13b4b1..884093fd2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1120CommentsMustContainText.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1120CommentsMustContainText.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -25,10 +27,10 @@ internal class SA1120CommentsMustContainText : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1120"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1120.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1120Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1120MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1120Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1120.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -82,10 +84,8 @@ private static void HandleMultiLineComment(SyntaxTreeAnalysisContext context, Sy private static void HandleSingleLineComment(SyntaxTreeAnalysisContext context, SyntaxTrivia singleLineComment) { - int index = 0; - // PERF: Explicitly cast to IReadOnlyList so we only box once. - IReadOnlyList list = TriviaHelper.GetContainingTriviaList(singleLineComment, out index); + IReadOnlyList list = TriviaHelper.GetContainingTriviaList(singleLineComment, out int index); var firstNonWhiteSpace = TriviaHelper.IndexOfFirstNonWhitespaceTrivia(list); // When we encounter a block of single line comments, we only want to raise this diagnostic diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1121UseBuiltInTypeAlias.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1121UseBuiltInTypeAlias.cs index 899b01ef1..8f86c7322 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1121UseBuiltInTypeAlias.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1121UseBuiltInTypeAlias.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -126,10 +128,10 @@ internal class SA1121UseBuiltInTypeAlias : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1121"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1121.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1121Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1121MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1121Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1121.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.Unnecessary); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1122UseStringEmptyForEmptyStrings.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1122UseStringEmptyForEmptyStrings.cs index 1a13a2700..0edcfae53 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1122UseStringEmptyForEmptyStrings.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1122UseStringEmptyForEmptyStrings.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -9,6 +11,7 @@ namespace StyleCop.Analyzers.ReadabilityRules using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; + using StyleCop.Analyzers.Lightup; /// /// The C# code includes an empty string, written as "". @@ -34,10 +37,10 @@ internal class SA1122UseStringEmptyForEmptyStrings : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1122"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1122.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1122Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1122MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1122Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1122.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -81,21 +84,20 @@ private static bool HasToBeConstant(LiteralExpressionSyntax literalExpression) ExpressionSyntax outermostExpression = FindOutermostExpression(literalExpression); if (outermostExpression.Parent.IsKind(SyntaxKind.AttributeArgument) - || outermostExpression.Parent.IsKind(SyntaxKind.CaseSwitchLabel)) + || outermostExpression.Parent.IsKind(SyntaxKind.CaseSwitchLabel) + || outermostExpression.Parent.IsKind(SyntaxKindEx.ConstantPattern)) { return true; } if (outermostExpression.Parent is EqualsValueClauseSyntax equalsValueClause) { - if (equalsValueClause.Parent is ParameterSyntax parameterSyntax) + if (equalsValueClause.Parent is ParameterSyntax) { return true; } - VariableDeclaratorSyntax variableDeclaratorSyntax = equalsValueClause.Parent as VariableDeclaratorSyntax; - VariableDeclarationSyntax variableDeclarationSyntax = variableDeclaratorSyntax?.Parent as VariableDeclarationSyntax; - if (variableDeclaratorSyntax == null || variableDeclarationSyntax == null) + if (!(equalsValueClause.Parent is VariableDeclaratorSyntax variableDeclaratorSyntax) || !(variableDeclaratorSyntax?.Parent is VariableDeclarationSyntax variableDeclarationSyntax)) { return false; } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1123DoNotPlaceRegionsWithinElements.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1123DoNotPlaceRegionsWithinElements.cs index 90fbdbe74..d12cd9536 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1123DoNotPlaceRegionsWithinElements.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1123DoNotPlaceRegionsWithinElements.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -27,10 +29,10 @@ internal class SA1123DoNotPlaceRegionsWithinElements : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1123"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1123.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1123Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1123MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1123Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1123.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1124DoNotUseRegions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1124DoNotUseRegions.cs index ce18615c0..76450854d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1124DoNotUseRegions.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1124DoNotUseRegions.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -26,10 +28,10 @@ internal class SA1124DoNotUseRegions : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1124"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1124.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1124Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1124MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1124Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1124.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1125UseShorthandForNullableTypes.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1125UseShorthandForNullableTypes.cs index ae7257ebc..9f7b60d18 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1125UseShorthandForNullableTypes.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1125UseShorthandForNullableTypes.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -26,10 +28,10 @@ internal class SA1125UseShorthandForNullableTypes : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1125"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1125.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1125Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1125MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1125Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1125.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1126PrefixCallsCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1126PrefixCallsCorrectly.cs index 4d86aa581..6121a1ab4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1126PrefixCallsCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1126PrefixCallsCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -29,13 +31,15 @@ internal class SA1126PrefixCallsCorrectly : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1126"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1126.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1126Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1126MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1126Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1126.md"; private static readonly DiagnosticDescriptor Descriptor = +#pragma warning disable RS2000 // Add analyzer diagnostic IDs to analyzer release. new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.NotConfigurable); +#pragma warning restore RS2000 // Add analyzer diagnostic IDs to analyzer release. /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -43,7 +47,11 @@ internal class SA1126PrefixCallsCorrectly : DiagnosticAnalyzer /// [ExcludeFromCodeCoverage] +#pragma warning disable RS1025 // Configure generated code analysis +#pragma warning disable RS1026 // Enable concurrent execution public override void Initialize(AnalysisContext context) +#pragma warning restore RS1026 // Enable concurrent execution +#pragma warning restore RS1025 // Configure generated code analysis { // This diagnostic is not implemented (by design) in StyleCopAnalyzers. } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1127GenericTypeConstraintsMustBeOnOwnLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1127GenericTypeConstraintsMustBeOnOwnLine.cs index e759394bd..ee833ab31 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1127GenericTypeConstraintsMustBeOnOwnLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1127GenericTypeConstraintsMustBeOnOwnLine.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -25,10 +27,10 @@ internal class SA1127GenericTypeConstraintsMustBeOnOwnLine : DiagnosticAnalyzer /// The ID for diagnostics produced by the . /// public const string DiagnosticId = "SA1127"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1127.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1127Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1127MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1127Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1127.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1128ConstructorInitializerMustBeOnOwnLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1128ConstructorInitializerMustBeOnOwnLine.cs index ecdc44bd4..6f33e2763 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1128ConstructorInitializerMustBeOnOwnLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1128ConstructorInitializerMustBeOnOwnLine.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -22,10 +24,10 @@ internal class SA1128ConstructorInitializerMustBeOnOwnLine : DiagnosticAnalyzer /// The ID for diagnostics produced by the . /// public const string DiagnosticId = "SA1128"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1128.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1128Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1128MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1128Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1128.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1129DoNotUseDefaultValueTypeConstructor.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1129DoNotUseDefaultValueTypeConstructor.cs index 543b90ffe..60a25a02b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1129DoNotUseDefaultValueTypeConstructor.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1129DoNotUseDefaultValueTypeConstructor.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -9,6 +11,7 @@ namespace StyleCop.Analyzers.ReadabilityRules using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; + using StyleCop.Analyzers.Lightup; /// /// A value type was constructed using the syntax new T(). @@ -20,14 +23,16 @@ internal class SA1129DoNotUseDefaultValueTypeConstructor : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1129"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1129.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1129Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1129MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1129Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1129.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + private static readonly Action ObjectCreationOperationAction = HandleObjectCreationOperation; + private static readonly Action TypeParameterObjectCreationOperationAction = HandleTypeParameterObjectCreationOperation; private static readonly Action ObjectCreationExpressionAction = HandleObjectCreationExpression; /// @@ -40,7 +45,63 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxNodeAction(ObjectCreationExpressionAction, SyntaxKind.ObjectCreationExpression); + if (LightupHelpers.SupportsIOperation) + { + context.RegisterOperationAction(ObjectCreationOperationAction, OperationKindEx.ObjectCreation); + context.RegisterOperationAction(TypeParameterObjectCreationOperationAction, OperationKindEx.TypeParameterObjectCreation); + } + else + { + context.RegisterSyntaxNodeAction(ObjectCreationExpressionAction, SyntaxKind.ObjectCreationExpression); + } + } + + private static void HandleObjectCreationOperation(OperationAnalysisContext context) + { + var objectCreation = IObjectCreationOperationWrapper.FromOperation(context.Operation); + + var typeToCreate = objectCreation.Constructor.ContainingType; + if ((typeToCreate == null) || typeToCreate.IsReferenceType || IsReferenceTypeParameter(typeToCreate)) + { + return; + } + + if (!objectCreation.Arguments.IsEmpty) + { + // Not a use of the default constructor + return; + } + + if (!objectCreation.Constructor.IsImplicitlyDeclared) + { + // The value type includes an explicit parameterless constructor + return; + } + + if (objectCreation.Initializer.WrappedOperation != null) + { + return; + } + + context.ReportDiagnostic(Diagnostic.Create(Descriptor, objectCreation.WrappedOperation.Syntax.GetLocation())); + } + + private static void HandleTypeParameterObjectCreationOperation(OperationAnalysisContext context) + { + var objectCreation = ITypeParameterObjectCreationOperationWrapper.FromOperation(context.Operation); + + var typeToCreate = objectCreation.Type; + if ((typeToCreate == null) || typeToCreate.IsReferenceType || IsReferenceTypeParameter(typeToCreate)) + { + return; + } + + if (objectCreation.Initializer.WrappedOperation != null) + { + return; + } + + context.ReportDiagnostic(Diagnostic.Create(Descriptor, objectCreation.WrappedOperation.Syntax.GetLocation())); } private static void HandleObjectCreationExpression(SyntaxNodeAnalysisContext context) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1130UseLambdaSyntax.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1130UseLambdaSyntax.cs index 326b151d3..0739c19ae 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1130UseLambdaSyntax.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1130UseLambdaSyntax.cs @@ -1,11 +1,12 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { using System; using System.Collections.Immutable; - using System.Linq; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -23,11 +24,10 @@ internal class SA1130UseLambdaSyntax : DiagnosticAnalyzer /// public const string DiagnosticId = "SA1130"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1130.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1130Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1130MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1130Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1130.md"; - private static readonly ParameterListSyntax EmptyParameterList = SyntaxFactory.ParameterList(); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -98,6 +98,27 @@ internal static ParameterListSyntax GetDelegateParameterList(ISymbol symbol, int return SyntaxFactory.ParameterList(SyntaxFactory.SeparatedList(syntaxParameters)); } + internal static int FindParameterIndex(SymbolInfo originalSymbolInfo, ArgumentSyntax argumentSyntax, BaseArgumentListSyntax argumentListSyntax) + { + // if delegate is passed as named argument of method try to find its position by argument name + if (argumentSyntax.NameColon != null + && originalSymbolInfo.Symbol is IMethodSymbol methodSymbol) + { + var calledMethodParameters = methodSymbol.Parameters; + var argumentIdentifier = argumentSyntax.NameColon.Name.Identifier.ValueText; + + for (var i = 0; i < calledMethodParameters.Length; ++i) + { + if (string.Equals(calledMethodParameters[i].Name, argumentIdentifier)) + { + return i; + } + } + } + + return argumentListSyntax.Arguments.IndexOf(argumentSyntax); + } + private static void HandleAnonymousMethodExpression(SyntaxNodeAnalysisContext context) { bool reportDiagnostic = true; @@ -128,9 +149,7 @@ private static void HandleAnonymousMethodExpression(SyntaxNodeAnalysisContext co private static bool HandleMethodInvocation(SemanticModel semanticModel, AnonymousMethodExpressionSyntax anonymousMethod, ArgumentSyntax argumentSyntax) { // invocation -> argument list -> argument -> anonymous method - var argumentListSyntax = argumentSyntax?.Parent as BaseArgumentListSyntax; - - if (argumentListSyntax != null) + if (argumentSyntax?.Parent is BaseArgumentListSyntax argumentListSyntax) { var originalInvocableExpression = argumentListSyntax.Parent; SymbolInfo originalSymbolInfo = semanticModel.GetSymbolInfo(originalInvocableExpression); @@ -142,14 +161,14 @@ private static bool HandleMethodInvocation(SemanticModel semanticModel, Anonymou return false; } - var argumentIndex = argumentListSyntax.Arguments.IndexOf(argumentSyntax); + var argumentIndex = FindParameterIndex(originalSymbolInfo, argumentSyntax, argumentListSyntax); // Determine the parameter list from the method that is invoked, as delegates without parameters are allowed, but they cannot be replaced by a lambda without parameters. var parameterList = GetDelegateParameterList(originalSymbolInfo.Symbol, argumentIndex); if (parameterList == null) { - // This might happen if the call was using params witha type unknown to the analyzer, e.g. params Span. + // This might happen if the call was using params with a type unknown to the analyzer, e.g. params Span. return false; } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1131UseReadableConditions.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1131UseReadableConditions.cs index d1d0513d0..e3af5070e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1131UseReadableConditions.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1131UseReadableConditions.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -22,10 +24,10 @@ internal class SA1131UseReadableConditions : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1131"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1131.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1131Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1131MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1131Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1131.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -80,12 +82,16 @@ private static bool IsLiteral(ExpressionSyntax expression, SemanticModel semanti return true; } - if (semanticModel.GetSymbolInfo(expression).Symbol is IFieldSymbol fieldSymbol) + var symbol = semanticModel.GetSymbolInfo(expression).Symbol; + switch (symbol) { - return fieldSymbol.IsStatic && fieldSymbol.IsReadOnly; - } + case IFieldSymbol fieldSymbol when fieldSymbol.IsStatic && fieldSymbol.IsReadOnly: + case IMethodSymbol: + return true; - return false; + default: + return false; + } } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1132DoNotCombineFields.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1132DoNotCombineFields.cs index 623eb16cc..d873866e7 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1132DoNotCombineFields.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1132DoNotCombineFields.cs @@ -1,12 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { using System; using System.Collections.Immutable; using Microsoft.CodeAnalysis; - using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; @@ -21,10 +22,10 @@ internal class SA1132DoNotCombineFields : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1132"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1132.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1132Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1132MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1132Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1132.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1133DoNotCombineAttributes.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1133DoNotCombineAttributes.cs index 9de3a11f3..3c3e37342 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1133DoNotCombineAttributes.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1133DoNotCombineAttributes.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -20,10 +22,10 @@ internal class SA1133DoNotCombineAttributes : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1133"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1133.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1133Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1133MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1133Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1133.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1134AttributesMustNotShareLine.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1134AttributesMustNotShareLine.cs index abc251058..b77a0d0dc 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1134AttributesMustNotShareLine.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1134AttributesMustNotShareLine.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -31,10 +33,10 @@ internal class SA1134AttributesMustNotShareLine : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1134"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1134.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1134Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1134MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1134Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1134.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1135UsingDirectivesMustBeQualified.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1135UsingDirectivesMustBeQualified.cs index 2b6495fdf..74e81154a 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1135UsingDirectivesMustBeQualified.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1135UsingDirectivesMustBeQualified.cs @@ -1,15 +1,19 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { using System.Collections.Immutable; + using System.Text; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Helpers.ObjectPools; using StyleCop.Analyzers.Lightup; /// @@ -27,11 +31,11 @@ internal class SA1135UsingDirectivesMustBeQualified : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1135"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1135.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1135Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormatNamespace = new LocalizableResourceString(nameof(ReadabilityResources.SA1135MessageFormatNamespace), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormatType = new LocalizableResourceString(nameof(ReadabilityResources.SA1135MessageFormatType), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1135Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1135.md"; public static DiagnosticDescriptor DescriptorNamespace { get; } = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormatNamespace, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -65,18 +69,13 @@ private static void HandleUsingDeclaration(SyntaxNodeAnalysisContext context) private static void CheckUsingDeclaration(SyntaxNodeAnalysisContext context, UsingDirectiveSyntax usingDirective) { - if (!usingDirective.Parent.IsKind(SyntaxKind.NamespaceDeclaration)) + if (!usingDirective.Parent.IsKind(SyntaxKind.NamespaceDeclaration) + && !usingDirective.Parent.IsKind(SyntaxKindEx.FileScopedNamespaceDeclaration)) { // Usings outside of a namespace are always qualified. return; } - if (!usingDirective.StaticKeyword.IsKind(SyntaxKind.None)) - { - // using static types is not considered. - return; - } - if (usingDirective.HasNamespaceAliasQualifier()) { // global qualified namespaces are OK. @@ -93,11 +92,12 @@ private static void CheckUsingDeclaration(SyntaxNodeAnalysisContext context, Usi if (symbol is INamedTypeSymbol typeSymbol && typeSymbol.IsTupleType()) { - symbol = typeSymbol.TupleUnderlyingType(); + symbol = typeSymbol.TupleUnderlyingTypeOrSelf(); } - string symbolString = symbol.ToString(); - string usingString = usingDirective.Name.ToString(); + string symbolString = symbol.ToQualifiedString(usingDirective.Name); + + string usingString = UsingDirectiveSyntaxToCanonicalString(usingDirective); if ((symbolString != usingString) && !usingDirective.StartsWithAlias(context.SemanticModel, context.CancellationToken)) { switch (symbol.Kind) @@ -107,7 +107,7 @@ private static void CheckUsingDeclaration(SyntaxNodeAnalysisContext context, Usi break; case SymbolKind.NamedType: - var containingNamespace = ((NamespaceDeclarationSyntax)usingDirective.Parent).Name.ToString(); + var containingNamespace = ((BaseNamespaceDeclarationSyntaxWrapper)usingDirective.Parent).Name.ToString(); if (containingNamespace != symbol.ContainingNamespace.ToString()) { context.ReportDiagnostic(Diagnostic.Create(DescriptorType, usingDirective.GetLocation(), symbolString)); @@ -117,5 +117,105 @@ private static void CheckUsingDeclaration(SyntaxNodeAnalysisContext context, Usi } } } + + private static string UsingDirectiveSyntaxToCanonicalString(UsingDirectiveSyntax usingDirective) + { + var builder = StringBuilderPool.Allocate(); + AppendCanonicalString(builder, usingDirective.Name); + return StringBuilderPool.ReturnAndFree(builder); + } + + private static bool AppendCanonicalString(StringBuilder builder, TypeSyntax type) + { + switch (type) + { + case AliasQualifiedNameSyntax aliasQualifiedName: + AppendCanonicalString(builder, aliasQualifiedName.Alias); + builder.Append("::"); + AppendCanonicalString(builder, aliasQualifiedName.Name); + return true; + + case IdentifierNameSyntax identifierName: + builder.Append(identifierName.Identifier.Text); + return true; + + case GenericNameSyntax genericName: + builder.Append(genericName.Identifier.Text); + builder.Append("<"); + + var typeArgumentList = genericName.TypeArgumentList; + for (int i = 0; i < typeArgumentList.Arguments.Count; i++) + { + if (i > 0) + { + builder.Append(", "); + } + + AppendCanonicalString(builder, typeArgumentList.Arguments[i]); + } + + builder.Append(">"); + return true; + + case QualifiedNameSyntax qualifiedName: + AppendCanonicalString(builder, qualifiedName.Left); + builder.Append("."); + AppendCanonicalString(builder, qualifiedName.Right); + return true; + + case PredefinedTypeSyntax predefinedType: + builder.Append(predefinedType.Keyword.Text); + return true; + + case ArrayTypeSyntax arrayType: + AppendCanonicalString(builder, arrayType.ElementType); + foreach (var rankSpecifier in arrayType.RankSpecifiers) + { + builder.Append("["); + builder.Append(',', rankSpecifier.Rank - 1); + builder.Append("]"); + } + + return true; + + case NullableTypeSyntax nullableType: + AppendCanonicalString(builder, nullableType.ElementType); + builder.Append("?"); + return true; + + case OmittedTypeArgumentSyntax _: + return false; + + default: + if (TupleTypeSyntaxWrapper.IsInstance(type)) + { + var tupleType = (TupleTypeSyntaxWrapper)type; + + builder.Append("("); + + var elements = tupleType.Elements; + for (int i = 0; i < elements.Count; i++) + { + if (i > 0) + { + builder.Append(", "); + } + + AppendCanonicalString(builder, elements[i].Type); + if (!elements[i].Identifier.IsKind(SyntaxKind.None)) + { + builder.Append(" ").Append(elements[i].Identifier.Text); + } + } + + builder.Append(")"); + return true; + } + else + { + return false; + } + } + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1136EnumValuesShouldBeOnSeparateLines.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1136EnumValuesShouldBeOnSeparateLines.cs index 683c1233b..4a1249605 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1136EnumValuesShouldBeOnSeparateLines.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1136EnumValuesShouldBeOnSeparateLines.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -21,10 +23,10 @@ internal class SA1136EnumValuesShouldBeOnSeparateLines : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1136"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1136.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1136Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1136MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1136Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1136.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1137ElementsShouldHaveTheSameIndentation.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1137ElementsShouldHaveTheSameIndentation.cs index f8a39af8c..ec5700d2f 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1137ElementsShouldHaveTheSameIndentation.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1137ElementsShouldHaveTheSameIndentation.cs @@ -1,9 +1,12 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { using System; + using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; using Microsoft.CodeAnalysis; @@ -11,6 +14,7 @@ namespace StyleCop.Analyzers.ReadabilityRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; [DiagnosticAnalyzer(LanguageNames.CSharp)] internal class SA1137ElementsShouldHaveTheSameIndentation : DiagnosticAnalyzer @@ -21,16 +25,16 @@ internal class SA1137ElementsShouldHaveTheSameIndentation : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1137"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1137.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1137Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1137MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1137Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1137.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); private static readonly Action CompilationUnitAction = HandleCompilationUnit; - private static readonly Action NamespaceDeclarationAction = HandleNamespaceDeclaration; + private static readonly Action BaseNamespaceDeclarationAction = HandleBaseNamespaceDeclaration; private static readonly Action TypeDeclarationAction = HandleTypeDeclaration; private static readonly Action EnumDeclarationAction = HandleEnumDeclaration; private static readonly Action MethodDeclarationAction = HandleMethodDeclaration; @@ -45,6 +49,8 @@ internal class SA1137ElementsShouldHaveTheSameIndentation : DiagnosticAnalyzer private static readonly Action SwitchStatementAction = HandleSwitchStatement; private static readonly Action InitializerExpressionAction = HandleInitializerExpression; private static readonly Action AnonymousObjectCreationExpressionAction = HandleAnonymousObjectCreationExpression; + private static readonly Action TupleTypeAction = HandleTupleType; + private static readonly Action TupleExpressionAction = HandleTupleExpression; /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -57,7 +63,7 @@ public override void Initialize(AnalysisContext context) context.EnableConcurrentExecution(); context.RegisterSyntaxNodeAction(CompilationUnitAction, SyntaxKind.CompilationUnit); - context.RegisterSyntaxNodeAction(NamespaceDeclarationAction, SyntaxKind.NamespaceDeclaration); + context.RegisterSyntaxNodeAction(BaseNamespaceDeclarationAction, SyntaxKinds.BaseNamespaceDeclaration); context.RegisterSyntaxNodeAction(TypeDeclarationAction, SyntaxKinds.TypeDeclaration); context.RegisterSyntaxNodeAction(EnumDeclarationAction, SyntaxKind.EnumDeclaration); context.RegisterSyntaxNodeAction(MethodDeclarationAction, SyntaxKind.MethodDeclaration); @@ -72,6 +78,8 @@ public override void Initialize(AnalysisContext context) context.RegisterSyntaxNodeAction(SwitchStatementAction, SyntaxKind.SwitchStatement); context.RegisterSyntaxNodeAction(InitializerExpressionAction, SyntaxKinds.InitializerExpression); context.RegisterSyntaxNodeAction(AnonymousObjectCreationExpressionAction, SyntaxKind.AnonymousObjectCreationExpression); + context.RegisterSyntaxNodeAction(TupleTypeAction, SyntaxKindEx.TupleType); + context.RegisterSyntaxNodeAction(TupleExpressionAction, SyntaxKindEx.TupleExpression); } private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context) @@ -88,9 +96,9 @@ private static void HandleCompilationUnit(SyntaxNodeAnalysisContext context) CheckElements(context, elements.ToImmutable()); } - private static void HandleNamespaceDeclaration(SyntaxNodeAnalysisContext context) + private static void HandleBaseNamespaceDeclaration(SyntaxNodeAnalysisContext context) { - var namespaceDeclaration = (NamespaceDeclarationSyntax)context.Node; + var namespaceDeclaration = (BaseNamespaceDeclarationSyntaxWrapper)context.Node; var elements = ImmutableList.CreateBuilder(); @@ -262,6 +270,20 @@ private static void HandleAnonymousObjectCreationExpression(SyntaxNodeAnalysisCo CheckElements(context, anonymousObjectCreationExpression.Initializers); } + private static void HandleTupleType(SyntaxNodeAnalysisContext context) + { + var tupleType = (TupleTypeSyntaxWrapper)context.Node; + + CheckElements(context, tupleType.Elements); + } + + private static void HandleTupleExpression(SyntaxNodeAnalysisContext context) + { + var tupleExpression = (TupleExpressionSyntaxWrapper)context.Node; + + CheckElements(context, tupleExpression.Arguments); + } + private static void AddMembersAndAttributes(ImmutableList.Builder elements, SeparatedSyntaxList members) where T : SyntaxNode { @@ -288,6 +310,8 @@ private static void AddMemberAndAttributes(ImmutableList.Builder ele case SyntaxKind.StructDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.EnumDeclaration: + case SyntaxKindEx.RecordDeclaration: + case SyntaxKindEx.RecordStructDeclaration: elements.AddRange(((BaseTypeDeclarationSyntax)member).AttributeLists); break; @@ -312,6 +336,7 @@ private static void AddMemberAndAttributes(ImmutableList.Builder ele case SyntaxKind.GetAccessorDeclaration: case SyntaxKind.SetAccessorDeclaration: + case SyntaxKindEx.InitAccessorDeclaration: case SyntaxKind.AddAccessorDeclaration: case SyntaxKind.RemoveAccessorDeclaration: case SyntaxKind.UnknownAccessorDeclaration: @@ -355,6 +380,16 @@ private static void CheckElements(SyntaxNodeAnalysisContext context, Separate CheckElements(context, elements.ToImmutableList()); } + private static void CheckElements(SyntaxNodeAnalysisContext context, SeparatedSyntaxListWrapper elements) + { + if (elements.Count < 2) + { + return; + } + + CheckElements(context, ((IEnumerable)elements.UnderlyingList).ToImmutableList()); + } + // BlockSyntax is analyzed separately because it needs to check both braces. private static void CheckBlocks(SyntaxNodeAnalysisContext context, ImmutableList elements) { @@ -480,6 +515,12 @@ private static void CheckBraces(SyntaxNodeAnalysisContext context, SyntaxToken o return; } + if (!openBraceToken.IsFirstInLine()) + { + // Do not check brace indentation if the opening brace is not the first token on a line. + return; + } + SyntaxTrivia openBraceIndentationTrivia = openBraceToken.LeadingTrivia.LastOrDefault(); string openBraceIndentation = openBraceIndentationTrivia.IsKind(SyntaxKind.WhitespaceTrivia) ? openBraceIndentationTrivia.ToString() : string.Empty; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1139UseLiteralSuffixNotationInsteadOfCasting.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1139UseLiteralSuffixNotationInsteadOfCasting.cs index 4f7a30a14..e0051a673 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1139UseLiteralSuffixNotationInsteadOfCasting.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1139UseLiteralSuffixNotationInsteadOfCasting.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -24,10 +26,10 @@ internal class SA1139UseLiteralSuffixNotationInsteadOfCasting : DiagnosticAnalyz /// public const string DiagnosticId = "SA1139"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1139.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1139Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1139MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1139Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1139.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); private static readonly Action CompilationStartAction = HandleCompilationStart; @@ -41,6 +43,7 @@ internal class SA1139UseLiteralSuffixNotationInsteadOfCasting : DiagnosticAnalyz public override void Initialize(AnalysisContext context) { context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); + context.EnableConcurrentExecution(); context.RegisterCompilationStartAction(CompilationStartAction); } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1141UseTupleSyntax.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1141UseTupleSyntax.cs new file mode 100644 index 000000000..bdc7b7d63 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1141UseTupleSyntax.cs @@ -0,0 +1,281 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.ReadabilityRules +{ + using System; + using System.Collections.Immutable; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using Microsoft.CodeAnalysis.Diagnostics; + using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; + + [DiagnosticAnalyzer(LanguageNames.CSharp)] + internal class SA1141UseTupleSyntax : DiagnosticAnalyzer + { + /// + /// The ID for diagnostics produced by the analyzer. + /// + public const string DiagnosticId = "SA1141"; + + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1141.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1141Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1141MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1141Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); + + private static readonly Action CompilationStartAction = HandleCompilationStart; + private static readonly Action MethodDeclarationAction = HandleMethodDeclaration; + private static readonly Action ConversionOperatorAction = HandleConversionOperator; + private static readonly Action PropertyDeclarationAction = HandleBasePropertyDeclaration; + private static readonly Action IndexerDeclarationAction = HandleBasePropertyDeclaration; + private static readonly Action FieldDeclarationAction = HandleFieldDeclaration; + private static readonly Action DelegateDeclarationAction = HandleDelegateDeclaration; + private static readonly Action LambdaExpressionAction = HandleLambdaExpression; + + private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + + private static readonly SymbolDisplayFormat DisplayFormat = SymbolDisplayFormat.FullyQualifiedFormat.WithGlobalNamespaceStyle(SymbolDisplayGlobalNamespaceStyle.Omitted); + + /// + public override ImmutableArray SupportedDiagnostics { get; } = ImmutableArray.Create(Descriptor); + + /// + public override void Initialize(AnalysisContext context) + { + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); + context.EnableConcurrentExecution(); + + context.RegisterCompilationStartAction(CompilationStartAction); + + context.RegisterSyntaxNodeAction(MethodDeclarationAction, SyntaxKind.MethodDeclaration); + context.RegisterSyntaxNodeAction(ConversionOperatorAction, SyntaxKind.ConversionOperatorDeclaration); + context.RegisterSyntaxNodeAction(PropertyDeclarationAction, SyntaxKind.PropertyDeclaration); + context.RegisterSyntaxNodeAction(IndexerDeclarationAction, SyntaxKind.IndexerDeclaration); + context.RegisterSyntaxNodeAction(FieldDeclarationAction, SyntaxKind.FieldDeclaration); + + context.RegisterSyntaxNodeAction(DelegateDeclarationAction, SyntaxKind.DelegateDeclaration); + context.RegisterSyntaxNodeAction(LambdaExpressionAction, SyntaxKinds.LambdaExpression); + } + + private static void HandleCompilationStart(CompilationStartAnalysisContext context) + { + var expressionType = context.Compilation.GetTypeByMetadataName("System.Linq.Expressions.Expression`1"); + + context.RegisterSyntaxNodeAction(context => HandleObjectCreationExpression(context, expressionType), SyntaxKind.ObjectCreationExpression); + context.RegisterSyntaxNodeAction(context => HandleInvocationExpression(context, expressionType), SyntaxKind.InvocationExpression); + + context.RegisterSyntaxNodeAction(context => HandleDefaultExpression(context, expressionType), SyntaxKind.DefaultExpression); + + context.RegisterSyntaxNodeAction(context => HandleCastExpression(context, expressionType), SyntaxKind.CastExpression); + } + + private static void HandleMethodDeclaration(SyntaxNodeAnalysisContext context) + { + if (!context.SupportsTuples()) + { + return; + } + + var methodDeclaration = (MethodDeclarationSyntax)context.Node; + + CheckType(context, expressionType: null, methodDeclaration.ReturnType); + CheckParameterList(context, methodDeclaration.ParameterList); + } + + private static void HandleConversionOperator(SyntaxNodeAnalysisContext context) + { + if (!context.SupportsTuples()) + { + return; + } + + var conversionOperatorDeclaration = (ConversionOperatorDeclarationSyntax)context.Node; + + CheckType(context, expressionType: null, conversionOperatorDeclaration.Type); + CheckParameterList(context, conversionOperatorDeclaration.ParameterList); + } + + private static void HandleBasePropertyDeclaration(SyntaxNodeAnalysisContext context) + { + if (!context.SupportsTuples()) + { + return; + } + + var propertyDeclaration = (BasePropertyDeclarationSyntax)context.Node; + CheckType(context, expressionType: null, propertyDeclaration.Type); + } + + private static void HandleFieldDeclaration(SyntaxNodeAnalysisContext context) + { + if (!context.SupportsTuples()) + { + return; + } + + var fieldDeclaration = (BaseFieldDeclarationSyntax)context.Node; + CheckType(context, expressionType: null, fieldDeclaration.Declaration.Type); + } + + private static void HandleLambdaExpression(SyntaxNodeAnalysisContext context) + { + if (!context.SupportsTuples()) + { + return; + } + + var lambdaExpression = (LambdaExpressionSyntax)context.Node; + if (lambdaExpression is ParenthesizedLambdaExpressionSyntax parenthesizedLambdaExpression) + { + CheckParameterList(context, parenthesizedLambdaExpression.ParameterList); + } + } + + private static void HandleObjectCreationExpression(SyntaxNodeAnalysisContext context, INamedTypeSymbol expressionType) + { + if (!context.SupportsTuples()) + { + return; + } + + var objectCreationExpression = (ObjectCreationExpressionSyntax)context.Node; + CheckType(context, expressionType, objectCreationExpression.Type, objectCreationExpression.GetLocation()); + } + + private static void HandleInvocationExpression(SyntaxNodeAnalysisContext context, INamedTypeSymbol expressionType) + { + if (!context.SupportsTuples()) + { + return; + } + + var invocationExpression = (InvocationExpressionSyntax)context.Node; + if (invocationExpression.ArgumentList.Arguments.Count < 2) + { + // Tuple creation with less than two elements cannot use the language syntax + return; + } + + if (!invocationExpression.Expression.IsKind(SyntaxKind.SimpleMemberAccessExpression)) + { + return; + } + + var memberAccessExpression = (MemberAccessExpressionSyntax)invocationExpression.Expression; + + var symbolInfo = context.SemanticModel.GetSymbolInfo(memberAccessExpression.Expression); + if (symbolInfo.Symbol is INamedTypeSymbol namedTypeSymbol + && namedTypeSymbol.ToDisplayString(DisplayFormat) == "System.ValueTuple" + && !context.Node.IsInExpressionTree(context.SemanticModel, expressionType, context.CancellationToken)) + { + if (memberAccessExpression.Name.Identifier.ValueText == "Create") + { + context.ReportDiagnostic(Diagnostic.Create(Descriptor, memberAccessExpression.GetLocation())); + } + } + } + + private static void HandleDefaultExpression(SyntaxNodeAnalysisContext context, INamedTypeSymbol expressionType) + { + if (!context.SupportsTuples()) + { + return; + } + + var defaultExpression = (DefaultExpressionSyntax)context.Node; + CheckType(context, expressionType, defaultExpression.Type); + } + + private static void HandleDelegateDeclaration(SyntaxNodeAnalysisContext context) + { + if (!context.SupportsTuples()) + { + return; + } + + var delegateDeclaration = (DelegateDeclarationSyntax)context.Node; + CheckType(context, expressionType: null, delegateDeclaration.ReturnType); + CheckParameterList(context, delegateDeclaration.ParameterList); + } + + private static void HandleCastExpression(SyntaxNodeAnalysisContext context, INamedTypeSymbol expressionType) + { + if (!context.SupportsTuples()) + { + return; + } + + var castExpression = (CastExpressionSyntax)context.Node; + CheckType(context, expressionType, castExpression.Type); + } + + private static void CheckParameterList(SyntaxNodeAnalysisContext context, ParameterListSyntax parameterList) + { + foreach (var parameter in parameterList.Parameters) + { + CheckType(context, expressionType: null, parameter.Type); + } + } + + private static void CheckType(SyntaxNodeAnalysisContext context, INamedTypeSymbol expressionType, TypeSyntax typeSyntax, Location reportLocation = null) + { + if (typeSyntax is null) + { + return; + } + + switch (typeSyntax.Kind()) + { + case SyntaxKindEx.TupleType: + CheckTupleType(context, expressionType, (TupleTypeSyntaxWrapper)typeSyntax, reportLocation); + break; + + case SyntaxKind.QualifiedName: + CheckType(context, expressionType, ((QualifiedNameSyntax)typeSyntax).Right, reportLocation ?? typeSyntax.GetLocation()); + break; + + case SyntaxKind.GenericName: + CheckGenericName(context, expressionType, (GenericNameSyntax)typeSyntax, reportLocation); + break; + } + } + + private static void CheckTupleType(SyntaxNodeAnalysisContext context, INamedTypeSymbol expressionType, TupleTypeSyntaxWrapper tupleTypeSyntax, Location reportLocation) + { + foreach (var tupleElementSyntax in tupleTypeSyntax.Elements) + { + CheckType(context, expressionType, tupleElementSyntax.Type, reportLocation); + } + } + + private static void CheckGenericName(SyntaxNodeAnalysisContext context, INamedTypeSymbol expressionType, GenericNameSyntax genericNameSyntax, Location reportLocation) + { + if (IsValueTupleWithLanguageRepresentation(context, expressionType, genericNameSyntax)) + { + var location = reportLocation ?? genericNameSyntax.GetLocation(); + context.ReportDiagnostic(Diagnostic.Create(Descriptor, location)); + + // only report a single diagnostic for a type. + return; + } + + foreach (var typeArgument in genericNameSyntax.TypeArgumentList.Arguments) + { + CheckType(context, expressionType, typeArgument); + } + } + + private static bool IsValueTupleWithLanguageRepresentation(SyntaxNodeAnalysisContext context, INamedTypeSymbol expressionType, ExpressionSyntax syntax) + { + var symbolInfo = context.SemanticModel.GetSymbolInfo(syntax, context.CancellationToken); + return symbolInfo.Symbol is INamedTypeSymbol typeSymbol + && typeSymbol.IsTupleType() + && typeSymbol.TupleElements().Length > 1 + && !syntax.IsInExpressionTree(context.SemanticModel, expressionType, context.CancellationToken); + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1142ReferToTupleElementsByName.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1142ReferToTupleElementsByName.cs new file mode 100644 index 000000000..f123e31dc --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SA1142ReferToTupleElementsByName.cs @@ -0,0 +1,110 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.ReadabilityRules +{ + using System; + using System.Collections.Immutable; + using System.Linq; + using Microsoft.CodeAnalysis; + using Microsoft.CodeAnalysis.CSharp; + using Microsoft.CodeAnalysis.CSharp.Syntax; + using Microsoft.CodeAnalysis.Diagnostics; + using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; + + [DiagnosticAnalyzer(LanguageNames.CSharp)] + internal class SA1142ReferToTupleElementsByName : DiagnosticAnalyzer + { + /// + /// The ID for diagnostics produced by the analyzer. + /// + public const string DiagnosticId = "SA1142"; + + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1142.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SA1142Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SA1142MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SA1142Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); + + private static readonly Action FieldReferenceOperationAction = HandleFieldReferenceOperation; + private static readonly Action SimpleMemberAccessExpressionAction = HandleSimpleMemberAccessExpression; + + private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + + /// + public override ImmutableArray SupportedDiagnostics { get; } = ImmutableArray.Create(Descriptor); + + /// + public override void Initialize(AnalysisContext context) + { + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); + context.EnableConcurrentExecution(); + + if (LightupHelpers.SupportsIOperation) + { + context.RegisterOperationAction(FieldReferenceOperationAction, OperationKindEx.FieldReference); + } + else + { + context.RegisterSyntaxNodeAction(SimpleMemberAccessExpressionAction, SyntaxKind.SimpleMemberAccessExpression); + } + } + + private static void HandleFieldReferenceOperation(OperationAnalysisContext context) + { + if (!context.SupportsTuples()) + { + return; + } + + var fieldReference = IFieldReferenceOperationWrapper.FromOperation(context.Operation); + + if (CheckFieldName(fieldReference.Field)) + { + var location = fieldReference.WrappedOperation.Syntax is MemberAccessExpressionSyntax memberAccessExpression + ? memberAccessExpression.Name.GetLocation() + : fieldReference.WrappedOperation.Syntax.GetLocation(); + context.ReportDiagnostic(Diagnostic.Create(Descriptor, location)); + } + } + + private static void HandleSimpleMemberAccessExpression(SyntaxNodeAnalysisContext context) + { + if (!context.SupportsTuples()) + { + return; + } + + var memberAccessExpression = (MemberAccessExpressionSyntax)context.Node; + + if (!(context.SemanticModel.GetSymbolInfo(memberAccessExpression).Symbol is IFieldSymbol fieldSymbol)) + { + return; + } + + if (CheckFieldName(fieldSymbol)) + { + context.ReportDiagnostic(Diagnostic.Create(Descriptor, memberAccessExpression.Name.GetLocation())); + } + } + + private static bool CheckFieldName(IFieldSymbol fieldSymbol) + { + if (!fieldSymbol.ContainingType.IsTupleType()) + { + return false; + } + + // check if this already is a proper tuple field name + if (!Equals(fieldSymbol.CorrespondingTupleField(), fieldSymbol)) + { + return false; + } + + // check if there is a tuple field name declared. + return fieldSymbol.ContainingType.GetMembers().OfType().Count(fs => Equals(fs.CorrespondingTupleField(), fieldSymbol)) > 1; + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SX1101DoNotPrefixLocalMembersWithThis.cs b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SX1101DoNotPrefixLocalMembersWithThis.cs index 57c5245cf..ca0da7a96 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SX1101DoNotPrefixLocalMembersWithThis.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/ReadabilityRules/SX1101DoNotPrefixLocalMembersWithThis.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.ReadabilityRules { @@ -18,10 +20,10 @@ internal class SX1101DoNotPrefixLocalMembersWithThis : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SX1101"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SX1101.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(ReadabilityResources.SX1101Title), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(ReadabilityResources.SX1101MessageFormat), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(ReadabilityResources.SX1101Description), ReadabilityResources.ResourceManager, typeof(ReadabilityResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SX1101.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.ReadabilityRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledAlternative, Description, HelpLink, WellKnownDiagnosticTags.Unnecessary); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/DeserializationFailureBehavior.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/DeserializationFailureBehavior.cs index 062cd8804..e26b5154d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/DeserializationFailureBehavior.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/DeserializationFailureBehavior.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/InvalidSettingsException.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/InvalidSettingsException.cs index bdb444116..f08c22e78 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/InvalidSettingsException.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/InvalidSettingsException.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/JsonHelper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/JsonHelper.cs index 979c49245..533e4511d 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/JsonHelper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/JsonHelper.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/AnalyzerConfigHelper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/AnalyzerConfigHelper.cs new file mode 100644 index 000000000..0cfc4a307 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/AnalyzerConfigHelper.cs @@ -0,0 +1,94 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable + +namespace StyleCop.Analyzers.Settings.ObjectModel +{ + using System.Collections.Generic; + using System.Collections.Immutable; + using System.Linq; + using StyleCop.Analyzers.Lightup; + + internal static class AnalyzerConfigHelper + { + internal static bool? TryGetBooleanValue(AnalyzerConfigOptionsWrapper analyzerConfigOptions, string key) + { + if (analyzerConfigOptions.TryGetValue(key, out var value) + && value != "unset" + && bool.TryParse(value, out var boolValue)) + { + return boolValue; + } + + return null; + } + + internal static int? TryGetInt32Value(AnalyzerConfigOptionsWrapper analyzerConfigOptions, string key) + { + if (analyzerConfigOptions.TryGetValue(key, out var value) + && value != "unset" + && int.TryParse(value, out var intValue)) + { + return intValue; + } + + return null; + } + + internal static string TryGetStringValue(AnalyzerConfigOptionsWrapper analyzerConfigOptions, string key, bool allowExplicitUnset = true) + { + if (analyzerConfigOptions.TryGetValue(key, out var value)) + { + if (allowExplicitUnset && value == "unset") + { + return null; + } + + return value; + } + + return null; + } + + internal static string TryGetMultiLineStringValue(AnalyzerConfigOptionsWrapper analyzerConfigOptions, string key, bool allowExplicitUnset = true) + { + var orgValue = TryGetStringValue(analyzerConfigOptions, key, allowExplicitUnset); + return orgValue?.Replace("\\r", "\r").Replace("\\n", "\n"); + } + + internal static KeyValuePair? TryGetStringValueAndNotification(AnalyzerConfigOptionsWrapper analyzerConfigOptions, string key, bool allowExplicitUnset = true) + { + if (analyzerConfigOptions.TryGetValue(key, out var value)) + { + if (allowExplicitUnset && value == "unset") + { + return null; + } + + var colonIndex = value.IndexOf(':'); + if (colonIndex >= 0) + { + return new KeyValuePair(value.Substring(0, colonIndex), value.Substring(colonIndex + 1)); + } + } + + return null; + } + + internal static ImmutableArray? TryGetStringListValue(AnalyzerConfigOptionsWrapper analyzerConfigOptions, string key, bool allowExplicitUnset = true) + { + if (analyzerConfigOptions.TryGetValue(key, out var value)) + { + if (allowExplicitUnset && value == "unset") + { + return null; + } + + return value.Split(',').Select(static x => x.Trim()).ToImmutableArray(); + } + + return null; + } + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/DocumentationSettings.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/DocumentationSettings.cs index 2815bf679..c0629daa0 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/DocumentationSettings.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/DocumentationSettings.cs @@ -1,14 +1,16 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Settings.ObjectModel { - using System; using System.Collections.Generic; using System.Collections.Immutable; - using System.Linq; + using System.Globalization; using System.Text.RegularExpressions; using LightJson; + using StyleCop.Analyzers.Lightup; internal class DocumentationSettings { @@ -50,7 +52,7 @@ internal class DocumentationSettings /// /// This is the backing field for the property. /// - private readonly ImmutableDictionary.Builder variables; + private readonly ImmutableDictionary variables; /// /// This is the backing field for the property. @@ -92,6 +94,11 @@ internal class DocumentationSettings /// private readonly string documentationCulture; + /// + /// This is backing field for the property. + /// + private readonly CultureInfo documentationCultureInfo; + /// /// This is the backing field for the property. /// @@ -110,7 +117,7 @@ protected internal DocumentationSettings() this.companyName = DefaultCompanyName; this.copyrightText = DefaultCopyrightText; this.headerDecoration = null; - this.variables = ImmutableDictionary.Empty.ToBuilder(); + this.variables = ImmutableDictionary.Empty; this.xmlHeader = true; this.documentExposedElements = true; @@ -122,6 +129,7 @@ protected internal DocumentationSettings() this.fileNamingConvention = FileNamingConvention.StyleCop; this.documentationCulture = DefaultDocumentationCulture; + this.documentationCultureInfo = CultureInfo.InvariantCulture; this.excludeFromPunctuationCheck = DefaultExcludeFromPunctuationCheck; } @@ -130,89 +138,142 @@ protected internal DocumentationSettings() /// Initializes a new instance of the class. /// /// The JSON object containing the settings. - protected internal DocumentationSettings(JsonObject documentationSettingsObject) - : this() + /// The .editorconfig options to use if + /// stylecop.json does not provide values. + protected internal DocumentationSettings(JsonObject documentationSettingsObject, AnalyzerConfigOptionsWrapper analyzerConfigOptions) { + bool? documentExposedElements = null; + bool? documentInternalElements = null; + bool? documentPrivateElements = null; + bool? documentInterfaces = null; + bool? documentPrivateFields = null; + string companyName = null; + string copyrightText = null; + string headerDecoration = null; + ImmutableDictionary.Builder variables = null; + bool? xmlHeader = null; + FileNamingConvention? fileNamingConvention = null; + string documentationCulture = null; + ImmutableArray.Builder excludeFromPunctuationCheck = null; + foreach (var kvp in documentationSettingsObject) { switch (kvp.Key) { case "documentExposedElements": - this.documentExposedElements = kvp.ToBooleanValue(); + documentExposedElements = kvp.ToBooleanValue(); break; case "documentInternalElements": - this.documentInternalElements = kvp.ToBooleanValue(); + documentInternalElements = kvp.ToBooleanValue(); break; case "documentPrivateElements": - this.documentPrivateElements = kvp.ToBooleanValue(); + documentPrivateElements = kvp.ToBooleanValue(); break; case "documentInterfaces": - this.documentInterfaces = kvp.ToBooleanValue(); + documentInterfaces = kvp.ToBooleanValue(); break; case "documentPrivateFields": - this.documentPrivateFields = kvp.ToBooleanValue(); + documentPrivateFields = kvp.ToBooleanValue(); break; case "companyName": - this.companyName = kvp.ToStringValue(); + companyName = kvp.ToStringValue(); break; + case "copyrightText": - this.copyrightText = kvp.ToStringValue(); + copyrightText = kvp.ToStringValue(); break; case "headerDecoration": - this.headerDecoration = kvp.ToStringValue(); + headerDecoration = kvp.ToStringValue(); break; case "variables": kvp.AssertIsObject(); + variables = ImmutableDictionary.CreateBuilder(); foreach (var child in kvp.Value.AsJsonObject) { string name = child.Key; - if (!Regex.IsMatch(name, "^[a-zA-Z0-9]+$")) + if (!IsValidVariableName(name)) { continue; } string value = child.ToStringValue(); - this.variables.Add(name, value); + variables.Add(name, value); } break; case "xmlHeader": - this.xmlHeader = kvp.ToBooleanValue(); + xmlHeader = kvp.ToBooleanValue(); break; case "fileNamingConvention": - this.fileNamingConvention = kvp.ToEnumValue(); + fileNamingConvention = kvp.ToEnumValue(); break; case "documentationCulture": - this.documentationCulture = kvp.ToStringValue(); + documentationCulture = kvp.ToStringValue(); break; case "excludeFromPunctuationCheck": kvp.AssertIsArray(); - var excludedTags = ImmutableArray.CreateBuilder(); + excludeFromPunctuationCheck = ImmutableArray.CreateBuilder(); foreach (var value in kvp.Value.AsJsonArray) { - excludedTags.Add(value.AsString); + excludeFromPunctuationCheck.Add(value.AsString); } - this.excludeFromPunctuationCheck = excludedTags.ToImmutable(); break; default: break; } } + + documentExposedElements ??= AnalyzerConfigHelper.TryGetBooleanValue(analyzerConfigOptions, "stylecop.documentation.documentExposedElements"); + documentInternalElements ??= AnalyzerConfigHelper.TryGetBooleanValue(analyzerConfigOptions, "stylecop.documentation.documentInternalElements"); + documentPrivateElements ??= AnalyzerConfigHelper.TryGetBooleanValue(analyzerConfigOptions, "stylecop.documentation.documentPrivateElements"); + documentInterfaces ??= AnalyzerConfigHelper.TryGetBooleanValue(analyzerConfigOptions, "stylecop.documentation.documentInterfaces"); + documentPrivateFields ??= AnalyzerConfigHelper.TryGetBooleanValue(analyzerConfigOptions, "stylecop.documentation.documentPrivateFields"); + + companyName ??= AnalyzerConfigHelper.TryGetStringValue(analyzerConfigOptions, "stylecop.documentation.companyName"); + copyrightText ??= AnalyzerConfigHelper.TryGetMultiLineStringValue(analyzerConfigOptions, "stylecop.documentation.copyrightText") + ?? AnalyzerConfigHelper.TryGetMultiLineStringValue(analyzerConfigOptions, "file_header_template"); + headerDecoration ??= AnalyzerConfigHelper.TryGetStringValue(analyzerConfigOptions, "stylecop.documentation.headerDecoration"); + + xmlHeader ??= AnalyzerConfigHelper.TryGetBooleanValue(analyzerConfigOptions, "stylecop.documentation.xmlHeader"); + fileNamingConvention ??= AnalyzerConfigHelper.TryGetStringValue(analyzerConfigOptions, "stylecop.documentation.fileNamingConvention") switch + { + "stylecop" => FileNamingConvention.StyleCop, + "metadata" => FileNamingConvention.Metadata, + _ => null, + }; + + documentationCulture ??= AnalyzerConfigHelper.TryGetStringValue(analyzerConfigOptions, "stylecop.documentation.documentationCulture"); + excludeFromPunctuationCheck ??= AnalyzerConfigHelper.TryGetStringListValue(analyzerConfigOptions, "stylecop.documentation.excludeFromPunctuationCheck")?.ToBuilder(); + + this.documentExposedElements = documentExposedElements.GetValueOrDefault(true); + this.documentInternalElements = documentInternalElements.GetValueOrDefault(true); + this.documentPrivateElements = documentPrivateElements.GetValueOrDefault(false); + this.documentInterfaces = documentInterfaces.GetValueOrDefault(true); + this.documentPrivateFields = documentPrivateFields.GetValueOrDefault(false); + this.companyName = companyName ?? DefaultCompanyName; + this.copyrightText = copyrightText ?? DefaultCopyrightText; + this.headerDecoration = headerDecoration; + this.variables = variables?.ToImmutable() ?? ImmutableDictionary.Empty; + this.xmlHeader = xmlHeader.GetValueOrDefault(true); + this.fileNamingConvention = fileNamingConvention.GetValueOrDefault(FileNamingConvention.StyleCop); + this.documentationCulture = documentationCulture ?? DefaultDocumentationCulture; + this.documentationCultureInfo = this.documentationCulture == DefaultDocumentationCulture ? CultureInfo.InvariantCulture : new CultureInfo(this.documentationCulture); + this.excludeFromPunctuationCheck = excludeFromPunctuationCheck?.ToImmutable() ?? DefaultExcludeFromPunctuationCheck; } public string CompanyName @@ -235,7 +296,7 @@ public ImmutableDictionary Variables { get { - return this.variables.ToImmutable(); + return this.variables; } } @@ -271,6 +332,9 @@ public bool XmlHeader public ImmutableArray ExcludeFromPunctuationCheck => this.excludeFromPunctuationCheck; + public CultureInfo DocumentationCultureInfo + => this.documentationCultureInfo; + public string GetCopyrightText(string fileName) { string copyrightText = this.copyrightTextCache; @@ -290,44 +354,58 @@ public string GetCopyrightText(string fileName) return this.copyrightTextCache; } + private static bool IsValidVariableName(string name) + { + // Equivalent to Regex.IsMatch(prefix, "^[a-zA-Z0-9]+$") + for (var i = 0; i < name.Length; i++) + { + if (name[i] is not ((>= 'a' and <= 'z') or (>= 'A' and <= 'Z') or (>= '0' and <= '9'))) + { + return false; + } + } + + return name.Length > 0; + } + private KeyValuePair BuildCopyrightText(string fileName) { bool canCache = true; - string pattern = Regex.Escape("{") + "(?[a-zA-Z0-9]+)" + Regex.Escape("}"); - MatchEvaluator evaluator = - match => - { - string key = match.Groups["Property"].Value; - switch (key) - { - case "companyName": - return this.CompanyName; - case "copyrightText": - return "[CircularReference]"; + string Evaluator(Match match) + { + string key = match.Groups["Property"].Value; + switch (key) + { + case "companyName": + return this.CompanyName; - default: - string value; - if (this.Variables.TryGetValue(key, out value)) - { - return value; - } + case "copyrightText": + return "[CircularReference]"; - if (key == "fileName") - { - // The 'fileName' built-in variable is only applied when the user did not include an - // explicit value for a custom 'fileName' variable. - canCache = false; - return fileName; - } + default: + string value; + if (this.Variables.TryGetValue(key, out value)) + { + return value; + } - break; + if (key == "fileName") + { + // The 'fileName' built-in variable is only applied when the user did not include an + // explicit value for a custom 'fileName' variable. + canCache = false; + return fileName; } - return "[InvalidReference]"; - }; + break; + } + + return "[InvalidReference]"; + } - string expanded = Regex.Replace(this.copyrightText, pattern, evaluator); + string pattern = Regex.Escape("{") + "(?[a-zA-Z0-9]+)" + Regex.Escape("}"); + string expanded = Regex.Replace(this.copyrightText, pattern, Evaluator); return new KeyValuePair(expanded, canCache); } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/FileNamingConvention.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/FileNamingConvention.cs index 6b1c8771b..7151215b1 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/FileNamingConvention.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/FileNamingConvention.cs @@ -1,17 +1,17 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Settings.ObjectModel { internal enum FileNamingConvention { /// - /// Files are named using the StyleCop convention (e.g. TypeName{T1,T2}) + /// Files are named using the StyleCop convention (e.g. TypeName{T1,T2}). /// StyleCop, /// - /// Files are named using the metadata convention (e.g. TypeName`2) + /// Files are named using the metadata convention (e.g. TypeName`2). /// Metadata, } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/IndentationSettings.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/IndentationSettings.cs index f7860d066..0904d35bb 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/IndentationSettings.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/IndentationSettings.cs @@ -1,9 +1,12 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Settings.ObjectModel { using LightJson; + using StyleCop.Analyzers.Lightup; internal class IndentationSettings { @@ -36,29 +39,47 @@ protected internal IndentationSettings() /// Initializes a new instance of the class. /// /// The JSON object containing the settings. - protected internal IndentationSettings(JsonObject indentationSettingsObject) - : this() + /// The .editorconfig options to use if + /// stylecop.json does not provide values. + protected internal IndentationSettings(JsonObject indentationSettingsObject, AnalyzerConfigOptionsWrapper analyzerConfigOptions) { + int? indentationSize = null; + int? tabSize = null; + bool? useTabs = null; + foreach (var kvp in indentationSettingsObject) { switch (kvp.Key) { case "indentationSize": - this.indentationSize = kvp.ToInt32Value(); + indentationSize = kvp.ToInt32Value(); break; case "tabSize": - this.tabSize = kvp.ToInt32Value(); + tabSize = kvp.ToInt32Value(); break; case "useTabs": - this.useTabs = kvp.ToBooleanValue(); + useTabs = kvp.ToBooleanValue(); break; default: break; } } + + indentationSize ??= AnalyzerConfigHelper.TryGetInt32Value(analyzerConfigOptions, "indent_size"); + tabSize ??= AnalyzerConfigHelper.TryGetInt32Value(analyzerConfigOptions, "tab_width"); + useTabs ??= AnalyzerConfigHelper.TryGetStringValue(analyzerConfigOptions, "indent_style") switch + { + "tab" => true, + "space" => false, + _ => null, + }; + + this.indentationSize = indentationSize.GetValueOrDefault(4); + this.tabSize = tabSize.GetValueOrDefault(4); + this.useTabs = useTabs.GetValueOrDefault(false); } public int IndentationSize => diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/LayoutSettings.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/LayoutSettings.cs index c6f116a0b..62186b222 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/LayoutSettings.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/LayoutSettings.cs @@ -1,9 +1,12 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Settings.ObjectModel { using LightJson; + using StyleCop.Analyzers.Lightup; internal class LayoutSettings { @@ -17,6 +20,11 @@ internal class LayoutSettings /// private readonly bool allowConsecutiveUsings; + /// + /// This is the backing field of the property. + /// + private readonly bool allowDoWhileOnClosingBrace; + /// /// Initializes a new instance of the class. /// @@ -24,31 +32,55 @@ protected internal LayoutSettings() { this.newlineAtEndOfFile = OptionSetting.Allow; this.allowConsecutiveUsings = true; + this.allowDoWhileOnClosingBrace = false; } /// /// Initializes a new instance of the class. /// /// The JSON object containing the settings. - protected internal LayoutSettings(JsonObject layoutSettingsObject) - : this() + /// The .editorconfig options to use if + /// stylecop.json does not provide values. + protected internal LayoutSettings(JsonObject layoutSettingsObject, AnalyzerConfigOptionsWrapper analyzerConfigOptions) { + OptionSetting? newlineAtEndOfFile = null; + bool? allowConsecutiveUsings = null; + bool? allowDoWhileOnClosingBrace = null; + foreach (var kvp in layoutSettingsObject) { switch (kvp.Key) { case "newlineAtEndOfFile": - this.newlineAtEndOfFile = kvp.ToEnumValue(); + newlineAtEndOfFile = kvp.ToEnumValue(); break; case "allowConsecutiveUsings": - this.allowConsecutiveUsings = kvp.ToBooleanValue(); + allowConsecutiveUsings = kvp.ToBooleanValue(); + break; + + case "allowDoWhileOnClosingBrace": + allowDoWhileOnClosingBrace = kvp.ToBooleanValue(); break; default: break; } } + + newlineAtEndOfFile ??= AnalyzerConfigHelper.TryGetBooleanValue(analyzerConfigOptions, "insert_final_newline") switch + { + true => OptionSetting.Require, + false => OptionSetting.Omit, + _ => null, + }; + + allowConsecutiveUsings ??= AnalyzerConfigHelper.TryGetBooleanValue(analyzerConfigOptions, "stylecop.layout.allowConsecutiveUsings"); + allowDoWhileOnClosingBrace ??= AnalyzerConfigHelper.TryGetBooleanValue(analyzerConfigOptions, "stylecop.layout.allowDoWhileOnClosingBrace"); + + this.newlineAtEndOfFile = newlineAtEndOfFile.GetValueOrDefault(OptionSetting.Allow); + this.allowConsecutiveUsings = allowConsecutiveUsings.GetValueOrDefault(true); + this.allowDoWhileOnClosingBrace = allowDoWhileOnClosingBrace.GetValueOrDefault(false); } public OptionSetting NewlineAtEndOfFile => @@ -56,5 +88,8 @@ protected internal LayoutSettings(JsonObject layoutSettingsObject) public bool AllowConsecutiveUsings => this.allowConsecutiveUsings; + + public bool AllowDoWhileOnClosingBrace => + this.allowDoWhileOnClosingBrace; } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/MaintainabilitySettings.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/MaintainabilitySettings.cs index ea311e792..210513857 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/MaintainabilitySettings.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/MaintainabilitySettings.cs @@ -1,10 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Settings.ObjectModel { using System.Collections.Immutable; using LightJson; + using StyleCop.Analyzers.Lightup; internal class MaintainabilitySettings { @@ -17,33 +20,37 @@ internal class MaintainabilitySettings /// /// This is the backing field for the property. /// - private readonly ImmutableArray.Builder topLevelTypes; + private readonly ImmutableArray topLevelTypes; /// /// Initializes a new instance of the class. /// protected internal MaintainabilitySettings() { - this.topLevelTypes = ImmutableArray.CreateBuilder(); + this.topLevelTypes = ImmutableArray.Empty; } /// /// Initializes a new instance of the class. /// /// The JSON object containing the settings. - protected internal MaintainabilitySettings(JsonObject maintainabilitySettingsObject) - : this() + /// The .editorconfig options to use if + /// stylecop.json does not provide values. + protected internal MaintainabilitySettings(JsonObject maintainabilitySettingsObject, AnalyzerConfigOptionsWrapper analyzerConfigOptions) { + ImmutableArray.Builder topLevelTypes = null; + foreach (var kvp in maintainabilitySettingsObject) { switch (kvp.Key) { case "topLevelTypes": kvp.AssertIsArray(); + topLevelTypes = ImmutableArray.CreateBuilder(); foreach (var value in kvp.Value.AsJsonArray) { var typeKind = value.ToEnumValue(kvp.Key); - this.topLevelTypes.Add(typeKind); + topLevelTypes.Add(typeKind); } break; @@ -52,13 +59,15 @@ protected internal MaintainabilitySettings(JsonObject maintainabilitySettingsObj break; } } + + this.topLevelTypes = topLevelTypes?.ToImmutable() ?? ImmutableArray.Empty; } public ImmutableArray TopLevelTypes { get { - return this.topLevelTypes.Count > 0 ? this.topLevelTypes.ToImmutable() : DefaultTopLevelTypes; + return this.topLevelTypes.Length > 0 ? this.topLevelTypes : DefaultTopLevelTypes; } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/NamingSettings.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/NamingSettings.cs index 3bba522e6..0b7278f91 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/NamingSettings.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/NamingSettings.cs @@ -1,79 +1,132 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Settings.ObjectModel { using System.Collections.Immutable; - using System.Text.RegularExpressions; + using System.Linq; using LightJson; + using StyleCop.Analyzers.Lightup; internal class NamingSettings { - /// - /// This is the backing field for the property. - /// - private readonly bool allowCommonHungarianPrefixes; - - /// - /// This is the backing field for the property. - /// - private readonly ImmutableArray.Builder allowedHungarianPrefixes; - /// /// Initializes a new instance of the class. /// protected internal NamingSettings() { - this.allowCommonHungarianPrefixes = true; - this.allowedHungarianPrefixes = ImmutableArray.CreateBuilder(); + this.AllowCommonHungarianPrefixes = true; + this.AllowedHungarianPrefixes = ImmutableArray.Empty; + this.AllowedNamespaceComponents = ImmutableArray.Empty; + + this.IncludeInferredTupleElementNames = false; + this.TupleElementNameCasing = TupleElementNameCase.PascalCase; } /// /// Initializes a new instance of the class. /// /// The JSON object containing the settings. - protected internal NamingSettings(JsonObject namingSettingsObject) - : this() + /// The .editorconfig options to use if + /// stylecop.json does not provide values. + protected internal NamingSettings(JsonObject namingSettingsObject, AnalyzerConfigOptionsWrapper analyzerConfigOptions) { + bool? allowCommonHungarianPrefixes = null; + ImmutableArray.Builder allowedHungarianPrefixes = null; + ImmutableArray.Builder allowedNamespaceComponents = null; + bool? includeInferredTupleElementNames = null; + TupleElementNameCase? tupleElementNameCasing = null; + foreach (var kvp in namingSettingsObject) { switch (kvp.Key) { case "allowCommonHungarianPrefixes": - this.allowCommonHungarianPrefixes = kvp.ToBooleanValue(); + allowCommonHungarianPrefixes = kvp.ToBooleanValue(); break; case "allowedHungarianPrefixes": kvp.AssertIsArray(); + allowedHungarianPrefixes = ImmutableArray.CreateBuilder(); foreach (var prefixJsonValue in kvp.Value.AsJsonArray) { var prefix = prefixJsonValue.ToStringValue(kvp.Key); - if (!Regex.IsMatch(prefix, "^[a-z]{1,2}$")) + if (!IsValidHungarianPrefix(prefix)) { continue; } - this.allowedHungarianPrefixes.Add(prefix); + allowedHungarianPrefixes.Add(prefix); } break; + case "allowedNamespaceComponents": + kvp.AssertIsArray(); + allowedNamespaceComponents = ImmutableArray.CreateBuilder(); + allowedNamespaceComponents.AddRange(kvp.Value.AsJsonArray.Select(x => x.ToStringValue(kvp.Key))); + break; + + case "includeInferredTupleElementNames": + includeInferredTupleElementNames = kvp.ToBooleanValue(); + break; + + case "tupleElementNameCasing": + tupleElementNameCasing = kvp.ToEnumValue(); + break; + default: break; } } + + allowCommonHungarianPrefixes ??= AnalyzerConfigHelper.TryGetBooleanValue(analyzerConfigOptions, "stylecop.naming.allowCommonHungarianPrefixes"); + allowedHungarianPrefixes ??= AnalyzerConfigHelper.TryGetStringListValue(analyzerConfigOptions, "stylecop.naming.allowedHungarianPrefixes") + ?.Where(value => IsValidHungarianPrefix(value)) + .ToImmutableArray() + .ToBuilder(); + allowedNamespaceComponents ??= AnalyzerConfigHelper.TryGetStringListValue(analyzerConfigOptions, "stylecop.naming.allowedNamespaceComponents")?.ToBuilder(); + includeInferredTupleElementNames ??= AnalyzerConfigHelper.TryGetBooleanValue(analyzerConfigOptions, "stylecop.naming.includeInferredTupleElementNames"); + tupleElementNameCasing ??= AnalyzerConfigHelper.TryGetStringValue(analyzerConfigOptions, "stylecop.naming.tupleElementNameCasing") switch + { + "camelCase" => TupleElementNameCase.CamelCase, + "pascalCase" => TupleElementNameCase.PascalCase, + _ => null, + }; + + this.AllowCommonHungarianPrefixes = allowCommonHungarianPrefixes.GetValueOrDefault(true); + this.AllowedHungarianPrefixes = allowedHungarianPrefixes?.ToImmutable() ?? ImmutableArray.Empty; + this.AllowedNamespaceComponents = allowedNamespaceComponents?.ToImmutable() ?? ImmutableArray.Empty; + + this.IncludeInferredTupleElementNames = includeInferredTupleElementNames.GetValueOrDefault(false); + this.TupleElementNameCasing = tupleElementNameCasing.GetValueOrDefault(TupleElementNameCase.PascalCase); } - public bool AllowCommonHungarianPrefixes => - this.allowCommonHungarianPrefixes; + public bool AllowCommonHungarianPrefixes { get; } + + public ImmutableArray AllowedHungarianPrefixes { get; } - public ImmutableArray AllowedHungarianPrefixes + public ImmutableArray AllowedNamespaceComponents { get; } + + public bool IncludeInferredTupleElementNames { get; } + + public TupleElementNameCase TupleElementNameCasing { get; } + + private static bool IsValidHungarianPrefix(string prefix) { - get + // Equivalent to Regex.IsMatch(prefix, "^[a-z]{1,2}$") + for (var i = 0; i < prefix.Length; i++) { - return this.allowedHungarianPrefixes.ToImmutable(); + if (prefix[i] is not (>= 'a' and <= 'z')) + { + return false; + } } + + return prefix.Length is (>= 1 and <= 2); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/OptionSetting.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/OptionSetting.cs index e8e4d3fa0..7e7e4d257 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/OptionSetting.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/OptionSetting.cs @@ -1,5 +1,5 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Settings.ObjectModel { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/OrderingSettings.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/OrderingSettings.cs index a5f24ba91..9a101bb15 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/OrderingSettings.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/OrderingSettings.cs @@ -1,11 +1,14 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Settings.ObjectModel { - using System.Collections.Generic; using System.Collections.Immutable; using LightJson; + using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; internal class OrderingSettings { @@ -20,7 +23,7 @@ internal class OrderingSettings /// /// This is the backing field for the property. /// - private readonly ImmutableArray.Builder elementOrder; + private readonly ImmutableArray elementOrder; /// /// This is the backing field for the property. @@ -42,7 +45,7 @@ internal class OrderingSettings /// protected internal OrderingSettings() { - this.elementOrder = ImmutableArray.CreateBuilder(); + this.elementOrder = ImmutableArray.Empty; this.systemUsingDirectivesFirst = true; this.usingDirectivesPlacement = UsingDirectivesPlacement.InsideNamespace; this.blankLinesBetweenUsingGroups = OptionSetting.Allow; @@ -52,45 +55,71 @@ protected internal OrderingSettings() /// Initializes a new instance of the class. /// /// The JSON object containing the settings. - protected internal OrderingSettings(JsonObject orderingSettingsObject) - : this() + /// The .editorconfig options to use if + /// stylecop.json does not provide values. + protected internal OrderingSettings(JsonObject orderingSettingsObject, AnalyzerConfigOptionsWrapper analyzerConfigOptions) { + ImmutableArray.Builder elementOrder = null; + bool? systemUsingDirectivesFirst = null; + UsingDirectivesPlacement? usingDirectivesPlacement = null; + OptionSetting? blankLinesBetweenUsingGroups = null; + foreach (var kvp in orderingSettingsObject) { switch (kvp.Key) { case "elementOrder": kvp.AssertIsArray(); + elementOrder = ImmutableArray.CreateBuilder(); foreach (var value in kvp.Value.AsJsonArray) { - this.elementOrder.Add(value.ToEnumValue(kvp.Key)); + elementOrder.Add(value.ToEnumValue(kvp.Key)); } break; case "systemUsingDirectivesFirst": - this.systemUsingDirectivesFirst = kvp.ToBooleanValue(); + systemUsingDirectivesFirst = kvp.ToBooleanValue(); break; case "usingDirectivesPlacement": - this.usingDirectivesPlacement = kvp.ToEnumValue(); + usingDirectivesPlacement = kvp.ToEnumValue(); break; case "blankLinesBetweenUsingGroups": - this.blankLinesBetweenUsingGroups = kvp.ToEnumValue(); + blankLinesBetweenUsingGroups = kvp.ToEnumValue(); break; default: break; } } + + systemUsingDirectivesFirst ??= AnalyzerConfigHelper.TryGetBooleanValue(analyzerConfigOptions, "dotnet_sort_system_directives_first"); + usingDirectivesPlacement ??= AnalyzerConfigHelper.TryGetStringValueAndNotification(analyzerConfigOptions, "csharp_using_directive_placement") switch + { + ("inside_namespace", _) => UsingDirectivesPlacement.InsideNamespace, + ("outside_namespace", _) => UsingDirectivesPlacement.OutsideNamespace, + _ => null, + }; + blankLinesBetweenUsingGroups ??= AnalyzerConfigHelper.TryGetBooleanValue(analyzerConfigOptions, "dotnet_separate_import_directive_groups") switch + { + true => OptionSetting.Require, + false => OptionSetting.Allow, + _ => null, + }; + + this.elementOrder = elementOrder?.ToImmutable() ?? ImmutableArray.Empty; + this.systemUsingDirectivesFirst = systemUsingDirectivesFirst.GetValueOrDefault(true); + this.usingDirectivesPlacement = usingDirectivesPlacement.GetValueOrDefault(UsingDirectivesPlacement.InsideNamespace); + this.blankLinesBetweenUsingGroups = blankLinesBetweenUsingGroups.GetValueOrDefault(OptionSetting.Allow); } public ImmutableArray ElementOrder { get { - return this.elementOrder.Count > 0 ? this.elementOrder.ToImmutable() : DefaultElementOrder; + return this.elementOrder.Length > 0 ? this.elementOrder : DefaultElementOrder; } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/OrderingTrait.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/OrderingTrait.cs index a356f5028..b072308e4 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/OrderingTrait.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/OrderingTrait.cs @@ -1,5 +1,5 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Settings.ObjectModel { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/ReadabilitySettings.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/ReadabilitySettings.cs index cd4f7c50b..712a0018e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/ReadabilitySettings.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/ReadabilitySettings.cs @@ -1,9 +1,12 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Settings.ObjectModel { using LightJson; + using StyleCop.Analyzers.Lightup; internal class ReadabilitySettings { @@ -24,21 +27,28 @@ protected internal ReadabilitySettings() /// Initializes a new instance of the class. /// /// The JSON object containing the settings. - protected internal ReadabilitySettings(JsonObject readabilitySettingsObject) - : this() + /// The .editorconfig options to use if + /// stylecop.json does not provide values. + protected internal ReadabilitySettings(JsonObject readabilitySettingsObject, AnalyzerConfigOptionsWrapper analyzerConfigOptions) { + bool? allowBuiltInTypeAliases = null; + foreach (var kvp in readabilitySettingsObject) { switch (kvp.Key) { case "allowBuiltInTypeAliases": - this.allowBuiltInTypeAliases = kvp.ToBooleanValue(); + allowBuiltInTypeAliases = kvp.ToBooleanValue(); break; default: break; } } + + allowBuiltInTypeAliases ??= AnalyzerConfigHelper.TryGetBooleanValue(analyzerConfigOptions, "stylecop.readability.allowBuiltInTypeAliases"); + + this.allowBuiltInTypeAliases = allowBuiltInTypeAliases.GetValueOrDefault(false); } public bool AllowBuiltInTypeAliases => diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/SpacingSettings.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/SpacingSettings.cs index f177f48ed..442106034 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/SpacingSettings.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/SpacingSettings.cs @@ -1,9 +1,12 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Settings.ObjectModel { using LightJson; + using StyleCop.Analyzers.Lightup; internal class SpacingSettings { @@ -18,9 +21,13 @@ protected internal SpacingSettings() /// Initializes a new instance of the class. /// /// The JSON object containing the settings. - protected internal SpacingSettings(JsonObject spacingSettingsObject) - : this() + /// The .editorconfig options to use if + /// stylecop.json does not provide values. + protected internal SpacingSettings(JsonObject spacingSettingsObject, AnalyzerConfigOptionsWrapper analyzerConfigOptions) { + // Currently unused + _ = spacingSettingsObject; + _ = analyzerConfigOptions; } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/StyleCopSettings.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/StyleCopSettings.cs index c6d818fee..4b6d6f150 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/StyleCopSettings.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/StyleCopSettings.cs @@ -1,9 +1,12 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.Settings.ObjectModel { using LightJson; + using StyleCop.Analyzers.Lightup; internal class StyleCopSettings { @@ -63,8 +66,7 @@ protected internal StyleCopSettings() this.documentationRules = new DocumentationSettings(); } - protected internal StyleCopSettings(JsonObject settingsObject) - : this() + protected internal StyleCopSettings(JsonObject settingsObject, AnalyzerConfigOptionsWrapper analyzerConfigOptions) { foreach (var kvp in settingsObject) { @@ -73,48 +75,58 @@ protected internal StyleCopSettings(JsonObject settingsObject) { case "indentation": kvp.AssertIsObject(); - this.indentation = new IndentationSettings(childSettingsObject); + this.indentation = new IndentationSettings(childSettingsObject, analyzerConfigOptions); break; case "spacingRules": kvp.AssertIsObject(); - this.spacingRules = new SpacingSettings(childSettingsObject); + this.spacingRules = new SpacingSettings(childSettingsObject, analyzerConfigOptions); break; case "readabilityRules": kvp.AssertIsObject(); - this.readabilityRules = new ReadabilitySettings(childSettingsObject); + this.readabilityRules = new ReadabilitySettings(childSettingsObject, analyzerConfigOptions); break; case "orderingRules": kvp.AssertIsObject(); - this.orderingRules = new OrderingSettings(childSettingsObject); + this.orderingRules = new OrderingSettings(childSettingsObject, analyzerConfigOptions); break; case "namingRules": kvp.AssertIsObject(); - this.namingRules = new NamingSettings(childSettingsObject); + this.namingRules = new NamingSettings(childSettingsObject, analyzerConfigOptions); break; case "maintainabilityRules": kvp.AssertIsObject(); - this.maintainabilityRules = new MaintainabilitySettings(childSettingsObject); + this.maintainabilityRules = new MaintainabilitySettings(childSettingsObject, analyzerConfigOptions); break; case "layoutRules": kvp.AssertIsObject(); - this.layoutRules = new LayoutSettings(childSettingsObject); + this.layoutRules = new LayoutSettings(childSettingsObject, analyzerConfigOptions); break; case "documentationRules": kvp.AssertIsObject(); - this.documentationRules = new DocumentationSettings(childSettingsObject); + this.documentationRules = new DocumentationSettings(childSettingsObject, analyzerConfigOptions); break; default: break; } } + + this.indentation ??= new IndentationSettings(new JsonObject(), analyzerConfigOptions); + + this.spacingRules ??= new SpacingSettings(new JsonObject(), analyzerConfigOptions); + this.readabilityRules ??= new ReadabilitySettings(new JsonObject(), analyzerConfigOptions); + this.orderingRules ??= new OrderingSettings(new JsonObject(), analyzerConfigOptions); + this.namingRules ??= new NamingSettings(new JsonObject(), analyzerConfigOptions); + this.maintainabilityRules ??= new MaintainabilitySettings(new JsonObject(), analyzerConfigOptions); + this.layoutRules ??= new LayoutSettings(new JsonObject(), analyzerConfigOptions); + this.documentationRules ??= new DocumentationSettings(new JsonObject(), analyzerConfigOptions); } public IndentationSettings Indentation => diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/TopLevelType.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/TopLevelType.cs index c2b9e91f2..439bd50dd 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/TopLevelType.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/TopLevelType.cs @@ -1,32 +1,32 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Settings.ObjectModel { internal enum TopLevelType { /// - /// Classes are considered top-level types + /// Classes are considered top-level types. /// Class, /// - /// Interfaces are considered top-level types + /// Interfaces are considered top-level types. /// Interface, /// - /// Structs are considered top-level types + /// Structs are considered top-level types. /// Struct, /// - /// Delegates are considered top-level types + /// Delegates are considered top-level types. /// Delegate, /// - /// Enums are considered top-level types + /// Enums are considered top-level types. /// Enum, } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/TupleElementNameCase.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/TupleElementNameCase.cs new file mode 100644 index 000000000..180a9e033 --- /dev/null +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/TupleElementNameCase.cs @@ -0,0 +1,18 @@ +// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace StyleCop.Analyzers.Settings.ObjectModel +{ + internal enum TupleElementNameCase + { + /// + /// Tuple element names must use camelCase. + /// + CamelCase = 0, + + /// + /// Tuple element names must use PascalCase. + /// + PascalCase, + } +} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/UsingDirectivesPlacement.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/UsingDirectivesPlacement.cs index 78a7249cf..86dafbb3e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/UsingDirectivesPlacement.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/UsingDirectivesPlacement.cs @@ -1,5 +1,5 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. namespace StyleCop.Analyzers.Settings.ObjectModel { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/SettingsHelper.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/SettingsHelper.cs index 3ecf264aa..9e903af33 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/SettingsHelper.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/SettingsHelper.cs @@ -1,16 +1,22 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers { using System; using System.Collections.Immutable; + using System.Diagnostics; + using System.Diagnostics.CodeAnalysis; using System.IO; using System.Threading; + using LightJson; using LightJson.Serialization; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Text; + using StyleCop.Analyzers.Lightup; using StyleCop.Analyzers.Settings.ObjectModel; /// @@ -21,9 +27,36 @@ internal static class SettingsHelper internal const string SettingsFileName = "stylecop.json"; internal const string AltSettingsFileName = ".stylecop.json"; - private static readonly SourceTextValueProvider SettingsValueProvider = - new SourceTextValueProvider( - text => GetStyleCopSettings(SettingsFileName, text, DeserializationFailureBehavior.ReturnDefaultSettings)); + private static SourceTextValueProvider> JsonValueProvider { get; } = + new SourceTextValueProvider>( + text => ParseJson(text)); + + /// + /// Gets the StyleCop settings from the JSON file, i.e. without adding information frmo the .editorconfig. + /// + /// The context that will be used to determine the StyleCop settings. + /// The cancellation token that the operation will observe. + /// A instance which contains information about the the StyleCop settings file for the given context. + /// Null if no settings file was found. + [SuppressMessage("MicrosoftCodeAnalysisPerformance", "RS1012:Start action has no registered actions", Justification = "This is not a start action")] + internal static SettingsFile GetStyleCopSettingsFile(this CompilationStartAnalysisContext context, CancellationToken cancellationToken) + { + return GetSettingsFile(context.Options, GetJsonValue, cancellationToken); + + Lazy GetJsonValue(SourceText settingsText) + { + if (context.TryGetValue(settingsText, JsonValueProvider, out var settingsFile)) + { + return settingsFile; + } + else + { + // This should never happen, since the Lazy<> instance can always be created, but parse it normally if it does + Debug.Assert(false, "Could not get settings through cache"); + return ParseJson(settingsText); + } + } + } /// /// Gets the StyleCop settings. @@ -33,11 +66,28 @@ internal static class SettingsHelper /// deserializing the settings file, a default settings instance is returned. /// /// The context that will be used to determine the StyleCop settings. + /// Information about the StyleCop settings file. + /// A instance that represents the StyleCop settings for the given context. + internal static StyleCopSettings GetStyleCopSettings(this SyntaxTreeAnalysisContext context, SettingsFile settingsFile) + { + return GetSettings(context.Options, context.Tree, settingsFile, DeserializationFailureBehavior.ReturnDefaultSettings); + } + + /// + /// Gets the StyleCop settings. + /// + /// + /// If a or occurs while + /// deserializing the settings file, a default settings instance is returned. + /// Note that this method does not use the cache. + /// + /// The context that will be used to determine the StyleCop settings. /// The cancellation token that the operation will observe. /// A instance that represents the StyleCop settings for the given context. internal static StyleCopSettings GetStyleCopSettings(this SyntaxTreeAnalysisContext context, CancellationToken cancellationToken) { - return context.Options.GetStyleCopSettings(cancellationToken); + var settingsFile = GetSettingsFile(context.Options, ParseJson, cancellationToken); + return GetSettings(context.Options, context.Tree, settingsFile, DeserializationFailureBehavior.ReturnDefaultSettings); } /// @@ -47,25 +97,59 @@ internal static StyleCopSettings GetStyleCopSettings(this SyntaxTreeAnalysisCont /// If a or occurs while /// deserializing the settings file, a default settings instance is returned. /// + /// The context that will be used to determine the StyleCop settings. + /// The contents of the StyleCop settnigs file. + /// A instance that represents the StyleCop settings for the given context. + internal static StyleCopSettings GetStyleCopSettings(this SyntaxNodeAnalysisContext context, SettingsFile settingsFile) + { + return GetSettings(context.Options, context.Node.SyntaxTree, settingsFile, DeserializationFailureBehavior.ReturnDefaultSettings); + } + + /// + /// Gets the StyleCop settings. + /// + /// + /// If a or occurs while + /// deserializing the settings file, a default settings instance is returned. + /// Note that this method does not use the cache. + /// /// The analyzer options that will be used to determine the StyleCop settings. + /// The syntax tree. /// The cancellation token that the operation will observe. /// A instance that represents the StyleCop settings for the given context. - internal static StyleCopSettings GetStyleCopSettings(this AnalyzerOptions options, CancellationToken cancellationToken) + internal static StyleCopSettings GetStyleCopSettings(this AnalyzerOptions options, SyntaxTree tree, CancellationToken cancellationToken) { - return GetStyleCopSettings(options, DeserializationFailureBehavior.ReturnDefaultSettings, cancellationToken); + var settingsFile = GetSettingsFile(options, ParseJson, cancellationToken); + return GetSettings(options, tree, settingsFile, DeserializationFailureBehavior.ReturnDefaultSettings); } /// /// Gets the StyleCop settings. /// - /// The analyzer options that will be used to determine the StyleCop settings. + /// The context that will be used to determine the StyleCop settings. + /// The syntax tree. /// The behavior of the method when a or /// occurs while deserializing the settings file. /// The cancellation token that the operation will observe. /// A instance that represents the StyleCop settings for the given context. - internal static StyleCopSettings GetStyleCopSettings(this AnalyzerOptions options, DeserializationFailureBehavior failureBehavior, CancellationToken cancellationToken) + internal static StyleCopSettings GetStyleCopSettings(this CompilationAnalysisContext context, SyntaxTree tree, DeserializationFailureBehavior failureBehavior, CancellationToken cancellationToken) { - return GetStyleCopSettings(options != null ? options.AdditionalFiles : ImmutableArray.Create(), failureBehavior, cancellationToken); + var settingsFile = GetSettingsFile(context.Options, GetJsonValue, cancellationToken); + return GetSettings(context.Options, tree, settingsFile, failureBehavior); + + Lazy GetJsonValue(SourceText settingsText) + { + if (context.TryGetValue(settingsText, JsonValueProvider, out var settingsFile)) + { + return settingsFile; + } + else + { + // This should never happen, since the Lazy<> instance can always be created, but parse it normally if it does + Debug.Assert(false, "Could not get settings through cache"); + return ParseJson(settingsText); + } + } } /// @@ -87,81 +171,44 @@ internal static bool IsStyleCopSettingsFile(string path) || string.Equals(fileName, AltSettingsFileName, StringComparison.OrdinalIgnoreCase); } - internal static StyleCopSettings GetStyleCopSettings(this AnalysisContext context, AnalyzerOptions options, CancellationToken cancellationToken) + private static StyleCopSettings GetSettings(AnalyzerOptions options, SyntaxTree tree, SettingsFile settingsFile, DeserializationFailureBehavior failureBehavior) { - return GetStyleCopSettings(context, options, DeserializationFailureBehavior.ReturnDefaultSettings, cancellationToken); - } - - internal static StyleCopSettings GetStyleCopSettings(this AnalysisContext context, AnalyzerOptions options, DeserializationFailureBehavior failureBehavior, CancellationToken cancellationToken) - { - string settingsFilePath; - SourceText text = TryGetStyleCopSettingsText(options, cancellationToken, out settingsFilePath); - if (text == null) + if (settingsFile != null) { - return new StyleCopSettings(); + return CreateSettingsObjectFromFile(options, tree, settingsFile, failureBehavior); } - if (failureBehavior == DeserializationFailureBehavior.ReturnDefaultSettings) + // TODO: Can this really be null? Review when nullable references has been enabled + if (tree != null) { - StyleCopSettings settings; - if (!context.TryGetValue(text, SettingsValueProvider, out settings)) - { - return new StyleCopSettings(); - } - - return settings; + var analyzerConfigOptions = options.AnalyzerConfigOptionsProvider().GetOptions(tree); + return new StyleCopSettings(new JsonObject(), analyzerConfigOptions); } - return GetStyleCopSettings(settingsFilePath, text, failureBehavior); + return new StyleCopSettings(); } - internal static StyleCopSettings GetStyleCopSettings(this CompilationStartAnalysisContext context, AnalyzerOptions options, CancellationToken cancellationToken) + private static StyleCopSettings CreateSettingsObjectFromFile(AnalyzerOptions options, SyntaxTree tree, SettingsFile settingsFile, DeserializationFailureBehavior failureBehavior) { - return GetStyleCopSettings(context, options, DeserializationFailureBehavior.ReturnDefaultSettings, cancellationToken); - } + var analyzerConfigOptions = options.AnalyzerConfigOptionsProvider().GetOptions(tree); -#pragma warning disable RS1012 // Start action has no registered actions. - internal static StyleCopSettings GetStyleCopSettings(this CompilationStartAnalysisContext context, AnalyzerOptions options, DeserializationFailureBehavior failureBehavior, CancellationToken cancellationToken) -#pragma warning restore RS1012 // Start action has no registered actions. - { - string settingsFilePath; - SourceText text = TryGetStyleCopSettingsText(options, cancellationToken, out settingsFilePath); - if (text == null) - { - return new StyleCopSettings(); - } - - if (failureBehavior == DeserializationFailureBehavior.ReturnDefaultSettings) - { - StyleCopSettings settings; - if (!context.TryGetValue(text, SettingsValueProvider, out settings)) - { - return new StyleCopSettings(); - } - - return settings; - } - - return GetStyleCopSettings(settingsFilePath, text, failureBehavior); - } - - private static StyleCopSettings GetStyleCopSettings(string path, SourceText text, DeserializationFailureBehavior failureBehavior) - { try { - var rootValue = JsonReader.Parse(text.ToString()); + // If the file was accessed through the cache, this statement will re-throw any exceptions from when parsing the file + var rootValue = settingsFile.Content.Value; + if (!rootValue.IsJsonObject) { throw new JsonParseException( - $"Settings file at '{path}' was missing or empty.", + $"Settings file at '{settingsFile.FilePath}' was missing or empty.", JsonParseException.ErrorType.InvalidOrUnexpectedCharacter, - default(TextPosition)); + default); } var settingsObject = rootValue.AsJsonObject["settings"]; if (settingsObject.IsJsonObject) { - return new StyleCopSettings(settingsObject.AsJsonObject); + return new StyleCopSettings(settingsObject.AsJsonObject, analyzerConfigOptions); } else if (settingsObject.IsNull) { @@ -182,35 +229,38 @@ private static StyleCopSettings GetStyleCopSettings(string path, SourceText text return new StyleCopSettings(); } - private static SourceText TryGetStyleCopSettingsText(this AnalyzerOptions options, CancellationToken cancellationToken, out string settingsFilePath) + private static SettingsFile GetSettingsFile(AnalyzerOptions options, Func> getJsonValue, CancellationToken cancellationToken) { - foreach (var additionalFile in options.AdditionalFiles) + var additionalFiles = options != null ? options.AdditionalFiles : ImmutableArray.Create(); + foreach (var additionalFile in additionalFiles) { if (IsStyleCopSettingsFile(additionalFile.Path)) { - settingsFilePath = additionalFile.Path; - - return additionalFile.GetText(cancellationToken); + SourceText additionalTextContent = additionalFile.GetText(cancellationToken); + var content = getJsonValue(additionalTextContent); + return new SettingsFile(additionalFile.Path, content); } } - settingsFilePath = null; - return null; } - private static StyleCopSettings GetStyleCopSettings(ImmutableArray additionalFiles, DeserializationFailureBehavior failureBehavior, CancellationToken cancellationToken) + private static Lazy ParseJson(SourceText text) { - foreach (var additionalFile in additionalFiles) + return new Lazy(() => JsonReader.Parse(text.ToString())); + } + + public class SettingsFile + { + public SettingsFile(string filePath, Lazy content) { - if (IsStyleCopSettingsFile(additionalFile.Path)) - { - SourceText additionalTextContent = additionalFile.GetText(cancellationToken); - return GetStyleCopSettings(additionalFile.Path, additionalTextContent, failureBehavior); - } + this.FilePath = filePath; + this.Content = content; } - return new StyleCopSettings(); + public string FilePath { get; } + + public Lazy Content { get; } } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/SettingsResources.Designer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/SettingsResources.Designer.cs deleted file mode 100644 index d75297373..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/SettingsResources.Designer.cs +++ /dev/null @@ -1,73 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace StyleCop.Analyzers.Settings { - using System; - using System.Reflection; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class SettingsResources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal SettingsResources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StyleCop.Analyzers.Settings.SettingsResources", typeof(SettingsResources).GetTypeInfo().Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Add StyleCop settings file to the project. - /// - internal static string SettingsFileCodeFix { - get { - return ResourceManager.GetString("SettingsFileCodeFix", resourceCulture); - } - } - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json index 0d6c10930..8ae727cc3 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json +++ b/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json @@ -1,4 +1,4 @@ -{ +{ "$schema": "http://json-schema.org/draft-04/schema#", "id": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", "title": "StyleCop Analyzers Configuration", @@ -121,12 +121,35 @@ "allowedHungarianPrefixes": { "type": "array", "description": "Allowed Hungarian notation prefixes.", - "default": [ ], + "default": [], "items": { "type": "string", "pattern": "^[a-z]{1,2}$", "uniqueItems": true } + }, + "allowedNamespaceComponents": { + "type": "array", + "description": "Allowed namespace components, such as ones beginning with a lowercase letter.", + "default": [], + "items": { + "type": "string", + "uniqueItems": true + } + }, + "includeInferredTupleElementNames": { + "type": "boolean", + "description": "Specifies whether inferred tuple element names will be analyzed as well.", + "default": false + }, + "tupleElementNameCasing": { + "type": "string", + "description": "Specifies the casing convention used for tuple element names.", + "enum": [ + "camelCase", + "PascalCase" + ], + "default": "PascalCase" } } }, @@ -174,6 +197,11 @@ "type": "boolean", "description": "Specifies if SA1519 will allow consecutive using statements without braces", "default": true + }, + "allowDoWhileOnClosingBrace": { + "type": "boolean", + "description": "Specifies if SA1500 will allow the 'while' expression of a 'do'/'while' loop to be on the same line as the closing brace.", + "default": false } } }, diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1000KeywordsMustBeSpacedCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1000KeywordsMustBeSpacedCorrectly.cs index a7c4d6e8e..cd86a7c12 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1000KeywordsMustBeSpacedCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1000KeywordsMustBeSpacedCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -21,15 +23,16 @@ namespace StyleCop.Analyzers.SpacingRules /// fixed, for, foreach, from, /// group, if, in, into, join, /// let, lock, orderby, out, - /// ref, return, select, stackalloc, - /// switch, throw, using, var, - /// where, while, yield. + /// ref, return, select, switch, + /// throw, using, var, where, + /// while, yield. /// /// The following keywords should not be followed by any space: checked, /// default, sizeof, typeof, unchecked. /// - /// The new keyword should always be followed by a space, unless it is used to create a new - /// array, in which case there should be no space between the new keyword and the opening array bracket. + /// The new and stackalloc keywords should always be followed by a space, + /// except where used to create a new implicitly-typed array, in which case there should be no space between the + /// keyword and the opening array bracket. /// [DiagnosticAnalyzer(LanguageNames.CSharp)] internal class SA1000KeywordsMustBeSpacedCorrectly : DiagnosticAnalyzer @@ -38,10 +41,10 @@ internal class SA1000KeywordsMustBeSpacedCorrectly : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1000"; - private const string Title = "Keywords should be spaced correctly"; - private const string MessageFormat = "The keyword '{0}' should{1} be followed by a space."; - private const string Description = "The spacing around a C# keyword is incorrect."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1000.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1000Title), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(SpacingResources.SA1000MessageFormat), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1000Description), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -84,6 +87,7 @@ private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context) { switch (token.Kind()) { + case SyntaxKindEx.AndKeyword: case SyntaxKind.AwaitKeyword: case SyntaxKind.CaseKeyword: case SyntaxKind.CatchKeyword: @@ -95,14 +99,16 @@ private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context) case SyntaxKind.IfKeyword: case SyntaxKind.InKeyword: case SyntaxKind.IntoKeyword: + case SyntaxKind.IsKeyword: case SyntaxKind.JoinKeyword: case SyntaxKind.LetKeyword: case SyntaxKind.LockKeyword: + case SyntaxKindEx.NotKeyword: + case SyntaxKindEx.OrKeyword: case SyntaxKind.OrderByKeyword: case SyntaxKind.OutKeyword: case SyntaxKind.RefKeyword: case SyntaxKind.SelectKeyword: - case SyntaxKind.StackAllocKeyword: case SyntaxKind.SwitchKeyword: case SyntaxKind.UsingKeyword: case SyntaxKind.WhereKeyword: @@ -113,13 +119,23 @@ private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context) case SyntaxKind.CheckedKeyword: case SyntaxKind.UncheckedKeyword: - if (token.GetNextToken().IsKind(SyntaxKind.OpenBraceToken)) + switch (token.Parent.Kind()) { + case SyntaxKind.CheckedStatement: + case SyntaxKind.UncheckedStatement: + case SyntaxKind.OperatorDeclaration: + case SyntaxKind.ConversionOperatorDeclaration: HandleRequiredSpaceToken(ref context, token); - } - else - { + break; + + case SyntaxKind.CheckedExpression: + case SyntaxKind.UncheckedExpression: HandleDisallowedSpaceToken(ref context, token); + break; + + default: + // So far an unknown case, so we have no opinion yet + break; } break; @@ -141,7 +157,8 @@ private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context) break; case SyntaxKind.NewKeyword: - HandleNewKeywordToken(ref context, token); + case SyntaxKind.StackAllocKeyword: + HandleNewOrStackAllocKeywordToken(ref context, token); break; case SyntaxKind.ReturnKeyword: @@ -267,7 +284,7 @@ private static void HandleDisallowedSpaceToken(ReportDiagnosticCallbac reportDiagnostic(ref context, Diagnostic.Create(Descriptor, token.GetLocation(), TokenSpacingProperties.RemoveFollowing, token.Text, " not")); } - private static void HandleNewKeywordToken(ref SyntaxTreeAnalysisContext context, SyntaxToken token) + private static void HandleNewOrStackAllocKeywordToken(ref SyntaxTreeAnalysisContext context, SyntaxToken token) { if (token.IsMissing) { @@ -279,7 +296,8 @@ private static void HandleNewKeywordToken(ref SyntaxTreeAnalysisContext context, switch (nextToken.Kind()) { case SyntaxKind.OpenBracketToken: - if (token.Parent.IsKind(SyntaxKind.ImplicitArrayCreationExpression)) + if (token.Parent.IsKind(SyntaxKind.ImplicitArrayCreationExpression) + || token.Parent.IsKind(SyntaxKindEx.ImplicitStackAllocArrayCreationExpression)) { // This is handled by SA1026 return; @@ -291,7 +309,8 @@ private static void HandleNewKeywordToken(ref SyntaxTreeAnalysisContext context, case SyntaxKind.OpenParenToken: // Disallowed for new() constraint, but otherwise allowed for tuple types - needSpace = !token.Parent.IsKind(SyntaxKind.ConstructorConstraint); + needSpace = !token.Parent.IsKind(SyntaxKind.ConstructorConstraint) + && !token.Parent.IsKind(SyntaxKindEx.ImplicitObjectCreationExpression); break; default: diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1001CommasMustBeSpacedCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1001CommasMustBeSpacedCorrectly.cs index b26231b1a..eced91ae2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1001CommasMustBeSpacedCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1001CommasMustBeSpacedCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -27,10 +29,10 @@ internal class SA1001CommasMustBeSpacedCorrectly : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1001"; - private const string Title = "Commas should be spaced correctly"; - private const string MessageFormat = "Commas should{0} be {1} by whitespace."; - private const string Description = "The spacing around a comma is incorrect, within a C# code file."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1001.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1001Title), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(SpacingResources.SA1001MessageFormat), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1001Description), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1002SemicolonsMustBeSpacedCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1002SemicolonsMustBeSpacedCorrectly.cs index a24e74d35..f2407ff98 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1002SemicolonsMustBeSpacedCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1002SemicolonsMustBeSpacedCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -26,10 +28,10 @@ internal class SA1002SemicolonsMustBeSpacedCorrectly : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1002"; - private const string Title = "Semicolons should be spaced correctly"; - private const string MessageFormat = "Semicolons should{0} be {1} by a space."; - private const string Description = "The spacing around a semicolon is incorrect, within a C# code file."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1002.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1002Title), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(SpacingResources.SA1002MessageFormat), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1002Description), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1003SymbolsMustBeSpacedCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1003SymbolsMustBeSpacedCorrectly.cs index 1d0e8b2c4..9e0d5316e 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1003SymbolsMustBeSpacedCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1003SymbolsMustBeSpacedCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -10,6 +12,7 @@ namespace StyleCop.Analyzers.SpacingRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; /// /// The spacing around an operator symbol is incorrect, within a C# code file. @@ -57,15 +60,15 @@ internal class SA1003SymbolsMustBeSpacedCorrectly : DiagnosticAnalyzer internal const string RemoveEndOfLineTag = "RemoveEndOfLine"; internal const string RemoveEndOfLineWithTrailingSpaceTag = "RemoveEndOfLineWithTrailingSpace"; - private const string Title = "Symbols should be spaced correctly"; - private const string MessageFormatNotFollowedByComment = "Operator '{0}' should not be followed by a comment."; - private const string MessageFormatPrecededByWhitespace = "Operator '{0}' should be preceded by whitespace."; - private const string MessageFormatNotPrecededByWhitespace = "Operator '{0}' should not be preceded by whitespace."; - private const string MessageFormatFollowedByWhitespace = "Operator '{0}' should be followed by whitespace."; - private const string MessageFormatNotFollowedByWhitespace = "Operator '{0}' should not be followed by whitespace."; - private const string MessageFormatNotAtEndOfLine = "Operator '{0}' should not appear at the end of a line."; - private const string Description = "The spacing around an operator symbol is incorrect, within a C# code file."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1003.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1003Title), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageFormatNotFollowedByComment = new LocalizableResourceString(nameof(SpacingResources.SA1003MessageFormatNotFollowedByComment), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageFormatPrecededByWhitespace = new LocalizableResourceString(nameof(SpacingResources.SA1003MessageFormatPrecededByWhitespace), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageFormatNotPrecededByWhitespace = new LocalizableResourceString(nameof(SpacingResources.SA1003MessageFormatNotPrecededByWhitespace), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageFormatFollowedByWhitespace = new LocalizableResourceString(nameof(SpacingResources.SA1003MessageFormatFollowedByWhitespace), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageFormatNotFollowedByWhitespace = new LocalizableResourceString(nameof(SpacingResources.SA1003MessageFormatNotFollowedByWhitespace), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageFormatNotAtEndOfLine = new LocalizableResourceString(nameof(SpacingResources.SA1003MessageFormatNotAtEndOfLine), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1003Description), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly ImmutableArray BinaryExpressionKinds = ImmutableArray.Create( @@ -312,6 +315,10 @@ private static void HandlePostfixUnaryExpression(SyntaxNodeAnalysisContext conte mustHaveTrailingWhitespace = !(followingToken.Parent is InterpolationSyntax); break; + case SyntaxKind.ColonToken: + mustHaveTrailingWhitespace = !(followingToken.Parent is InterpolationFormatClauseSyntax); + break; + default: mustHaveTrailingWhitespace = true; break; @@ -340,7 +347,8 @@ private static void HandleCastExpression(SyntaxNodeAnalysisContext context) && !(castExpression.Parent is CastExpressionSyntax) && !precedingToken.IsKind(SyntaxKind.OpenParenToken) && !precedingToken.IsKind(SyntaxKind.OpenBracketToken) - && !(precedingToken.IsKind(SyntaxKind.OpenBraceToken) && (precedingToken.Parent is InterpolationSyntax)); + && !(precedingToken.IsKind(SyntaxKind.OpenBraceToken) && (precedingToken.Parent is InterpolationSyntax)) + && !precedingToken.IsKind(SyntaxKindEx.DotDotToken); var tokenString = castExpression.OpenParenToken.ToString() + castExpression.Type.ToString() + castExpression.CloseParenToken.ToString(); CheckToken(context, castExpression.OpenParenToken, mustHaveLeadingWhitespace, false, false, tokenString); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1004DocumentationLinesMustBeginWithSingleSpace.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1004DocumentationLinesMustBeginWithSingleSpace.cs index 58577ca1c..0521e9277 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1004DocumentationLinesMustBeginWithSingleSpace.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1004DocumentationLinesMustBeginWithSingleSpace.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -48,10 +50,10 @@ internal class SA1004DocumentationLinesMustBeginWithSingleSpace : DiagnosticAnal /// analyzer. /// public const string DiagnosticId = "SA1004"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1004.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1004Title), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(SpacingResources.SA1004MessageFormat), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1004Description), SpacingResources.ResourceManager, typeof(SpacingResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1004.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1005SingleLineCommentsMustBeginWithSingleSpace.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1005SingleLineCommentsMustBeginWithSingleSpace.cs index 0d8ad7ea4..6614f74a2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1005SingleLineCommentsMustBeginWithSingleSpace.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1005SingleLineCommentsMustBeginWithSingleSpace.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -54,10 +56,10 @@ internal class SA1005SingleLineCommentsMustBeginWithSingleSpace : DiagnosticAnal /// analyzer. /// public const string DiagnosticId = "SA1005"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1005.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1005Title), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(SpacingResources.SA1005MessageFormat), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1005Description), SpacingResources.ResourceManager, typeof(SpacingResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1005.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1006PreprocessorKeywordsMustNotBePrecededBySpace.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1006PreprocessorKeywordsMustNotBePrecededBySpace.cs index 0bbf68467..8060710d5 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1006PreprocessorKeywordsMustNotBePrecededBySpace.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1006PreprocessorKeywordsMustNotBePrecededBySpace.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -35,10 +37,10 @@ internal class SA1006PreprocessorKeywordsMustNotBePrecededBySpace : DiagnosticAn /// analyzer. /// public const string DiagnosticId = "SA1006"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1006.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1006Title), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(SpacingResources.SA1006MessageFormat), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1006Description), SpacingResources.ResourceManager, typeof(SpacingResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1006.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1007OperatorKeywordMustBeFollowedBySpace.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1007OperatorKeywordMustBeFollowedBySpace.cs index 6b46955ec..ee17d7368 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1007OperatorKeywordMustBeFollowedBySpace.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1007OperatorKeywordMustBeFollowedBySpace.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -30,10 +32,10 @@ internal class SA1007OperatorKeywordMustBeFollowedBySpace : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1007"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1007.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1007Title), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(SpacingResources.SA1007MessageFormat), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1007Description), SpacingResources.ResourceManager, typeof(SpacingResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1007.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1008OpeningParenthesisMustBeSpacedCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1008OpeningParenthesisMustBeSpacedCorrectly.cs index bea696ab2..4f3a67fe2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1008OpeningParenthesisMustBeSpacedCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1008OpeningParenthesisMustBeSpacedCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -32,13 +34,13 @@ internal class SA1008OpeningParenthesisMustBeSpacedCorrectly : DiagnosticAnalyze /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1008"; - private const string Title = "Opening parenthesis should be spaced correctly"; - private const string Description = "An opening parenthesis within a C# statement is not spaced correctly."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1008.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1008Title), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1008Description), SpacingResources.ResourceManager, typeof(SpacingResources)); - private const string MessageNotPreceded = "Opening parenthesis should not be preceded by a space."; - private const string MessagePreceded = "Opening parenthesis should be preceded by a space."; - private const string MessageNotFollowed = "Opening parenthesis should not be followed by a space."; + private static readonly LocalizableString MessageNotPreceded = new LocalizableResourceString(nameof(SpacingResources.SA1008MessageNotPreceded), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessagePreceded = new LocalizableResourceString(nameof(SpacingResources.SA1008MessagePreceded), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageNotFollowed = new LocalizableResourceString(nameof(SpacingResources.SA1008MessageNotFollowed), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly Action SyntaxTreeAction = HandleSyntaxTree; @@ -92,12 +94,6 @@ private static void HandleOpenParenToken(SyntaxTreeAnalysisContext context, Synt return; } - if (token.IsLastInLine()) - { - // ignore open parenthesis when last on line. - return; - } - var prevToken = token.GetPreviousToken(); // Don't check leading spaces when preceded by a keyword that is already handled by SA1000 @@ -146,7 +142,11 @@ private static void HandleOpenParenToken(SyntaxTreeAnalysisContext context, Synt var leadingTriviaList = TriviaHelper.MergeTriviaLists(prevToken.TrailingTrivia, token.LeadingTrivia); var isFirstOnLine = false; - if (prevToken.GetLineSpan().EndLinePosition.Line < token.GetLineSpan().StartLinePosition.Line) + if (prevToken.IsKind(SyntaxKind.None)) + { + isFirstOnLine = true; // This means that it doesn't matter if there are spaces before or not + } + else if (prevToken.GetLineSpan().EndLinePosition.Line < token.GetLineSpan().StartLinePosition.Line) { var done = false; for (var i = leadingTriviaList.Count - 1; !done && (i >= 0); i--) @@ -190,6 +190,20 @@ private static void HandleOpenParenToken(SyntaxTreeAnalysisContext context, Synt haveLeadingSpace = true; break; + case SyntaxKindEx.PositionalPatternClause: + haveLeadingSpace = prevToken.IsKind(SyntaxKind.IsKeyword) + || prevToken.IsKind(SyntaxKindEx.OrKeyword) + || prevToken.IsKind(SyntaxKindEx.AndKeyword) + || prevToken.IsKind(SyntaxKindEx.NotKeyword) + || prevToken.IsKind(SyntaxKind.CommaToken) + || prevToken.IsKind(SyntaxKind.ColonToken); + break; + + case SyntaxKindEx.ParenthesizedPattern: + var partOfCastExpression = prevToken.IsKind(SyntaxKind.CloseParenToken) && prevToken.Parent.IsKind(SyntaxKind.CastExpression); + haveLeadingSpace = !partOfCastExpression; + break; + case SyntaxKind.ArgumentList: case SyntaxKind.AttributeArgumentList: case SyntaxKind.CheckedExpression: @@ -208,7 +222,8 @@ private static void HandleOpenParenToken(SyntaxTreeAnalysisContext context, Synt case SyntaxKind.ParenthesizedExpression: case SyntaxKindEx.TupleExpression: - if (prevToken.Parent.IsKind(SyntaxKind.Interpolation)) + if (prevToken.Parent.IsKind(SyntaxKind.Interpolation) + || token.Parent.Parent.IsKind(SyntaxKindEx.RangeExpression)) { haveLeadingSpace = false; break; @@ -216,7 +231,7 @@ private static void HandleOpenParenToken(SyntaxTreeAnalysisContext context, Synt partOfUnaryExpression = prevToken.Parent is PrefixUnaryExpressionSyntax; startOfIndexer = prevToken.IsKind(SyntaxKind.OpenBracketToken); - var partOfCastExpression = prevToken.IsKind(SyntaxKind.CloseParenToken) && prevToken.Parent.IsKind(SyntaxKind.CastExpression); + partOfCastExpression = prevToken.IsKind(SyntaxKind.CloseParenToken) && prevToken.Parent.IsKind(SyntaxKind.CastExpression); haveLeadingSpace = !partOfUnaryExpression && !startOfIndexer && !partOfCastExpression; break; @@ -226,8 +241,9 @@ private static void HandleOpenParenToken(SyntaxTreeAnalysisContext context, Synt startOfIndexer = prevToken.IsKind(SyntaxKind.OpenBracketToken); var consecutiveCast = prevToken.IsKind(SyntaxKind.CloseParenToken) && prevToken.Parent.IsKind(SyntaxKind.CastExpression); var partOfInterpolation = prevToken.IsKind(SyntaxKind.OpenBraceToken) && prevToken.Parent.IsKind(SyntaxKind.Interpolation); + var partOfRange = prevToken.IsKind(SyntaxKindEx.DotDotToken); - haveLeadingSpace = !partOfUnaryExpression && !startOfIndexer && !consecutiveCast && !partOfInterpolation; + haveLeadingSpace = !partOfUnaryExpression && !startOfIndexer && !consecutiveCast && !partOfInterpolation && !partOfRange; break; case SyntaxKind.ParameterList: @@ -237,10 +253,14 @@ private static void HandleOpenParenToken(SyntaxTreeAnalysisContext context, Synt case SyntaxKindEx.TupleType: // Comma covers tuple types in parameters and nested within other tuple types. + // Equals covers definition of a tuple type alias. // 'out', 'ref', 'in', 'params' parameters are covered by IsKeywordKind. + // Attributes of parameters are covered by checking the previous token's parent. // Return types are handled by a helper. haveLeadingSpace = prevToken.IsKind(SyntaxKind.CommaToken) + || prevToken.IsKind(SyntaxKind.EqualsToken) || SyntaxFacts.IsKeywordKind(prevToken.Kind()) + || prevToken.Parent.IsKind(SyntaxKind.AttributeList) || ((TypeSyntax)token.Parent).GetContainingNotEnclosingType().IsReturnType(); break; } @@ -267,7 +287,7 @@ private static void HandleOpenParenToken(SyntaxTreeAnalysisContext context, Synt if (token.IsFollowedByWhitespace()) { - context.ReportDiagnostic(Diagnostic.Create(DescriptorNotFollowed, token.GetLocation(), TokenSpacingProperties.RemoveFollowing)); + context.ReportDiagnostic(Diagnostic.Create(DescriptorNotFollowed, token.GetLocation(), TokenSpacingProperties.RemoveFollowingPreserveLayout)); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1009ClosingParenthesisMustBeSpacedCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1009ClosingParenthesisMustBeSpacedCorrectly.cs index 881cf0c30..c33850329 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1009ClosingParenthesisMustBeSpacedCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1009ClosingParenthesisMustBeSpacedCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -34,19 +36,30 @@ internal class SA1009ClosingParenthesisMustBeSpacedCorrectly : DiagnosticAnalyze /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1009"; - private const string Title = "Closing parenthesis should be spaced correctly"; - private const string MessageFormat = "Closing parenthesis should{0} be {1} by a space."; - private const string Description = "A closing parenthesis within a C# statement is not spaced correctly."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1009.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1009Title), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1009Description), SpacingResources.ResourceManager, typeof(SpacingResources)); - private static readonly DiagnosticDescriptor Descriptor = - new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + private static readonly LocalizableString MessageNotPreceded = new LocalizableResourceString(nameof(SpacingResources.SA1009MessageNotPreceded), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageNotFollowed = new LocalizableResourceString(nameof(SpacingResources.SA1009MessageNotFollowed), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageFollowed = new LocalizableResourceString(nameof(SpacingResources.SA1009MessageFollowed), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly Action SyntaxTreeAction = HandleSyntaxTree; +#pragma warning disable SA1202 // Elements should be ordered by access + internal static readonly DiagnosticDescriptor DescriptorNotPreceded = + new DiagnosticDescriptor(DiagnosticId, Title, MessageNotPreceded, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + + internal static readonly DiagnosticDescriptor DescriptorNotFollowed = + new DiagnosticDescriptor(DiagnosticId, Title, MessageNotFollowed, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + + internal static readonly DiagnosticDescriptor DescriptorFollowed = + new DiagnosticDescriptor(DiagnosticId, Title, MessageFollowed, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); +#pragma warning restore SA1202 // Elements should be ordered by access + /// public override ImmutableArray SupportedDiagnostics { get; } = - ImmutableArray.Create(Descriptor); + ImmutableArray.Create(DescriptorNotPreceded); /// public override void Initialize(AnalysisContext context) @@ -105,6 +118,8 @@ private static void HandleCloseParenToken(SyntaxTreeAnalysisContext context, Syn case SyntaxKind.SemicolonToken: case SyntaxKind.CommaToken: case SyntaxKind.DoubleQuoteToken: + case SyntaxKind.SingleQuoteToken: + case SyntaxKindEx.DotDotToken: precedesStickyCharacter = true; break; @@ -159,13 +174,16 @@ private static void HandleCloseParenToken(SyntaxTreeAnalysisContext context, Syn bool requireSpace = nextToken.Parent.IsKind(SyntaxKind.ConditionalExpression) || nextToken.Parent.IsKind(SyntaxKind.BaseConstructorInitializer) - || nextToken.Parent.IsKind(SyntaxKind.ThisConstructorInitializer); + || nextToken.Parent.IsKind(SyntaxKind.ThisConstructorInitializer) + || nextToken.Parent.IsKind(SyntaxKind.BaseList); precedesStickyCharacter = !requireSpace; break; case SyntaxKind.PlusPlusToken: case SyntaxKind.MinusMinusToken: - precedesStickyCharacter = true; + precedesStickyCharacter = + !nextToken.Parent.IsKind(SyntaxKind.PreIncrementExpression) + && !nextToken.Parent.IsKind(SyntaxKind.PreDecrementExpression); suppressFollowingSpaceError = false; break; @@ -173,6 +191,10 @@ private static void HandleCloseParenToken(SyntaxTreeAnalysisContext context, Syn precedesStickyCharacter = nextToken.Parent is InterpolationSyntax; break; + case SyntaxKind.ExclamationToken when nextToken.Parent.IsKind(SyntaxKindEx.SuppressNullableWarningExpression): + precedesStickyCharacter = true; + break; + default: precedesStickyCharacter = false; break; @@ -219,7 +241,7 @@ private static void HandleCloseParenToken(SyntaxTreeAnalysisContext context, Syn : TokenSpacingProperties.RemoveImmediatePreceding; } - context.ReportDiagnostic(Diagnostic.Create(Descriptor, token.GetLocation(), properties, " not", "preceded")); + context.ReportDiagnostic(Diagnostic.Create(DescriptorNotPreceded, token.GetLocation(), properties)); } if (!suppressFollowingSpaceError) @@ -228,13 +250,17 @@ private static void HandleCloseParenToken(SyntaxTreeAnalysisContext context, Syn { // Closing parenthesis should{} be {followed} by a space. var properties = TokenSpacingProperties.InsertFollowing; - context.ReportDiagnostic(Diagnostic.Create(Descriptor, token.GetLocation(), properties, string.Empty, "followed")); +#pragma warning disable RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor (https://github.com/dotnet/roslyn-analyzers/issues/4103) + context.ReportDiagnostic(Diagnostic.Create(DescriptorFollowed, token.GetLocation(), properties)); +#pragma warning restore RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor } else if (precedesStickyCharacter && followedBySpace && (!lastInLine || !allowEndOfLine)) { // Closing parenthesis should{ not} be {followed} by a space. var properties = TokenSpacingProperties.RemoveFollowing; - context.ReportDiagnostic(Diagnostic.Create(Descriptor, token.GetLocation(), properties, " not", "followed")); +#pragma warning disable RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor (https://github.com/dotnet/roslyn-analyzers/issues/4103) + context.ReportDiagnostic(Diagnostic.Create(DescriptorNotFollowed, token.GetLocation(), properties)); +#pragma warning restore RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1010OpeningSquareBracketsMustBeSpacedCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1010OpeningSquareBracketsMustBeSpacedCorrectly.cs index 63345bc8d..575e4f159 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1010OpeningSquareBracketsMustBeSpacedCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1010OpeningSquareBracketsMustBeSpacedCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -9,6 +11,7 @@ namespace StyleCop.Analyzers.SpacingRules using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; /// /// An opening square bracket within a C# statement is not spaced correctly. @@ -29,19 +32,26 @@ internal class SA1010OpeningSquareBracketsMustBeSpacedCorrectly : DiagnosticAnal /// analyzer. /// public const string DiagnosticId = "SA1010"; - private const string Title = "Opening square brackets should be spaced correctly"; - private const string MessageFormat = "Opening square brackets should {0} by a space."; - private const string Description = "An opening square bracket within a C# statement is not spaced correctly."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1010.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1010Title), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1010Description), SpacingResources.ResourceManager, typeof(SpacingResources)); - private static readonly DiagnosticDescriptor Descriptor = - new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + private static readonly LocalizableString MessageNotPreceded = new LocalizableResourceString(nameof(SpacingResources.SA1010MessageNotPreceded), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageNotFollowed = new LocalizableResourceString(nameof(SpacingResources.SA1010MessageNotFollowed), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly Action SyntaxTreeAction = HandleSyntaxTree; +#pragma warning disable SA1202 // Elements should be ordered by access + internal static readonly DiagnosticDescriptor DescriptorNotPreceded = + new DiagnosticDescriptor(DiagnosticId, Title, MessageNotPreceded, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + + internal static readonly DiagnosticDescriptor DescriptorNotFollowed = + new DiagnosticDescriptor(DiagnosticId, Title, MessageNotFollowed, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); +#pragma warning restore SA1202 // Elements should be ordered by access + /// public override ImmutableArray SupportedDiagnostics { get; } = - ImmutableArray.Create(Descriptor); + ImmutableArray.Create(DescriptorNotPreceded); /// public override void Initialize(AnalysisContext context) @@ -79,22 +89,32 @@ private static void HandleOpenBracketToken(SyntaxTreeAnalysisContext context, Sy precededBySpace = token.IsPrecededByWhitespace(context.CancellationToken); // ignore if handled by SA1026 - ignorePrecedingSpaceProblem = precededBySpace && token.GetPreviousToken().IsKind(SyntaxKind.NewKeyword); + if (precededBySpace) + { + var previousToken = token.GetPreviousToken(); + if (previousToken.IsKind(SyntaxKind.NewKeyword) || previousToken.IsKind(SyntaxKind.StackAllocKeyword)) + { + ignorePrecedingSpaceProblem = true; + } + } } - bool followedBySpace = token.IsFollowedByWhitespace(); - bool lastInLine = token.IsLastInLine(); - - if (!firstInLine && precededBySpace && !ignorePrecedingSpaceProblem && !IsPartOfIndexInitializer(token)) + if (!firstInLine && precededBySpace && !ignorePrecedingSpaceProblem && + !IsPartOfIndexInitializer(token) && !IsPartOfListPattern(token) && !IsPartOfCollectionExpression(token)) { // Opening square bracket should {not be preceded} by a space. - context.ReportDiagnostic(Diagnostic.Create(Descriptor, token.GetLocation(), TokenSpacingProperties.RemovePreceding, "not be preceded")); + context.ReportDiagnostic(Diagnostic.Create(DescriptorNotPreceded, token.GetLocation(), TokenSpacingProperties.RemovePreceding)); } + bool followedBySpace = token.IsFollowedByWhitespace(); + bool lastInLine = token.IsLastInLine(); + if (!lastInLine && followedBySpace) { // Opening square bracket should {not be followed} by a space. - context.ReportDiagnostic(Diagnostic.Create(Descriptor, token.GetLocation(), TokenSpacingProperties.RemoveFollowing, "not be followed")); +#pragma warning disable RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor (https://github.com/dotnet/roslyn-analyzers/issues/4103) + context.ReportDiagnostic(Diagnostic.Create(DescriptorNotFollowed, token.GetLocation(), TokenSpacingProperties.RemoveFollowing)); +#pragma warning restore RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor } } @@ -103,5 +123,15 @@ private static bool IsPartOfIndexInitializer(SyntaxToken token) return token.Parent.IsKind(SyntaxKind.BracketedArgumentList) && token.Parent.Parent.IsKind(SyntaxKind.ImplicitElementAccess); } + + private static bool IsPartOfListPattern(SyntaxToken token) + { + return token.Parent.IsKind(SyntaxKindEx.ListPattern); + } + + private static bool IsPartOfCollectionExpression(SyntaxToken token) + { + return token.Parent.IsKind(SyntaxKindEx.CollectionExpression); + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1011ClosingSquareBracketsMustBeSpacedCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1011ClosingSquareBracketsMustBeSpacedCorrectly.cs index 3e830f8aa..f942f5a6c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1011ClosingSquareBracketsMustBeSpacedCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1011ClosingSquareBracketsMustBeSpacedCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -10,6 +12,7 @@ namespace StyleCop.Analyzers.SpacingRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; /// /// A closing square bracket within a C# statement is not spaced correctly. @@ -33,10 +36,10 @@ internal class SA1011ClosingSquareBracketsMustBeSpacedCorrectly : DiagnosticAnal /// analyzer. /// public const string DiagnosticId = "SA1011"; - private const string Title = "Closing square brackets should be spaced correctly"; - private const string MessageFormat = "Closing square bracket should{0} be {1} by a space."; - private const string Description = "A closing square bracket within a C# statement is not spaced correctly."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1011.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1011Title), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(SpacingResources.SA1011MessageFormat), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1011Description), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -104,20 +107,28 @@ private static void HandleCloseBracketToken(SyntaxTreeAnalysisContext context, S case SyntaxKind.OpenBracketToken: case SyntaxKind.CloseParenToken: case SyntaxKind.MinusGreaterThanToken: + case SyntaxKindEx.DotDotToken: precedesSpecialCharacter = true; break; + + case SyntaxKind.ExclamationToken: case SyntaxKind.PlusPlusToken: case SyntaxKind.MinusMinusToken: precedesSpecialCharacter = true; suppressFollowingSpaceError = false; break; + case SyntaxKind.LessThanToken: + precedesSpecialCharacter = token.Parent.IsKind(SyntaxKindEx.FunctionPointerUnmanagedCallingConventionList); + suppressFollowingSpaceError = false; + break; + case SyntaxKind.GreaterThanToken: precedesSpecialCharacter = nextToken.Parent.IsKind(SyntaxKind.TypeArgumentList); break; case SyntaxKind.QuestionToken: - precedesSpecialCharacter = nextToken.Parent.IsKind(SyntaxKind.ConditionalAccessExpression); + precedesSpecialCharacter = nextToken.Parent.IsKind(SyntaxKind.ConditionalAccessExpression) || nextToken.Parent.IsKind(SyntaxKind.NullableType); break; case SyntaxKind.CloseBraceToken: @@ -125,7 +136,9 @@ private static void HandleCloseBracketToken(SyntaxTreeAnalysisContext context, S break; case SyntaxKind.ColonToken: - precedesSpecialCharacter = nextToken.Parent.IsKind(SyntaxKind.InterpolationFormatClause); + precedesSpecialCharacter = + nextToken.Parent.IsKind(SyntaxKind.InterpolationFormatClause) || + nextToken.Parent.IsKind(SyntaxKindEx.CasePatternSwitchLabel); suppressFollowingSpaceError = false; break; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1012OpeningBracesMustBeSpacedCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1012OpeningBracesMustBeSpacedCorrectly.cs index e0aa40a2a..fee245d20 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1012OpeningBracesMustBeSpacedCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1012OpeningBracesMustBeSpacedCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -10,6 +12,7 @@ namespace StyleCop.Analyzers.SpacingRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; /// /// An opening brace within a C# element is not spaced correctly. @@ -32,10 +35,10 @@ internal class SA1012OpeningBracesMustBeSpacedCorrectly : DiagnosticAnalyzer /// analyzer. /// public const string DiagnosticId = "SA1012"; - private const string Title = "Opening braces should be spaced correctly"; - private const string MessageFormat = "Opening brace should{0} be {1} by a space."; - private const string Description = "An opening brace within a C# element is not spaced correctly."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1012.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1012Title), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(SpacingResources.SA1012MessageFormat), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1012Description), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -88,13 +91,30 @@ private static void HandleOpenBraceToken(SyntaxTreeAnalysisContext context, Synt return; } + bool expectPrecedingSpace = true; + if (token.Parent.IsKind(SyntaxKindEx.PropertyPatternClause)) + { + var prevToken = token.GetPreviousToken(); + if (prevToken is { RawKind: (int)SyntaxKind.OpenParenToken, Parent: { RawKind: (int)SyntaxKindEx.PositionalPatternClause } }) + { + // value is ({ P: 0 }, { P: 0 }) + expectPrecedingSpace = false; + } + else if (prevToken is { RawKind: (int)SyntaxKind.OpenBracketToken, Parent: { RawKind: (int)SyntaxKindEx.ListPattern } }) + { + // value is [{ P: 0 }, { P: 0 }] + expectPrecedingSpace = false; + } + } + bool precededBySpace = token.IsFirstInLine() || token.IsPrecededByWhitespace(context.CancellationToken); - if (!precededBySpace) + if (precededBySpace != expectPrecedingSpace) { // Opening brace should{} be {preceded} by a space. - var properties = TokenSpacingProperties.InsertPreceding; - context.ReportDiagnostic(Diagnostic.Create(Descriptor, token.GetLocation(), properties, string.Empty, "preceded")); + // Opening brace should{ not} be {preceded} by a space. + var properties = expectPrecedingSpace ? TokenSpacingProperties.InsertPreceding : TokenSpacingProperties.RemovePrecedingPreserveLayout; + context.ReportDiagnostic(Diagnostic.Create(Descriptor, token.GetLocation(), properties, expectPrecedingSpace ? string.Empty : " not", "preceded")); } if (!token.IsLastInLine() && !followedBySpace) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1013ClosingBracesMustBeSpacedCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1013ClosingBracesMustBeSpacedCorrectly.cs index 304cb025f..b9a741487 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1013ClosingBracesMustBeSpacedCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1013ClosingBracesMustBeSpacedCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -10,6 +12,7 @@ namespace StyleCop.Analyzers.SpacingRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; /// /// A closing brace within a C# element is not spaced correctly. @@ -31,10 +34,10 @@ internal class SA1013ClosingBracesMustBeSpacedCorrectly : DiagnosticAnalyzer /// analyzer. /// public const string DiagnosticId = "SA1013"; - private const string Title = "Closing braces should be spaced correctly"; - private const string MessageFormat = "Closing brace should{0} be {1} by a space."; - private const string Description = "A closing brace within a C# element is not spaced correctly."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1013.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1013Title), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(SpacingResources.SA1013MessageFormat), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1013Description), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -100,7 +103,10 @@ private static void HandleCloseBraceToken(SyntaxTreeAnalysisContext context, Syn || nextToken.IsKind(SyntaxKind.SemicolonToken) || nextToken.IsKind(SyntaxKind.DotToken) || (nextToken.IsKind(SyntaxKind.QuestionToken) && nextToken.GetNextToken(includeZeroWidth: true).IsKind(SyntaxKind.DotToken)) - || nextToken.IsKind(SyntaxKind.CloseBracketToken); + || nextToken.IsKind(SyntaxKind.CloseBracketToken) + || (nextToken.IsKind(SyntaxKind.ColonToken) && nextToken.Parent.IsKind(SyntaxKindEx.CasePatternSwitchLabel)) + || (nextToken.IsKind(SyntaxKind.ExclamationToken) && nextToken.Parent.IsKind(SyntaxKindEx.SuppressNullableWarningExpression)) + || (nextToken.IsKind(SyntaxKind.CloseBraceToken) && nextToken.Parent.IsKind(SyntaxKind.Interpolation)); } else { diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1014OpeningGenericBracketsMustBeSpacedCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1014OpeningGenericBracketsMustBeSpacedCorrectly.cs index ca2e3e08f..575c422f9 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1014OpeningGenericBracketsMustBeSpacedCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1014OpeningGenericBracketsMustBeSpacedCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -27,10 +29,10 @@ internal class SA1014OpeningGenericBracketsMustBeSpacedCorrectly : DiagnosticAna /// analyzer. /// public const string DiagnosticId = "SA1014"; - private const string Title = "Opening generic brackets should be spaced correctly"; - private const string MessageFormat = "Opening generic brackets should not be {0} by a space."; - private const string Description = "An opening generic bracket within a C# element is not spaced correctly."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1014.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1014Title), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(SpacingResources.SA1014MessageFormat), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1014Description), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1015ClosingGenericBracketsMustBeSpacedCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1015ClosingGenericBracketsMustBeSpacedCorrectly.cs index bdbc355f2..7b5642f12 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1015ClosingGenericBracketsMustBeSpacedCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1015ClosingGenericBracketsMustBeSpacedCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -30,19 +32,30 @@ internal class SA1015ClosingGenericBracketsMustBeSpacedCorrectly : DiagnosticAna /// analyzer. /// public const string DiagnosticId = "SA1015"; - private const string Title = "Closing generic brackets should be spaced correctly"; - private const string MessageFormat = "Closing generic bracket should{0} be {1} by a space."; - private const string Description = "A closing generic bracket within a C# element is not spaced correctly."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1015.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1015Title), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1015Description), SpacingResources.ResourceManager, typeof(SpacingResources)); - private static readonly DiagnosticDescriptor Descriptor = - new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + private static readonly LocalizableString MessageNotPreceded = new LocalizableResourceString(nameof(SpacingResources.SA1015MessageNotPreceded), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageNotFollowed = new LocalizableResourceString(nameof(SpacingResources.SA1015MessageNotFollowed), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageFollowed = new LocalizableResourceString(nameof(SpacingResources.SA1015MessageFollowed), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly Action SyntaxTreeAction = HandleSyntaxTree; +#pragma warning disable SA1202 // Elements should be ordered by access + internal static readonly DiagnosticDescriptor DescriptorNotPreceded = + new DiagnosticDescriptor(DiagnosticId, Title, MessageNotPreceded, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + + internal static readonly DiagnosticDescriptor DescriptorNotFollowed = + new DiagnosticDescriptor(DiagnosticId, Title, MessageNotFollowed, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + + internal static readonly DiagnosticDescriptor DescriptorFollowed = + new DiagnosticDescriptor(DiagnosticId, Title, MessageFollowed, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); +#pragma warning restore SA1202 // Elements should be ordered by access + /// public override ImmutableArray SupportedDiagnostics { get; } = - ImmutableArray.Create(Descriptor); + ImmutableArray.Create(DescriptorNotPreceded); /// public override void Initialize(AnalysisContext context) @@ -95,7 +108,6 @@ private static void HandleGreaterThanToken(SyntaxTreeAnalysisContext context, Sy SyntaxToken nextToken = token.GetNextToken(); switch (nextToken.Kind()) { - case SyntaxKind.OpenParenToken: // DotToken isn't listed above, but it's required for reasonable member access formatting case SyntaxKind.DotToken: // CommaToken isn't listed above, but it's required for reasonable nested generic type arguments formatting @@ -109,17 +121,36 @@ private static void HandleGreaterThanToken(SyntaxTreeAnalysisContext context, Sy allowTrailingSpace = false; break; + case SyntaxKind.OpenParenToken: + AnalyzeWithTrailingOpenParen(nextToken, out allowTrailingNoSpace, out allowTrailingSpace); + break; + case SyntaxKind.CloseParenToken: case SyntaxKind.GreaterThanToken: allowTrailingNoSpace = true; allowTrailingSpace = true; break; + case SyntaxKind.AsteriskToken: + allowTrailingNoSpace = nextToken.Parent.IsKind(SyntaxKind.PointerType); + allowTrailingSpace = true; + break; + case SyntaxKind.QuestionToken: allowTrailingNoSpace = nextToken.Parent.IsKind(SyntaxKind.NullableType); allowTrailingSpace = true; break; + // values[x as T] + // ^^ + case SyntaxKind.CloseBracketToken when nextToken.Parent.IsKind(SyntaxKind.BracketedArgumentList): + // [MyAttribute] + // ^^ + case SyntaxKind.CloseBracketToken when nextToken.Parent.IsKind(SyntaxKind.AttributeList): + allowTrailingNoSpace = true; + allowTrailingSpace = false; + break; + default: allowTrailingNoSpace = false; allowTrailingSpace = true; @@ -136,7 +167,7 @@ private static void HandleGreaterThanToken(SyntaxTreeAnalysisContext context, Sy { // Closing generic bracket should{ not} be {preceded} by a space. var properties = TokenSpacingProperties.RemovePreceding; - context.ReportDiagnostic(Diagnostic.Create(Descriptor, token.GetLocation(), properties, " not", "preceded")); + context.ReportDiagnostic(Diagnostic.Create(DescriptorNotPreceded, token.GetLocation(), properties)); } if (!lastInLine) @@ -145,15 +176,47 @@ private static void HandleGreaterThanToken(SyntaxTreeAnalysisContext context, Sy { // Closing generic bracket should{} be {followed} by a space. var properties = TokenSpacingProperties.InsertFollowing; - context.ReportDiagnostic(Diagnostic.Create(Descriptor, token.GetLocation(), properties, string.Empty, "followed")); +#pragma warning disable RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor (https://github.com/dotnet/roslyn-analyzers/issues/4103) + context.ReportDiagnostic(Diagnostic.Create(DescriptorFollowed, token.GetLocation(), properties)); +#pragma warning restore RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor } else if (!allowTrailingSpace && followedBySpace) { // Closing generic bracket should{ not} be {followed} by a space. var properties = TokenSpacingProperties.RemoveFollowing; - context.ReportDiagnostic(Diagnostic.Create(Descriptor, token.GetLocation(), properties, " not", "followed")); +#pragma warning disable RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor (https://github.com/dotnet/roslyn-analyzers/issues/4103) + context.ReportDiagnostic(Diagnostic.Create(DescriptorNotFollowed, token.GetLocation(), properties)); +#pragma warning restore RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor } } } + + private static void AnalyzeWithTrailingOpenParen( + SyntaxToken nextToken, + out bool allowTrailingNoSpace, + out bool allowTrailingSpace) + { + switch (nextToken.Parent.Kind()) + { + // List (int x) => new List { x } + // ^ ^ + case SyntaxKind.ParameterList when nextToken.Parent.Parent.IsKind(SyntaxKind.ParenthesizedLambdaExpression): + allowTrailingNoSpace = false; + allowTrailingSpace = true; + break; + + // NOTE: Intentionally keeping redundant cases here as documentation of what is known to occur + // M() + // ^^ + case SyntaxKind.ArgumentList: + // void M(T x) { } + // ^^ + case SyntaxKind.ParameterList when nextToken.Parent.Parent.IsKind(SyntaxKind.MethodDeclaration): + default: + allowTrailingNoSpace = true; + allowTrailingSpace = false; + break; + } + } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1016OpeningAttributeBracketsMustBeSpacedCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1016OpeningAttributeBracketsMustBeSpacedCorrectly.cs index 6c5e3bfbe..745ac68d2 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1016OpeningAttributeBracketsMustBeSpacedCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1016OpeningAttributeBracketsMustBeSpacedCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -28,10 +30,10 @@ internal class SA1016OpeningAttributeBracketsMustBeSpacedCorrectly : DiagnosticA /// analyzer. /// public const string DiagnosticId = "SA1016"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1016.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1016Title), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(SpacingResources.SA1016MessageFormat), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1016Description), SpacingResources.ResourceManager, typeof(SpacingResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1016.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1017ClosingAttributeBracketsMustBeSpacedCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1017ClosingAttributeBracketsMustBeSpacedCorrectly.cs index 187a2a932..6ff58ad5b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1017ClosingAttributeBracketsMustBeSpacedCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1017ClosingAttributeBracketsMustBeSpacedCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -27,10 +29,10 @@ internal class SA1017ClosingAttributeBracketsMustBeSpacedCorrectly : DiagnosticA /// analyzer. /// public const string DiagnosticId = "SA1017"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1017.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1017Title), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(SpacingResources.SA1017MessageFormat), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1017Description), SpacingResources.ResourceManager, typeof(SpacingResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1017.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1018NullableTypeSymbolsMustNotBePrecededBySpace.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1018NullableTypeSymbolsMustNotBePrecededBySpace.cs index 0fa86c8a5..dfdf3b37b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1018NullableTypeSymbolsMustNotBePrecededBySpace.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1018NullableTypeSymbolsMustNotBePrecededBySpace.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -28,10 +30,10 @@ internal class SA1018NullableTypeSymbolsMustNotBePrecededBySpace : DiagnosticAna /// analyzer. /// public const string DiagnosticId = "SA1018"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1018.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1018Title), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(SpacingResources.SA1018MessageFormat), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1018Description), SpacingResources.ResourceManager, typeof(SpacingResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1018.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1019MemberAccessSymbolsMustBeSpacedCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1019MemberAccessSymbolsMustBeSpacedCorrectly.cs index 59f4ec891..b6c877dfe 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1019MemberAccessSymbolsMustBeSpacedCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1019MemberAccessSymbolsMustBeSpacedCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -25,19 +27,26 @@ internal class SA1019MemberAccessSymbolsMustBeSpacedCorrectly : DiagnosticAnalyz /// analyzer. /// public const string DiagnosticId = "SA1019"; - private const string Title = "Member access symbols should be spaced correctly"; - private const string MessageFormat = "Member access symbol '{0}' should not be {1} by a space."; - private const string Description = "The spacing around a member access symbol is incorrect, within a C# code file."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1019.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1019Title), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1019Description), SpacingResources.ResourceManager, typeof(SpacingResources)); - private static readonly DiagnosticDescriptor Descriptor = - new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + private static readonly LocalizableString MessageNotPreceded = new LocalizableResourceString(nameof(SpacingResources.SA1019MessageNotPreceded), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageNotFollowed = new LocalizableResourceString(nameof(SpacingResources.SA1019MessageNotFollowed), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly Action SyntaxTreeAction = HandleSyntaxTree; +#pragma warning disable SA1202 // Elements should be ordered by access + internal static readonly DiagnosticDescriptor DescriptorNotPreceded = + new DiagnosticDescriptor(DiagnosticId, Title, MessageNotPreceded, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + + internal static readonly DiagnosticDescriptor DescriptorNotFollowed = + new DiagnosticDescriptor(DiagnosticId, Title, MessageNotFollowed, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); +#pragma warning restore SA1202 // Elements should be ordered by access + /// public override ImmutableArray SupportedDiagnostics { get; } = - ImmutableArray.Create(Descriptor); + ImmutableArray.Create(DescriptorNotPreceded); /// public override void Initialize(AnalysisContext context) @@ -109,14 +118,16 @@ private static void HandleMemberAccessSymbol(SyntaxTreeAnalysisContext context, { // Member access symbol '{.}' should not be {preceded} by a space. var properties = TokenSpacingProperties.RemovePreceding; - context.ReportDiagnostic(Diagnostic.Create(Descriptor, token.GetLocation(), properties, token.Text, "preceded")); + context.ReportDiagnostic(Diagnostic.Create(DescriptorNotPreceded, token.GetLocation(), properties, token.Text)); } if (followedBySpace) { // Member access symbol '{.}' should not be {followed} by a space. var properties = TokenSpacingProperties.RemoveFollowing; - context.ReportDiagnostic(Diagnostic.Create(Descriptor, token.GetLocation(), properties, token.Text, "followed")); +#pragma warning disable RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor (https://github.com/dotnet/roslyn-analyzers/issues/4103) + context.ReportDiagnostic(Diagnostic.Create(DescriptorNotFollowed, token.GetLocation(), properties, token.Text)); +#pragma warning restore RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1020IncrementDecrementSymbolsMustBeSpacedCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1020IncrementDecrementSymbolsMustBeSpacedCorrectly.cs index 2b8c7939f..d263b2285 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1020IncrementDecrementSymbolsMustBeSpacedCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1020IncrementDecrementSymbolsMustBeSpacedCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -27,10 +29,10 @@ internal class SA1020IncrementDecrementSymbolsMustBeSpacedCorrectly : Diagnostic /// analyzer. /// public const string DiagnosticId = "SA1020"; - private const string Title = "Increment decrement symbols should be spaced correctly"; - private const string MessageFormat = "{0} symbol '{1}' should not be {2} by a space."; - private const string Description = "An increment or decrement symbol within a C# element is not spaced correctly."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1020.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1020Title), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(SpacingResources.SA1020MessageFormat), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1020Description), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1021NegativeSignsMustBeSpacedCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1021NegativeSignsMustBeSpacedCorrectly.cs index b6538ada5..74827bc03 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1021NegativeSignsMustBeSpacedCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1021NegativeSignsMustBeSpacedCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -30,10 +32,10 @@ internal class SA1021NegativeSignsMustBeSpacedCorrectly : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1021"; - private const string Title = "Negative signs should be spaced correctly"; - private const string MessageFormat = "Negative sign should{0} be {1} by a space."; - private const string Description = "A negative sign within a C# element is not spaced correctly."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1021.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1021Title), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(SpacingResources.SA1021MessageFormat), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1021Description), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1022PositiveSignsMustBeSpacedCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1022PositiveSignsMustBeSpacedCorrectly.cs index 253bc860c..8f8afe435 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1022PositiveSignsMustBeSpacedCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1022PositiveSignsMustBeSpacedCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -30,10 +32,10 @@ internal class SA1022PositiveSignsMustBeSpacedCorrectly : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1022"; - private const string Title = "Positive signs should be spaced correctly"; - private const string MessageFormat = "Positive sign should{0} be {1} by a space."; - private const string Description = "A positive sign within a C# element is not spaced correctly."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1022.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1022Title), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(SpacingResources.SA1022MessageFormat), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1022Description), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1023DereferenceAndAccessOfSymbolsMustBeSpacedCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1023DereferenceAndAccessOfSymbolsMustBeSpacedCorrectly.cs index 370bc79f3..8855745bd 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1023DereferenceAndAccessOfSymbolsMustBeSpacedCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1023DereferenceAndAccessOfSymbolsMustBeSpacedCorrectly.cs @@ -1,15 +1,17 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { using System; - using System.Collections.Generic; using System.Collections.Immutable; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; /// /// A dereference symbol or an access-of symbol within a C# element is not spaced correctly. @@ -46,19 +48,38 @@ internal class SA1023DereferenceAndAccessOfSymbolsMustBeSpacedCorrectly : Diagno /// analyzer. /// public const string DiagnosticId = "SA1023"; - private const string Title = "Dereference and access of symbols should be spaced correctly"; - private const string MessageFormat = "Dereference symbol '*' should {0}."; - private const string Description = "A dereference symbol or an access-of symbol within a C# element is not spaced correctly."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1023.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1023Title), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1023Description), SpacingResources.ResourceManager, typeof(SpacingResources)); - private static readonly DiagnosticDescriptor Descriptor = - new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + private static readonly LocalizableString MessageNotPreceded = new LocalizableResourceString(nameof(SpacingResources.SA1023MessageNotPreceded), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageNotFollowed = new LocalizableResourceString(nameof(SpacingResources.SA1023MessageNotFollowed), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageFollowed = new LocalizableResourceString(nameof(SpacingResources.SA1023MessageFollowed), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageNotAtBeginningOfLine = new LocalizableResourceString(nameof(SpacingResources.SA1023MessageNotAtBeginningOfLine), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageNotAtEndOfLine = new LocalizableResourceString(nameof(SpacingResources.SA1023MessageNotAtEndOfLine), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly Action SyntaxTreeAction = HandleSyntaxTree; +#pragma warning disable SA1202 // Elements should be ordered by access + internal static readonly DiagnosticDescriptor DescriptorNotPreceded = + new DiagnosticDescriptor(DiagnosticId, Title, MessageNotPreceded, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + + internal static readonly DiagnosticDescriptor DescriptorNotFollowed = + new DiagnosticDescriptor(DiagnosticId, Title, MessageNotFollowed, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + + internal static readonly DiagnosticDescriptor DescriptorFollowed = + new DiagnosticDescriptor(DiagnosticId, Title, MessageFollowed, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + + internal static readonly DiagnosticDescriptor DescriptorNotAtBeginningOfLine = + new DiagnosticDescriptor(DiagnosticId, Title, MessageNotAtBeginningOfLine, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + + internal static readonly DiagnosticDescriptor DescriptorNotAtEndOfLine = + new DiagnosticDescriptor(DiagnosticId, Title, MessageNotAtEndOfLine, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); +#pragma warning restore SA1202 // Elements should be ordered by access + /// public override ImmutableArray SupportedDiagnostics { get; } = - ImmutableArray.Create(Descriptor); + ImmutableArray.Create(DescriptorNotPreceded); /// public override void Initialize(AnalysisContext context) @@ -94,11 +115,37 @@ private static void HandleAsteriskToken(SyntaxTreeAnalysisContext context, Synta bool allowTrailingSpace; switch (token.Parent.Kind()) { + case SyntaxKindEx.FunctionPointerType: + allowAtLineStart = true; + allowAtLineEnd = true; + allowPrecedingSpace = false; + var nextToken = token.GetNextToken(); + switch (nextToken.Kind()) + { + case SyntaxKindEx.ManagedKeyword: + case SyntaxKindEx.UnmanagedKeyword: + allowTrailingSpace = true; + break; + + default: + allowTrailingSpace = false; + break; + } + + break; + + case SyntaxKind.PointerType when token.Parent.Parent.IsKind(SyntaxKindEx.FunctionPointerParameter): + allowAtLineStart = true; + allowAtLineEnd = true; + allowPrecedingSpace = false; + allowTrailingSpace = false; + break; + case SyntaxKind.PointerType: allowAtLineStart = false; allowAtLineEnd = true; allowPrecedingSpace = false; - var nextToken = token.GetNextToken(); + nextToken = token.GetNextToken(); switch (nextToken.Kind()) { case SyntaxKind.OpenBracketToken: @@ -147,33 +194,45 @@ private static void HandleAsteriskToken(SyntaxTreeAnalysisContext context, Synta { // Dereference symbol '*' should {not appear at the beginning of a line}. var properties = TokenSpacingProperties.RemovePreceding; - context.ReportDiagnostic(Diagnostic.Create(Descriptor, token.GetLocation(), properties, "not appear at the beginning of a line")); +#pragma warning disable RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor (https://github.com/dotnet/roslyn-analyzers/issues/4103) + context.ReportDiagnostic(Diagnostic.Create(DescriptorNotAtBeginningOfLine, token.GetLocation(), properties)); +#pragma warning restore RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor + } + else if (allowAtLineStart && firstInLine) + { + // The case below should not trigger } else if (!allowPrecedingSpace && precededBySpace) { // Dereference symbol '*' should {not be preceded by a space}. var properties = TokenSpacingProperties.RemovePreceding; - context.ReportDiagnostic(Diagnostic.Create(Descriptor, token.GetLocation(), properties, "not be preceded by a space")); + context.ReportDiagnostic(Diagnostic.Create(DescriptorNotPreceded, token.GetLocation(), properties)); } if (!allowAtLineEnd && lastInLine) { // Dereference symbol '*' should {not appear at the end of a line}. var properties = TokenSpacingProperties.RemoveFollowing; - context.ReportDiagnostic(Diagnostic.Create(Descriptor, token.GetLocation(), properties, "not appear at the end of a line")); +#pragma warning disable RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor (https://github.com/dotnet/roslyn-analyzers/issues/4103) + context.ReportDiagnostic(Diagnostic.Create(DescriptorNotAtEndOfLine, token.GetLocation(), properties)); +#pragma warning restore RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor } else if (!allowTrailingSpace && followedBySpace) { // Dereference symbol '*' should {not be followed by a space}. var properties = TokenSpacingProperties.RemoveFollowing; - context.ReportDiagnostic(Diagnostic.Create(Descriptor, token.GetLocation(), properties, "not be followed by a space")); +#pragma warning disable RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor (https://github.com/dotnet/roslyn-analyzers/issues/4103) + context.ReportDiagnostic(Diagnostic.Create(DescriptorNotFollowed, token.GetLocation(), properties)); +#pragma warning restore RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor } if (!followedBySpace && allowTrailingSpace) { // Dereference symbol '*' should {be followed by a space}. var properties = TokenSpacingProperties.InsertFollowing; - context.ReportDiagnostic(Diagnostic.Create(Descriptor, token.GetLocation(), properties, "be followed by a space")); +#pragma warning disable RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor (https://github.com/dotnet/roslyn-analyzers/issues/4103) + context.ReportDiagnostic(Diagnostic.Create(DescriptorFollowed, token.GetLocation(), properties)); +#pragma warning restore RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1024ColonsMustBeSpacedCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1024ColonsMustBeSpacedCorrectly.cs index 3a867f3e4..fb200343c 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1024ColonsMustBeSpacedCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1024ColonsMustBeSpacedCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -63,19 +65,31 @@ internal class SA1024ColonsMustBeSpacedCorrectly : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1024"; - private const string Title = "Colons Should Be Spaced Correctly"; - private const string MessageFormat = "Colon should{0} be {1}{2} by a space."; - private const string Description = "A colon within a C# element is not spaced correctly."; private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1024.md"; + private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1024Title), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(SpacingResources.SA1024MessageNotPreceded), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1024Description), SpacingResources.ResourceManager, typeof(SpacingResources)); - private static readonly DiagnosticDescriptor Descriptor = - new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + private static readonly LocalizableString MessageNotPreceded = new LocalizableResourceString(nameof(SpacingResources.SA1024MessageNotPreceded), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessagePreceded = new LocalizableResourceString(nameof(SpacingResources.SA1024MessagePreceded), SpacingResources.ResourceManager, typeof(SpacingResources)); + private static readonly LocalizableString MessageFollowed = new LocalizableResourceString(nameof(SpacingResources.SA1024MessageFollowed), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly Action SyntaxTreeAction = HandleSyntaxTree; +#pragma warning disable SA1202 // Elements should be ordered by access + internal static readonly DiagnosticDescriptor DescriptorNotPreceded = + new DiagnosticDescriptor(DiagnosticId, Title, MessageNotPreceded, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + + internal static readonly DiagnosticDescriptor DescriptorPreceded = + new DiagnosticDescriptor(DiagnosticId, Title, MessagePreceded, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + + internal static readonly DiagnosticDescriptor DescriptorFollowed = + new DiagnosticDescriptor(DiagnosticId, Title, MessageFollowed, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); +#pragma warning restore SA1202 // Elements should be ordered by access + /// public override ImmutableArray SupportedDiagnostics { get; } = - ImmutableArray.Create(Descriptor); + ImmutableArray.Create(DescriptorNotPreceded); /// public override void Initialize(AnalysisContext context) @@ -91,7 +105,7 @@ private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context) SyntaxNode root = context.Tree.GetCompilationUnitRoot(context.CancellationToken); foreach (var token in root.DescendantTokens()) { - if (token.Kind() == SyntaxKind.ColonToken) + if (token.IsKind(SyntaxKind.ColonToken)) { HandleColonToken(context, token); } @@ -165,13 +179,15 @@ private static void HandleColonToken(SyntaxTreeAnalysisContext context, SyntaxTo { // colon should{ not}? be {preceded}{} by a space var properties = requireBefore ? TokenSpacingProperties.InsertPreceding : TokenSpacingProperties.RemovePreceding; - context.ReportDiagnostic(Diagnostic.Create(Descriptor, token.GetLocation(), properties, requireBefore ? string.Empty : " not", "preceded", string.Empty)); + context.ReportDiagnostic(Diagnostic.Create(requireBefore ? DescriptorPreceded : DescriptorNotPreceded, token.GetLocation(), properties)); } if (missingFollowingSpace && checkRequireAfter) { // colon should{} be {followed}{} by a space - context.ReportDiagnostic(Diagnostic.Create(Descriptor, token.GetLocation(), TokenSpacingProperties.InsertFollowing, string.Empty, "followed", string.Empty)); +#pragma warning disable RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor (https://github.com/dotnet/roslyn-analyzers/issues/4103) + context.ReportDiagnostic(Diagnostic.Create(DescriptorFollowed, token.GetLocation(), TokenSpacingProperties.InsertFollowing)); +#pragma warning restore RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1025CodeMustNotContainMultipleWhitespaceInARow.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1025CodeMustNotContainMultipleWhitespaceInARow.cs index 1e07cd0da..873947e92 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1025CodeMustNotContainMultipleWhitespaceInARow.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1025CodeMustNotContainMultipleWhitespaceInARow.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -26,10 +28,10 @@ internal class SA1025CodeMustNotContainMultipleWhitespaceInARow : DiagnosticAnal /// analyzer. /// public const string DiagnosticId = "SA1025"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1025.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1025Title), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(SpacingResources.SA1025MessageFormat), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1025Description), SpacingResources.ResourceManager, typeof(SpacingResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1025.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -109,7 +111,7 @@ private static void HandleWhitespaceTrivia(SyntaxTreeAnalysisContext context, Sy return; } - var followingTrivia = index + 1 < list.Count ? list[index + 1] : default(SyntaxTrivia); + var followingTrivia = index + 1 < list.Count ? list[index + 1] : default; if (precedingToken.IsKind(SyntaxKind.CommaToken) || precedingToken.IsKind(SyntaxKind.SemicolonToken) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1026CodeMustNotContainSpaceAfterNewKeywordInImplicitlyTypedArrayAllocation.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1026CodeMustNotContainSpaceAfterNewKeywordInImplicitlyTypedArrayAllocation.cs index 5315fe8a8..32dfd3cfb 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1026CodeMustNotContainSpaceAfterNewKeywordInImplicitlyTypedArrayAllocation.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1026CodeMustNotContainSpaceAfterNewKeywordInImplicitlyTypedArrayAllocation.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -10,6 +12,7 @@ namespace StyleCop.Analyzers.SpacingRules using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; using StyleCop.Analyzers.Helpers; + using StyleCop.Analyzers.Lightup; /// /// An implicitly typed new array allocation within a C# code file is not spaced correctly. @@ -31,15 +34,16 @@ internal class SA1026CodeMustNotContainSpaceAfterNewKeywordInImplicitlyTypedArra /// analyzer. /// public const string DiagnosticId = "SA1026"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1026.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1026Title), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(SpacingResources.SA1026MessageFormat), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1026Description), SpacingResources.ResourceManager, typeof(SpacingResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1026.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); private static readonly Action ImplicitArrayCreationExpressionAction = HandleImplicitArrayCreationExpression; + private static readonly Action ImplicitStackAllocArrayCreationExpressionAction = HandleImplicitStackAllocArrayCreationExpression; /// public override ImmutableArray SupportedDiagnostics { get; } = @@ -52,6 +56,7 @@ public override void Initialize(AnalysisContext context) context.EnableConcurrentExecution(); context.RegisterSyntaxNodeAction(ImplicitArrayCreationExpressionAction, SyntaxKind.ImplicitArrayCreationExpression); + context.RegisterSyntaxNodeAction(ImplicitStackAllocArrayCreationExpressionAction, SyntaxKindEx.ImplicitStackAllocArrayCreationExpression); } private static void HandleImplicitArrayCreationExpression(SyntaxNodeAnalysisContext context) @@ -61,7 +66,18 @@ private static void HandleImplicitArrayCreationExpression(SyntaxNodeAnalysisCont if (newKeywordToken.IsFollowedByWhitespace() || newKeywordToken.IsLastInLine()) { - context.ReportDiagnostic(Diagnostic.Create(Descriptor, newKeywordToken.GetLocation(), TokenSpacingProperties.RemoveFollowing)); + context.ReportDiagnostic(Diagnostic.Create(Descriptor, newKeywordToken.GetLocation(), TokenSpacingProperties.RemoveFollowing, "new")); + } + } + + private static void HandleImplicitStackAllocArrayCreationExpression(SyntaxNodeAnalysisContext context) + { + var arrayCreation = (ImplicitStackAllocArrayCreationExpressionSyntaxWrapper)context.Node; + var stackAllocKeywordToken = arrayCreation.StackAllocKeyword; + + if (stackAllocKeywordToken.IsFollowedByWhitespace() || stackAllocKeywordToken.IsLastInLine()) + { + context.ReportDiagnostic(Diagnostic.Create(Descriptor, stackAllocKeywordToken.GetLocation(), TokenSpacingProperties.RemoveFollowing, "stackalloc")); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1027UseTabsCorrectly.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1027UseTabsCorrectly.cs index 9f03a385c..658a01e26 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1027UseTabsCorrectly.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1027UseTabsCorrectly.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -26,10 +28,10 @@ internal class SA1027UseTabsCorrectly : DiagnosticAnalyzer internal static readonly string ConvertToTabsBehavior = "ConvertToTabs"; internal static readonly string ConvertToSpacesBehavior = "ConvertToSpaces"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1027.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1027Title), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(SpacingResources.SA1027MessageFormat), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1027Description), SpacingResources.ResourceManager, typeof(SpacingResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1027.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); @@ -52,7 +54,10 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); - context.RegisterSyntaxTreeAction(SyntaxTreeAction); + context.RegisterCompilationStartAction(context => + { + context.RegisterSyntaxTreeAction(SyntaxTreeAction); + }); } private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context, StyleCopSettings settings) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1028CodeMustNotContainTrailingWhitespace.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1028CodeMustNotContainTrailingWhitespace.cs index 5fd510839..779dca95b 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1028CodeMustNotContainTrailingWhitespace.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SA1028CodeMustNotContainTrailingWhitespace.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -30,10 +32,10 @@ internal class SA1028CodeMustNotContainTrailingWhitespace : DiagnosticAnalyzer /// The ID for diagnostics produced by the analyzer. /// public const string DiagnosticId = "SA1028"; + private const string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md"; private static readonly LocalizableString Title = new LocalizableResourceString(nameof(SpacingResources.SA1028Title), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly LocalizableString MessageFormat = new LocalizableResourceString(nameof(SpacingResources.SA1028MessageFormat), SpacingResources.ResourceManager, typeof(SpacingResources)); private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpacingResources.SA1028Description), SpacingResources.ResourceManager, typeof(SpacingResources)); - private static readonly string HelpLink = "https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1028.md"; private static readonly DiagnosticDescriptor Descriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpacingRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.Unnecessary); @@ -68,7 +70,7 @@ private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context) var root = context.Tree.GetRoot(context.CancellationToken); var text = context.Tree.GetText(context.CancellationToken); - SyntaxTrivia previousTrivia = default(SyntaxTrivia); + SyntaxTrivia previousTrivia = default; foreach (var trivia in root.DescendantTrivia(descendIntoTrivia: true)) { switch (trivia.Kind()) @@ -131,7 +133,7 @@ private static void HandleSyntaxTree(SyntaxTreeAnalysisContext context) case SyntaxKind.SingleLineDocumentationCommentTrivia: case SyntaxKind.MultiLineDocumentationCommentTrivia: - SyntaxToken previousToken = default(SyntaxToken); + SyntaxToken previousToken = default; foreach (var token in trivia.GetStructure().DescendantTokens(descendIntoTrivia: true)) { if (token.IsKind(SyntaxKind.XmlTextLiteralNewLineToken) diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SpacingResources.Designer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SpacingResources.Designer.cs deleted file mode 100644 index 2924bd85c..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SpacingResources.Designer.cs +++ /dev/null @@ -1,442 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace StyleCop.Analyzers.SpacingRules { - using System; - using System.Reflection; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class SpacingResources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal SpacingResources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StyleCop.Analyzers.SpacingRules.SpacingResources", typeof(SpacingResources).GetTypeInfo().Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Fix spacing. - /// - internal static string SA1003CodeFix { - get { - return ResourceManager.GetString("SA1003CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Fix spacing. - /// - internal static string SA1004CodeFix { - get { - return ResourceManager.GetString("SA1004CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A line within a documentation header above a C# element does not begin with a single space.. - /// - internal static string SA1004Description { - get { - return ResourceManager.GetString("SA1004Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Documentation line should begin with a space.. - /// - internal static string SA1004MessageFormat { - get { - return ResourceManager.GetString("SA1004MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Documentation lines should begin with single space. - /// - internal static string SA1004Title { - get { - return ResourceManager.GetString("SA1004Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Fix spacing. - /// - internal static string SA1005CodeFix { - get { - return ResourceManager.GetString("SA1005CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A single-line comment within a C# code file does not begin with a single space.. - /// - internal static string SA1005Description { - get { - return ResourceManager.GetString("SA1005Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Single line comment should begin with a space.. - /// - internal static string SA1005MessageFormat { - get { - return ResourceManager.GetString("SA1005MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Single line comments should begin with single space. - /// - internal static string SA1005Title { - get { - return ResourceManager.GetString("SA1005Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A C# preprocessor-type keyword is preceded by space.. - /// - internal static string SA1006Description { - get { - return ResourceManager.GetString("SA1006Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Preprocessor keyword '{0}' should not be preceded by a space.. - /// - internal static string SA1006MessageFormat { - get { - return ResourceManager.GetString("SA1006MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Preprocessor keywords should not be preceded by space. - /// - internal static string SA1006Title { - get { - return ResourceManager.GetString("SA1006Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The operator keyword within a C# operator overload method is not followed by any whitespace.. - /// - internal static string SA1007Description { - get { - return ResourceManager.GetString("SA1007Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Operator keyword should be followed by a space.. - /// - internal static string SA1007MessageFormat { - get { - return ResourceManager.GetString("SA1007MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Operator keyword should be followed by space. - /// - internal static string SA1007Title { - get { - return ResourceManager.GetString("SA1007Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Fix spacing. - /// - internal static string SA1008CodeFix { - get { - return ResourceManager.GetString("SA1008CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to An opening attribute bracket within a C# element is not spaced correctly.. - /// - internal static string SA1016Description { - get { - return ResourceManager.GetString("SA1016Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Opening attribute brackets should not be followed by a space.. - /// - internal static string SA1016MessageFormat { - get { - return ResourceManager.GetString("SA1016MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Opening attribute brackets should be spaced correctly. - /// - internal static string SA1016Title { - get { - return ResourceManager.GetString("SA1016Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A closing attribute bracket within a C# element is not spaced correctly.. - /// - internal static string SA1017Description { - get { - return ResourceManager.GetString("SA1017Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Closing attribute brackets should not be preceded by a space.. - /// - internal static string SA1017MessageFormat { - get { - return ResourceManager.GetString("SA1017MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Closing attribute brackets should be spaced correctly. - /// - internal static string SA1017Title { - get { - return ResourceManager.GetString("SA1017Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Fix spacing. - /// - internal static string SA1018CodeFix { - get { - return ResourceManager.GetString("SA1018CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A nullable type symbol within a C# element is not spaced correctly.. - /// - internal static string SA1018Description { - get { - return ResourceManager.GetString("SA1018Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Nullable type symbol should not be preceded by a space.. - /// - internal static string SA1018MessageFormat { - get { - return ResourceManager.GetString("SA1018MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Nullable type symbols should be spaced correctly. - /// - internal static string SA1018Title { - get { - return ResourceManager.GetString("SA1018Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Fix spacing. - /// - internal static string SA1025CodeFix { - get { - return ResourceManager.GetString("SA1025CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The code contains multiple whitespace characters in a row.. - /// - internal static string SA1025Description { - get { - return ResourceManager.GetString("SA1025Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Code should not contain multiple whitespace characters in a row.. - /// - internal static string SA1025MessageFormat { - get { - return ResourceManager.GetString("SA1025MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Code should not contain multiple whitespace in a row. - /// - internal static string SA1025Title { - get { - return ResourceManager.GetString("SA1025Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to An implicitly typed new array allocation within a C# code file is not spaced correctly.. - /// - internal static string SA1026Description { - get { - return ResourceManager.GetString("SA1026Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The keyword 'new' should not be followed by a space or a blank line.. - /// - internal static string SA1026MessageFormat { - get { - return ResourceManager.GetString("SA1026MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Code should not contain space after new keyword in implicitly typed array allocation. - /// - internal static string SA1026Title { - get { - return ResourceManager.GetString("SA1026Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Replace tabs with spaces. - /// - internal static string SA1027CodeFix { - get { - return ResourceManager.GetString("SA1027CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The code contains a tab or space character which is not consistent with the current project settings.. - /// - internal static string SA1027Description { - get { - return ResourceManager.GetString("SA1027Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Tabs and spaces should be used correctly. - /// - internal static string SA1027MessageFormat { - get { - return ResourceManager.GetString("SA1027MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Use tabs correctly. - /// - internal static string SA1027Title { - get { - return ResourceManager.GetString("SA1027Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Remove trailing whitespace. - /// - internal static string SA1028CodeFix { - get { - return ResourceManager.GetString("SA1028CodeFix", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to There should not be any whitespace at the end of a line of code.. - /// - internal static string SA1028Description { - get { - return ResourceManager.GetString("SA1028Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Code should not contain trailing whitespace. - /// - internal static string SA1028MessageFormat { - get { - return ResourceManager.GetString("SA1028MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Code should not contain trailing whitespace. - /// - internal static string SA1028Title { - get { - return ResourceManager.GetString("SA1028Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Fix spacing. - /// - internal static string TokenSpacingCodeFix { - get { - return ResourceManager.GetString("TokenSpacingCodeFix", resourceCulture); - } - } - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SpacingResources.resx b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SpacingResources.resx index c0fff4ba6..42ef5e349 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SpacingResources.resx +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/SpacingResources.resx @@ -117,9 +117,60 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + The spacing around a C# keyword is incorrect. + + + The keyword '{0}' should{1} be followed by a space + + + Keywords should be spaced correctly + + + The spacing around a comma is incorrect, within a C# code file. + + + Commas should{0} be {1} by whitespace + + + Commas should be spaced correctly + + + The spacing around a semicolon is incorrect, within a C# code file. + + + Semicolons should{0} be {1} by a space + + + Semicolons should be spaced correctly + Fix spacing + + The spacing around an operator symbol is incorrect, within a C# code file. + + + Operator '{0}' should be followed by whitespace. + + + Operator '{0}' should not appear at the end of a line. + + + Operator '{0}' should not be followed by a comment. + + + Operator '{0}' should not be followed by whitespace. + + + Operator '{0}' should not be preceded by whitespace. + + + Operator '{0}' should be preceded by whitespace. + + + Symbols should be spaced correctly + Fix spacing @@ -127,7 +178,7 @@ A line within a documentation header above a C# element does not begin with a single space. - Documentation line should begin with a space. + Documentation line should begin with a space Documentation lines should begin with single space @@ -139,7 +190,7 @@ A single-line comment within a C# code file does not begin with a single space. - Single line comment should begin with a space. + Single line comment should begin with a space Single line comments should begin with single space @@ -148,7 +199,7 @@ A C# preprocessor-type keyword is preceded by space. - Preprocessor keyword '{0}' should not be preceded by a space. + Preprocessor keyword '{0}' should not be preceded by a space Preprocessor keywords should not be preceded by space @@ -157,7 +208,7 @@ The operator keyword within a C# operator overload method is not followed by any whitespace. - Operator keyword should be followed by a space. + Operator keyword should be followed by a space Operator keyword should be followed by space @@ -165,11 +216,104 @@ Fix spacing + + An opening parenthesis within a C# statement is not spaced correctly. + + + Opening parenthesis should not be followed by a space. + + + Opening parenthesis should not be preceded by a space. + + + Opening parenthesis should be preceded by a space. + + + Opening parenthesis should be spaced correctly + + + A closing parenthesis within a C# statement is not spaced correctly. + + + Closing parenthesis should be followed by a space + + + Closing parenthesis should not be followed by a space + + + Closing parenthesis should not be preceded by a space + + + Closing parenthesis should be spaced correctly + + + An opening square bracket within a C# statement is not spaced correctly. + + + Opening square brackets should not be followed by a space + + + Opening square brackets should not be preceded by a space + + + Opening square brackets should be spaced correctly + + + A closing square bracket within a C# statement is not spaced correctly. + + + Closing square bracket should{0} be {1} by a space + + + Closing square brackets should be spaced correctly + + + An opening brace within a C# element is not spaced correctly. + + + Opening brace should{0} be {1} by a space + + + Opening braces should be spaced correctly + + + A closing brace within a C# element is not spaced correctly. + + + Closing brace should{0} be {1} by a space + + + Closing braces should be spaced correctly + + + An opening generic bracket within a C# element is not spaced correctly. + + + Opening generic brackets should not be {0} by a space + + + Opening generic brackets should be spaced correctly + + + A closing generic bracket within a C# element is not spaced correctly. + + + Closing generic bracket should be followed by a space + + + Closing generic bracket should not be followed by a space + + + Closing generic bracket should not be preceded by a space + + + Closing generic brackets should be spaced correctly + An opening attribute bracket within a C# element is not spaced correctly. - Opening attribute brackets should not be followed by a space. + Opening attribute brackets should not be followed by a space Opening attribute brackets should be spaced correctly @@ -178,7 +322,7 @@ A closing attribute bracket within a C# element is not spaced correctly. - Closing attribute brackets should not be preceded by a space. + Closing attribute brackets should not be preceded by a space Closing attribute brackets should be spaced correctly @@ -190,11 +334,86 @@ A nullable type symbol within a C# element is not spaced correctly. - Nullable type symbol should not be preceded by a space. + Nullable type symbol should not be preceded by a space Nullable type symbols should be spaced correctly + + The spacing around a member access symbol is incorrect, within a C# code file. + + + Member access symbol '{0}' should not be followed by a space + + + Member access symbol '{0}' should not be preceded by a space + + + Member access symbols should be spaced correctly + + + An increment or decrement symbol within a C# element is not spaced correctly. + + + {0} symbol '{1}' should not be {2} by a space + + + Increment decrement symbols should be spaced correctly + + + A negative sign within a C# element is not spaced correctly. + + + Negative sign should{0} be {1} by a space + + + Negative signs should be spaced correctly + + + A positive sign within a C# element is not spaced correctly. + + + Positive sign should{0} be {1} by a space + + + Positive signs should be spaced correctly + + + A dereference symbol or an access-of symbol within a C# element is not spaced correctly. + + + Dereference symbol '*' should be followed by a space + + + Dereference symbol '*' should not appear at the beginning of a line + + + Dereference symbol '*' should not appear at the end of a line + + + Dereference symbol '*' should not be followed by a space + + + Dereference symbol '*' should not be preceded by a space + + + Dereference and access of symbols should be spaced correctly + + + A colon within a C# element is not spaced correctly. + + + Colon should be followed by a space + + + Colon should not be preceded by a space + + + Colon should be preceded by a space + + + Colons Should Be Spaced Correctly + Fix spacing @@ -202,22 +421,22 @@ The code contains multiple whitespace characters in a row. - Code should not contain multiple whitespace characters in a row. + Code should not contain multiple whitespace characters in a row Code should not contain multiple whitespace in a row - An implicitly typed new array allocation within a C# code file is not spaced correctly. + An implicitly typed array allocation within a C# code file is not spaced correctly. - The keyword 'new' should not be followed by a space or a blank line. + The keyword '{0}' should not be followed by a space or a blank line - Code should not contain space after new keyword in implicitly typed array allocation + Code should not contain space after new or stackalloc keyword in implicitly typed array allocation - Replace tabs with spaces + Fix tabs The code contains a tab or space character which is not consistent with the current project settings. diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/TokenSpacingProperties.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/TokenSpacingProperties.cs index e272208a7..1b6e357ae 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/TokenSpacingProperties.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpacingRules/TokenSpacingProperties.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpacingRules { @@ -61,5 +63,11 @@ internal static class TokenSpacingProperties ImmutableDictionary.Empty .SetItem(LocationKey, LocationFollowing) .SetItem(ActionKey, ActionRemove); + + internal static ImmutableDictionary RemoveFollowingPreserveLayout { get; } = + ImmutableDictionary.Empty + .SetItem(LocationKey, LocationFollowing) + .SetItem(ActionKey, ActionRemove) + .SetItem(LayoutKey, LayoutPreserve); } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpecialRules/SA0001XmlCommentAnalysisDisabled.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpecialRules/SA0001XmlCommentAnalysisDisabled.cs index f45f7b4be..7b94f9f65 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpecialRules/SA0001XmlCommentAnalysisDisabled.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpecialRules/SA0001XmlCommentAnalysisDisabled.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpecialRules { @@ -27,7 +29,7 @@ internal class SA0001XmlCommentAnalysisDisabled : DiagnosticAnalyzer private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpecialResources.SA0001Description), SpecialResources.ResourceManager, typeof(SpecialResources)); private static readonly DiagnosticDescriptor Descriptor = - new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpecialRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); + new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpecialRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink, customTags: new string[] { "CompilationEnd" }); private static readonly Action CompilationStartAction = HandleCompilationStart; diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpecialRules/SA0002InvalidSettingsFile.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpecialRules/SA0002InvalidSettingsFile.cs index 192d9e34c..8bb93b623 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpecialRules/SA0002InvalidSettingsFile.cs +++ b/StyleCop.Analyzers/StyleCop.Analyzers/SpecialRules/SA0002InvalidSettingsFile.cs @@ -1,11 +1,13 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCop.Analyzers.SpecialRules { using System; using System.Collections.Immutable; - using System.Globalization; + using System.Linq; using LightJson.Serialization; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; @@ -27,7 +29,9 @@ internal class SA0002InvalidSettingsFile : DiagnosticAnalyzer private static readonly LocalizableString Description = new LocalizableResourceString(nameof(SpecialResources.SA0002Description), SpecialResources.ResourceManager, typeof(SpecialResources)); private static readonly DiagnosticDescriptor Descriptor = - new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpecialRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink); +#pragma warning disable RS1033 // Define diagnostic description correctly (Description ends with formatted exception text) + new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpecialRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, Description, HelpLink, customTags: new[] { "CompilationEnd" }); +#pragma warning restore RS1033 // Define diagnostic description correctly private static readonly Action CompilationAction = HandleCompilation; @@ -38,22 +42,27 @@ internal class SA0002InvalidSettingsFile : DiagnosticAnalyzer /// public override void Initialize(AnalysisContext context) { + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); + context.EnableConcurrentExecution(); + context.RegisterCompilationAction(CompilationAction); } private static void HandleCompilation(CompilationAnalysisContext context) { + var firstSyntaxTree = context.Compilation.SyntaxTrees.FirstOrDefault(); + if (firstSyntaxTree is null) + { + return; + } + try { - SettingsHelper.GetStyleCopSettings(context.Options, DeserializationFailureBehavior.ThrowException, context.CancellationToken); + context.GetStyleCopSettings(firstSyntaxTree, DeserializationFailureBehavior.ThrowException, context.CancellationToken); } catch (Exception ex) when (ex is JsonParseException || ex is InvalidSettingsException) { - string details = ex.Message; - string completeDescription = string.Format(Description.ToString(CultureInfo.CurrentCulture), details); - - var completeDescriptor = new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.SpecialRules, DiagnosticSeverity.Warning, AnalyzerConstants.EnabledByDefault, completeDescription, HelpLink); - context.ReportDiagnostic(Diagnostic.Create(completeDescriptor, Location.None)); + context.ReportDiagnostic(Diagnostic.Create(Descriptor, Location.None, ex.Message)); } } } diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/SpecialRules/SpecialResources.Designer.cs b/StyleCop.Analyzers/StyleCop.Analyzers/SpecialRules/SpecialResources.Designer.cs deleted file mode 100644 index f5a5cb6c6..000000000 --- a/StyleCop.Analyzers/StyleCop.Analyzers/SpecialRules/SpecialResources.Designer.cs +++ /dev/null @@ -1,120 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace StyleCop.Analyzers.SpecialRules { - using System; - using System.Reflection; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class SpecialResources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal SpecialResources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StyleCop.Analyzers.SpecialRules.SpecialResources", typeof(SpecialResources).GetTypeInfo().Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to XML comment analysis can only be performed when the project is configured to parse documentation comments. To enable this functionality, update the project to produce an XML documentation file as part of the build.. - /// - internal static string SA0001Description { - get { - return ResourceManager.GetString("SA0001Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to XML comment analysis is disabled due to project configuration. - /// - internal static string SA0001MessageFormat { - get { - return ResourceManager.GetString("SA0001MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to XML comment analysis disabled. - /// - internal static string SA0001Title { - get { - return ResourceManager.GetString("SA0001Title", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Various errors in the stylecop.json file can prevent the file from being loaded by the analyzers. In this case, the default settings are used instead. - /// - ///{0}. - /// - internal static string SA0002Description { - get { - return ResourceManager.GetString("SA0002Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The stylecop.json settings file could not be loaded. - /// - internal static string SA0002MessageFormat { - get { - return ResourceManager.GetString("SA0002MessageFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Invalid settings file. - /// - internal static string SA0002Title { - get { - return ResourceManager.GetString("SA0002Title", resourceCulture); - } - } - } -} diff --git a/StyleCop.Analyzers/StyleCop.Analyzers/StyleCop.Analyzers.csproj b/StyleCop.Analyzers/StyleCop.Analyzers/StyleCop.Analyzers.csproj index 3d6cf4add..1b7e93789 100644 --- a/StyleCop.Analyzers/StyleCop.Analyzers/StyleCop.Analyzers.csproj +++ b/StyleCop.Analyzers/StyleCop.Analyzers/StyleCop.Analyzers.csproj @@ -20,16 +20,35 @@ true - ..\..\build\keys\StyleCopAnalyzers.snk - ..\..\build\keys\StyleCopAnalyzers.dev.snk + ..\..\build\keys\StyleCopAnalyzers.snk - - $(DefineConstants);DEVELOPMENT_KEY + + true + $(MSBuildProjectDirectory)\Lightup\.generated + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/StyleCop.Analyzers/StyleCopTester/CodeFixEquivalenceGroup.cs b/StyleCop.Analyzers/StyleCopTester/CodeFixEquivalenceGroup.cs index 5b83aa022..5650edd2b 100644 --- a/StyleCop.Analyzers/StyleCopTester/CodeFixEquivalenceGroup.cs +++ b/StyleCop.Analyzers/StyleCopTester/CodeFixEquivalenceGroup.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCopTester { diff --git a/StyleCop.Analyzers/StyleCopTester/Extensions.cs b/StyleCop.Analyzers/StyleCopTester/Extensions.cs index 8a3084b9b..bf6669f5b 100644 --- a/StyleCop.Analyzers/StyleCopTester/Extensions.cs +++ b/StyleCop.Analyzers/StyleCopTester/Extensions.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCopTester { diff --git a/StyleCop.Analyzers/StyleCopTester/Program.cs b/StyleCop.Analyzers/StyleCopTester/Program.cs index c38e5163c..a259cded4 100644 --- a/StyleCop.Analyzers/StyleCopTester/Program.cs +++ b/StyleCop.Analyzers/StyleCopTester/Program.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCopTester { @@ -129,7 +131,7 @@ private static async Task MainAsync(string[] args, CancellationToken cancellatio bool force = args.Contains("/force"); - var diagnostics = await GetAnalyzerDiagnosticsAsync(solution, solutionPath, analyzers, force, cancellationToken).ConfigureAwait(true); + var diagnostics = await GetAnalyzerDiagnosticsAsync(solution, analyzers, force, cancellationToken).ConfigureAwait(true); var allDiagnostics = diagnostics.SelectMany(i => i.Value).ToImmutableArray(); Console.WriteLine($"Found {allDiagnostics.Length} diagnostics in {stopwatch.ElapsedMilliseconds}ms"); @@ -269,7 +271,7 @@ private static async Task TestDocumentPerformanceAs var processedProject = project.WithCompilationOptions(modifiedCompilationOptions); Compilation compilation = await processedProject.GetCompilationAsync(cancellationToken).ConfigureAwait(false); - CompilationWithAnalyzers compilationWithAnalyzers = compilation.WithAnalyzers(analyzers, new CompilationWithAnalyzersOptions(new AnalyzerOptions(ImmutableArray.Create()), null, true, false)); + CompilationWithAnalyzers compilationWithAnalyzers = compilation.WithAnalyzers(analyzers, new CompilationWithAnalyzersOptions(processedProject.AnalyzerOptions, null, true, false)); SyntaxTree tree = await project.GetDocument(documentId).GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false); await compilationWithAnalyzers.GetAnalyzerSyntaxDiagnosticsAsync(tree, cancellationToken).ConfigureAwait(false); @@ -528,24 +530,7 @@ private static ImmutableDictionary> GetAl return providers.ToImmutableDictionary(); } - private static ImmutableDictionary> GetAllFixAllProviders(IEnumerable providers) - { - Dictionary> fixAllProviders = new Dictionary>(); - - foreach (var provider in providers) - { - var fixAllProvider = provider.GetFixAllProvider(); - var supportedDiagnosticIds = fixAllProvider.GetSupportedFixAllDiagnosticIds(provider); - foreach (var id in supportedDiagnosticIds) - { - fixAllProviders.AddToInnerSet(fixAllProvider, id); - } - } - - return fixAllProviders.ToImmutableDictionary(); - } - - private static async Task>> GetAnalyzerDiagnosticsAsync(Solution solution, string solutionPath, ImmutableArray analyzers, bool force, CancellationToken cancellationToken) + private static async Task>> GetAnalyzerDiagnosticsAsync(Solution solution, ImmutableArray analyzers, bool force, CancellationToken cancellationToken) { List>>> projectDiagnosticTasks = new List>>>(); @@ -602,7 +587,7 @@ private static async Task> GetProjectAnalyzerDiagnost var processedProject = project.WithCompilationOptions(modifiedCompilationOptions); Compilation compilation = await processedProject.GetCompilationAsync(cancellationToken).ConfigureAwait(false); - CompilationWithAnalyzers compilationWithAnalyzers = compilation.WithAnalyzers(analyzers, new CompilationWithAnalyzersOptions(new AnalyzerOptions(ImmutableArray.Create()), null, true, false)); + CompilationWithAnalyzers compilationWithAnalyzers = compilation.WithAnalyzers(analyzers, new CompilationWithAnalyzersOptions(processedProject.AnalyzerOptions, null, true, false)); var diagnostics = await compilationWithAnalyzers.GetAllDiagnosticsAsync(cancellationToken).ConfigureAwait(false); return diagnostics; diff --git a/StyleCop.Analyzers/StyleCopTester/Properties/AssemblyInfo.cs b/StyleCop.Analyzers/StyleCopTester/Properties/AssemblyInfo.cs index 5b18b986e..cf39ebde7 100644 --- a/StyleCop.Analyzers/StyleCopTester/Properties/AssemblyInfo.cs +++ b/StyleCop.Analyzers/StyleCopTester/Properties/AssemblyInfo.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable using System; using System.Runtime.InteropServices; diff --git a/StyleCop.Analyzers/StyleCopTester/Statistic.cs b/StyleCop.Analyzers/StyleCopTester/Statistic.cs index 57b69861e..bb7151a07 100644 --- a/StyleCop.Analyzers/StyleCopTester/Statistic.cs +++ b/StyleCop.Analyzers/StyleCopTester/Statistic.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCopTester { diff --git a/StyleCop.Analyzers/StyleCopTester/StyleCopTester.csproj b/StyleCop.Analyzers/StyleCopTester/StyleCopTester.csproj index cc76ef90f..61672301a 100644 --- a/StyleCop.Analyzers/StyleCopTester/StyleCopTester.csproj +++ b/StyleCop.Analyzers/StyleCopTester/StyleCopTester.csproj @@ -4,6 +4,7 @@ Exe net46 + false true @@ -23,11 +24,11 @@ - - - - - + + + + + diff --git a/StyleCop.Analyzers/StyleCopTester/TesterDiagnosticProvider.cs b/StyleCop.Analyzers/StyleCopTester/TesterDiagnosticProvider.cs index 2db610db5..40596facc 100644 --- a/StyleCop.Analyzers/StyleCopTester/TesterDiagnosticProvider.cs +++ b/StyleCop.Analyzers/StyleCopTester/TesterDiagnosticProvider.cs @@ -1,5 +1,7 @@ // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#nullable disable namespace StyleCopTester { diff --git a/StyleCop.Analyzers/stylecop.json b/StyleCop.Analyzers/stylecop.json index 75127ffaf..57375f9d0 100644 --- a/StyleCop.Analyzers/stylecop.json +++ b/StyleCop.Analyzers/stylecop.json @@ -3,12 +3,15 @@ "settings": { "documentationRules": { "companyName": "Tunnel Vision Laboratories, LLC", - "copyrightText": "Copyright (c) {companyName}. All Rights Reserved.\r\nLicensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.", + "copyrightText": "Copyright (c) {companyName}. All Rights Reserved.\r\nLicensed under the MIT License. See LICENSE in the project root for license information.", "xmlHeader": false, "fileNamingConvention": "metadata" }, "layoutRules": { "newlineAtEndOfFile": "require" + }, + "namingRules": { + "tupleElementNameCasing": "camelCase" } } } diff --git a/StyleCop.Analyzers/version.json b/StyleCop.Analyzers/version.json index 82ce5caf6..5a4d75749 100644 --- a/StyleCop.Analyzers/version.json +++ b/StyleCop.Analyzers/version.json @@ -1,20 +1,19 @@ { "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "1.1.0-beta.{height}", - // The build number offset accounts for the delay in adopting Nerdbank.GitVersioning - "buildNumberOffset": 40, + "version": "1.2.0-beta.{height}", "assemblyVersion": { "precision": "revision" }, "publicReleaseRefSpec": [ - "^refs/heads/master$" + "^refs/heads/master$", + "^refs/heads/stabilization$" ], "nugetPackageVersion": { "semVer": 2 }, "cloudBuild": { "buildNumber": { - "enabled": true + "enabled": false } } } diff --git a/StyleCopAnalyzers.sln b/StyleCopAnalyzers.sln index 6cfe2015d..1ca396001 100644 --- a/StyleCopAnalyzers.sln +++ b/StyleCopAnalyzers.sln @@ -1,8 +1,8 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26711.1 -MinimumVisualStudioVersion = 10.0.40219.1 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.31907.60 +MinimumVisualStudioVersion = 17.0.31903.59 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StyleCop.Analyzers", "StyleCop.Analyzers\StyleCop.Analyzers\StyleCop.Analyzers.csproj", "{3B052737-06CE-4182-AE0F-08EB82DFA73E}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{E359E48C-93DA-4C17-AA0E-94D4831BE5AB}" @@ -22,18 +22,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution CONTRIBUTING.md = CONTRIBUTING.md LICENSE = LICENSE README.md = README.md + THIRD-PARTY-NOTICES.txt = THIRD-PARTY-NOTICES.txt EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{A0840AD0-B615-487C-AEFF-9DCB691D037B}" ProjectSection(SolutionItems) = preProject build\build.ps1 = build\build.ps1 - build\check-key.ps1 = build\check-key.ps1 StyleCop.Analyzers\Directory.Build.props = StyleCop.Analyzers\Directory.Build.props StyleCop.Analyzers\Directory.Build.targets = StyleCop.Analyzers\Directory.Build.targets - build\keys.ps1 = build\keys.ps1 build\opencover-report.ps1 = build\opencover-report.ps1 - build\push.ps1 = build\push.ps1 - build\version.ps1 = build\version.ps1 EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "documentation", "documentation", "{19DD9E9D-877A-4492-9B7F-2E681DD58308}" @@ -119,6 +116,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "documentation", "documentat documentation\SA1136.md = documentation\SA1136.md documentation\SA1137.md = documentation\SA1137.md documentation\SA1139.md = documentation\SA1139.md + documentation\SA1141.md = documentation\SA1141.md + documentation\SA1142.md = documentation\SA1142.md documentation\SA1200.md = documentation\SA1200.md documentation\SA1201.md = documentation\SA1201.md documentation\SA1202.md = documentation\SA1202.md @@ -152,6 +151,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "documentation", "documentat documentation\SA1312.md = documentation\SA1312.md documentation\SA1313.md = documentation\SA1313.md documentation\SA1314.md = documentation\SA1314.md + documentation\SA1316.md = documentation\SA1316.md documentation\SA1400.md = documentation\SA1400.md documentation\SA1401.md = documentation\SA1401.md documentation\SA1402.md = documentation\SA1402.md @@ -166,6 +166,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "documentation", "documentat documentation\SA1411.md = documentation\SA1411.md documentation\SA1412.md = documentation\SA1412.md documentation\SA1413.md = documentation\SA1413.md + documentation\SA1414.md = documentation\SA1414.md documentation\SA1500.md = documentation\SA1500.md documentation\SA1501.md = documentation\SA1501.md documentation\SA1502.md = documentation\SA1502.md @@ -259,6 +260,22 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StyleCop.Analyzers.Status.G {3B052737-06CE-4182-AE0F-08EB82DFA73E} = {3B052737-06CE-4182-AE0F-08EB82DFA73E} EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StyleCop.Analyzers.Test.CSharp8", "StyleCop.Analyzers\StyleCop.Analyzers.Test.CSharp8\StyleCop.Analyzers.Test.CSharp8.csproj", "{0F8D1A26-ACC2-42BA-9CEC-FFADBD6FB1E7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StyleCop.Analyzers.Test.CSharp9", "StyleCop.Analyzers\StyleCop.Analyzers.Test.CSharp9\StyleCop.Analyzers.Test.CSharp9.csproj", "{AE37F270-3E2E-429E-A758-09FEBF11D57C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StyleCop.Analyzers.CodeGeneration", "StyleCop.Analyzers\StyleCop.Analyzers.CodeGeneration\StyleCop.Analyzers.CodeGeneration.csproj", "{3A5631C1-A338-412F-9F5B-ED55DE48853F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StyleCop.Analyzers.Test.CSharp10", "StyleCop.Analyzers\StyleCop.Analyzers.Test.CSharp10\StyleCop.Analyzers.Test.CSharp10.csproj", "{1A654DFB-8C99-4604-A1C3-A0057D60380B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StyleCop.Analyzers.Test.CSharp11", "StyleCop.Analyzers\StyleCop.Analyzers.Test.CSharp11\StyleCop.Analyzers.Test.CSharp11.csproj", "{F7D63A25-EBBC-40B5-AF7E-C49213AD33CE}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StyleCop.Analyzers.PrivateAnalyzers", "StyleCop.Analyzers\StyleCop.Analyzers.PrivateAnalyzers\StyleCop.Analyzers.PrivateAnalyzers.csproj", "{465F3586-165A-4454-8276-32FC93B509AA}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StyleCop.Analyzers.PrivateCodeFixes", "StyleCop.Analyzers\StyleCop.Analyzers.PrivateCodeFixes\StyleCop.Analyzers.PrivateCodeFixes.csproj", "{BEA9E1FE-E297-4EBD-BA00-B778DC99F37D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StyleCop.Analyzers.Test.CSharp12", "StyleCop.Analyzers\StyleCop.Analyzers.Test.CSharp12\StyleCop.Analyzers.Test.CSharp12.csproj", "{A900C5D5-D324-4145-B795-A347A50919C7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -293,6 +310,38 @@ Global {80EA831D-D993-44A8-BB77-33D84BACE711}.Debug|Any CPU.Build.0 = Debug|Any CPU {80EA831D-D993-44A8-BB77-33D84BACE711}.Release|Any CPU.ActiveCfg = Release|Any CPU {80EA831D-D993-44A8-BB77-33D84BACE711}.Release|Any CPU.Build.0 = Release|Any CPU + {0F8D1A26-ACC2-42BA-9CEC-FFADBD6FB1E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0F8D1A26-ACC2-42BA-9CEC-FFADBD6FB1E7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0F8D1A26-ACC2-42BA-9CEC-FFADBD6FB1E7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0F8D1A26-ACC2-42BA-9CEC-FFADBD6FB1E7}.Release|Any CPU.Build.0 = Release|Any CPU + {AE37F270-3E2E-429E-A758-09FEBF11D57C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AE37F270-3E2E-429E-A758-09FEBF11D57C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AE37F270-3E2E-429E-A758-09FEBF11D57C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AE37F270-3E2E-429E-A758-09FEBF11D57C}.Release|Any CPU.Build.0 = Release|Any CPU + {3A5631C1-A338-412F-9F5B-ED55DE48853F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3A5631C1-A338-412F-9F5B-ED55DE48853F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3A5631C1-A338-412F-9F5B-ED55DE48853F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3A5631C1-A338-412F-9F5B-ED55DE48853F}.Release|Any CPU.Build.0 = Release|Any CPU + {1A654DFB-8C99-4604-A1C3-A0057D60380B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1A654DFB-8C99-4604-A1C3-A0057D60380B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1A654DFB-8C99-4604-A1C3-A0057D60380B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1A654DFB-8C99-4604-A1C3-A0057D60380B}.Release|Any CPU.Build.0 = Release|Any CPU + {F7D63A25-EBBC-40B5-AF7E-C49213AD33CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F7D63A25-EBBC-40B5-AF7E-C49213AD33CE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F7D63A25-EBBC-40B5-AF7E-C49213AD33CE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F7D63A25-EBBC-40B5-AF7E-C49213AD33CE}.Release|Any CPU.Build.0 = Release|Any CPU + {465F3586-165A-4454-8276-32FC93B509AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {465F3586-165A-4454-8276-32FC93B509AA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {465F3586-165A-4454-8276-32FC93B509AA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {465F3586-165A-4454-8276-32FC93B509AA}.Release|Any CPU.Build.0 = Release|Any CPU + {BEA9E1FE-E297-4EBD-BA00-B778DC99F37D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BEA9E1FE-E297-4EBD-BA00-B778DC99F37D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BEA9E1FE-E297-4EBD-BA00-B778DC99F37D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BEA9E1FE-E297-4EBD-BA00-B778DC99F37D}.Release|Any CPU.Build.0 = Release|Any CPU + {A900C5D5-D324-4145-B795-A347A50919C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A900C5D5-D324-4145-B795-A347A50919C7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A900C5D5-D324-4145-B795-A347A50919C7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A900C5D5-D324-4145-B795-A347A50919C7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/THIRD-PARTY-NOTICES.txt b/THIRD-PARTY-NOTICES.txt index 215473477..f09ff16d3 100644 --- a/THIRD-PARTY-NOTICES.txt +++ b/THIRD-PARTY-NOTICES.txt @@ -6,6 +6,76 @@ bring it to our attention by posting an issue. The attached notices are provided for information only. + +License notice for .NET Compiler Platform ("Roslyn") +---------------------------------------------------- + +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +License notice for Code Cracker +------------------------------- + +Copyright 2014 Giovanni Bassi and Elemar Jr. + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +these files except in compliance with the License. You may obtain a copy of the +License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed +under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. + + +License notice for LightJson +---------------------------- + +Copyright (c) 2017 Marcos Lpez C. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + License notice for StyleCop.Analyzers.Status -------------------------------------------------- diff --git a/appveyor.yml b/appveyor.yml index cf315dc9a..65fa524a0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,32 +1,19 @@ version: '{build}' -image: Visual Studio 2017 +image: Visual Studio 2019 init: - git config --global core.autocrlf true configuration: - Debug - Release before_build: +- ps: .\init.ps1 -NoRestore - nuget restore skip_tags: true build: project: StyleCopAnalyzers.sln verbosity: minimal test_script: -- cd build -- ps: | - if ($env:Configuration -eq 'Debug') { - .\opencover-report.ps1 -Debug -NoBuild -NoReport -AppVeyor - if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) } - $packageConfig = [xml](Get-Content ..\.nuget\packages.config) - $codecov_version = $packageConfig.SelectSingleNode('/packages/package[@id="Codecov"]').version - $codecov = "..\packages\Codecov.$codecov_version\tools\codecov.exe" - &$codecov -f '..\build\OpenCover.Reports\OpenCover.StyleCopAnalyzers.xml' - } else { - .\opencover-report.ps1 -NoBuild -NoReport -AppVeyor - if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) } - } -- cd .. -- .\StyleCop.Analyzers\StyleCop.Analyzers.Status.Generator\bin\%Configuration%\net46\StyleCop.Analyzers.Status.Generator.exe .\StyleCopAnalyzers.sln > StyleCop.Analyzers.Status.json +- .\StyleCop.Analyzers\StyleCop.Analyzers.Status.Generator\bin\%Configuration%\net472\StyleCop.Analyzers.Status.Generator.exe .\StyleCopAnalyzers.sln > StyleCop.Analyzers.Status.json cache: - packages -> **\packages.config - C:\Users\appveyor\.nuget\packages -> appveyor.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..ef1f3f898 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,16 @@ +pool: + name: Azure Pipelines + vmImage: windows-latest + demands: + - msbuild + - visualstudio + - vstest + +stages: +- template: build/build-and-test.yml + parameters: + BuildConfiguration: Debug + +- template: build/build-and-test.yml + parameters: + BuildConfiguration: Release diff --git a/build/Install-DotNetSdk.ps1 b/build/Install-DotNetSdk.ps1 new file mode 100644 index 000000000..202dd8e0b --- /dev/null +++ b/build/Install-DotNetSdk.ps1 @@ -0,0 +1,161 @@ +<# +.SYNOPSIS +Installs the .NET SDK specified in the global.json file at the root of this repository, +along with supporting .NET Core runtimes used for testing. +.DESCRIPTION +This MAY not require elevation, as the SDK and runtimes are installed locally to this repo location, +unless `-InstallLocality machine` is specified. +.PARAMETER InstallLocality +A value indicating whether dependencies should be installed locally to the repo or at a per-user location. +Per-user allows sharing the installed dependencies across repositories and allows use of a shared expanded package cache. +Visual Studio will only notice and use these SDKs/runtimes if VS is launched from the environment that runs this script. +Per-repo allows for high isolation, allowing for a more precise recreation of the environment within an Azure Pipelines build. +When using 'repo', environment variables are set to cause the locally installed dotnet SDK to be used. +Per-repo can lead to file locking issues when dotnet.exe is left running as a build server and can be mitigated by running `dotnet build-server shutdown`. +Per-machine requires elevation and will download and install all SDKs and runtimes to machine-wide locations so all applications can find it. +#> +[CmdletBinding(SupportsShouldProcess=$true,ConfirmImpact='Medium')] +Param ( + [ValidateSet('repo','user','machine')] + [string]$InstallLocality='user' +) + +$DotNetInstallScriptRoot = "$PSScriptRoot/../obj/tools" +if (!(Test-Path $DotNetInstallScriptRoot)) { New-Item -ItemType Directory -Path $DotNetInstallScriptRoot | Out-Null } +$DotNetInstallScriptRoot = Resolve-Path $DotNetInstallScriptRoot + +# Look up actual required .NET Core SDK version from global.json +$globalJson = Get-Content -Path "$PSScriptRoot\..\global.json" | ConvertFrom-Json +$sdkVersion = $globalJson.sdk.version + +# Search for all .NET Core runtime versions referenced from MSBuild projects and arrange to install them. +$runtimeVersions = @() +Get-ChildItem "$PSScriptRoot\..\*.*proj" -Recurse |% { + $projXml = [xml](Get-Content -Path $_) + $targetFrameworks = $projXml.Project.PropertyGroup.TargetFramework + if (!$targetFrameworks) { + $targetFrameworks = $projXml.Project.PropertyGroup.TargetFrameworks + if ($targetFrameworks) { + $targetFrameworks = $targetFrameworks -Split ';' + } + } + $targetFrameworks |? { $_ -match 'netcoreapp(\d+\.\d+)' } |% { + $runtimeVersions += $Matches[1] + } +} + +Function Get-FileFromWeb([Uri]$Uri, $OutDir) { + $OutFile = Join-Path $OutDir $Uri.Segments[-1] + if (!(Test-Path $OutFile)) { + Write-Verbose "Downloading $Uri..." + try { + (New-Object System.Net.WebClient).DownloadFile($Uri, $OutFile) + } finally { + # This try/finally causes the script to abort + } + } + + $OutFile +} + +Function Get-InstallerExe($Version, [switch]$Runtime) { + $sdkOrRuntime = 'Sdk' + if ($Runtime) { $sdkOrRuntime = 'Runtime' } + + # Get the latest/actual version for the specified one + if (([Version]$Version).Build -eq -1) { + $versionInfo = -Split (Invoke-WebRequest -Uri "https://dotnetcli.blob.core.windows.net/dotnet/$sdkOrRuntime/$Version/latest.version" -UseBasicParsing) + $Version = $versionInfo[-1] + } + + Get-FileFromWeb -Uri "https://dotnetcli.blob.core.windows.net/dotnet/$sdkOrRuntime/$Version/dotnet-$($sdkOrRuntime.ToLowerInvariant())-$Version-win-x64.exe" -OutDir "$DotNetInstallScriptRoot" +} + +Function Install-DotNet($Version, [switch]$Runtime) { + if ($Runtime) { $sdkSubstring = '' } else { $sdkSubstring = 'SDK ' } + Write-Host "Downloading .NET Core $sdkSubstring$Version..." + $Installer = Get-InstallerExe -Version $Version -Runtime:$Runtime + Write-Host "Installing .NET Core $sdkSubstring$Version..." + cmd /c start /wait $Installer /install /quiet + if ($LASTEXITCODE -ne 0) { + throw "Failure to install .NET Core SDK" + } +} + +if ($InstallLocality -eq 'machine') { + if ($IsMacOS -or $IsLinux) { + Write-Error "Installing the .NET Core SDK or runtime at a machine-wide location is only supported by this script on Windows." + exit 1 + } + + if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { + Install-DotNet -Version $sdkVersion + } + + $runtimeVersions | Get-Unique |% { + if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { + Install-DotNet -Version $_ -Runtime + } + } + + return +} + +$switches = @( + '-Architecture','x64' +) +$envVars = @{ + # For locally installed dotnet, skip first time experience which takes a long time + 'DOTNET_SKIP_FIRST_TIME_EXPERIENCE' = 'true'; +} + +if ($InstallLocality -eq 'repo') { + $DotNetInstallDir = "$DotNetInstallScriptRoot/.dotnet" +} elseif ($env:AGENT_TOOLSDIRECTORY) { + $DotNetInstallDir = "$env:AGENT_TOOLSDIRECTORY/dotnet" +} else { + $DotNetInstallDir = Join-Path $HOME .dotnet +} + +Write-Host "Installing .NET Core SDK and runtimes to $DotNetInstallDir" -ForegroundColor Blue + +if ($DotNetInstallDir) { + $switches += '-InstallDir',$DotNetInstallDir + $envVars['DOTNET_MULTILEVEL_LOOKUP'] = '0' + $envVars['DOTNET_ROOT'] = $DotNetInstallDir +} + +if ($IsMacOS -or $IsLinux) { + $DownloadUri = "https://dot.net/v1/dotnet-install.sh" + $DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.sh" +} else { + $DownloadUri = "https://dot.net/v1/dotnet-install.ps1" + $DotNetInstallScriptPath = "$DotNetInstallScriptRoot/dotnet-install.ps1" +} + +if (-not (Test-Path $DotNetInstallScriptPath)) { + Invoke-WebRequest -Uri $DownloadUri -OutFile $DotNetInstallScriptPath -UseBasicParsing + if ($IsMacOS -or $IsLinux) { + chmod +x $DotNetInstallScriptPath + } +} + +if ($PSCmdlet.ShouldProcess(".NET Core SDK $sdkVersion", "Install")) { + Invoke-Expression -Command "$DotNetInstallScriptPath -Version $sdkVersion $switches" +} else { + Invoke-Expression -Command "$DotNetInstallScriptPath -Version $sdkVersion $switches -DryRun" +} + +$switches += '-Runtime','dotnet' + +$runtimeVersions | Get-Unique |% { + if ($PSCmdlet.ShouldProcess(".NET Core runtime $_", "Install")) { + Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $switches" + } else { + Invoke-Expression -Command "$DotNetInstallScriptPath -Channel $_ $switches -DryRun" + } +} + +if ($PSCmdlet.ShouldProcess("Set DOTNET environment variables to discover these installed runtimes?")) { + & "$PSScriptRoot/Set-EnvVars.ps1" -Variables $envVars -PrependPath $DotNetInstallDir | Out-Null +} diff --git a/build/Set-EnvVars.ps1 b/build/Set-EnvVars.ps1 new file mode 100644 index 000000000..907659a7b --- /dev/null +++ b/build/Set-EnvVars.ps1 @@ -0,0 +1,79 @@ +<# +.SYNOPSIS + Set environment variables in the environment. + Azure Pipeline and CMD environments are considered. +.PARAMETER Variables + A hashtable of variables to be set. +.OUTPUTS + A boolean indicating whether the environment variables can be expected to propagate to the caller's environment. +#> +[CmdletBinding(SupportsShouldProcess=$true)] +Param( + [Parameter(Mandatory=$true, Position=1)] + $Variables, + [string[]]$PrependPath +) + +if ($Variables.Count -eq 0) { + return $true +} + +$cmdInstructions = !$env:TF_BUILD -and !$env:GITHUB_ACTIONS -and $env:PS1UnderCmd -eq '1' +if ($cmdInstructions) { + Write-Warning "Environment variables have been set that will be lost because you're running under cmd.exe" + Write-Host "Environment variables that must be set manually:" -ForegroundColor Blue +} else { + Write-Host "Environment variables set:" -ForegroundColor Blue + $envVars + if ($PrependPath) { + Write-Host "Paths prepended to PATH: $PrependPath" + } +} + +if ($env:TF_BUILD) { + Write-Host "Azure Pipelines detected. Logging commands will be used to propagate environment variables and prepend path." +} + +if ($env:GITHUB_ACTIONS) { + Write-Host "GitHub Actions detected. Logging commands will be used to propagate environment variables and prepend path." +} + +$Variables.GetEnumerator() |% { + Set-Item -Path env:$($_.Key) -Value $_.Value + + # If we're running in a cloud CI, set these environment variables so they propagate. + if ($env:TF_BUILD) { + Write-Host "##vso[task.setvariable variable=$($_.Key);]$($_.Value)" + } + if ($env:GITHUB_ACTIONS) { + Write-Host "::set-env name=$($_.Key)::$($_.Value)" + } + + if ($cmdInstructions) { + Write-Host "SET $($_.Key)=$($_.Value)" + } +} + +$pathDelimiter = ';' +if ($IsMacOS -or $IsLinux) { + $pathDelimiter = ':' +} + +if ($PrependPath) { + $PrependPath |% { + $newPathValue = "$_$pathDelimiter$env:PATH" + Set-Item -Path env:PATH -Value $newPathValue + if ($cmdInstructions) { + Write-Host "SET PATH=$newPathValue" + } + + if ($env:TF_BUILD) { + Write-Host "##vso[task.prependpath]$_" + } + if ($env:GITHUB_ACTIONS) { + Write-Host "::add-path::$_" + } + } +} + +return !$cmdInstructions diff --git a/build/build-and-test.yml b/build/build-and-test.yml new file mode 100644 index 000000000..4638aeb99 --- /dev/null +++ b/build/build-and-test.yml @@ -0,0 +1,280 @@ +parameters: +- name: BuildConfiguration + displayName: Build Configuration + type: string + default: Debug + values: [ 'Debug', 'Release' ] +- name: BuildSolution + displayName: Solution + type: string + default: StyleCopAnalyzers.sln +- name: BuildPlatform + displayName: Platform + type: string + default: Any CPU + +stages: +- stage: Build_${{ parameters.BuildConfiguration }} + displayName: Build ${{ parameters.BuildConfiguration }} + dependsOn: [] + jobs: + - job: Build + steps: + - powershell: .\init.ps1 -NoRestore + displayName: Install .NET Core SDK + + - task: NuGetToolInstaller@0 + displayName: 'Use NuGet 5.3.1' + inputs: + versionSpec: 5.3.1 + + - task: NuGetCommand@2 + displayName: 'NuGet restore' + inputs: + restoreSolution: '${{ parameters.BuildSolution }}' + feedsToUse: 'config' + nugetConfigPath: 'NuGet.config' + + - task: VSBuild@1 + displayName: 'Build solution ${{ parameters.BuildSolution }}' + inputs: + solution: '${{ parameters.BuildSolution }}' + platform: '${{ parameters.BuildPlatform }}' + configuration: '${{ parameters.BuildConfiguration }}' + maximumCpuCount: false # AnnotatorBuildTask doesn't support parallel builds yet + msbuildArgs: '/v:minimal /bl:$(Build.SourcesDirectory)/msbuild.binlog' + +# - task: PowerShell@2 +# displayName: Upload coverage reports to codecov.io +# condition: eq(variables['BuildConfiguration'], 'Debug') +# inputs: +# workingDirectory: '$(Build.SourcesDirectory)/build' +# targetType: inline +# script: | +# $packageConfig = [xml](Get-Content ..\.nuget\packages.config) +# $codecov_version = $packageConfig.SelectSingleNode('/packages/package[@id="Codecov"]').version +# $codecov = "..\packages\Codecov.$codecov_version\tools\codecov.exe" +# &$codecov -f '..\build\OpenCover.Reports\OpenCover.StyleCopAnalyzers.xml' --required + + - task: PublishPipelineArtifact@1 + displayName: Publish build logs + inputs: + targetPath: msbuild.binlog + artifact: Build logs ${{ parameters.BuildConfiguration }} + condition: failed() + + - task: PublishPipelineArtifact@1 + displayName: Publish solution packages + inputs: + targetPath: $(Build.SourcesDirectory)/packages + artifact: slnPackages-${{ parameters.BuildConfiguration }} + + - task: PublishPipelineArtifact@1 + displayName: Publish build output (Test C# 6) + inputs: + targetPath: $(Build.SourcesDirectory)/StyleCop.Analyzers/StyleCop.Analyzers.Test/bin + artifact: buildTest-cs6-${{ parameters.BuildConfiguration }} + + - task: PublishPipelineArtifact@1 + displayName: Publish build output (Test C# 7) + inputs: + targetPath: $(Build.SourcesDirectory)/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp7/bin + artifact: buildTest-cs7-${{ parameters.BuildConfiguration }} + + - task: PublishPipelineArtifact@1 + displayName: Publish build output (Test C# 8) + inputs: + targetPath: $(Build.SourcesDirectory)/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp8/bin + artifact: buildTest-cs8-${{ parameters.BuildConfiguration }} + + - task: PublishPipelineArtifact@1 + displayName: Publish build output (Test C# 9) + inputs: + targetPath: $(Build.SourcesDirectory)/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp9/bin + artifact: buildTest-cs9-${{ parameters.BuildConfiguration }} + + - task: PublishPipelineArtifact@1 + displayName: Publish build output (Test C# 10) + inputs: + targetPath: $(Build.SourcesDirectory)/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp10/bin + artifact: buildTest-cs10-${{ parameters.BuildConfiguration }} + + - task: PublishPipelineArtifact@1 + displayName: Publish build output (Test C# 11) + inputs: + targetPath: $(Build.SourcesDirectory)/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp11/bin + artifact: buildTest-cs11-${{ parameters.BuildConfiguration }} + + - task: PublishPipelineArtifact@1 + displayName: Publish build output (Test C# 12) + inputs: + targetPath: $(Build.SourcesDirectory)/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp12/bin + artifact: buildTest-cs12-${{ parameters.BuildConfiguration }} + +- stage: Test_CSharp_6_${{ parameters.BuildConfiguration }} + displayName: Test C# 6 ${{ parameters.BuildConfiguration }} + dependsOn: [ 'Build_${{ parameters.BuildConfiguration }}' ] + jobs: + - template: test.yml + parameters: + BuildConfiguration: ${{ parameters.BuildConfiguration }} + BuildSolution: ${{ parameters.BuildSolution }} + BuildPlatform: ${{ parameters.BuildPlatform }} + LangVersion: '6' + FrameworkVersion: 'net452' + +- stage: Test_CSharp_7_${{ parameters.BuildConfiguration }} + displayName: Test C# 7 ${{ parameters.BuildConfiguration }} + dependsOn: [ 'Build_${{ parameters.BuildConfiguration }}' ] + jobs: + - template: test.yml + parameters: + BuildConfiguration: ${{ parameters.BuildConfiguration }} + BuildSolution: ${{ parameters.BuildSolution }} + BuildPlatform: ${{ parameters.BuildPlatform }} + LangVersion: '7' + FrameworkVersion: 'net46' + +- stage: Test_CSharp_8_${{ parameters.BuildConfiguration }} + displayName: Test C# 8 ${{ parameters.BuildConfiguration }} + dependsOn: [ 'Build_${{ parameters.BuildConfiguration }}' ] + jobs: + - template: test.yml + parameters: + BuildConfiguration: ${{ parameters.BuildConfiguration }} + BuildSolution: ${{ parameters.BuildSolution }} + BuildPlatform: ${{ parameters.BuildPlatform }} + LangVersion: '8' + FrameworkVersion: 'net472' + +- stage: Test_CSharp_9_${{ parameters.BuildConfiguration }} + displayName: Test C# 9 ${{ parameters.BuildConfiguration }} + dependsOn: [ 'Build_${{ parameters.BuildConfiguration }}' ] + jobs: + - template: test.yml + parameters: + BuildConfiguration: ${{ parameters.BuildConfiguration }} + BuildSolution: ${{ parameters.BuildSolution }} + BuildPlatform: ${{ parameters.BuildPlatform }} + LangVersion: '9' + FrameworkVersion: 'net472' + +- stage: Test_CSharp_10_${{ parameters.BuildConfiguration }} + displayName: Test C# 10 ${{ parameters.BuildConfiguration }} + dependsOn: [ 'Build_${{ parameters.BuildConfiguration }}' ] + jobs: + - template: test.yml + parameters: + BuildConfiguration: ${{ parameters.BuildConfiguration }} + BuildSolution: ${{ parameters.BuildSolution }} + BuildPlatform: ${{ parameters.BuildPlatform }} + LangVersion: '10' + FrameworkVersion: 'net472' + +- stage: Test_CSharp_11_${{ parameters.BuildConfiguration }} + displayName: Test C# 11 ${{ parameters.BuildConfiguration }} + dependsOn: [ 'Build_${{ parameters.BuildConfiguration }}' ] + jobs: + - template: test.yml + parameters: + BuildConfiguration: ${{ parameters.BuildConfiguration }} + BuildSolution: ${{ parameters.BuildSolution }} + BuildPlatform: ${{ parameters.BuildPlatform }} + LangVersion: '11' + FrameworkVersion: 'net472' + +- stage: Test_CSharp_12_${{ parameters.BuildConfiguration }} + displayName: Test C# 12 ${{ parameters.BuildConfiguration }} + dependsOn: [ 'Build_${{ parameters.BuildConfiguration }}' ] + jobs: + - template: test.yml + parameters: + BuildConfiguration: ${{ parameters.BuildConfiguration }} + BuildSolution: ${{ parameters.BuildSolution }} + BuildPlatform: ${{ parameters.BuildPlatform }} + LangVersion: '12' + FrameworkVersion: 'net472' + +- stage: Publish_Code_Coverage_${{ parameters.BuildConfiguration }} + displayName: Publish Code Coverage + condition: eq('${{ parameters.BuildConfiguration }}', 'Debug') + dependsOn: + - Test_CSharp_6_${{ parameters.BuildConfiguration }} + - Test_CSharp_7_${{ parameters.BuildConfiguration }} + - Test_CSharp_8_${{ parameters.BuildConfiguration }} + - Test_CSharp_9_${{ parameters.BuildConfiguration }} + - Test_CSharp_10_${{ parameters.BuildConfiguration }} + - Test_CSharp_11_${{ parameters.BuildConfiguration }} + - Test_CSharp_12_${{ parameters.BuildConfiguration }} + jobs: + - job: WrapUp + steps: + - checkout: self + fetchDepth: 0 # avoid shallow clone so nbgv can do its work. + clean: true + - task: DownloadPipelineArtifact@2 + displayName: 🔻 Download solution packages + continueOnError: true + inputs: + buildType: current + artifactName: slnPackages-${{ parameters.BuildConfiguration }} + targetPath: $(Build.SourcesDirectory)/packages + - download: current + artifact: coverageResults-cs6 + displayName: 🔻 Download C# 6 code coverage results + continueOnError: true + - download: current + artifact: coverageResults-cs7 + displayName: 🔻 Download C# 7 code coverage results + continueOnError: true + - download: current + artifact: coverageResults-cs8 + displayName: 🔻 Download C# 8 code coverage results + continueOnError: true + - download: current + artifact: coverageResults-cs9 + displayName: 🔻 Download C# 9 code coverage results + continueOnError: true + - download: current + artifact: coverageResults-cs10 + displayName: 🔻 Download C# 10 code coverage results + continueOnError: true + - download: current + artifact: coverageResults-cs11 + displayName: 🔻 Download C# 11 code coverage results + continueOnError: true + - download: current + artifact: coverageResults-cs12 + displayName: 🔻 Download C# 12 code coverage results + continueOnError: true + - task: PowerShell@2 + displayName: ⚙ Merge coverage + timeoutInMinutes: 20 + inputs: + workingDirectory: $(Build.SourcesDirectory) + targetType: inline + script: | + $packageConfig = [xml](Get-Content .\.nuget\packages.config) + $packages_folder = '.\packages' + $reportgenerator_version = $packageConfig.SelectSingleNode('/packages/package[@id="ReportGenerator"]').version + $report_generator = "$packages_folder\ReportGenerator.$reportgenerator_version\tools\net47\ReportGenerator.exe" + &$report_generator -targetdir:$(Pipeline.Workspace)/coverageResults-final -reporttypes:Cobertura "-reports:$(Pipeline.Workspace)/coverageResults-*/OpenCover.*.xml" + + - task: PowerShell@2 + displayName: Public code coverage to codecov.io + timeoutInMinutes: 20 + inputs: + workingDirectory: $(Build.SourcesDirectory) + targetType: inline + script: | + $packageConfig = [xml](Get-Content .\.nuget\packages.config) + $packages_folder = '.\packages' + $codecov_version = $packageConfig.SelectSingleNode('/packages/package[@id="CodecovUploader"]').version + $codecov = "$packages_folder\CodecovUploader.$codecov_version\tools\codecov.exe" + &$codecov -f '$(Pipeline.Workspace)/coverageResults-final/Cobertura.xml' --required + + - task: PublishPipelineArtifact@1 + displayName: Publish merged coverage + inputs: + targetPath: $(Pipeline.Workspace)/coverageResults-final + artifact: coverageResults-final$(System.JobAttempt)-${{ parameters.BuildConfiguration }} diff --git a/build/build.ps1 b/build/build.ps1 index ac9772ce5..4603fb54a 100644 --- a/build/build.ps1 +++ b/build/build.ps1 @@ -1,22 +1,13 @@ param ( [switch]$Debug, [string]$VisualStudioVersion = '15.0', - [switch]$SkipKeyCheck, [string]$Verbosity = 'minimal', [string]$Logger, [switch]$Incremental ) # build the solution -$SolutionPath = "..\StyleCopAnalyzers.sln" - -# make sure the script was run from the expected path -if (!(Test-Path $SolutionPath)) { - $host.ui.WriteErrorLine('The script was run from an invalid working directory.') - exit 1 -} - -. .\version.ps1 +$SolutionPath = Resolve-Path "$PSScriptRoot\..\StyleCopAnalyzers.sln" If ($Debug) { $BuildConfig = 'Debug' @@ -24,17 +15,12 @@ If ($Debug) { $BuildConfig = 'Release' } -If ($Version.Contains('-')) { - $KeyConfiguration = 'Dev' -} Else { - $KeyConfiguration = 'Final' -} - # download nuget.exe if necessary -$nuget = '..\.nuget\nuget.exe' +$nugetDir = "$PSScriptRoot\..\.nuget" +$nuget = "$nugetDir\nuget.exe" If (-not (Test-Path $nuget)) { - If (-not (Test-Path '..\.nuget')) { - mkdir '..\.nuget' + If (-not (Test-Path $nugetDir)) { + mkdir $nugetDir } $nugetSource = 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe' @@ -75,43 +61,8 @@ If ($Incremental) { $Target = 'rebuild' } -&$msbuild '/nologo' '/m' '/nr:false' "/t:$Target" $LoggerArgument "/verbosity:$Verbosity" "/p:Configuration=$BuildConfig" "/p:VisualStudioVersion=$VisualStudioVersion" "/p:KeyConfiguration=$KeyConfiguration" $SolutionPath +&$msbuild '/nologo' '/m' '/nr:false' "/t:$Target" $LoggerArgument "/verbosity:$Verbosity" "/p:Configuration=$BuildConfig" "/p:VisualStudioVersion=$VisualStudioVersion" $SolutionPath If (-not $?) { $host.ui.WriteErrorLine('Build failed, aborting!') exit $LASTEXITCODE } - -if ($Incremental) { - # Skip NuGet validation and copying packages to the output directory - exit 0 -} - -# By default, do not create a NuGet package unless the expected strong name key files were used -if (-not $SkipKeyCheck) { - . .\keys.ps1 - - foreach ($pair in $Keys.GetEnumerator()) { - $assembly = Resolve-FullPath -Path "..\StyleCop.Analyzers\StyleCop.Analyzers.CodeFixes\bin\$BuildConfig\$($pair.Key)\StyleCop.Analyzers.dll" - # Run the actual check in a separate process or the current process will keep the assembly file locked - powershell -Command ".\check-key.ps1 -Assembly '$assembly' -ExpectedKey '$($pair.Value)' -Build '$($pair.Key)'" - If (-not $?) { - $host.ui.WriteErrorLine('Failed to verify strong name key for build, aborting!') - exit $LASTEXITCODE - } - - $assembly = Resolve-FullPath -Path "..\StyleCop.Analyzers\StyleCop.Analyzers.CodeFixes\bin\$BuildConfig\$($pair.Key)\StyleCop.Analyzers.CodeFixes.dll" - # Run the actual check in a separate process or the current process will keep the assembly file locked - powershell -Command ".\check-key.ps1 -Assembly '$assembly' -ExpectedKey '$($pair.Value)' -Build '$($pair.Key)'" - If (-not $?) { - $host.ui.WriteErrorLine('Failed to verify strong name key for build, aborting!') - exit $LASTEXITCODE - } - } -} - -if (-not (Test-Path 'nuget')) { - mkdir "nuget" -} - -Copy-Item "..\StyleCop.Analyzers\StyleCop.Analyzers.CodeFixes\bin\$BuildConfig\StyleCop.Analyzers.$Version.nupkg" 'nuget' -Copy-Item "..\StyleCop.Analyzers\StyleCop.Analyzers.CodeFixes\bin\$BuildConfig\StyleCop.Analyzers.$Version.symbols.nupkg" 'nuget' diff --git a/build/check-key.ps1 b/build/check-key.ps1 deleted file mode 100644 index b92a9cdcc..000000000 --- a/build/check-key.ps1 +++ /dev/null @@ -1,31 +0,0 @@ -param( - [string]$Assembly, - [string]$ExpectedKey, - [string]$Build = $null -) - -function Get-PublicKeyToken() { - param([string]$assembly = $null) - if ($assembly) { - $bytes = $null - $bytes = [System.Reflection.Assembly]::ReflectionOnlyLoadFrom($assembly).GetName().GetPublicKeyToken() - if ($bytes) { - $key = "" - for ($i=0; $i -lt $bytes.Length; $i++) { - $key += "{0:x2}" -f $bytes[$i] - } - - $key - } - } -} - -if (-not $Build) { - $Build = $Assembly -} - -$actual = Get-PublicKeyToken -assembly $Assembly -if ($actual -ne $ExpectedKey) { - $host.ui.WriteErrorLine("Invalid publicKeyToken for '$Build'; expected '$ExpectedKey' but found '$actual'") - exit 1 -} diff --git a/build/keys.ps1 b/build/keys.ps1 deleted file mode 100644 index cb305ddbe..000000000 --- a/build/keys.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -# Note: these values may only change during major release - -If ($Version.Contains('-')) { - - # Use the development keys - $Keys = @{ - 'netstandard1.1' = '97d9e3aa481481c8' - 'net452' = '97d9e3aa481481c8' - } - -} Else { - - # Use the final release keys - $Keys = @{ - 'netstandard1.1' = 'cfeb5dbada5e1c25' - 'net452' = 'cfeb5dbada5e1c25' - } - -} - -function Resolve-FullPath() { - param([string]$Path) - [System.IO.Path]::GetFullPath((Join-Path (pwd) $Path)) -} diff --git a/build/keys/StyleCopAnalyzers.dev.snk b/build/keys/StyleCopAnalyzers.dev.snk deleted file mode 100644 index 91967d7fd..000000000 Binary files a/build/keys/StyleCopAnalyzers.dev.snk and /dev/null differ diff --git a/build/opencover-report.ps1 b/build/opencover-report.ps1 index a3d179b24..4f2b0b617 100644 --- a/build/opencover-report.ps1 +++ b/build/opencover-report.ps1 @@ -2,7 +2,8 @@ param ( [switch]$Debug, [switch]$NoBuild, [switch]$NoReport, - [switch]$AppVeyor + [switch]$AppVeyor, + [switch]$Azure ) If (-not $NoBuild) { @@ -29,121 +30,166 @@ $packageConfig = [xml](Get-Content ..\.nuget\packages.config) $opencover_version = $packageConfig.SelectSingleNode('/packages/package[@id="OpenCover"]').version $reportgenerator_version = $packageConfig.SelectSingleNode('/packages/package[@id="ReportGenerator"]').version $xunitrunner_version = $packageConfig.SelectSingleNode('/packages/package[@id="xunit.runner.console"]').version -$pdb2pdb_version = $packageConfig.SelectSingleNode('/packages/package[@id="Microsoft.DiaSymReader.Pdb2Pdb"]').version $packages_folder = '..\packages' $opencover_console = "$packages_folder\OpenCover.$opencover_version\tools\OpenCover.Console.exe" -$xunit_runner_console = "$packages_folder\xunit.runner.console.$xunitrunner_version\tools\xunit.console.x86.exe" +$xunit_runner_console_net452 = "$packages_folder\xunit.runner.console.$xunitrunner_version\tools\net452\xunit.console.x86.exe" +$xunit_runner_console_net46 = "$packages_folder\xunit.runner.console.$xunitrunner_version\tools\net46\xunit.console.x86.exe" +$xunit_runner_console_net472 = "$packages_folder\xunit.runner.console.$xunitrunner_version\tools\net472\xunit.console.x86.exe" $report_generator = "$packages_folder\ReportGenerator.$reportgenerator_version\tools\ReportGenerator.exe" -$pdb2pdb = "$packages_folder\Microsoft.DiaSymReader.Pdb2Pdb.$pdb2pdb_version\tools\Pdb2Pdb.exe" $report_folder = '.\OpenCover.Reports' -$symbols_folder = '.\OpenCover.Symbols' $target_dll = "..\StyleCop.Analyzers\StyleCop.Analyzers.Test\bin\$Configuration\net452\StyleCop.Analyzers.Test.dll" $target_dll_csharp7 = "..\StyleCop.Analyzers\StyleCop.Analyzers.Test.CSharp7\bin\$Configuration\net46\StyleCop.Analyzers.Test.CSharp7.dll" +$target_dll_csharp8 = "..\StyleCop.Analyzers\StyleCop.Analyzers.Test.CSharp8\bin\$Configuration\net472\StyleCop.Analyzers.Test.CSharp8.dll" +$target_dll_csharp9 = "..\StyleCop.Analyzers\StyleCop.Analyzers.Test.CSharp9\bin\$Configuration\net472\StyleCop.Analyzers.Test.CSharp9.dll" +$target_dll_csharp10 = "..\StyleCop.Analyzers\StyleCop.Analyzers.Test.CSharp10\bin\$Configuration\net472\StyleCop.Analyzers.Test.CSharp10.dll" +$target_dll_csharp11 = "..\StyleCop.Analyzers\StyleCop.Analyzers.Test.CSharp11\bin\$Configuration\net472\StyleCop.Analyzers.Test.CSharp11.dll" +$target_dll_csharp12 = "..\StyleCop.Analyzers\StyleCop.Analyzers.Test.CSharp12\bin\$Configuration\net472\StyleCop.Analyzers.Test.CSharp12.dll" -If (Test-Path $symbols_folder) { - Remove-Item -Recurse -Force $symbols_folder +If (Test-Path $report_folder) { + Remove-Item -Recurse -Force $report_folder } -$symbols_folder_csharp6 = Join-Path $symbols_folder 'CSharp6' -$symbols_folder_csharp7 = Join-Path $symbols_folder 'CSharp7' -mkdir $symbols_folder | Out-Null -mkdir $symbols_folder_csharp6 | Out-Null -mkdir $symbols_folder_csharp7 | Out-Null - -function Convert-Coverage-Pdb() { - param ( - [string]$assembly, - [string]$outputDir - ) - $sourceDir = [IO.Path]::GetDirectoryName($assembly) - $outputName = [IO.Path]::ChangeExtension([IO.Path]::GetFileName($assembly), 'pdb') - $sourcePdb = Join-Path $sourceDir $outputName - $output = Join-Path $outputDir $outputName - if (Test-Path $sourcePdb) { - &$pdb2pdb $assembly /out $output - - # Workaround for https://github.com/OpenCover/opencover/issues/800 - Remove-Item $sourcePdb - Copy-Item $assembly $outputDir - } +mkdir $report_folder | Out-Null + +$register_mode = 'user' +If ($AppVeyor) { + $AppVeyorArg = '-appveyor' + $register_mode = 'Path32' +} ElseIf ($Azure) { + $register_mode = 'Path32' } -function Extract-Coverage-Pdb() { - param ( - [string]$assembly, - [string]$outputDir - ) - $sourceDir = [IO.Path]::GetDirectoryName($assembly) - $outputName = [IO.Path]::ChangeExtension([IO.Path]::GetFileName($assembly), 'pdb') - $intermediatePdb = Join-Path $sourceDir $outputName - $output = Join-Path $outputDir $outputName - if (-not (Test-Path $output)) { - &$pdb2pdb $assembly /out $intermediatePdb /extract - if (Test-Path $intermediatePdb) { - &$pdb2pdb $assembly /pdb $intermediatePdb /out $output - Remove-Item $intermediatePdb - - # Workaround for https://github.com/OpenCover/opencover/issues/800 - Copy-Item $assembly $outputDir - } - } +$exitCode = 0 + +&$opencover_console ` + -register:$register_mode ` + -threshold:1 -oldStyle ` + -returntargetcode ` + -hideskipped:All ` + -filter:"+[StyleCop*]*" ` + -excludebyattribute:*.ExcludeFromCodeCoverage* ` + -excludebyfile:*\*Designer.cs ` + -output:"$report_folder\OpenCover.StyleCopAnalyzers.xml" ` + -target:"$xunit_runner_console_net452" ` + -targetargs:"$target_dll -noshadow $AppVeyorArg -xml StyleCopAnalyzers.xunit.xml" + +If (($AppVeyor -or $Azure) -and -not $?) { + $host.UI.WriteErrorLine('Build failed; coverage analysis may be incomplete.') + $exitCode = $LASTEXITCODE } -$target_dir = [IO.Path]::GetDirectoryName($target_dll) -Get-ChildItem $target_dir -Filter *.dll | Foreach-Object { Convert-Coverage-Pdb -assembly $_.FullName -outputDir $symbols_folder_csharp6 } -Get-ChildItem $target_dir -Filter *.dll | Foreach-Object { Extract-Coverage-Pdb -assembly $_.FullName -outputDir $symbols_folder_csharp6 } +&$opencover_console ` + -register:$register_mode ` + -threshold:1 -oldStyle ` + -returntargetcode ` + -hideskipped:All ` + -filter:"+[StyleCop*]*" ` + -excludebyattribute:*.ExcludeFromCodeCoverage* ` + -excludebyfile:*\*Designer.cs ` + -output:"$report_folder\OpenCover.StyleCopAnalyzers.xml" ` + -mergebyhash -mergeoutput ` + -target:"$xunit_runner_console_net46" ` + -targetargs:"$target_dll_csharp7 -noshadow $AppVeyorArg -xml StyleCopAnalyzers.CSharp7.xunit.xml" -$target_dir = [IO.Path]::GetDirectoryName($target_dll_csharp7) -Get-ChildItem $target_dir -Filter *.dll | Foreach-Object { Convert-Coverage-Pdb -assembly $_.FullName -outputDir $symbols_folder_csharp7 } -Get-ChildItem $target_dir -Filter *.dll | Foreach-Object { Extract-Coverage-Pdb -assembly $_.FullName -outputDir $symbols_folder_csharp7 } +If (($AppVeyor -or $Azure) -and -not $?) { + $host.UI.WriteErrorLine('Build failed; coverage analysis may be incomplete.') + $exitCode = $LASTEXITCODE +} -If (Test-Path $report_folder) { - Remove-Item -Recurse -Force $report_folder +&$opencover_console ` + -register:$register_mode ` + -threshold:1 -oldStyle ` + -returntargetcode ` + -hideskipped:All ` + -filter:"+[StyleCop*]*" ` + -excludebyattribute:*.ExcludeFromCodeCoverage* ` + -excludebyfile:*\*Designer.cs ` + -output:"$report_folder\OpenCover.StyleCopAnalyzers.xml" ` + -mergebyhash -mergeoutput ` + -target:"$xunit_runner_console_net472" ` + -targetargs:"$target_dll_csharp8 -noshadow $AppVeyorArg -xml StyleCopAnalyzers.CSharp8.xunit.xml" + +If (($AppVeyor -or $Azure) -and -not $?) { + $host.UI.WriteErrorLine('Build failed; coverage analysis may be incomplete.') + $exitCode = $LASTEXITCODE } -mkdir $report_folder | Out-Null +&$opencover_console ` + -register:$register_mode ` + -threshold:1 -oldStyle ` + -returntargetcode ` + -hideskipped:All ` + -filter:"+[StyleCop*]*" ` + -excludebyattribute:*.ExcludeFromCodeCoverage* ` + -excludebyfile:*\*Designer.cs ` + -output:"$report_folder\OpenCover.StyleCopAnalyzers.xml" ` + -mergebyhash -mergeoutput ` + -target:"$xunit_runner_console_net472" ` + -targetargs:"$target_dll_csharp9 -noshadow $AppVeyorArg -xml StyleCopAnalyzers.CSharp9.xunit.xml" -If ($AppVeyor) { - $AppVeyorArg = '-appveyor' +If (($AppVeyor -or $Azure) -and -not $?) { + $host.UI.WriteErrorLine('Build failed; coverage analysis may be incomplete.') + $exitCode = $LASTEXITCODE } &$opencover_console ` - -register:user ` + -register:$register_mode ` + -threshold:1 -oldStyle ` -returntargetcode ` -hideskipped:All ` -filter:"+[StyleCop*]*" ` -excludebyattribute:*.ExcludeFromCodeCoverage* ` -excludebyfile:*\*Designer.cs ` - -searchdirs:"$symbols_folder_csharp6" ` -output:"$report_folder\OpenCover.StyleCopAnalyzers.xml" ` - -target:"$xunit_runner_console" ` - -targetargs:"$target_dll -noshadow $AppVeyorArg" + -mergebyhash -mergeoutput ` + -target:"$xunit_runner_console_net472" ` + -targetargs:"$target_dll_csharp10 -noshadow $AppVeyorArg -xml StyleCopAnalyzers.CSharp10.xunit.xml" -If ($AppVeyor -and -not $?) { - $host.UI.WriteErrorLine('Build failed; coverage analysis aborted.') - Exit $LASTEXITCODE +If (($AppVeyor -or $Azure) -and -not $?) { + $host.UI.WriteErrorLine('Build failed; coverage analysis may be incomplete.') + $exitCode = $LASTEXITCODE } &$opencover_console ` - -register:user ` + -register:$register_mode ` + -threshold:1 -oldStyle ` -returntargetcode ` -hideskipped:All ` -filter:"+[StyleCop*]*" ` -excludebyattribute:*.ExcludeFromCodeCoverage* ` -excludebyfile:*\*Designer.cs ` - -searchdirs:"$symbols_folder_csharp7" ` -output:"$report_folder\OpenCover.StyleCopAnalyzers.xml" ` -mergebyhash -mergeoutput ` - -target:"$xunit_runner_console" ` - -targetargs:"$target_dll_csharp7 -noshadow $AppVeyorArg" + -target:"$xunit_runner_console_net472" ` + -targetargs:"$target_dll_csharp11 -noshadow $AppVeyorArg -xml StyleCopAnalyzers.CSharp11.xunit.xml" -If ($AppVeyor -and -not $?) { - $host.UI.WriteErrorLine('Build failed; coverage analysis aborted.') - Exit $LASTEXITCODE +If (($AppVeyor -or $Azure) -and -not $?) { + $host.UI.WriteErrorLine('Build failed; coverage analysis may be incomplete.') + $exitCode = $LASTEXITCODE +} + +&$opencover_console ` + -register:$register_mode ` + -threshold:1 -oldStyle ` + -returntargetcode ` + -hideskipped:All ` + -filter:"+[StyleCop*]*" ` + -excludebyattribute:*.ExcludeFromCodeCoverage* ` + -excludebyfile:*\*Designer.cs ` + -output:"$report_folder\OpenCover.StyleCopAnalyzers.xml" ` + -mergebyhash -mergeoutput ` + -target:"$xunit_runner_console_net472" ` + -targetargs:"$target_dll_csharp12 -noshadow $AppVeyorArg -xml StyleCopAnalyzers.CSharp12.xunit.xml" + +If (($AppVeyor -or $Azure) -and -not $?) { + $host.UI.WriteErrorLine('Build failed; coverage analysis may be incomplete.') + $exitCode = $LASTEXITCODE } If (-not $NoReport) { &$report_generator -targetdir:$report_folder -reports:$report_folder\OpenCover.*.xml $host.UI.WriteLine("Open $report_folder\index.htm to see code coverage results.") } + +Exit $exitCode diff --git a/build/push.ps1 b/build/push.ps1 deleted file mode 100644 index dfd8714e8..000000000 --- a/build/push.ps1 +++ /dev/null @@ -1,8 +0,0 @@ -. .\version.ps1 - -If ($Version.EndsWith('-dev')) { - $host.ui.WriteErrorLine("Cannot push development version '$Version' to NuGet.") - Exit 1 -} - -..\.nuget\NuGet.exe 'push' ".\nuget\StyleCop.Analyzers.$Version.nupkg" -Source 'https://www.nuget.org/api/v2/package' diff --git a/build/test.yml b/build/test.yml new file mode 100644 index 000000000..e1491acdf --- /dev/null +++ b/build/test.yml @@ -0,0 +1,108 @@ +parameters: +- name: BuildConfiguration + displayName: Build Configuration + type: string + default: Debug + values: [ 'Debug', 'Release' ] +- name: LangVersion + displayName: C# Language Version + type: string + default: '6' + values: [ '6', '7', '8', '9', '10', '11', '12' ] +- name: FrameworkVersion + displayName: .NET Framework Version + type: string + default: 'net472' + values: [ 'net452', 'net46', 'net472' ] +- name: BuildSolution + displayName: Solution + type: string + default: StyleCopAnalyzers.sln +- name: BuildPlatform + displayName: Platform + type: string + default: Any CPU + +jobs: +- job: Test_CSharp_${{ parameters.LangVersion }} + displayName: Test C# ${{ parameters.LangVersion }} + steps: + - powershell: .\init.ps1 -NoRestore + displayName: Install .NET Core SDK + + - task: NuGetToolInstaller@0 + displayName: 'Use NuGet 5.3.1' + inputs: + versionSpec: 5.3.1 + + - task: DownloadPipelineArtifact@2 + displayName: 🔻 Download solution packages + continueOnError: true + inputs: + buildType: current + artifactName: slnPackages-${{ parameters.BuildConfiguration }} + targetPath: $(Build.SourcesDirectory)/packages + + - ${{ if eq(parameters.LangVersion, '6') }}: + - task: DownloadPipelineArtifact@2 + displayName: 🔻 Download build output + continueOnError: true + inputs: + buildType: current + artifactName: buildTest-cs${{ parameters.LangVersion }}-${{ parameters.BuildConfiguration }} + targetPath: $(Build.SourcesDirectory)/StyleCop.Analyzers/StyleCop.Analyzers.Test/bin + + - ${{ if ne(parameters.LangVersion, '6') }}: + - task: DownloadPipelineArtifact@2 + displayName: 🔻 Download build output + continueOnError: true + inputs: + buildType: current + artifactName: buildTest-cs${{ parameters.LangVersion }}-${{ parameters.BuildConfiguration }} + targetPath: $(Build.SourcesDirectory)/StyleCop.Analyzers/StyleCop.Analyzers.Test.CSharp${{ parameters.LangVersion }}/bin + + - task: PowerShell@2 + displayName: 'Run tests' + timeoutInMinutes: 20 + inputs: + workingDirectory: '$(Build.SourcesDirectory)/build' + targetType: inline + script: | + $packageConfig = [xml](Get-Content ..\.nuget\packages.config) + $opencover_version = $packageConfig.SelectSingleNode('/packages/package[@id="OpenCover"]').version + $xunitrunner_version = $packageConfig.SelectSingleNode('/packages/package[@id="xunit.runner.console"]').version + + $packages_folder = '..\packages' + $opencover_console = "$packages_folder\OpenCover.$opencover_version\tools\OpenCover.Console.exe" + $xunit_runner_console_${{ parameters.FrameworkVersion }} = "$packages_folder\xunit.runner.console.$xunitrunner_version\tools\${{ parameters.FrameworkVersion }}\xunit.console.x86.exe" + $report_folder = '.\OpenCover.Reports' + mkdir $report_folder + $target_dll_name = If ('${{ parameters.LangVersion }}' -Eq '6') { "StyleCop.Analyzers.Test" } Else { "StyleCop.Analyzers.Test.CSharp${{ parameters.LangVersion }}" } + $target_dll_csharp${{ parameters.LangVersion }} = "..\StyleCop.Analyzers\$target_dll_name\bin\${{ parameters.BuildConfiguration }}\${{ parameters.FrameworkVersion }}\$target_dll_name.dll" + &$opencover_console ` + -register:Path32 ` + -threshold:1 -oldStyle ` + -returntargetcode ` + -hideskipped:All ` + -filter:"+[StyleCop*]*" ` + -excludebyattribute:*.ExcludeFromCodeCoverage* ` + -excludebyfile:*\*Designer.cs ` + -output:"$report_folder\OpenCover.StyleCopAnalyzers.CSharp${{ parameters.LangVersion }}.xml" ` + -target:"$xunit_runner_console_${{ parameters.FrameworkVersion }}" ` + -targetargs:"$target_dll_csharp${{ parameters.LangVersion }} -noshadow -xml StyleCopAnalyzers.CSharp${{ parameters.LangVersion }}.xunit.xml" + + - task: PublishTestResults@2 + displayName: 📢 Publish test results + condition: always() + inputs: + testResultsFormat: xUnit + testResultsFiles: 'build/*.xml' + mergeTestResults: true + testRunTitle: 'C# ${{ parameters.LangVersion }} ${{ parameters.BuildConfiguration }}' + + - ${{ if eq(parameters.BuildConfiguration, 'Debug') }}: + - task: PublishPipelineArtifact@1 + displayName: Publish code coverage + inputs: + targetPath: $(Build.SourcesDirectory)/build/OpenCover.Reports + artifact: coverageResults-cs${{ parameters.LangVersion }} diff --git a/build/version.ps1 b/build/version.ps1 deleted file mode 100644 index 769d1551c..000000000 --- a/build/version.ps1 +++ /dev/null @@ -1 +0,0 @@ -$Version = "1.1.0-dev" diff --git a/documentation/Configuration.md b/documentation/Configuration.md index 1c947da54..8f0ce75b0 100644 --- a/documentation/Configuration.md +++ b/documentation/Configuration.md @@ -14,6 +14,8 @@ StyleCop Analyzers is configured using two separate mechanisms: code analysis ru Code analysis rule sets are the standard way to configure most diagnostic analyzers within Visual Studio. Information about creating and customizing these files can be found in the [Using Rule Sets to Group Code Analysis Rules](https://docs.microsoft.com/visualstudio/code-quality/using-rule-sets-to-group-code-analysis-rules) documentation on docs.microsoft.com. +An example rule set file containing the default StyleCop Analyzers configuration is available at . + ## Getting Started with **stylecop.json** The easiest way to add a **stylecop.json** configuration file to a new project is using a code fix provided by the project. To invoke the code fix, open any file where SA1633 is reported¹ and press Ctrl+. to bring up the Quick Fix menu. From the menu, select **Add StyleCop settings file to the project**. @@ -70,7 +72,7 @@ The following properties are used to configure basic indentation in StyleCop Ana > :bulb: When working in Visual Studio, the IDE will not automatically adjust editor settings according to the values in > **stylecop.json**. To provide this functionality as well, we recommend duplicating the basic indentation settings in a > [**.editorconfig**](http://editorconfig.org/) file. Users of the [EditorConfig](https://visualstudiogallery.msdn.microsoft.com/c8bccfe2-650c-4b42-bc5c-845e21f96328) -> extension for Visual Studio will no need to update their C# indentation settings in order to match your project style. +> extension for Visual Studio will not need to update their C# indentation settings in order to match your project style. ## Spacing Rules @@ -314,6 +316,64 @@ The following example shows a settings file which allows the common prefixes as } ``` +### Namespace Components + +The following property is used to configure allowable namespace components (e.g. ones that start with a lowercase letter). + +| Property | Default Value | Minimum Version | Summary | +| --- | --- | --- | --- | +| `allowedNamespaceComponents` | `[ ]` | 1.2.0 | Specifies namespace components that are allowed to be used. See the example below for more information. | + +The following example shows a settings file which allows namespace components such as `eBay` or `Apple.iPod`. + +```json +{ + "settings": { + "namingRules": { + "allowedNamespaceComponents": [ + "eBay", + "iPod" + ] + } + } +} +``` + + +### Tuple element names + +The following properties are used to configure the behavior of the tuple element name analyzers. + +| Property | Default Value | Minimum Version | Summary | +| --- | --- | --- | --- | +| `includeInferredTupleElementNames` | false | 1.2.0 | Specifies whether inferred tuple element names will be analyzed as well. | +| `tupleElementNameCasing` | "PascalCase" | 1.2.0 | Specifies the casing convention used for tuple element names. | + +The following example shows a settings file which requires tuple element names to use camel case for all tuple elements (including inferred element names). + +```json +{ + "settings": { + "namingRules": { + "includeInferredTupleElementNames": true, + "tupleElementNameCasing" : "camelCase" + } + } +} +``` + +#### Tuple Element Name Casing +The `tupleElementNameCasing` property affects the behavior of the [SA1316 Tuple element names should use correct casing](SA1316.md) analyzer. + +This property has two allowed values, which are described as follows. + +##### `"camelCase"` +In this mode, tuple element names must start with a lowercase letter. + +##### `"PascalCase"` +In this mode, tuple element names must start with an uppercase letter. + + ## Maintainability Rules This section describes the features of maintainability rules which can be configured in **stylecop.json**. Each of the described properties are configured in the `maintainabilityRules` object, which is shown in the following sample file. @@ -360,6 +420,7 @@ The following properties are used to configure layout rules in StyleCop Analyzer | --- | --- | --- | --- | | `newlineAtEndOfFile` | `"allow"` | 1.0.0 | Specifies the handling for newline characters which appear at the end of a file | | `allowConsecutiveUsings` | `true` | 1.1.0 | Specifies if SA1519 will allow consecutive using statements without braces | +| `allowDoWhileOnClosingBrace` | `false` | >1.2.0 | Specifies if SA1500 will allow the `while` expression of a `do`/`while` loop to be on the same line as the closing brace, as is generated by the default code snippet of Visual Studio | ### Lines at End of File @@ -381,6 +442,13 @@ The `allowConsecutiveUsings` property specifies the behavior: This only allows omitting the braces for a using followed by another using statement. A using statement followed by any other type of statement will still require braces to used. +### Do-While Loop Placement + +The behavior of [SA1500](SA1500.md) can be customized regarding the manner in which the `while` expression of a `do`/`while` loop is allowed to be placed. The `allowDoWhileOnClosingBrace` property specified the behavior: + +* `true`: the `while` expression of a `do`/`while` loop may be placed on the same line as the closing brace or on a separate line +* `false`: the `while` expression of a `do`/`while` loop must be on a separate line from the closing brace + ## Documentation Rules This section describes the features of documentation rules which can be configured in **stylecop.json**. Each of the described properties are configured in the `documentationRules` object, which is shown in the following sample file. @@ -630,15 +698,10 @@ Example `.props` file: - $(NuGetPackageRoot)\acme.stylecop\1.0.0 - $(SolutionDir)\packages\acme.stylecop.1.0.0 - $([System.IO.Path]::GetDirectoryName($(MSBuildProjectDirectory)))\packages\acme.stylecop.1.0.0 - - - $(CodeAnalysisRuleSetLocation)\acme.stylecop.ruleset + $(MSBuildThisFileDirectory)..\acme.stylecop.ruleset - + ``` diff --git a/documentation/EnableConfiguration.md b/documentation/EnableConfiguration.md index c19544a8b..7a6884b91 100644 --- a/documentation/EnableConfiguration.md +++ b/documentation/EnableConfiguration.md @@ -4,7 +4,7 @@ At this time, the code fix is not able to fully configure the newly-created **st tracked in bug report [dotnet/roslyn#4655](https://github.com/dotnet/roslyn/issues/4655). In the mean time, users must manually perform the following additional steps after creating the **stylecop.json** file. -In Visual Studio 2017: +In Visual Studio 2017, 2019, and 2022: 1. Select the file in **Solution Explorer**. 2. In the **Properties** window, set the value for **Build Action** to: diff --git a/documentation/KnownChanges.md b/documentation/KnownChanges.md index 05e70ee15..7a6462188 100644 --- a/documentation/KnownChanges.md +++ b/documentation/KnownChanges.md @@ -33,6 +33,7 @@ lists each of these issues, along with a link to the issue where the decision wa | SA1630 | Documentation text should contain whitespace | [#1057](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1057) | | SA1631 | Documentation should meet character percentage | [#1057](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1057) | | SA1632 | Documentation text should meet minimum character length | [#1057](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/1057) | +| SA1644 | DocumentationHeadersMustNotContainBlankLines | [#164](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/164) | | SA1645 | Included documentation file does not exist | [#165](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/165) | | SA1646 | Included documentation XPath does not exist | [#166](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/166) | | SA1647 | Include node does not contain valid file and path | [#167](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/167) | diff --git a/documentation/MaintainabilityRules.md b/documentation/MaintainabilityRules.md index 646d25087..88a807f28 100644 --- a/documentation/MaintainabilityRules.md +++ b/documentation/MaintainabilityRules.md @@ -18,3 +18,4 @@ Identifier | Name | Description [SA1411](SA1411.md) | AttributeConstructorMustNotUseUnnecessaryParenthesis | An attribute declaration does not contain any parameters, yet it still includes parenthesis. [SA1412](SA1412.md) | StoreFilesAsUtf8 | The encoding of the file is not UTF-8 with byte order mark. [SA1413](SA1413.md) | UseTrailingCommasInMultiLineInitializers | A multi-line initializer should use a comma on the last item. +[SA1414](SA1414.md) | TupleTypesInSignaturesShouldHaveElementNames | Tuple types appearing in member declarations should have explicitly named tuple elements. \ No newline at end of file diff --git a/documentation/NamingRules.md b/documentation/NamingRules.md index 2e26b133b..ddfb5d8e4 100644 --- a/documentation/NamingRules.md +++ b/documentation/NamingRules.md @@ -17,4 +17,5 @@ Identifier | Name | Description [SA1311](SA1311.md) | StaticReadonlyFieldsMustBeginWithUpperCaseLetter | The name of a static readonly field does not begin with an upper-case letter. [SA1312](SA1312.md) | VariableNamesMustBeginWithLowerCaseLetter | The name of a variable in C# does not begin with a lower-case letter. [SA1313](SA1313.md) | ParameterNamesMustBeginWithLowerCaseLetter | The name of a parameter in C# does not begin with a lower-case letter. -[SA1314](SA1314.md) | TypeParameterNamesMustBeginWithT | The name of a C# type parameter does not begin with the capital letter T +[SA1314](SA1314.md) | TypeParameterNamesMustBeginWithT | The name of a C# type parameter does not begin with the capital letter T. +[SA1316](SA1316.md) | TupleElementNamesShouldUseCorrectCasing | Element names within a tuple type should have the correct casing. diff --git a/documentation/ReadabilityRules.md b/documentation/ReadabilityRules.md index fdc476c84..14da7a05f 100644 --- a/documentation/ReadabilityRules.md +++ b/documentation/ReadabilityRules.md @@ -41,3 +41,5 @@ Identifier | Name | Description [SA1136](SA1136.md) | EnumValuesShouldBeOnSeparateLines | Multiple enum values are placed on the same line of code. [SA1137](SA1137.md) | ElementsShouldHaveTheSameIndentation | Two sibling elements which each start on their own line have different levels of indentation. [SA1139](SA1139.md) | UseLiteralsSuffixNotationInsteadOfCasting | Use literal suffix notation instead of casting. +[SA1141](SA1141.md) | UseTupleSyntax | Use tuple syntax instead of the underlying ValueTuple implementation type. +[SA1142](SA1142.md) | ReferToTupleElementsByName | An element of a tuple was referenced by its metadata name when an element name is available. diff --git a/documentation/SA0001.md b/documentation/SA0001.md index d0eea84f8..c1ba7c1ef 100644 --- a/documentation/SA0001.md +++ b/documentation/SA0001.md @@ -33,7 +33,7 @@ errors over time. ## How to fix violations -To fix a violation of this rule, enable the XML documentation file as part of the project output. +To fix a violation of this rule, enable the XML documentation file as part of the project output by adding `true` to your project file. **Note:** In some cases, enabling XML documentation output will produce a large number of warnings CS1573, CS1591, and/or CS1712 to be reported. To improve the ability of teams to resolve SA0001 before CS1573, CS1591, and CS1712, diff --git a/documentation/SA1000.md b/documentation/SA1000.md index e13f10ea4..e3b22b272 100644 --- a/documentation/SA1000.md +++ b/documentation/SA1000.md @@ -23,16 +23,17 @@ The spacing around a C# keyword is incorrect. A violation of this rule occurs when the spacing around a keyword is incorrect. -The following C# keywords should always be followed by a single space: `await`, `case`, `catch`, `fixed`, `for`, -`foreach`, `from`, `group`, `if`, `in`, `into`, `join`, `let`, `lock`, `orderby`, `out`, `ref`, `return`, `select`, -`stackalloc`, `switch`, `using`, `var`, `where`, `while`, `yield`. +The following C# keywords should always be followed by a single space: `and`, `await`, `case`, `catch`, `fixed`, `for`, +`foreach`, `from`, `group`, `if`, `in`, `is`, `into`, `join`, `let`, `lock`, `not`, `orderby`, `or`, `out`, `ref`, `return`, `select`, +`switch`, `using`, `var`, `where`, `while`, `yield`. -The following keywords should not be followed by any space: `checked`, `default`, `sizeof`, `typeof`, `unchecked`. +The following keywords should not be followed by any space: `checked`, `default`, `nameof`, `sizeof`, `typeof`, `unchecked`. -The `new` keyword should always be followed by a space, except in the following cases: +The `new` and `stackalloc` keywords should always be followed by a space, except in the following cases: -* The `new` keyword is used to create a new array. In this case there should be no space between the `new` keyword and - the opening array bracket. +* The `new` or `stackalloc` keyword is used to create a new implicitly-typed array. In this case there should be no + space between the keyword and the opening array bracket. +* The `new` keyword is part of implicit object creation (target-typed new). In this case there should be no space between the keyword and the opening parenthesis. * The `new` keyword is part of a generic type constraint. In this case there should be no space between the `new` keyword and the opening parenthesis. diff --git a/documentation/SA1026.md b/documentation/SA1026.md index c4e636fc8..ce32902f1 100644 --- a/documentation/SA1026.md +++ b/documentation/SA1026.md @@ -17,24 +17,25 @@ ## Cause -An implicitly typed new array allocation within a C# code file is not spaced correctly. +An implicitly typed array allocation within a C# code file is not spaced correctly. ## Rule description -A violation of this rule occurs whenever the code contains an implicitly typed new array allocation which is not spaced correctly. Within an implicitly typed new array allocation, there should not be any space or a blank line between the new keyword and the opening array bracket. For example: +A violation of this rule occurs whenever the code contains an implicitly-typed array allocation which is not spaced correctly. Within an implicitly typed array allocation, there should not be any space or a blank line between the `new` or `stackalloc` keyword and the opening array bracket. For example: ```csharp var a = new[] { 1, 10, 100, 1000 }; +Span a = stackalloc[] { 1, 10, 100, 1000 }; ``` ## How to fix violations -To fix a violation of this rule, remove any whitespace between the new keyword and the opening array bracket. +To fix a violation of this rule, remove any whitespace between the `new` or `stackalloc` keyword and the opening array bracket. ## How to suppress violations ```csharp -#pragma warning disable SA1026 // Code should not contain space after new keyword in implicitly typed array allocation +#pragma warning disable SA1026 // Code should not contain space after new or stackalloc keyword in implicitly typed array allocation var ints = new [] { 1, 2, 3 }; -#pragma warning restore SA1026 // Code should not contain space after new keyword in implicitly typed array allocation +#pragma warning restore SA1026 // Code should not contain space after new or stackalloc keyword in implicitly typed array allocation ``` diff --git a/documentation/SA1027.md b/documentation/SA1027.md index 40abf2056..48c7c28b9 100644 --- a/documentation/SA1027.md +++ b/documentation/SA1027.md @@ -55,9 +55,9 @@ To avoid unintentionally changing the behavior of code, this violation is never ```csharp #if DEBUG - This is ignored in debug configurations - #else This is ignored in release configurations + #else + This is ignored in debug configurations #endif ``` diff --git a/documentation/SA1102.md b/documentation/SA1102.md index 091272de9..05b683ba5 100644 --- a/documentation/SA1102.md +++ b/documentation/SA1102.md @@ -27,21 +27,21 @@ A C# query clause does not begin on the same line as the previous clause, or on A violation of this rule occurs when a clause within a query expression does not begin on the same line as the previous clause, or on the line after the query clause. For example: ```c# - object x = select a in b + object x = from num in numbers - from c; + select num; ``` The query clause can correctly be written as: ```c# - object x = select a in b from c; + object x = from num in numbers select num; ``` or: ```c# object x = - select a - in b - from c; + from num + in numbers + select num; ``` ## How to fix violations @@ -52,8 +52,8 @@ To fix a violation of this rule, ensure that each clause in the query expression ```c# #pragma warning disable SA1102 // Query clause should follow previous clause - object x = select a in b + object x = from num in numbers - from c; + select num; #pragma warning restore SA1102 // Query clause should follow previous clause ``` diff --git a/documentation/SA1118.md b/documentation/SA1118.md index 0f7f5971d..a4f7c53a2 100644 --- a/documentation/SA1118.md +++ b/documentation/SA1118.md @@ -30,7 +30,8 @@ cases: * The first parameter may span multiple lines * Anonymous methods (including lambda expressions) may span multiple lines * Invocation expressions may span multiple lines -* Object creation expressions may span multiple lines +* Object and array creation expressions may span multiple lines +* `with` expressions (C# 9) may span multiple lines For example, the following code would violate this rule, since the second parameter spans across multiple lines: diff --git a/documentation/SA1130.md b/documentation/SA1130.md index 7e0dbe70b..75421e241 100644 --- a/documentation/SA1130.md +++ b/documentation/SA1130.md @@ -71,5 +71,5 @@ To fix a violation of this rule, replace the anonymous function with an equivale ```csharp #pragma warning disable SA1130 // Use lambda syntax Action a = delegate { x = 0; }; -#pragma warning restore SA1128 // Use lambda syntax +#pragma warning restore SA1130 // Use lambda syntax ``` diff --git a/documentation/SA1141.md b/documentation/SA1141.md new file mode 100644 index 000000000..03da634a7 --- /dev/null +++ b/documentation/SA1141.md @@ -0,0 +1,54 @@ +## SA1141 + + + + + + + + + + + + + + +
TypeNameSA1141UseTupleSyntax
CheckIdSA1141
CategoryReadability Rules
+ +:memo: This rule is new for StyleCop Analyzers, and was not present in StyleCop Classic. +:memo: This rule is only active for C# 7.0 and higher + +## Cause + +A ValueTuple type declaration was used instead of the preferred tuple language construct. + +## Rule description + +A ValueTuple type declaration was used instead of the preferred tuple language construct. See the documentation on [tuple types](https://docs.microsoft.com/en-us/dotnet/csharp/tuples) for information on how to work with tuples in C# 7. + +For example, the following code would produce a violation of this rule: + +```csharp +ValueTuple x; // SA1141 +``` + +The following code would not produce any violations: + +```csharp +(int, int) x; +``` + +## How to fix violations + +To fix a violation of this rule, use the appropriate tuple type in code instead of the ValueTuple type. + +## How to suppress violations + +```csharp +[SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1141:UseTupleSyntax", Justification = "Reviewed.")] +``` + +```csharp +#pragma warning disable SA1141 // Use tuple syntax +#pragma warning restore SA1141 // Use tuple syntax +``` diff --git a/documentation/SA1142.md b/documentation/SA1142.md new file mode 100644 index 000000000..c435e8939 --- /dev/null +++ b/documentation/SA1142.md @@ -0,0 +1,58 @@ +## SA1142 + + + + + + + + + + + + + + +
TypeNameSA1142ReferToTupleElementsByName
CheckIdSA1142
CategoryReadability Rules
+ +:memo: This rule is new for StyleCop Analyzers, and was not present in StyleCop Classic. +:memo: This rule is only active for C# 7.0 and higher + +## Cause + +An element of a tuple was referenced by its metadata name when an element name is available. + +## Rule description + +An element of a tuple was referenced by its metadata name when an element name is available. See the documentation on [tuple types](https://docs.microsoft.com/en-us/dotnet/csharp/tuples) for information on how to work with tuples in C# 7. + +For example, the following code would produce a violation of this rule: + +```csharp +(int valueA, int valueB) x; + +var y = x.Item1; // SA1142 +``` + +The following code would not produce any violations: + +```csharp +(int valueA, int valueB) x; + +var y = x.valueA; +``` + +## How to fix violations + +To fix a violation of this rule, use the appropriate tuple element name in code instead of the metadata name. + +## How to suppress violations + +```csharp +[SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1142:ReferToTupleElementsByName", Justification = "Reviewed.")] +``` + +```csharp +#pragma warning disable SA1142 // Refer to tuple elements by name +#pragma warning restore SA1142 // Refer to tuple elements by name +``` diff --git a/documentation/SA1201.md b/documentation/SA1201.md index f66c76706..ccf2d2c51 100644 --- a/documentation/SA1201.md +++ b/documentation/SA1201.md @@ -49,6 +49,8 @@ Within a class, struct, or interface, elements should be positioned in the follo * Structs * Classes* +> 📝 For ordering purposes, C# 9 records are treated as classes. + Complying with a standard ordering scheme based on element type can increase the readability and maintainability of the file and encourage code reuse. When implementing an interface, it is sometimes desirable to group all members of the interface next to one another. This will sometimes require violating this rule, if the interface contains elements of different types. This problem can be solved through the use of partial classes. diff --git a/documentation/SA1202.md b/documentation/SA1202.md index 404e600df..27edc404b 100644 --- a/documentation/SA1202.md +++ b/documentation/SA1202.md @@ -31,6 +31,7 @@ To comply with this rule, adjacent elements of the same type should be positione * internal * protected internal * protected +* private protected * private :memo: Static constructors and explicitly implemented interface members are considered *public* for the purposes of this diff --git a/documentation/SA1207.md b/documentation/SA1207.md index e38444b48..995c39dc0 100644 --- a/documentation/SA1207.md +++ b/documentation/SA1207.md @@ -17,15 +17,15 @@ ## Cause -The keyword *protected* is positioned after the keyword *internal* within the declaration of a protected internal C# element. +The keyword *protected* is positioned after the keyword *internal* within the declaration of a protected internal C# element, or the keyword *private* is positioned after the keyword *protected*. ## Rule description -A violation of this rule occurs when a protected internal element's access modifiers are written as *internal protected*. In reality, an element with the keywords *protected internal* will have the same access level as an element with the keywords *internal protected*. To make the code easier to read and more consistent, StyleCop standardizes the ordering of these keywords, so that a protected internal element will always be described as such, and never as internal protected. This can help to reduce confusion about whether these access levels are indeed the same. +A violation of this rule occurs when a protected internal element's access modifiers are written as *internal protected*, or when a private protected element's access modifiers are written as *protected private*. In reality, an element with the keywords *protected internal* will have the same access level as an element with the keywords *internal protected*. To make the code easier to read and more consistent, StyleCop standardizes the ordering of these keywords, so that a protected internal element will always be described as such, and never as internal protected. This can help to reduce confusion about whether these access levels are indeed the same. ## How to fix violations -To fix an instance of this violation, place the *protected* keyword before the *internal* keyword. +To fix an instance of this violation, place the *protected* keyword before the *internal* keyword, or place the *private* keyword before the *protected* keyword. ## How to suppress violations diff --git a/documentation/SA1212.md b/documentation/SA1212.md index e735b0c09..2790f8ae4 100644 --- a/documentation/SA1212.md +++ b/documentation/SA1212.md @@ -17,11 +17,11 @@ ## Cause -A get accessor appears after a set accessor within a property or indexer. +A get accessor appears after a set or init accessor within a property or indexer. ## Rule description -A violation of this rule occurs when a get accessor is placed after a set accessor within a property or indexer. To comply with this rule, the get accessor should appear before the set accessor. +A violation of this rule occurs when a get accessor is placed after a set or init accessor within a property or indexer. To comply with this rule, the get accessor should appear first. For example, the following code would raise an instance of this violation: diff --git a/documentation/SA1300.md b/documentation/SA1300.md index fa9ef4faf..000421d6d 100644 --- a/documentation/SA1300.md +++ b/documentation/SA1300.md @@ -42,10 +42,14 @@ begin with a lower-case letter, place the field or variable within a special `Na class is any class which contains a name ending in `NativeMethods`, and is intended as a placeholder for Win32 or COM wrappers. StyleCop will ignore this violation if the item is placed within a `NativeMethods` class. +For namespace components that begin with a small letter, due to branding issues or other reasons, add the appropriate +term to the `allowedNamespaceComponents` list. + ## How to fix violations -To fix a violation of this rule, change the name of the element so that it begins with an upper-case letter, or place -the item within a `NativeMethods` class if appropriate. +To fix a violation of this rule, change the name of the element so that it begins with an upper-case letter, place +the item within a `NativeMethods` class if appropriate, or add it to the `allowedNamespaceComponents` list if +it is a namespace component. ## How to suppress violations diff --git a/documentation/SA1305.md b/documentation/SA1305.md index 69350b55f..def384f0a 100644 --- a/documentation/SA1305.md +++ b/documentation/SA1305.md @@ -29,9 +29,17 @@ In addition, modern code editors such as Visual Studio make it easy to identify StyleCop assumes that any variable name that begins with one or two lower-case letters followed by an upper-case letter is making use of Hungarian notation, and will flag a violation of this rule in each case. It is possible to declare certain prefixes as legal, in which case they will be ignored. For example, a variable named *onExecute* will appear to StyleCop to be using Hungarian notation, when in reality it is not. Thus, the *on* prefix should be flagged as an allowed prefix. -To configure the list of allowed prefixes, bring up the StyleCop settings for a project, and navigate to the Hungarian tab, as shown below: - -![](Images/HungarianSettings.JPG) +To configure the list of allowed prefixes, use **stylecop.json** like the following: + +```json +{ + "settings": { + "namingRules": { + "allowedHungarianPrefixes": [ "aa", "bb" ], + }, + } +} +``` Adding a one or two letter prefix to this list will cause StyleCop to ignore variables or fields which begin with this prefix. diff --git a/documentation/SA1307.md b/documentation/SA1307.md index f73f501d1..afd201677 100644 --- a/documentation/SA1307.md +++ b/documentation/SA1307.md @@ -21,7 +21,7 @@ The name of a public or internal field in C# does not begin with an upper-case l ## Rule description -A violation of this rule occurs when the name of a public or internal field begins with a lower-case letter. Public or internal fields should being with an upper-case letter. +A violation of this rule occurs when the name of a public or internal field begins with a lower-case letter. Public or internal fields should begin with an upper-case letter. If the field or variable name is intended to match the name of an item associated with Win32 or COM, and thus needs to start with a lower-case letter, place the field or variable within a special *NativeMethods* class. A NativeMethods class is any class which contains a name ending in NativeMethods, and is intended as a placeholder for Win32 or COM wrappers. StyleCop will ignore this violation if the item is placed within a NativeMethods class. diff --git a/documentation/SA1308.md b/documentation/SA1308.md index 30af452d0..89a6300bf 100644 --- a/documentation/SA1308.md +++ b/documentation/SA1308.md @@ -17,11 +17,11 @@ ## Cause -A field name in C# is prefixed with *m_* or *s_*. +A field name in C# is prefixed with *m_*, *s_*, or *t_*. ## Rule description -A violation of this rule occurs when a field name is prefixed by *m_* or *s_*. +A violation of this rule occurs when a field name is prefixed by *m_*, *s_*, or *t_*. By default, StyleCop disallows the use of underscores, *m_*, etc., to mark local class fields, in favor of the 'this.' prefix. The advantage of using 'this.' is that it applies equally to all element types including methods, properties, etc., and not just fields, making all calls to class members instantly recognizable, regardless of which editor is being used to view the code. Another advantage is that it creates a quick, recognizable differentiation between instance members and static members, which will not be prefixed. diff --git a/documentation/SA1316.md b/documentation/SA1316.md new file mode 100644 index 000000000..3e1a870d7 --- /dev/null +++ b/documentation/SA1316.md @@ -0,0 +1,64 @@ +## SA1316 + + + + + + + + + + + + + + +
TypeNameSA1316TupleElementNamesShouldUseCorrectCasing
CheckIdSA1316
CategoryNaming Rules
+ +:memo: This rule is new for StyleCop Analyzers, and was not present in StyleCop Classic. +:memo: This rule is only active for C# 7.0 and higher + +## Cause + +Element names within a tuple type should have the correct casing. + +## Rule description + +Tuple types with element names should use the configured casing for the element names (see [Configuration.md](Configuration.md) for details). See the documentation on [tuple types](https://docs.microsoft.com/en-us/dotnet/csharp/tuples) for information on how to work with tuples in C# 7. + +For example, the following code would produce a violation of this rule (with default settings): + +```csharp +public class ExampleClass +{ + public (int valueA, int valueB) ExampleMethod() // SA1316 + { + } +} +``` + +The following code would not produce any violations: + +```csharp +public class ExampleClass +{ + public (int ValueA, int ValueB) ExampleMethod() + { + } +} +``` + +## How to fix violations + +To fix a violation of this rule, correct the casing of the tuple element name. + +## How to suppress violations + +```csharp +[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1316:TupleElementNamesShouldUseCorrectCasing", Justification = "Reviewed.")] +``` + +```csharp +#pragma warning disable SA1316 // Tuple element names should use correct casing +#pragma warning restore SA1316 // Tuple element names should use correct casing +``` diff --git a/documentation/SA1414.md b/documentation/SA1414.md new file mode 100644 index 000000000..b451842c6 --- /dev/null +++ b/documentation/SA1414.md @@ -0,0 +1,64 @@ +## SA1414 + + + + + + + + + + + + + + +
TypeNameSA1414TupleTypesInSignaturesShouldHaveElementNames
CheckIdSA1414
CategoryMaintainability Rules
+ +:memo: This rule is new for StyleCop Analyzers, and was not present in StyleCop Classic. +:memo: This rule is only active for C# 7.0 and higher + +## Cause + +A tuple type without element names is present in a member declaration. + +## Rule description + +Tuple types appearing in member declarations should have explicitly named elements. See the documentation on [tuple types](https://docs.microsoft.com/en-us/dotnet/csharp/tuples) for information on how to work with tuples in C# 7. + +For example, the following code would produce a violation of this rule: + +```csharp +public class ExampleClass +{ + public (int, int) ExampleMethod() // SA1414 + { + } +} +``` + +The following code would not produce any violations: + +```csharp +public class ExampleClass +{ + public (int valueA, int valueB) ExampleMethod() + { + } +} +``` + +## How to fix violations + +To fix a violation of this rule, provide an element name for each tuple element. + +## How to suppress violations + +```csharp +[SuppressMessage("StyleCop.CSharp.MaintainAbilityRules", "SA1414:TupleTypesInSignaturesShouldHaveElementNames", Justification = "Reviewed.")] +``` + +```csharp +#pragma warning disable SA1414 // Tuple types appearing in member declarations should have explicitly named tuple elements +#pragma warning restore SA1414 // Tuple types appearing in member declarations should have explicitly named tuple elements +``` diff --git a/documentation/SA1500.md b/documentation/SA1500.md index eaa039f65..652728001 100644 --- a/documentation/SA1500.md +++ b/documentation/SA1500.md @@ -19,6 +19,8 @@ The opening or closing brace within a C# statement, element, or expression is not placed on its own line. +> :memo: The behavior of this rule can change based on the configuration of the `allowDoWhileOnClosingBrace` property in **stylecop.json**. See [Configuration.md](Configuration.md#Layout-Rules) for more information. + ## Rule description A violation of this rule occurs when the opening or closing brace within a statement, element, or expression is not placed on its own line. For example: diff --git a/documentation/SA1516.md b/documentation/SA1516.md index 31b955639..f86801575 100644 --- a/documentation/SA1516.md +++ b/documentation/SA1516.md @@ -19,7 +19,7 @@ Adjacent C# elements are not separated by a blank line. -> :memo: The behavior of this rule can change based on the configuration of the `useBlankLinesBetweenUsingGroups` property in **stylecop.json**. See [Configuration.md](Configuration.md) for more information. +> :memo: The behavior of this rule can change based on the configuration of the `blankLinesBetweenUsingGroups` property in **stylecop.json**. See [Configuration.md](Configuration.md) for more information. ## Rule description diff --git a/documentation/SA1600.md b/documentation/SA1600.md index 77665426f..a93042599 100644 --- a/documentation/SA1600.md +++ b/documentation/SA1600.md @@ -23,7 +23,7 @@ A C# code element is missing a documentation header. C# syntax provides a mechanism for inserting documentation for classes and elements directly into the code, through the use of Xml documentation headers. For an introduction to these headers and a description of the header syntax, see the following article: [https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/xmldoc/xml-documentation-comments](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/xmldoc/xml-documentation-comments). -A violation of this rule occurs if an element is completely missing a documentation header, or if the header is empty. In C# the following types of elements can have documentation headers: classes, constructors, delegates, enums, events, finalizers, indexers, interfaces, methods, properties, and structs. +A violation of this rule occurs if an element is completely missing a documentation header, or if the header is empty. In C# the following types of elements can have documentation headers: classes, constructors, delegates, enums, events, finalizers, indexers, interfaces, methods, properties, records, and structs. ## How to fix violations @@ -44,6 +44,36 @@ public string JoinNames(string firstName, string lastName) } ``` +The next example shows a method that inherits documentation from a method in the base class: + +```csharp +/// +/// Example base class. +/// +class Vehicle +{ + /// + /// Accelerates the vehicle. + /// + public virtual void Accelerate() + { + Console.WriteLine("Vehicle is accelerating"); + } +} + +/// +/// Example derived class. +/// +class Car : Vehicle +{ + /// + public override void Accelerate() + { + Console.Writeline("Car is accelerating"); + } +} +``` + ## How to suppress violations ```csharp diff --git a/documentation/SA1633.md b/documentation/SA1633.md index ceb216268..cf2e8eaff 100644 --- a/documentation/SA1633.md +++ b/documentation/SA1633.md @@ -39,7 +39,7 @@ or ```csharp // Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. -// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. +// Licensed under the MIT License. See LICENSE in the project root for license information. ``` The type of header to use depends on the setting of the `xmlHeader` property. See the [configuration](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/Configuration.md) section for details on how to set this up. diff --git a/documentation/SA1644.md b/documentation/SA1644.md index 6fb46b142..f2b1f8427 100644 --- a/documentation/SA1644.md +++ b/documentation/SA1644.md @@ -15,6 +15,9 @@ +:warning: This rule has been intentionally omitted from StyleCop Analyzers. See [KnownChanges.md](KnownChanges.md) for +additional information. + ## Cause A section within the Xml documentation header for a C# element contains blank lines. diff --git a/documentation/SA1649.md b/documentation/SA1649.md index 63ef4e01b..e36c0a377 100644 --- a/documentation/SA1649.md +++ b/documentation/SA1649.md @@ -49,6 +49,10 @@ To fix a violation of this rule, rename the file to match the name of the first ## How to suppress violations +```csharp +[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1649:FileNameMustMatchTypeName", Justification = "Reviewed.")] +``` + ```csharp #pragma warning disable SA1649 // SA1649FileNameMustMatchTypeName #pragma warning restore SA1649 // SA1649FileNameMustMatchTypeName diff --git a/global.json b/global.json new file mode 100644 index 000000000..7bdadf68e --- /dev/null +++ b/global.json @@ -0,0 +1,6 @@ +{ + "sdk": { + "version": "6.0.100", + "rollForward": "feature" + } +} diff --git a/init.ps1 b/init.ps1 new file mode 100644 index 000000000..2e66b4577 --- /dev/null +++ b/init.ps1 @@ -0,0 +1,57 @@ +<# +.SYNOPSIS +Installs dependencies required to build and test the projects in this repository. +.DESCRIPTION +This MAY not require elevation, as the SDK and runtimes are installed to a per-user location, +unless the `-InstallLocality` switch is specified directing to a per-repo or per-machine location. +See detailed help on that switch for more information. +.PARAMETER InstallLocality +A value indicating whether dependencies should be installed locally to the repo or at a per-user location. +Per-user allows sharing the installed dependencies across repositories and allows use of a shared expanded package cache. +Visual Studio will only notice and use these SDKs/runtimes if VS is launched from the environment that runs this script. +Per-repo allows for high isolation, allowing for a more precise recreation of the environment within an Azure Pipelines build. +When using 'repo', environment variables are set to cause the locally installed dotnet SDK to be used. +Per-repo can lead to file locking issues when dotnet.exe is left running as a build server and can be mitigated by running `dotnet build-server shutdown`. +Per-machine requires elevation and will download and install all SDKs and runtimes to machine-wide locations so all applications can find it. +.PARAMETER NoPrerequisites +Skips the installation of prerequisite software (e.g. SDKs, tools). +.PARAMETER NoRestore +Skips the package restore step. +#> +[CmdletBinding(SupportsShouldProcess=$true)] +Param ( + [ValidateSet('repo','user','machine')] + [string]$InstallLocality='user', + [Parameter()] + [switch]$NoPrerequisites, + [Parameter()] + [switch]$NoRestore +) + +if (!$NoPrerequisites) { + & "$PSScriptRoot\build\Install-DotNetSdk.ps1" -InstallLocality $InstallLocality +} + +# Workaround nuget credential provider bug that causes very unreliable package restores on Azure Pipelines +$env:NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS=20 +$env:NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS=20 + +Push-Location $PSScriptRoot +try { + $HeaderColor = 'Green' + + if (!$NoRestore -and $PSCmdlet.ShouldProcess("NuGet packages", "Restore")) { + Write-Host "Restoring NuGet packages" -ForegroundColor $HeaderColor + dotnet restore + if ($lastexitcode -ne 0) { + throw "Failure while restoring packages." + } + } +} +catch { + Write-Error $error[0] + exit $lastexitcode +} +finally { + Pop-Location +}