diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 96812605bc..53f29f6464 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -109,8 +109,10 @@ jobs: working-directory: src/${{ matrix.component.name }}.CodeFixes steps: - uses: actions/checkout@v3 - - run: dotnet restore - - run: dotnet build --no-restore /p:Roslynator${{ matrix.component.propertyName }}NuGet=true + - run: dotnet restore --force /p:RoslynVersion=roslyn3.8 + - run: dotnet build --no-restore /p:Roslynator${{ matrix.component.propertyName }}NuGet=true /p:RoslynVersion=roslyn3.8 + - run: dotnet restore --force /p:RoslynVersion=roslyn4.7 + - run: dotnet build --no-restore /p:Roslynator${{ matrix.component.propertyName }}NuGet=true /p:RoslynVersion=roslyn4.7 - run: dotnet pack --no-build - uses: actions/upload-artifact@v3 with: @@ -158,7 +160,7 @@ jobs: steps: - uses: actions/checkout@v3 - run: dotnet restore - - run: dotnet build --no-restore /p:DefineConstants=VSCODE + - run: dotnet build --no-restore - run: | mkdir package/roslyn/analyzers mkdir package/roslyn/refactorings diff --git a/ChangeLog.md b/ChangeLog.md index 55f330dcb4..3cfed9dbf7 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Add support for Unity ([PR](https://github.com/dotnet/roslynator/pull/1349)) + - [Unity uses Roslyn 3.8](https://docs.unity3d.com/Manual/roslyn-analyzers.html) and this version is now supported by Roslynator NuGet packages with analyzers (Roslynator.Analyzers etc.) + ### Fixed - Fix analyzer [RCS0034](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS0034) ([PR](https://github.com/dotnet/roslynator/pull/1351)) diff --git a/src/Analyzers.CodeFixes/Analyzers.CodeFixes.csproj b/src/Analyzers.CodeFixes/Analyzers.CodeFixes.csproj index c54038d85d..01e74e9637 100644 --- a/src/Analyzers.CodeFixes/Analyzers.CodeFixes.csproj +++ b/src/Analyzers.CodeFixes/Analyzers.CodeFixes.csproj @@ -4,6 +4,10 @@ netstandard2.0 + + bin\$(RoslynVersion)\ + + $(RoslynatorAnalyzersVersion) Roslynator.CSharp.Analyzers.CodeFixes @@ -12,7 +16,7 @@ configuration=$(Configuration);version=$(RoslynatorAnalyzersPackageVersion) true false - + diff --git a/src/Analyzers.CodeFixes/CSharp/CodeFixes/ImplementNonGenericCounterpartCodeFixProvider.cs b/src/Analyzers.CodeFixes/CSharp/CodeFixes/ImplementNonGenericCounterpartCodeFixProvider.cs index 809384066a..d60342ee79 100644 --- a/src/Analyzers.CodeFixes/CSharp/CodeFixes/ImplementNonGenericCounterpartCodeFixProvider.cs +++ b/src/Analyzers.CodeFixes/CSharp/CodeFixes/ImplementNonGenericCounterpartCodeFixProvider.cs @@ -303,7 +303,10 @@ private static async Task RefactorAsync( newTypeDeclaration = recordDeclaration.WithBaseList(baseList.WithTypes(baseTypes)); } else if (kind == SyntaxKind.StructDeclaration - || kind == SyntaxKind.RecordStructDeclaration) +#if ROSLYN_4_0 + || kind == SyntaxKind.RecordStructDeclaration +#endif + ) { var structDeclaration = (StructDeclarationSyntax)newTypeDeclaration; diff --git a/src/Analyzers.CodeFixes/CSharp/CodeFixes/ParameterNameDiffersFromBaseCodeFixProvider.cs b/src/Analyzers.CodeFixes/CSharp/CodeFixes/ParameterNameDiffersFromBaseCodeFixProvider.cs index d0e6ff9092..30128e3220 100644 --- a/src/Analyzers.CodeFixes/CSharp/CodeFixes/ParameterNameDiffersFromBaseCodeFixProvider.cs +++ b/src/Analyzers.CodeFixes/CSharp/CodeFixes/ParameterNameDiffersFromBaseCodeFixProvider.cs @@ -83,12 +83,12 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) CodeAction codeAction = CodeAction.Create( $"Rename '{oldName}' to '{newName}'", - ct => Renamer.RenameSymbolAsync( - context.Document.Solution(), - parameterSymbol, - default(SymbolRenameOptions), - newName, - ct), + ct => +#if ROSLYN_4_4 + Renamer.RenameSymbolAsync(context.Document.Solution(), parameterSymbol, default(SymbolRenameOptions), newName, ct), +#else + Renamer.RenameSymbolAsync(context.Document.Solution(), parameterSymbol, newName, default(Microsoft.CodeAnalysis.Options.OptionSet), ct), +#endif GetEquivalenceKey(diagnostic)); context.RegisterCodeFix(codeAction, diagnostic); diff --git a/src/Analyzers.CodeFixes/CSharp/CodeFixes/RemoveEmptySyntaxCodeFixProvider.cs b/src/Analyzers.CodeFixes/CSharp/CodeFixes/RemoveEmptySyntaxCodeFixProvider.cs index f17307406e..6518c01fd0 100644 --- a/src/Analyzers.CodeFixes/CSharp/CodeFixes/RemoveEmptySyntaxCodeFixProvider.cs +++ b/src/Analyzers.CodeFixes/CSharp/CodeFixes/RemoveEmptySyntaxCodeFixProvider.cs @@ -40,7 +40,9 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) case SyntaxKind.EmptyStatement: case SyntaxKind.FinallyClause: case SyntaxKind.NamespaceDeclaration: +#if ROSLYN_4_0 case SyntaxKind.FileScopedNamespaceDeclaration: +#endif case SyntaxKind.ObjectCreationExpression: case SyntaxKind.RegionDirectiveTrivia: return true; @@ -98,6 +100,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) context.RegisterCodeFix(codeAction, diagnostic); break; } +#if ROSLYN_4_0 case BaseNamespaceDeclarationSyntax namespaceDeclaration: { CodeAction codeAction = CodeAction.Create( @@ -108,6 +111,18 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) context.RegisterCodeFix(codeAction, diagnostic); break; } +#else + case NamespaceDeclarationSyntax namespaceDeclaration: + { + CodeAction codeAction = CodeAction.Create( + "Remove empty namespace declaration", + ct => document.RemoveNodeAsync(namespaceDeclaration, ct), + GetEquivalenceKey(diagnostic)); + + context.RegisterCodeFix(codeAction, diagnostic); + break; + } +#endif case RegionDirectiveTriviaSyntax regionDirective: { CodeAction codeAction = CodeAction.Create( diff --git a/src/Analyzers.CodeFixes/CSharp/CodeFixes/UnnecessaryRawStringLiteralCodeFixProvider.cs b/src/Analyzers.CodeFixes/CSharp/CodeFixes/UnnecessaryRawStringLiteralCodeFixProvider.cs index 49242198e9..e727358c72 100644 --- a/src/Analyzers.CodeFixes/CSharp/CodeFixes/UnnecessaryRawStringLiteralCodeFixProvider.cs +++ b/src/Analyzers.CodeFixes/CSharp/CodeFixes/UnnecessaryRawStringLiteralCodeFixProvider.cs @@ -1,4 +1,5 @@ -// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +#if ROSLYN_4_2 +// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Immutable; using System.Composition; @@ -96,3 +97,4 @@ private static Task RefactorAsync( return document.WithTextChangeAsync(interpolatedString.Span, newText, cancellationToken); } } +#endif diff --git a/src/Analyzers.CodeFixes/CSharp/CodeFixes/UnusedParameterCodeFixProvider.cs b/src/Analyzers.CodeFixes/CSharp/CodeFixes/UnusedParameterCodeFixProvider.cs index 4c2529ffd5..df1c2ebb96 100644 --- a/src/Analyzers.CodeFixes/CSharp/CodeFixes/UnusedParameterCodeFixProvider.cs +++ b/src/Analyzers.CodeFixes/CSharp/CodeFixes/UnusedParameterCodeFixProvider.cs @@ -67,6 +67,10 @@ private static async Task RefactorAsync( string newName = NameGenerators.UnderscoreSuffix.EnsureUniqueParameterName("_", anonymousFunctionSymbol, semanticModel, cancellationToken: cancellationToken); +#if ROSLYN_4_4 return await Renamer.RenameSymbolAsync(document.Solution(), parameterSymbol, default(SymbolRenameOptions), newName, cancellationToken).ConfigureAwait(false); +#else + return await Renamer.RenameSymbolAsync(document.Solution(), parameterSymbol, newName, default(Microsoft.CodeAnalysis.Options.OptionSet), cancellationToken).ConfigureAwait(false); +#endif } } diff --git a/src/Analyzers.CodeFixes/CSharp/CodeFixes/UseExplicitlyOrImplicitlyTypedArrayCodeFixProvider.cs b/src/Analyzers.CodeFixes/CSharp/CodeFixes/UseExplicitlyOrImplicitlyTypedArrayCodeFixProvider.cs index 53c21f1800..bad8dd0a3a 100644 --- a/src/Analyzers.CodeFixes/CSharp/CodeFixes/UseExplicitlyOrImplicitlyTypedArrayCodeFixProvider.cs +++ b/src/Analyzers.CodeFixes/CSharp/CodeFixes/UseExplicitlyOrImplicitlyTypedArrayCodeFixProvider.cs @@ -31,6 +31,7 @@ public override ImmutableArray FixableDiagnosticIds get { return ImmutableArray.Create(DiagnosticIdentifiers.UseExplicitlyOrImplicitlyTypedArray); } } +#if ROSLYN_4_0 public override FixAllProvider GetFixAllProvider() { return FixAllProvider.Create(async (context, document, diagnostics) => await FixAllAsync(document, diagnostics, context.CancellationToken).ConfigureAwait(false)); @@ -51,6 +52,7 @@ static async Task FixAllAsync( return document; } } +#endif public override async Task RegisterCodeFixesAsync(CodeFixContext context) { @@ -80,23 +82,29 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) diagnostic.Location.SourceSpan, out SyntaxNode node, predicate: f => f.IsKind( +#if ROSLYN_4_7 + SyntaxKind.CollectionExpression, +#endif SyntaxKind.ImplicitArrayCreationExpression, - SyntaxKind.ArrayCreationExpression, - SyntaxKind.CollectionExpression))) + SyntaxKind.ArrayCreationExpression))) { throw new InvalidOperationException(); } if (node is ArrayCreationExpressionSyntax arrayCreation) { +#if ROSLYN_4_7 if (diagnostic.Properties.ContainsKey(DiagnosticPropertyKeys.ExplicitToCollectionExpression)) { return (ct => ConvertToCollectionExpressionAsync(document, arrayCreation, ct), UseCollectionExpressionTitle); } else { +#endif return (ct => ConvertToImplicitAsync(document, arrayCreation, ct), UseImplicitlyTypedArrayTitle); +#if ROSLYN_4_7 } +#endif } else if (node is ImplicitArrayCreationExpressionSyntax implicitArrayCreation) { @@ -104,15 +112,20 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) { return (ct => ConvertToExplicitAndUseVarAsync(document, implicitArrayCreation, ct), UseCollectionExpressionTitle); } +#if ROSLYN_4_7 else if (diagnostic.Properties.ContainsKey(DiagnosticPropertyKeys.ImplicitToCollectionExpression)) { return (ct => ConvertToCollectionExpressionAsync(document, implicitArrayCreation, ct), UseCollectionExpressionTitle); } else { +#endif return (ct => ConvertToExplicitAsync(document, implicitArrayCreation, ct), UseExplicitlyTypedArrayTitle); +#if ROSLYN_4_7 } +#endif } +#if ROSLYN_4_7 else if (node is CollectionExpressionSyntax collectionExpression) { if (diagnostic.Properties.ContainsKey(DiagnosticPropertyKeys.CollectionExpressionToImplicit)) @@ -124,6 +137,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) return (ct => ConvertToExplicitAsync(document, collectionExpression, ct), UseExplicitlyTypedArrayTitle); } } +#endif else { throw new InvalidOperationException(); @@ -180,23 +194,6 @@ private static async Task CreateArrayCreationAsyn newInitializer); } - private static async Task ConvertToExplicitAsync( - Document document, - CollectionExpressionSyntax collectionExpression, - CancellationToken cancellationToken) - { - SemanticModel semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); - ITypeSymbol typeSymbol = semanticModel.GetTypeInfo(collectionExpression, cancellationToken).ConvertedType; - - ArrayCreationExpressionSyntax arrayCreation = ArrayCreationExpression( - Token(SyntaxKind.NewKeyword), - (ArrayTypeSyntax)typeSymbol.ToTypeSyntax().WithSimplifierAnnotation(), - ConvertCollectionExpressionToInitializer(collectionExpression, SyntaxKind.ArrayInitializerExpression)) - .WithTriviaFrom(collectionExpression); - - return await document.ReplaceNodeAsync(collectionExpression, arrayCreation, cancellationToken).ConfigureAwait(false); - } - private static async Task ConvertToImplicitAsync( Document document, ArrayCreationExpressionSyntax arrayCreation, @@ -233,6 +230,24 @@ private static async Task ConvertToImplicitAsync( return await document.ReplaceNodeAsync(arrayCreation, implicitArrayCreation, cancellationToken).ConfigureAwait(false); } +#if ROSLYN_4_7 + private static async Task ConvertToExplicitAsync( + Document document, + CollectionExpressionSyntax collectionExpression, + CancellationToken cancellationToken) + { + SemanticModel semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); + ITypeSymbol typeSymbol = semanticModel.GetTypeInfo(collectionExpression, cancellationToken).ConvertedType; + + ArrayCreationExpressionSyntax arrayCreation = ArrayCreationExpression( + Token(SyntaxKind.NewKeyword), + (ArrayTypeSyntax)typeSymbol.ToTypeSyntax().WithSimplifierAnnotation(), + ConvertCollectionExpressionToInitializer(collectionExpression, SyntaxKind.ArrayInitializerExpression)) + .WithTriviaFrom(collectionExpression); + + return await document.ReplaceNodeAsync(collectionExpression, arrayCreation, cancellationToken).ConfigureAwait(false); + } + private static async Task ConvertToImplicitAsync( Document document, CollectionExpressionSyntax collectionExpression, @@ -269,4 +284,5 @@ private static async Task ConvertToCollectionExpressionAsync( return await document.ReplaceNodeAsync(implicitArrayCreation, collectionExpression, cancellationToken).ConfigureAwait(false); } +#endif } diff --git a/src/Analyzers.CodeFixes/CSharp/CodeFixes/UseImplicitOrExplicitObjectCreationCodeFixProvider.cs b/src/Analyzers.CodeFixes/CSharp/CodeFixes/UseImplicitOrExplicitObjectCreationCodeFixProvider.cs index 41a4315479..e43a8e0200 100644 --- a/src/Analyzers.CodeFixes/CSharp/CodeFixes/UseImplicitOrExplicitObjectCreationCodeFixProvider.cs +++ b/src/Analyzers.CodeFixes/CSharp/CodeFixes/UseImplicitOrExplicitObjectCreationCodeFixProvider.cs @@ -40,9 +40,12 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) context.Span, out SyntaxNode node, predicate: f => f.IsKind( +#if ROSLYN_4_7 + SyntaxKind.CollectionExpression, +#endif SyntaxKind.ObjectCreationExpression, - SyntaxKind.ImplicitObjectCreationExpression, - SyntaxKind.CollectionExpression))) + SyntaxKind.ImplicitObjectCreationExpression))) + { return; } @@ -52,27 +55,35 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) if (node is ObjectCreationExpressionSyntax objectCreation) { +#if ROSLYN_4_7 bool useCollectionExpression = diagnostic.Properties.ContainsKey(DiagnosticPropertyKeys.ExplicitToCollectionExpression); - +#endif CodeAction codeAction = CodeAction.Create( +#if ROSLYN_4_7 (useCollectionExpression) ? UseCollectionExpressionTitle : UseImplicitObjectCreationTitle, +#else + UseImplicitObjectCreationTitle, +#endif ct => { SyntaxNode newNode; - +#if ROSLYN_4_7 if (useCollectionExpression) { newNode = ConvertInitializerToCollectionExpression(objectCreation.Initializer).WithFormatterAnnotation(); } else { +#endif newNode = ImplicitObjectCreationExpression( objectCreation.NewKeyword.WithTrailingTrivia(objectCreation.NewKeyword.TrailingTrivia.EmptyIfWhitespace()), objectCreation.ArgumentList ?? ArgumentList().WithTrailingTrivia(objectCreation.Type.GetTrailingTrivia()), objectCreation.Initializer); +#if ROSLYN_4_7 } +#endif if (objectCreation.IsParentKind(SyntaxKind.EqualsValueClause) && objectCreation.Parent.IsParentKind(SyntaxKind.VariableDeclarator) @@ -90,7 +101,14 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) return document.ReplaceNodeAsync(objectCreation, newNode, ct); } }, - GetEquivalenceKey(diagnostic, (useCollectionExpression) ? UseCollectionExpressionEquivalenceKey : null)); + GetEquivalenceKey( + diagnostic, +#if ROSLYN_4_7 + (useCollectionExpression) ? UseCollectionExpressionEquivalenceKey : null +#else + null +#endif + )); context.RegisterCodeFix(codeAction, diagnostic); } @@ -126,6 +144,7 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) context.RegisterCodeFix(codeAction, diagnostic); } +#if ROSLYN_4_7 else if (diagnostic.Properties.ContainsKey(DiagnosticPropertyKeys.ImplicitToCollectionExpression)) { CodeAction codeAction = CodeAction.Create( @@ -146,6 +165,7 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) context.RegisterCodeFix(codeAction, diagnostic); } +#endif else { CodeAction codeAction = CodeAction.Create( @@ -174,6 +194,7 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) context.RegisterCodeFix(codeAction, diagnostic); } } +#if ROSLYN_4_7 else if (node is CollectionExpressionSyntax collectionExpression) { if (diagnostic.Properties.ContainsKey(DiagnosticPropertyKeys.CollectionExpressionToImplicit)) @@ -228,5 +249,6 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) context.RegisterCodeFix(codeAction, diagnostic); } } +#endif } } diff --git a/src/Analyzers.CodeFixes/Roslynator.Analyzers.nuspec b/src/Analyzers.CodeFixes/Roslynator.Analyzers.nuspec index ba5c9a1a83..f3a04a3f3a 100644 --- a/src/Analyzers.CodeFixes/Roslynator.Analyzers.nuspec +++ b/src/Analyzers.CodeFixes/Roslynator.Analyzers.nuspec @@ -11,7 +11,7 @@ false A collection of 200+ analyzers for C#, powered by Roslyn. - - This package is dependent on Microsoft.CodeAnalysis.CSharp.Workspaces 4.7.0. + - This package requires Roslyn 3.8 or higher. A collection of 200+ analyzers for C#, powered by Roslyn. Copyright (c) 2016-2023 Josef Pihrt Roslyn Analyzer Refactoring Productivity CodeAnalysis C# CSharp @@ -20,7 +20,8 @@ docs\README.md - + + diff --git a/src/Analyzers/CSharp/Analysis/AddOrRemoveAccessibilityModifiersAnalyzer.cs b/src/Analyzers/CSharp/Analysis/AddOrRemoveAccessibilityModifiersAnalyzer.cs index 6c34bf97dd..07fef41f71 100644 --- a/src/Analyzers/CSharp/Analysis/AddOrRemoveAccessibilityModifiersAnalyzer.cs +++ b/src/Analyzers/CSharp/Analysis/AddOrRemoveAccessibilityModifiersAnalyzer.cs @@ -74,7 +74,11 @@ public override void Initialize(AnalysisContext context) context.RegisterSyntaxNodeAction(f => AnalyzeOperatorDeclaration(f), SyntaxKind.OperatorDeclaration); context.RegisterSyntaxNodeAction(f => AnalyzePropertyDeclaration(f), SyntaxKind.PropertyDeclaration); context.RegisterSyntaxNodeAction(f => AnalyzeStructDeclaration(f), SyntaxKind.StructDeclaration); +#if ROSLYN_4_0 context.RegisterSyntaxNodeAction(f => AnalyzeRecordDeclaration(f), SyntaxKind.RecordDeclaration, SyntaxKind.RecordStructDeclaration); +#else + context.RegisterSyntaxNodeAction(f => AnalyzeRecordDeclaration(f), SyntaxKind.RecordDeclaration); +#endif } private static void AnalyzeClassDeclaration(SyntaxNodeAnalysisContext context) diff --git a/src/Analyzers/CSharp/Analysis/ConvertCommentToDocumentationCommentAnalyzer.cs b/src/Analyzers/CSharp/Analysis/ConvertCommentToDocumentationCommentAnalyzer.cs index 2167b2e4b4..e3fa18ecc0 100644 --- a/src/Analyzers/CSharp/Analysis/ConvertCommentToDocumentationCommentAnalyzer.cs +++ b/src/Analyzers/CSharp/Analysis/ConvertCommentToDocumentationCommentAnalyzer.cs @@ -33,7 +33,11 @@ public override void Initialize(AnalysisContext context) context.RegisterSyntaxNodeAction(f => AnalyzeNamespaceDeclaration(f), SyntaxKind.NamespaceDeclaration); context.RegisterSyntaxNodeAction(f => AnalyzeClassDeclaration(f), SyntaxKind.ClassDeclaration); context.RegisterSyntaxNodeAction(f => AnalyzeStructDeclaration(f), SyntaxKind.StructDeclaration); +#if ROSLYN_4_0 context.RegisterSyntaxNodeAction(f => AnalyzeRecordDeclaration(f), SyntaxKind.RecordDeclaration, SyntaxKind.RecordStructDeclaration); +#else + context.RegisterSyntaxNodeAction(f => AnalyzeRecordDeclaration(f), SyntaxKind.RecordDeclaration); +#endif context.RegisterSyntaxNodeAction(f => AnalyzeInterfaceDeclaration(f), SyntaxKind.InterfaceDeclaration); context.RegisterSyntaxNodeAction(f => AnalyzeEnumDeclaration(f), SyntaxKind.EnumDeclaration); context.RegisterSyntaxNodeAction(f => AnalyzeDelegateDeclaration(f), SyntaxKind.DelegateDeclaration); diff --git a/src/Analyzers/CSharp/Analysis/MakeMemberReadOnly/MakeMemberReadOnlyAnalyzer.cs b/src/Analyzers/CSharp/Analysis/MakeMemberReadOnly/MakeMemberReadOnlyAnalyzer.cs index 683e8ec563..ab11ee869a 100644 --- a/src/Analyzers/CSharp/Analysis/MakeMemberReadOnly/MakeMemberReadOnlyAnalyzer.cs +++ b/src/Analyzers/CSharp/Analysis/MakeMemberReadOnly/MakeMemberReadOnlyAnalyzer.cs @@ -45,8 +45,10 @@ public override void Initialize(AnalysisContext context) context.RegisterSyntaxNodeAction( f => AnalyzeTypeDeclaration(f), SyntaxKind.ClassDeclaration, - SyntaxKind.StructDeclaration, - SyntaxKind.RecordStructDeclaration); +#if ROSLYN_4_0 + SyntaxKind.RecordStructDeclaration, +#endif + SyntaxKind.StructDeclaration); } private static void AnalyzeTypeDeclaration(SyntaxNodeAnalysisContext context) diff --git a/src/Analyzers/CSharp/Analysis/ObjectCreation/ImplicitOrExpressionArrayCreationAnalysis.cs b/src/Analyzers/CSharp/Analysis/ObjectCreation/ImplicitOrExplicitArrayCreationAnalysis.cs similarity index 97% rename from src/Analyzers/CSharp/Analysis/ObjectCreation/ImplicitOrExpressionArrayCreationAnalysis.cs rename to src/Analyzers/CSharp/Analysis/ObjectCreation/ImplicitOrExplicitArrayCreationAnalysis.cs index 841e463a19..a7d052952c 100644 --- a/src/Analyzers/CSharp/Analysis/ObjectCreation/ImplicitOrExpressionArrayCreationAnalysis.cs +++ b/src/Analyzers/CSharp/Analysis/ObjectCreation/ImplicitOrExplicitArrayCreationAnalysis.cs @@ -9,9 +9,9 @@ namespace Roslynator.CSharp.Analysis; -internal class ImplicitOrExpressionArrayCreationAnalysis : ImplicitOrExplicitCreationAnalysis +internal class ImplicitOrExplicitArrayCreationAnalysis : ImplicitOrExplicitCreationAnalysis { - public static ImplicitOrExpressionArrayCreationAnalysis Instance { get; } = new(); + public static ImplicitOrExplicitArrayCreationAnalysis Instance { get; } = new(); public override void AnalyzeExplicitCreation(ref SyntaxNodeAnalysisContext context) { @@ -160,6 +160,7 @@ private bool AnalyzeExplicit(ref SyntaxNodeAnalysisContext context, bool isObvio if (style == TypeStyle.Implicit) { +#if ROSLYN_4_7 if (allowCollectionExpression && UseCollectionExpression(ref context)) { @@ -168,12 +169,17 @@ private bool AnalyzeExplicit(ref SyntaxNodeAnalysisContext context, bool isObvio } else { +#endif ReportExplicitToImplicit(ref context); return true; +#if ROSLYN_4_7 } +#endif + } else if (style == TypeStyle.ImplicitWhenTypeIsObvious) { +#if ROSLYN_4_7 if (isObvious && allowCollectionExpression && UseCollectionExpression(ref context)) @@ -181,7 +187,9 @@ private bool AnalyzeExplicit(ref SyntaxNodeAnalysisContext context, bool isObvio ReportExplicitToCollectionExpression(ref context); return true; } - else if (isObvious + else +#endif + if (isObvious || IsInitializerObvious(ref context)) { ReportExplicitToImplicit(ref context); @@ -225,8 +233,10 @@ protected override bool IsInitializerObvious(ref SyntaxNodeAnalysisContext conte if (context.Node is ImplicitArrayCreationExpressionSyntax implicitArrayCreation) return IsInitializerObvious(ref context, implicitArrayCreation, implicitArrayCreation.Initializer); +#if ROSLYN_4_7 if (context.Node is CollectionExpressionSyntax collectionExpression) return IsInitializerObvious(ref context, collectionExpression); +#endif return false; } @@ -263,42 +273,6 @@ private static bool IsInitializerObvious( return false; } - private static bool IsInitializerObvious(ref SyntaxNodeAnalysisContext context, CollectionExpressionSyntax collectionExpression) - { - SeparatedSyntaxList elements = collectionExpression.Elements; - - IArrayTypeSymbol arrayTypeSymbol = null; - var isObvious = false; - - foreach (CollectionElementSyntax element in elements) - { - if (element is not ExpressionElementSyntax expressionElement) - return false; - - if (arrayTypeSymbol is null) - { - ITypeSymbol type = context.SemanticModel.GetTypeInfo(collectionExpression, context.CancellationToken).ConvertedType; - - arrayTypeSymbol = type as IArrayTypeSymbol; - - if (arrayTypeSymbol?.ElementType.SupportsExplicitDeclaration() != true) - return true; - } - - isObvious = CSharpTypeAnalysis.IsTypeObvious(expressionElement.Expression, arrayTypeSymbol.ElementType, includeNullability: true, context.SemanticModel, context.CancellationToken); - - if (!isObvious) - return false; - } - - return isObvious; - } - - protected override bool UseCollectionExpressionFromImplicit(ref SyntaxNodeAnalysisContext context) - { - return UseCollectionExpression(ref context); - } - public override TypeStyle GetTypeStyle(ref SyntaxNodeAnalysisContext context) { return context.GetArrayCreationTypeStyle(); @@ -313,16 +287,6 @@ protected override void ReportExplicitToImplicit(ref SyntaxNodeAnalysisContext c "Simplify array creation"); } - protected override void ReportExplicitToCollectionExpression(ref SyntaxNodeAnalysisContext context) - { - DiagnosticHelpers.ReportDiagnostic( - context, - DiagnosticRules.UseExplicitlyOrImplicitlyTypedArray, - GetLocationFromExplicit(ref context), - properties: _explicitToCollectionExpression, - "Simplify array creation"); - } - private static Location GetLocationFromExplicit(ref SyntaxNodeAnalysisContext context) { return ((ArrayCreationExpressionSyntax)context.Node).Type.ElementType.GetLocation(); @@ -330,12 +294,13 @@ private static Location GetLocationFromExplicit(ref SyntaxNodeAnalysisContext co protected override void ReportImplicitToExplicit(ref SyntaxNodeAnalysisContext context) { +#if ROSLYN_4_7 if (context.Node is CollectionExpressionSyntax collectionExpression && !CanConvertCollectionExpression(ref context, collectionExpression)) { return; } - +#endif DiagnosticHelpers.ReportDiagnostic( context, DiagnosticRules.UseExplicitlyOrImplicitlyTypedArray, @@ -343,11 +308,24 @@ protected override void ReportImplicitToExplicit(ref SyntaxNodeAnalysisContext c "Use explicitly typed array"); } + private static Location GetLocationFromImplicit(ref SyntaxNodeAnalysisContext context) + { + if (context.Node is ImplicitArrayCreationExpressionSyntax implicitCreation) + { + return Location.Create( + implicitCreation.SyntaxTree, + TextSpan.FromBounds(implicitCreation.NewKeyword.SpanStart, implicitCreation.CloseBracketToken.Span.End)); + } + + return context.Node.GetLocation(); + } + protected override void ReportVarToExplicit(ref SyntaxNodeAnalysisContext context, TypeSyntax type) { +#if ROSLYN_4_7 if (context.Node.IsKind(SyntaxKind.CollectionExpression)) return; - +#endif ITypeSymbol typeSymbol = context.SemanticModel.GetTypeSymbol(type, context.CancellationToken); if (typeSymbol?.IsErrorType() != false) @@ -366,26 +344,61 @@ protected override void ReportVarToExplicit(ref SyntaxNodeAnalysisContext contex "Use explicitly typed array"); } - protected override void ReportImplicitToCollectionExpression(ref SyntaxNodeAnalysisContext context) +#if ROSLYN_4_7 + private static bool IsInitializerObvious(ref SyntaxNodeAnalysisContext context, CollectionExpressionSyntax collectionExpression) + { + SeparatedSyntaxList elements = collectionExpression.Elements; + + IArrayTypeSymbol arrayTypeSymbol = null; + var isObvious = false; + + foreach (CollectionElementSyntax element in elements) + { + if (element is not ExpressionElementSyntax expressionElement) + return false; + + if (arrayTypeSymbol is null) + { + ITypeSymbol type = context.SemanticModel.GetTypeInfo(collectionExpression, context.CancellationToken).ConvertedType; + + arrayTypeSymbol = type as IArrayTypeSymbol; + + if (arrayTypeSymbol?.ElementType.SupportsExplicitDeclaration() != true) + return true; + } + + isObvious = CSharpTypeAnalysis.IsTypeObvious(expressionElement.Expression, arrayTypeSymbol.ElementType, includeNullability: true, context.SemanticModel, context.CancellationToken); + + if (!isObvious) + return false; + } + + return isObvious; + } + + protected override bool UseCollectionExpressionFromImplicit(ref SyntaxNodeAnalysisContext context) + { + return UseCollectionExpression(ref context); + } + + protected override void ReportExplicitToCollectionExpression(ref SyntaxNodeAnalysisContext context) { DiagnosticHelpers.ReportDiagnostic( context, DiagnosticRules.UseExplicitlyOrImplicitlyTypedArray, - GetLocationFromImplicit(ref context), - properties: _implicitToCollectionExpression, + GetLocationFromExplicit(ref context), + properties: _explicitToCollectionExpression, "Simplify array creation"); } - private static Location GetLocationFromImplicit(ref SyntaxNodeAnalysisContext context) + protected override void ReportImplicitToCollectionExpression(ref SyntaxNodeAnalysisContext context) { - if (context.Node is ImplicitArrayCreationExpressionSyntax implicitCreation) - { - return Location.Create( - implicitCreation.SyntaxTree, - TextSpan.FromBounds(implicitCreation.NewKeyword.SpanStart, implicitCreation.CloseBracketToken.Span.End)); - } - - return context.Node.GetLocation(); + DiagnosticHelpers.ReportDiagnostic( + context, + DiagnosticRules.UseExplicitlyOrImplicitlyTypedArray, + GetLocationFromImplicit(ref context), + properties: _implicitToCollectionExpression, + "Simplify array creation"); } protected override void ReportCollectionExpressionToImplicit(ref SyntaxNodeAnalysisContext context) @@ -416,4 +429,5 @@ private static bool CanConvertCollectionExpression(ref SyntaxNodeAnalysisContext .ConvertedType? .IsKind(SymbolKind.ArrayType) == true; } +#endif } diff --git a/src/Analyzers/CSharp/Analysis/ObjectCreation/ImplicitOrExplicitCreationAnalysis.cs b/src/Analyzers/CSharp/Analysis/ObjectCreation/ImplicitOrExplicitCreationAnalysis.cs index bbd20e040a..1292585a5c 100644 --- a/src/Analyzers/CSharp/Analysis/ObjectCreation/ImplicitOrExplicitCreationAnalysis.cs +++ b/src/Analyzers/CSharp/Analysis/ObjectCreation/ImplicitOrExplicitCreationAnalysis.cs @@ -38,15 +38,17 @@ internal abstract class ImplicitOrExplicitCreationAnalysis protected abstract void ReportExplicitToImplicit(ref SyntaxNodeAnalysisContext context); - protected abstract void ReportExplicitToCollectionExpression(ref SyntaxNodeAnalysisContext context); - protected abstract void ReportImplicitToExplicit(ref SyntaxNodeAnalysisContext context); protected abstract void ReportVarToExplicit(ref SyntaxNodeAnalysisContext context, TypeSyntax type); +#if ROSLYN_4_7 + protected abstract void ReportExplicitToCollectionExpression(ref SyntaxNodeAnalysisContext context); + protected abstract void ReportImplicitToCollectionExpression(ref SyntaxNodeAnalysisContext context); protected abstract void ReportCollectionExpressionToImplicit(ref SyntaxNodeAnalysisContext context); +#endif protected virtual bool IsInitializerObvious(ref SyntaxNodeAnalysisContext context) => false; @@ -341,7 +343,11 @@ private void AnalyzeImplicit(ref SyntaxNodeAnalysisContext context) { bool isVar = variableDeclaration.Type.IsVar; +#if ROSLYN_4_7 SyntaxDebug.Assert(!isVar || context.Node.IsKind(SyntaxKind.CollectionExpression, SyntaxKind.ImplicitArrayCreationExpression), variableDeclaration); +#else + SyntaxDebug.Assert(!isVar || context.Node.IsKind(SyntaxKind.ImplicitArrayCreationExpression), variableDeclaration); +#endif SyntaxDebug.Assert(parent.IsParentKind(SyntaxKind.FieldDeclaration, SyntaxKind.LocalDeclarationStatement, SyntaxKind.UsingStatement), parent.Parent); if (!AnalyzeImplicit(ref context, isObvious: !isVar, allowCollectionExpression: !isVar) @@ -537,15 +543,20 @@ private void AnalyzeTypeSymbol( if (SymbolEqualityComparer.Default.Equals(typeSymbol1, typeSymbol2)) { +#if ROSLYN_4_7 if (((ObjectCreationExpressionSyntax)context.Node).ArgumentList?.Arguments.Any() != true - && UseCollectionExpression(ref context)) + && UseCollectionExpression(ref context) + ) { ReportExplicitToCollectionExpression(ref context); } else { +#endif ReportExplicitToImplicit(ref context); +#if ROSLYN_4_7 } +#endif } } } @@ -601,6 +612,7 @@ private bool AnalyzeImplicit(ref SyntaxNodeAnalysisContext context, bool isObvio if (style == TypeStyle.Implicit) { +#if ROSLYN_4_7 if (context.Node.IsKind(SyntaxKind.CollectionExpression)) { if (context.UseCollectionExpression() == false) @@ -615,6 +627,7 @@ private bool AnalyzeImplicit(ref SyntaxNodeAnalysisContext context, bool isObvio ReportImplicitToCollectionExpression(ref context); return true; } +#endif } else if (style == TypeStyle.ImplicitWhenTypeIsObvious) { @@ -625,6 +638,7 @@ private bool AnalyzeImplicit(ref SyntaxNodeAnalysisContext context, bool isObvio return true; } +#if ROSLYN_4_7 if (context.Node.IsKind(SyntaxKind.CollectionExpression)) { if (context.UseCollectionExpression() == false) @@ -639,13 +653,12 @@ private bool AnalyzeImplicit(ref SyntaxNodeAnalysisContext context, bool isObvio ReportImplicitToCollectionExpression(ref context); return true; } +#endif } return false; } - protected abstract bool UseCollectionExpressionFromImplicit(ref SyntaxNodeAnalysisContext context); - protected static bool IsSingleReturnStatement(SyntaxNode parent) { return parent.IsKind(SyntaxKind.ReturnStatement) @@ -654,6 +667,9 @@ protected static bool IsSingleReturnStatement(SyntaxNode parent) && parent.Parent.Parent is MemberDeclarationSyntax; } +#if ROSLYN_4_7 + protected abstract bool UseCollectionExpressionFromImplicit(ref SyntaxNodeAnalysisContext context); + protected static bool UseCollectionExpression(ref SyntaxNodeAnalysisContext context) { Debug.Assert(!context.Node.IsKind(SyntaxKind.CollectionExpression), context.Node.Kind().ToString()); @@ -662,4 +678,5 @@ protected static bool UseCollectionExpression(ref SyntaxNodeAnalysisContext cont && ((CSharpCompilation)context.Compilation).SupportsCollectionExpression() && SyntaxUtility.CanConvertToCollectionExpression(context.Node, context.SemanticModel, context.CancellationToken); } +#endif } diff --git a/src/Analyzers/CSharp/Analysis/ObjectCreation/ImplicitOrExpressionObjectCreationAnalysis.cs b/src/Analyzers/CSharp/Analysis/ObjectCreation/ImplicitOrExplicitObjectCreationAnalysis.cs similarity index 93% rename from src/Analyzers/CSharp/Analysis/ObjectCreation/ImplicitOrExpressionObjectCreationAnalysis.cs rename to src/Analyzers/CSharp/Analysis/ObjectCreation/ImplicitOrExplicitObjectCreationAnalysis.cs index 9e6ebc17cf..55935e90c6 100644 --- a/src/Analyzers/CSharp/Analysis/ObjectCreation/ImplicitOrExpressionObjectCreationAnalysis.cs +++ b/src/Analyzers/CSharp/Analysis/ObjectCreation/ImplicitOrExplicitObjectCreationAnalysis.cs @@ -6,21 +6,15 @@ namespace Roslynator.CSharp.Analysis; -internal class ImplicitOrExpressionObjectCreationAnalysis : ImplicitOrExplicitCreationAnalysis +internal class ImplicitOrExplicitObjectCreationAnalysis : ImplicitOrExplicitCreationAnalysis { - public static ImplicitOrExpressionObjectCreationAnalysis Instance { get; } = new(); + public static ImplicitOrExplicitObjectCreationAnalysis Instance { get; } = new(); public override TypeStyle GetTypeStyle(ref SyntaxNodeAnalysisContext context) { return context.GetObjectCreationTypeStyle(); } - protected override bool UseCollectionExpressionFromImplicit(ref SyntaxNodeAnalysisContext context) - { - return ((ImplicitObjectCreationExpressionSyntax)context.Node).ArgumentList?.Arguments.Any() != true - && UseCollectionExpression(ref context); - } - protected override void ReportExplicitToImplicit(ref SyntaxNodeAnalysisContext context) { var objectCreation = (ObjectCreationExpressionSyntax)context.Node; @@ -32,18 +26,6 @@ protected override void ReportExplicitToImplicit(ref SyntaxNodeAnalysisContext c "Simplify object creation"); } - protected override void ReportExplicitToCollectionExpression(ref SyntaxNodeAnalysisContext context) - { - var objectCreation = (ObjectCreationExpressionSyntax)context.Node; - - DiagnosticHelpers.ReportDiagnostic( - context, - DiagnosticRules.UseImplicitOrExplicitObjectCreation, - objectCreation.Type.GetLocation(), - properties: _explicitToCollectionExpression, - "Simplify object creation"); - } - protected override void ReportImplicitToExplicit(ref SyntaxNodeAnalysisContext context) { DiagnosticHelpers.ReportDiagnostic( @@ -63,6 +45,25 @@ protected override void ReportVarToExplicit(ref SyntaxNodeAnalysisContext contex "Use explicit object creation"); } +#if ROSLYN_4_7 + protected override bool UseCollectionExpressionFromImplicit(ref SyntaxNodeAnalysisContext context) + { + return ((ImplicitObjectCreationExpressionSyntax)context.Node).ArgumentList?.Arguments.Any() != true + && UseCollectionExpression(ref context); + } + + protected override void ReportExplicitToCollectionExpression(ref SyntaxNodeAnalysisContext context) + { + var objectCreation = (ObjectCreationExpressionSyntax)context.Node; + + DiagnosticHelpers.ReportDiagnostic( + context, + DiagnosticRules.UseImplicitOrExplicitObjectCreation, + objectCreation.Type.GetLocation(), + properties: _explicitToCollectionExpression, + "Simplify object creation"); + } + protected override void ReportImplicitToCollectionExpression(ref SyntaxNodeAnalysisContext context) { DiagnosticHelpers.ReportDiagnostic( @@ -82,4 +83,5 @@ protected override void ReportCollectionExpressionToImplicit(ref SyntaxNodeAnaly properties: _collectionExpressionToImplicit, "Simplify object creation"); } +#endif } diff --git a/src/Analyzers/CSharp/Analysis/OptimizeStringBuilderAppendCallAnalysis.cs b/src/Analyzers/CSharp/Analysis/OptimizeStringBuilderAppendCallAnalysis.cs index f235597ff2..1a4e5bba5a 100644 --- a/src/Analyzers/CSharp/Analysis/OptimizeStringBuilderAppendCallAnalysis.cs +++ b/src/Analyzers/CSharp/Analysis/OptimizeStringBuilderAppendCallAnalysis.cs @@ -73,7 +73,7 @@ public static void Analyze(SyntaxNodeAnalysisContext context, in SimpleMemberInv { case SyntaxKind.InterpolatedStringExpression: { - if (((CSharpCompilation)context.Compilation).LanguageVersion < LanguageVersion.CSharp10 + if (((CSharpCompilation)context.Compilation).LanguageVersion <= LanguageVersion.CSharp9 || !context.SemanticModel.HasConstantValue(expression, context.CancellationToken)) { ReportDiagnostic(argument); diff --git a/src/Analyzers/CSharp/Analysis/OrderModifiersAnalyzer.cs b/src/Analyzers/CSharp/Analysis/OrderModifiersAnalyzer.cs index 6937d64d7e..091a819bdf 100644 --- a/src/Analyzers/CSharp/Analysis/OrderModifiersAnalyzer.cs +++ b/src/Analyzers/CSharp/Analysis/OrderModifiersAnalyzer.cs @@ -42,7 +42,11 @@ public override void Initialize(AnalysisContext context) context.RegisterSyntaxNodeAction(f => AnalyzeOperatorDeclaration(f), SyntaxKind.OperatorDeclaration); context.RegisterSyntaxNodeAction(f => AnalyzePropertyDeclaration(f), SyntaxKind.PropertyDeclaration); context.RegisterSyntaxNodeAction(f => AnalyzeStructDeclaration(f), SyntaxKind.StructDeclaration); +#if ROSLYN_4_0 context.RegisterSyntaxNodeAction(f => AnalyzeRecordDeclaration(f), SyntaxKind.RecordDeclaration, SyntaxKind.RecordStructDeclaration); +#else + context.RegisterSyntaxNodeAction(f => AnalyzeRecordDeclaration(f), SyntaxKind.RecordDeclaration); +#endif } private static void AnalyzeClassDeclaration(SyntaxNodeAnalysisContext context) diff --git a/src/Analyzers/CSharp/Analysis/RemoveEmptySyntaxAnalyzer.cs b/src/Analyzers/CSharp/Analysis/RemoveEmptySyntaxAnalyzer.cs index 2b4dc2b304..9fba2536cc 100644 --- a/src/Analyzers/CSharp/Analysis/RemoveEmptySyntaxAnalyzer.cs +++ b/src/Analyzers/CSharp/Analysis/RemoveEmptySyntaxAnalyzer.cs @@ -34,7 +34,9 @@ public override void Initialize(AnalysisContext context) context.RegisterSyntaxNodeAction(f => AnalyzeFinallyClause(f), SyntaxKind.FinallyClause); context.RegisterSyntaxNodeAction(f => AnalyzeObjectCreationExpression(f), SyntaxKind.ObjectCreationExpression); context.RegisterSyntaxNodeAction(f => AnalyzeNamespaceDeclaration(f), SyntaxKind.NamespaceDeclaration); +#if ROSLYN_4_0 context.RegisterSyntaxNodeAction(f => AnalyzeFileScopedNamespaceDeclaration(f), SyntaxKind.FileScopedNamespaceDeclaration); +#endif context.RegisterSyntaxNodeAction(f => AnalyzeRegionDirective(f), SyntaxKind.RegionDirectiveTrivia); context.RegisterSyntaxNodeAction(f => AnalyzeEmptyStatement(f), SyntaxKind.EmptyStatement); } @@ -181,6 +183,7 @@ private static void AnalyzeNamespaceDeclaration(SyntaxNodeAnalysisContext contex ReportDiagnostic(context, declaration, "namespace declaration"); } +#if ROSLYN_4_0 private static void AnalyzeFileScopedNamespaceDeclaration(SyntaxNodeAnalysisContext context) { var declaration = (FileScopedNamespaceDeclarationSyntax)context.Node; @@ -190,6 +193,7 @@ private static void AnalyzeFileScopedNamespaceDeclaration(SyntaxNodeAnalysisCont ReportDiagnostic(context, declaration, "namespace declaration"); } +#endif private static void AnalyzeRegionDirective(SyntaxNodeAnalysisContext context) { diff --git a/src/Analyzers/CSharp/Analysis/RemoveRedundantBaseInterfaceAnalyzer.cs b/src/Analyzers/CSharp/Analysis/RemoveRedundantBaseInterfaceAnalyzer.cs index de36fbb7ad..3e3b891a2e 100644 --- a/src/Analyzers/CSharp/Analysis/RemoveRedundantBaseInterfaceAnalyzer.cs +++ b/src/Analyzers/CSharp/Analysis/RemoveRedundantBaseInterfaceAnalyzer.cs @@ -42,7 +42,9 @@ private static void AnalyzeBaseList(SyntaxNodeAnalysisContext context) if (!baseList.IsParentKind( SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, +#if ROSLYN_4_0 SyntaxKind.RecordStructDeclaration, +#endif SyntaxKind.InterfaceDeclaration)) { return; diff --git a/src/Analyzers/CSharp/Analysis/RemoveRedundantConstructorAnalyzer.cs b/src/Analyzers/CSharp/Analysis/RemoveRedundantConstructorAnalyzer.cs index 6f74d8af3b..59f91e88e2 100644 --- a/src/Analyzers/CSharp/Analysis/RemoveRedundantConstructorAnalyzer.cs +++ b/src/Analyzers/CSharp/Analysis/RemoveRedundantConstructorAnalyzer.cs @@ -84,7 +84,10 @@ private static bool CheckStructWithFieldInitializer(ConstructorDeclarationSyntax members = structDeclaration.Members; } else if (memberDeclaration is RecordDeclarationSyntax recordDeclaration - && recordDeclaration.ClassOrStructKeyword.IsKind(SyntaxKind.StructKeyword)) +#if ROSLYN_4_0 + && recordDeclaration.ClassOrStructKeyword.IsKind(SyntaxKind.StructKeyword) +#endif + ) { if (memberDeclaration.Modifiers.Contains(SyntaxKind.PartialKeyword)) return false; diff --git a/src/Analyzers/CSharp/Analysis/RemoveRedundantFieldInitializationAnalyzer.cs b/src/Analyzers/CSharp/Analysis/RemoveRedundantFieldInitializationAnalyzer.cs index 161b5e3180..8c206733ce 100644 --- a/src/Analyzers/CSharp/Analysis/RemoveRedundantFieldInitializationAnalyzer.cs +++ b/src/Analyzers/CSharp/Analysis/RemoveRedundantFieldInitializationAnalyzer.cs @@ -42,7 +42,11 @@ private static void AnalyzeFieldDeclaration(SyntaxNodeAnalysisContext context) if (fieldDeclaration.Modifiers.Contains(SyntaxKind.ConstKeyword)) return; - if (fieldDeclaration.IsParentKind(SyntaxKind.StructDeclaration, SyntaxKind.RecordStructDeclaration)) + if (fieldDeclaration.IsParentKind( +#if ROSLYN_4_0 + SyntaxKind.RecordStructDeclaration, +#endif + SyntaxKind.StructDeclaration)) { var structSymbol = context.SemanticModel.GetDeclaredSymbol(fieldDeclaration.Parent, context.CancellationToken) as INamedTypeSymbol; diff --git a/src/Analyzers/CSharp/Analysis/RemoveRedundantOverridingMemberAnalyzer.cs b/src/Analyzers/CSharp/Analysis/RemoveRedundantOverridingMemberAnalyzer.cs index 54d57ec0f2..a0f961f875 100644 --- a/src/Analyzers/CSharp/Analysis/RemoveRedundantOverridingMemberAnalyzer.cs +++ b/src/Analyzers/CSharp/Analysis/RemoveRedundantOverridingMemberAnalyzer.cs @@ -87,6 +87,7 @@ private static void AnalyzeMethodDeclaration(SyntaxNodeAnalysisContext context) if (!SymbolEqualityComparer.Default.Equals(overriddenMethod, symbol)) return; +#if ROSLYN_4_0 if (symbol.ContainingType?.IsRecord == true) { switch (symbol.Name) @@ -97,6 +98,7 @@ private static void AnalyzeMethodDeclaration(SyntaxNodeAnalysisContext context) return; } } +#endif if (!CheckParameters(methodDeclaration.ParameterList, invocationInfo.ArgumentList, semanticModel, cancellationToken)) return; diff --git a/src/Analyzers/CSharp/Analysis/RemoveUnnecessaryBlankLineAnalyzer.cs b/src/Analyzers/CSharp/Analysis/RemoveUnnecessaryBlankLineAnalyzer.cs index d83b0d4416..bd640c9351 100644 --- a/src/Analyzers/CSharp/Analysis/RemoveUnnecessaryBlankLineAnalyzer.cs +++ b/src/Analyzers/CSharp/Analysis/RemoveUnnecessaryBlankLineAnalyzer.cs @@ -34,7 +34,11 @@ public override void Initialize(AnalysisContext context) context.RegisterSyntaxNodeAction(f => AnalyzeClassDeclaration(f), SyntaxKind.ClassDeclaration); context.RegisterSyntaxNodeAction(f => AnalyzeStructDeclaration(f), SyntaxKind.StructDeclaration); +#if ROSLYN_4_0 context.RegisterSyntaxNodeAction(f => AnalyzeRecordDeclaration(f), SyntaxKind.RecordDeclaration, SyntaxKind.RecordStructDeclaration); +#else + context.RegisterSyntaxNodeAction(f => AnalyzeRecordDeclaration(f), SyntaxKind.RecordDeclaration); +#endif context.RegisterSyntaxNodeAction(f => AnalyzeInterfaceDeclaration(f), SyntaxKind.InterfaceDeclaration); context.RegisterSyntaxNodeAction(f => AnalyzeEnumDeclaration(f), SyntaxKind.EnumDeclaration); context.RegisterSyntaxNodeAction(f => AnalyzeNamespaceDeclaration(f), SyntaxKind.NamespaceDeclaration); diff --git a/src/Analyzers/CSharp/Analysis/RemoveUnnecessaryBracesAnalyzer.cs b/src/Analyzers/CSharp/Analysis/RemoveUnnecessaryBracesAnalyzer.cs index dc1cf09c95..f1d1f60a1a 100644 --- a/src/Analyzers/CSharp/Analysis/RemoveUnnecessaryBracesAnalyzer.cs +++ b/src/Analyzers/CSharp/Analysis/RemoveUnnecessaryBracesAnalyzer.cs @@ -28,7 +28,12 @@ public override void Initialize(AnalysisContext context) { base.Initialize(context); - context.RegisterSyntaxNodeAction(c => AnalyzeRecordDeclaration(c), SyntaxKind.RecordDeclaration, SyntaxKind.RecordStructDeclaration); + context.RegisterSyntaxNodeAction( + c => AnalyzeRecordDeclaration(c), +#if ROSLYN_4_0 + SyntaxKind.RecordStructDeclaration, +#endif + SyntaxKind.RecordDeclaration); context.RegisterCompilationStartAction(startContext => { @@ -65,7 +70,10 @@ private static void Analyze(SyntaxNodeAnalysisContext context, TypeDeclarationSy if (!closeBrace.IsKind(SyntaxKind.None) && openBrace.TrailingTrivia.IsEmptyOrWhitespace() && closeBrace.LeadingTrivia.IsEmptyOrWhitespace() - && typeDeclaration.ParameterList?.CloseParenToken.TrailingTrivia.IsEmptyOrWhitespace() != false) +#if ROSLYN_4_7 + && typeDeclaration.ParameterList?.CloseParenToken.TrailingTrivia.IsEmptyOrWhitespace() != false +#endif + ) { DiagnosticHelpers.ReportDiagnostic( context, @@ -81,7 +89,10 @@ private static void AnalyzeTypeDeclaration(SyntaxNodeAnalysisContext context) var typeDeclaration = (TypeDeclarationSyntax)context.Node; if (!typeDeclaration.Members.Any() - && typeDeclaration.ParameterList is null) +#if ROSLYN_4_7 + && typeDeclaration.ParameterList is null +#endif + ) { Analyze(context, typeDeclaration); } diff --git a/src/Analyzers/CSharp/Analysis/UnnecessaryRawStringLiteralAnalyzer.cs b/src/Analyzers/CSharp/Analysis/UnnecessaryRawStringLiteralAnalyzer.cs index 8da47483a8..1981ddb5f8 100644 --- a/src/Analyzers/CSharp/Analysis/UnnecessaryRawStringLiteralAnalyzer.cs +++ b/src/Analyzers/CSharp/Analysis/UnnecessaryRawStringLiteralAnalyzer.cs @@ -1,4 +1,5 @@ -// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +#if ROSLYN_4_2 +// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Immutable; using Microsoft.CodeAnalysis; @@ -116,3 +117,4 @@ private static bool ContainsBackSlashOrQuoteOrOpenBrace(string text, int start, return false; } } +#endif diff --git a/src/Analyzers/CSharp/Analysis/UnnecessarySemicolonAtEndOfDeclarationAnalyzer.cs b/src/Analyzers/CSharp/Analysis/UnnecessarySemicolonAtEndOfDeclarationAnalyzer.cs index 10ded52782..0467d57bdf 100644 --- a/src/Analyzers/CSharp/Analysis/UnnecessarySemicolonAtEndOfDeclarationAnalyzer.cs +++ b/src/Analyzers/CSharp/Analysis/UnnecessarySemicolonAtEndOfDeclarationAnalyzer.cs @@ -32,7 +32,11 @@ public override void Initialize(AnalysisContext context) context.RegisterSyntaxNodeAction(f => AnalyzeClassDeclaration(f), SyntaxKind.ClassDeclaration); context.RegisterSyntaxNodeAction(f => AnalyzeInterfaceDeclaration(f), SyntaxKind.InterfaceDeclaration); context.RegisterSyntaxNodeAction(f => AnalyzeStructDeclaration(f), SyntaxKind.StructDeclaration); +#if ROSLYN_4_0 context.RegisterSyntaxNodeAction(f => AnalyzeRecordDeclaration(f), SyntaxKind.RecordDeclaration, SyntaxKind.RecordStructDeclaration); +#else + context.RegisterSyntaxNodeAction(f => AnalyzeRecordDeclaration(f), SyntaxKind.RecordDeclaration); +#endif context.RegisterSyntaxNodeAction(f => AnalyzeEnumDeclaration(f), SyntaxKind.EnumDeclaration); } diff --git a/src/Analyzers/CSharp/Analysis/UnnecessaryUnsafeContextAnalyzer.cs b/src/Analyzers/CSharp/Analysis/UnnecessaryUnsafeContextAnalyzer.cs index c4a258dd46..22115bffd3 100644 --- a/src/Analyzers/CSharp/Analysis/UnnecessaryUnsafeContextAnalyzer.cs +++ b/src/Analyzers/CSharp/Analysis/UnnecessaryUnsafeContextAnalyzer.cs @@ -33,7 +33,9 @@ public override void Initialize(AnalysisContext context) f => AnalyzeTypeDeclaration(f), SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, +#if ROSLYN_4_0 SyntaxKind.RecordStructDeclaration, +#endif SyntaxKind.InterfaceDeclaration); context.RegisterSyntaxNodeAction(f => AnalyzeUnsafeStatement(f), SyntaxKind.UnsafeStatement); diff --git a/src/Analyzers/CSharp/Analysis/UnusedMember/UnusedMemberAnalyzer.cs b/src/Analyzers/CSharp/Analysis/UnusedMember/UnusedMemberAnalyzer.cs index 2669d9d247..f9f88ca165 100644 --- a/src/Analyzers/CSharp/Analysis/UnusedMember/UnusedMemberAnalyzer.cs +++ b/src/Analyzers/CSharp/Analysis/UnusedMember/UnusedMemberAnalyzer.cs @@ -38,8 +38,10 @@ public override void Initialize(AnalysisContext context) context.RegisterSyntaxNodeAction( f => AnalyzeTypeDeclaration(f), SyntaxKind.ClassDeclaration, - SyntaxKind.StructDeclaration, - SyntaxKind.RecordStructDeclaration); +#if ROSLYN_4_0 + SyntaxKind.RecordStructDeclaration, +#endif + SyntaxKind.StructDeclaration); } [SuppressMessage("Simplification", "RCS1180:Inline lazy initialization.")] @@ -56,7 +58,11 @@ private static void AnalyzeTypeDeclaration(SyntaxNodeAnalysisContext context) INamedTypeSymbol declarationSymbol = null; ImmutableArray attributes = default; +#if ROSLYN_4_0 if (typeDeclaration.IsKind(SyntaxKind.StructDeclaration, SyntaxKind.RecordStructDeclaration)) +#else + if (typeDeclaration.IsKind(SyntaxKind.StructDeclaration)) +#endif { declarationSymbol = semanticModel.GetDeclaredSymbol(typeDeclaration, cancellationToken); diff --git a/src/Analyzers/CSharp/Analysis/UnusedMember/UnusedMemberWalker.cs b/src/Analyzers/CSharp/Analysis/UnusedMember/UnusedMemberWalker.cs index 4174423064..8d809bffee 100644 --- a/src/Analyzers/CSharp/Analysis/UnusedMember/UnusedMemberWalker.cs +++ b/src/Analyzers/CSharp/Analysis/UnusedMember/UnusedMemberWalker.cs @@ -230,7 +230,9 @@ public override void VisitNamespaceDeclaration(NamespaceDeclarationSyntax node) public override void VisitClassDeclaration(ClassDeclarationSyntax node) { VisitAttributeLists(node.AttributeLists); +#if ROSLYN_4_7 VisitParameterList(node.ParameterList); +#endif VisitBaseList(node.BaseList); VisitMembers(node.Members); } @@ -238,7 +240,9 @@ public override void VisitClassDeclaration(ClassDeclarationSyntax node) public override void VisitInterfaceDeclaration(InterfaceDeclarationSyntax node) { VisitAttributeLists(node.AttributeLists); +#if ROSLYN_4_7 VisitParameterList(node.ParameterList); +#endif VisitBaseList(node.BaseList); VisitMembers(node.Members); } @@ -246,7 +250,9 @@ public override void VisitInterfaceDeclaration(InterfaceDeclarationSyntax node) public override void VisitStructDeclaration(StructDeclarationSyntax node) { VisitAttributeLists(node.AttributeLists); +#if ROSLYN_4_7 VisitParameterList(node.ParameterList); +#endif VisitBaseList(node.BaseList); VisitMembers(node.Members); } diff --git a/src/Analyzers/CSharp/Analysis/UnusedParameter/UnusedParameterAnalyzer.cs b/src/Analyzers/CSharp/Analysis/UnusedParameter/UnusedParameterAnalyzer.cs index b8e4ac1d07..968990ef7c 100644 --- a/src/Analyzers/CSharp/Analysis/UnusedParameter/UnusedParameterAnalyzer.cs +++ b/src/Analyzers/CSharp/Analysis/UnusedParameter/UnusedParameterAnalyzer.cs @@ -101,8 +101,16 @@ private static void AnalyzeMethodDeclaration(SyntaxNodeAnalysisContext context) if (methodDeclaration.ContainsDiagnostics) return; - if (!methodDeclaration.IsParentKind(SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.RecordDeclaration, SyntaxKind.RecordStructDeclaration)) + if (!methodDeclaration.IsParentKind( + SyntaxKind.ClassDeclaration, + SyntaxKind.StructDeclaration, +#if ROSLYN_4_0 + SyntaxKind.RecordStructDeclaration, +#endif + SyntaxKind.RecordDeclaration)) + { return; + } if (methodDeclaration.Modifiers.ContainsAny( SyntaxKind.AbstractKeyword, @@ -202,8 +210,16 @@ private static void AnalyzeIndexerDeclaration(SyntaxNodeAnalysisContext context) if (indexerDeclaration.ContainsDiagnostics) return; - if (!indexerDeclaration.IsParentKind(SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.RecordDeclaration, SyntaxKind.RecordStructDeclaration)) + if (!indexerDeclaration.IsParentKind( + SyntaxKind.ClassDeclaration, + SyntaxKind.StructDeclaration, +#if ROSLYN_4_0 + SyntaxKind.RecordStructDeclaration, +#endif + SyntaxKind.RecordDeclaration)) + { return; + } if (indexerDeclaration.Modifiers.ContainsAny(SyntaxKind.AbstractKeyword, SyntaxKind.VirtualKeyword, SyntaxKind.OverrideKeyword)) return; diff --git a/src/Analyzers/CSharp/Analysis/UseExplicitlyOrImplicitlyTypedArrayAnalyzer.cs b/src/Analyzers/CSharp/Analysis/UseExplicitlyOrImplicitlyTypedArrayAnalyzer.cs index 60764a4fb1..33eaa526b9 100644 --- a/src/Analyzers/CSharp/Analysis/UseExplicitlyOrImplicitlyTypedArrayAnalyzer.cs +++ b/src/Analyzers/CSharp/Analysis/UseExplicitlyOrImplicitlyTypedArrayAnalyzer.cs @@ -29,21 +29,23 @@ public override void Initialize(AnalysisContext context) context.RegisterSyntaxNodeAction(c => AnalyzeArrayCreationExpression(c), SyntaxKind.ArrayCreationExpression); context.RegisterSyntaxNodeAction(c => AnalyzeImplicitArrayCreationExpression(c), SyntaxKind.ImplicitArrayCreationExpression); +#if ROSLYN_4_7 context.RegisterSyntaxNodeAction(c => AnalyzeCollectionExpression(c), SyntaxKind.CollectionExpression); +#endif } private static void AnalyzeArrayCreationExpression(SyntaxNodeAnalysisContext context) { - ImplicitOrExpressionArrayCreationAnalysis.Instance.AnalyzeExplicitCreation(ref context); + ImplicitOrExplicitArrayCreationAnalysis.Instance.AnalyzeExplicitCreation(ref context); } private static void AnalyzeImplicitArrayCreationExpression(SyntaxNodeAnalysisContext context) { - ImplicitOrExpressionArrayCreationAnalysis.Instance.AnalyzeImplicitCreation(ref context); + ImplicitOrExplicitArrayCreationAnalysis.Instance.AnalyzeImplicitCreation(ref context); } private static void AnalyzeCollectionExpression(SyntaxNodeAnalysisContext context) { - ImplicitOrExpressionArrayCreationAnalysis.Instance.AnalyzeCollectionExpression(ref context); + ImplicitOrExplicitArrayCreationAnalysis.Instance.AnalyzeCollectionExpression(ref context); } } diff --git a/src/Analyzers/CSharp/Analysis/UseImplicitOrExplicitObjectCreationAnalyzer.cs b/src/Analyzers/CSharp/Analysis/UseImplicitOrExplicitObjectCreationAnalyzer.cs index ac29469529..a982060ddb 100644 --- a/src/Analyzers/CSharp/Analysis/UseImplicitOrExplicitObjectCreationAnalyzer.cs +++ b/src/Analyzers/CSharp/Analysis/UseImplicitOrExplicitObjectCreationAnalyzer.cs @@ -35,22 +35,26 @@ public override void Initialize(AnalysisContext context) } startContext.RegisterSyntaxNodeAction(c => AnalyzeImplicitObjectCreationExpression(c), SyntaxKind.ImplicitObjectCreationExpression); +#if ROSLYN_4_7 startContext.RegisterSyntaxNodeAction(c => AnalyzeCollectionExpression(c), SyntaxKind.CollectionExpression); +#endif }); } private static void AnalyzeObjectCreationExpression(SyntaxNodeAnalysisContext context) { - ImplicitOrExpressionObjectCreationAnalysis.Instance.AnalyzeExplicitCreation(ref context); + ImplicitOrExplicitObjectCreationAnalysis.Instance.AnalyzeExplicitCreation(ref context); } private static void AnalyzeImplicitObjectCreationExpression(SyntaxNodeAnalysisContext context) { - ImplicitOrExpressionObjectCreationAnalysis.Instance.AnalyzeImplicitCreation(ref context); + ImplicitOrExplicitObjectCreationAnalysis.Instance.AnalyzeImplicitCreation(ref context); } +#if ROSLYN_4_7 private static void AnalyzeCollectionExpression(SyntaxNodeAnalysisContext context) { - ImplicitOrExpressionObjectCreationAnalysis.Instance.AnalyzeCollectionExpression(ref context); + ImplicitOrExplicitObjectCreationAnalysis.Instance.AnalyzeCollectionExpression(ref context); } +#endif } diff --git a/src/Analyzers/CSharp/RawStringLiteralInfo.cs b/src/Analyzers/CSharp/RawStringLiteralInfo.cs index db4ebee87c..7318f544f3 100644 --- a/src/Analyzers/CSharp/RawStringLiteralInfo.cs +++ b/src/Analyzers/CSharp/RawStringLiteralInfo.cs @@ -1,4 +1,5 @@ -// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +#if ROSLYN_4_2 +// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using Microsoft.CodeAnalysis; @@ -73,3 +74,4 @@ public static RawStringLiteralInfo Create(LiteralExpressionSyntax literalExpress throw new InvalidOperationException(); } } +#endif diff --git a/src/CSharp.Workspaces/CSharp/CSharpSyntaxFactsService.cs b/src/CSharp.Workspaces/CSharp/CSharpSyntaxFactsService.cs index 6ba690141f..dc4d95e6e9 100644 --- a/src/CSharp.Workspaces/CSharp/CSharpSyntaxFactsService.cs +++ b/src/CSharp.Workspaces/CSharp/CSharpSyntaxFactsService.cs @@ -79,7 +79,9 @@ public bool AreEquivalent(SyntaxTree oldTree, SyntaxTree newTree) case SyntaxKind.TypeParameter: case SyntaxKind.ClassDeclaration: case SyntaxKind.StructDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif case SyntaxKind.InterfaceDeclaration: case SyntaxKind.RecordDeclaration: case SyntaxKind.EnumDeclaration: diff --git a/src/CSharp.Workspaces/CSharp/Extensions/WorkspaceExtensions.cs b/src/CSharp.Workspaces/CSharp/Extensions/WorkspaceExtensions.cs index ba66f83877..ba06589f76 100644 --- a/src/CSharp.Workspaces/CSharp/Extensions/WorkspaceExtensions.cs +++ b/src/CSharp.Workspaces/CSharp/Extensions/WorkspaceExtensions.cs @@ -92,12 +92,19 @@ internal static Task RemoveMemberAsync( return document.ReplaceNodeAsync(compilationUnit, SyntaxRefactorings.RemoveMember(compilationUnit, member), cancellationToken); } case SyntaxKind.NamespaceDeclaration: + { + var namespaceDeclaration = (NamespaceDeclarationSyntax)parent; + + return document.ReplaceNodeAsync(namespaceDeclaration, SyntaxRefactorings.RemoveMember(namespaceDeclaration, member), cancellationToken); + } +#if ROSLYN_4_0 case SyntaxKind.FileScopedNamespaceDeclaration: { - var namespaceDeclaration = (BaseNamespaceDeclarationSyntax)parent; + var namespaceDeclaration = (FileScopedNamespaceDeclarationSyntax)parent; return document.ReplaceNodeAsync(namespaceDeclaration, SyntaxRefactorings.RemoveMember(namespaceDeclaration, member), cancellationToken); } +#endif case SyntaxKind.ClassDeclaration: { var classDeclaration = (ClassDeclarationSyntax)parent; @@ -117,7 +124,9 @@ internal static Task RemoveMemberAsync( return document.ReplaceNodeAsync(interfaceDeclaration, SyntaxRefactorings.RemoveMember(interfaceDeclaration, member), cancellationToken); } case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif { var recordDeclaration = (RecordDeclarationSyntax)parent; diff --git a/src/CSharp.Workspaces/CSharp/FindSymbols/CSharpFindSymbolService.cs b/src/CSharp.Workspaces/CSharp/FindSymbols/CSharpFindSymbolService.cs index d0bb58270a..c1ebfb8c47 100644 --- a/src/CSharp.Workspaces/CSharp/FindSymbols/CSharpFindSymbolService.cs +++ b/src/CSharp.Workspaces/CSharp/FindSymbols/CSharpFindSymbolService.cs @@ -37,7 +37,9 @@ internal class CSharpFindSymbolService : FindSymbolService case SyntaxKind.PropertyDeclaration: case SyntaxKind.RecordDeclaration: case SyntaxKind.StructDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif case SyntaxKind.TypeParameter: case SyntaxKind.UsingDirective: case SyntaxKind.VariableDeclarator: diff --git a/src/CSharp.Workspaces/CSharp/Spelling/CSharpSpellingWalker.cs b/src/CSharp.Workspaces/CSharp/Spelling/CSharpSpellingWalker.cs index 3147579be9..c4a0220a87 100644 --- a/src/CSharp.Workspaces/CSharp/Spelling/CSharpSpellingWalker.cs +++ b/src/CSharp.Workspaces/CSharp/Spelling/CSharpSpellingWalker.cs @@ -175,7 +175,9 @@ public override void VisitTupleType(TupleTypeSyntax node) break; } case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif { if (ShouldVisit(SpellingScopeFilter.Record)) base.VisitTupleType(node); diff --git a/src/CSharp/CSharp/CSharpFacts.cs b/src/CSharp/CSharp/CSharpFacts.cs index e29e5bb83b..f8fbfc2959 100644 --- a/src/CSharp/CSharp/CSharpFacts.cs +++ b/src/CSharp/CSharp/CSharpFacts.cs @@ -93,7 +93,9 @@ internal static string GetTitle(SyntaxNode node) case SyntaxKind.EnumDeclaration: return "enum"; case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return "record"; case SyntaxKind.IncompleteMember: return "member"; @@ -154,11 +156,13 @@ public static bool CanHaveMembers(SyntaxKind kind) { case SyntaxKind.CompilationUnit: case SyntaxKind.NamespaceDeclaration: - case SyntaxKind.FileScopedNamespaceDeclaration: case SyntaxKind.ClassDeclaration: case SyntaxKind.StructDeclaration: - case SyntaxKind.RecordStructDeclaration: case SyntaxKind.InterfaceDeclaration: +#if ROSLYN_4_0 + case SyntaxKind.FileScopedNamespaceDeclaration: + case SyntaxKind.RecordStructDeclaration: +#endif return true; default: return false; @@ -305,7 +309,9 @@ public static bool CanHaveModifiers(SyntaxKind kind) case SyntaxKind.PropertyDeclaration: case SyntaxKind.RecordDeclaration: case SyntaxKind.StructDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif case SyntaxKind.IncompleteMember: case SyntaxKind.GetAccessorDeclaration: case SyntaxKind.SetAccessorDeclaration: @@ -1047,7 +1053,9 @@ internal static bool HasTypeParameterList(SyntaxKind kind) case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.StructDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif case SyntaxKind.RecordDeclaration: case SyntaxKind.MethodDeclaration: case SyntaxKind.DelegateDeclaration: diff --git a/src/CSharp/CSharp/CSharpTypeAnalysis.cs b/src/CSharp/CSharp/CSharpTypeAnalysis.cs index 46fc4680e8..2fbe7ddd92 100644 --- a/src/CSharp/CSharp/CSharpTypeAnalysis.cs +++ b/src/CSharp/CSharp/CSharpTypeAnalysis.cs @@ -38,10 +38,10 @@ public static TypeAnalysis AnalyzeType( if (expression is null) return default; - +#if ROSLYN_4_7 if (expression.IsKind(SyntaxKind.CollectionExpression)) return default; - +#endif ITypeSymbol? typeSymbol = semanticModel.GetTypeSymbol(type, cancellationToken); if (typeSymbol is null) @@ -205,8 +205,10 @@ public static bool IsExplicitThatCanBeImplicit( if (expression.IsKind( SyntaxKind.NullLiteralExpression, SyntaxKind.DefaultLiteralExpression, - SyntaxKind.ImplicitObjectCreationExpression, - SyntaxKind.CollectionExpression)) +#if ROSLYN_4_7 + SyntaxKind.CollectionExpression, +#endif + SyntaxKind.ImplicitObjectCreationExpression)) { return false; } diff --git a/src/CSharp/CSharp/CSharpUtility.cs b/src/CSharp/CSharp/CSharpUtility.cs index b8d61636e9..ee75ed74ee 100644 --- a/src/CSharp/CSharp/CSharpUtility.cs +++ b/src/CSharp/CSharp/CSharpUtility.cs @@ -392,8 +392,10 @@ public static SyntaxToken GetIdentifier(SyntaxNode node) case SyntaxKind.VariableDeclarator: return ((VariableDeclaratorSyntax)node).Identifier; case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: return ((RecordDeclarationSyntax)node).Identifier; +#endif case SyntaxKind.Parameter: return ((ParameterSyntax)node).Identifier; case SyntaxKind.TypeParameter: @@ -460,7 +462,9 @@ public static bool IsPartOfExpressionThatMustBeConstant(ExpressionSyntax express case SyntaxKind.NamespaceDeclaration: case SyntaxKind.ClassDeclaration: case SyntaxKind.StructDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif case SyntaxKind.InterfaceDeclaration: case SyntaxKind.RecordDeclaration: case SyntaxKind.EnumDeclaration: @@ -695,12 +699,16 @@ public static SeparatedSyntaxList GetParameters(SyntaxNode decl case SyntaxKind.LocalFunctionStatement: return ((LocalFunctionStatementSyntax)declaration).ParameterList; case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return ((RecordDeclarationSyntax)declaration).ParameterList; +#if ROSLYN_4_7 case SyntaxKind.ClassDeclaration: case SyntaxKind.StructDeclaration: case SyntaxKind.InterfaceDeclaration: return ((TypeDeclarationSyntax)declaration).ParameterList; +#endif default: return null; } @@ -728,7 +736,9 @@ public static SeparatedSyntaxList GetTypeParameters(SyntaxN case SyntaxKind.LocalFunctionStatement: return ((LocalFunctionStatementSyntax)declaration).TypeParameterList; case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return ((RecordDeclarationSyntax)declaration).TypeParameterList; default: return null; diff --git a/src/CSharp/CSharp/Documentation/DocumentationCommentGenerator.cs b/src/CSharp/CSharp/Documentation/DocumentationCommentGenerator.cs index 28ac3fecf6..6fe58f2b3a 100644 --- a/src/CSharp/CSharp/Documentation/DocumentationCommentGenerator.cs +++ b/src/CSharp/CSharp/Documentation/DocumentationCommentGenerator.cs @@ -63,7 +63,9 @@ public static SyntaxTriviaList Generate(MemberDeclarationSyntax memberDeclaratio case SyntaxKind.IndexerDeclaration: return Generate((IndexerDeclarationSyntax)memberDeclaration, settings); case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return Generate((RecordDeclarationSyntax)memberDeclaration, settings); default: throw new ArgumentException("", nameof(memberDeclaration)); @@ -633,7 +635,9 @@ private static bool ContainingTypeHasBaseType(MemberDeclarationSyntax memberDecl case SyntaxKind.ClassDeclaration: return ((ClassDeclarationSyntax)parent).BaseList?.Types.Any() == true; case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return ((RecordDeclarationSyntax)parent).BaseList?.Types.Any() == true; case SyntaxKind.StructDeclaration: return ((StructDeclarationSyntax)parent).BaseList?.Types.Any() == true; diff --git a/src/CSharp/CSharp/Extensions/SyntaxExtensions.cs b/src/CSharp/CSharp/Extensions/SyntaxExtensions.cs index 1ce73ae76f..2c827c279b 100644 --- a/src/CSharp/CSharp/Extensions/SyntaxExtensions.cs +++ b/src/CSharp/CSharp/Extensions/SyntaxExtensions.cs @@ -2990,7 +2990,9 @@ public static bool IsInExpressionTree( case SyntaxKind.ReturnStatement: case SyntaxKind.SetAccessorDeclaration: case SyntaxKind.StructDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif case SyntaxKind.SwitchStatement: case SyntaxKind.ThrowStatement: case SyntaxKind.TryStatement: @@ -3835,7 +3837,9 @@ internal static TypeDeclarationSyntax WithMembers(this TypeDeclarationSyntax typ case SyntaxKind.ClassDeclaration: return ((ClassDeclarationSyntax)typeDeclaration).WithMembers(newMembers); case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return ((RecordDeclarationSyntax)typeDeclaration).WithMembers(newMembers); case SyntaxKind.StructDeclaration: return ((StructDeclarationSyntax)typeDeclaration).WithMembers(newMembers); diff --git a/src/CSharp/CSharp/MemberDeclarationComparer.cs b/src/CSharp/CSharp/MemberDeclarationComparer.cs index 71c3e64925..8dde045ca0 100644 --- a/src/CSharp/CSharp/MemberDeclarationComparer.cs +++ b/src/CSharp/CSharp/MemberDeclarationComparer.cs @@ -52,7 +52,9 @@ internal static bool CanBeSortedByName(SyntaxKind kind) case SyntaxKind.EnumDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.StructDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif case SyntaxKind.ClassDeclaration: case SyntaxKind.RecordDeclaration: case SyntaxKind.NamespaceDeclaration: @@ -133,7 +135,9 @@ public override int Compare(MemberDeclarationSyntax x, MemberDeclarationSyntax y case SyntaxKind.ClassDeclaration: return ((ClassDeclarationSyntax)member).Identifier.ValueText; case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return ((RecordDeclarationSyntax)member).Identifier.ValueText; case SyntaxKind.NamespaceDeclaration: return ((NamespaceDeclarationSyntax)member).Name.ToString(); diff --git a/src/CSharp/CSharp/MemberDeclarationKindComparer.cs b/src/CSharp/CSharp/MemberDeclarationKindComparer.cs index 25748673b7..7607c49bc9 100644 --- a/src/CSharp/CSharp/MemberDeclarationKindComparer.cs +++ b/src/CSharp/CSharp/MemberDeclarationKindComparer.cs @@ -51,8 +51,10 @@ public virtual int GetRank(SyntaxKind kind) return 15; case SyntaxKind.RecordDeclaration: return 16; +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: return 17; +#endif case SyntaxKind.NamespaceDeclaration: return 18; case SyntaxKind.IncompleteMember: diff --git a/src/CSharp/CSharp/ModifierList.cs b/src/CSharp/CSharp/ModifierList.cs index 9c178d81d7..70adac6549 100644 --- a/src/CSharp/CSharp/ModifierList.cs +++ b/src/CSharp/CSharp/ModifierList.cs @@ -149,7 +149,9 @@ public static TNode Insert(TNode node, SyntaxKind kind, IComparer.Instance.Insert((PropertyDeclarationSyntax)(SyntaxNode)node, kind, comparer); case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return (TNode)(SyntaxNode)ModifierList.Instance.Insert((RecordDeclarationSyntax)(SyntaxNode)node, kind, comparer); case SyntaxKind.StructDeclaration: return (TNode)(SyntaxNode)ModifierList.Instance.Insert((StructDeclarationSyntax)(SyntaxNode)node, kind, comparer); @@ -213,7 +215,9 @@ public static TNode Insert(TNode node, SyntaxToken modifier, IComparer.Instance.Insert((PropertyDeclarationSyntax)(SyntaxNode)node, modifier, comparer); case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return (TNode)(SyntaxNode)ModifierList.Instance.Insert((RecordDeclarationSyntax)(SyntaxNode)node, modifier, comparer); case SyntaxKind.StructDeclaration: return (TNode)(SyntaxNode)ModifierList.Instance.Insert((StructDeclarationSyntax)(SyntaxNode)node, modifier, comparer); @@ -272,7 +276,9 @@ public static TNode Remove(TNode node, SyntaxKind kind) where TNode : Syn case SyntaxKind.PropertyDeclaration: return (TNode)(SyntaxNode)ModifierList.Instance.Remove((PropertyDeclarationSyntax)(SyntaxNode)node, kind); case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return (TNode)(SyntaxNode)ModifierList.Instance.Remove((RecordDeclarationSyntax)(SyntaxNode)node, kind); case SyntaxKind.StructDeclaration: return (TNode)(SyntaxNode)ModifierList.Instance.Remove((StructDeclarationSyntax)(SyntaxNode)node, kind); @@ -331,7 +337,9 @@ public static TNode Remove(TNode node, SyntaxToken modifier) where TNode case SyntaxKind.PropertyDeclaration: return (TNode)(SyntaxNode)ModifierList.Instance.Remove((PropertyDeclarationSyntax)(SyntaxNode)node, modifier); case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return (TNode)(SyntaxNode)ModifierList.Instance.Remove((RecordDeclarationSyntax)(SyntaxNode)node, modifier); case SyntaxKind.StructDeclaration: return (TNode)(SyntaxNode)ModifierList.Instance.Remove((StructDeclarationSyntax)(SyntaxNode)node, modifier); @@ -390,7 +398,9 @@ public static TNode RemoveAt(TNode node, int index) where TNode : SyntaxN case SyntaxKind.PropertyDeclaration: return (TNode)(SyntaxNode)ModifierList.Instance.RemoveAt((PropertyDeclarationSyntax)(SyntaxNode)node, index); case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return (TNode)(SyntaxNode)ModifierList.Instance.RemoveAt((RecordDeclarationSyntax)(SyntaxNode)node, index); case SyntaxKind.StructDeclaration: return (TNode)(SyntaxNode)ModifierList.Instance.RemoveAt((StructDeclarationSyntax)(SyntaxNode)node, index); @@ -449,7 +459,9 @@ public static TNode RemoveAll(TNode node, Func predica case SyntaxKind.PropertyDeclaration: return (TNode)(SyntaxNode)ModifierList.Instance.RemoveAll((PropertyDeclarationSyntax)(SyntaxNode)node, predicate); case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return (TNode)(SyntaxNode)ModifierList.Instance.RemoveAll((RecordDeclarationSyntax)(SyntaxNode)node, predicate); case SyntaxKind.StructDeclaration: return (TNode)(SyntaxNode)ModifierList.Instance.RemoveAll((StructDeclarationSyntax)(SyntaxNode)node, predicate); @@ -508,7 +520,9 @@ public static TNode RemoveAll(TNode node) where TNode : SyntaxNode case SyntaxKind.PropertyDeclaration: return (TNode)(SyntaxNode)ModifierList.Instance.RemoveAll((PropertyDeclarationSyntax)(SyntaxNode)node); case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return (TNode)(SyntaxNode)ModifierList.Instance.RemoveAll((RecordDeclarationSyntax)(SyntaxNode)node); case SyntaxKind.StructDeclaration: return (TNode)(SyntaxNode)ModifierList.Instance.RemoveAll((StructDeclarationSyntax)(SyntaxNode)node); diff --git a/src/CSharp/CSharp/ModifierList`1.cs b/src/CSharp/CSharp/ModifierList`1.cs index f8b510f656..3399e2af81 100644 --- a/src/CSharp/CSharp/ModifierList`1.cs +++ b/src/CSharp/CSharp/ModifierList`1.cs @@ -770,7 +770,11 @@ private class LambdaExpressionModifierList : ModifierList GetAttributeLists(LambdaExpressionSyntax node) { +#if ROSLYN_4_0 return node.AttributeLists; +#else + return default; +#endif } internal override SyntaxTokenList GetModifiers(LambdaExpressionSyntax node) diff --git a/src/CSharp/CSharp/Syntax/GenericInfo.cs b/src/CSharp/CSharp/Syntax/GenericInfo.cs index 0cc245e371..f363ada17a 100644 --- a/src/CSharp/CSharp/Syntax/GenericInfo.cs +++ b/src/CSharp/CSharp/Syntax/GenericInfo.cs @@ -132,8 +132,10 @@ internal static GenericInfo Create(SyntaxNode? node) case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.StructDeclaration: - case SyntaxKind.RecordStructDeclaration: case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 + case SyntaxKind.RecordStructDeclaration: +#endif { return new GenericInfo((TypeDeclarationSyntax)node); } @@ -241,7 +243,9 @@ public GenericInfo WithTypeParameterList(TypeParameterListSyntax typeParameterLi case SyntaxKind.MethodDeclaration: return new GenericInfo(((MethodDeclarationSyntax)Node).WithTypeParameterList(typeParameterList)); case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return new GenericInfo(((RecordDeclarationSyntax)Node).WithTypeParameterList(typeParameterList)); case SyntaxKind.StructDeclaration: return new GenericInfo(((StructDeclarationSyntax)Node).WithTypeParameterList(typeParameterList)); @@ -273,7 +277,9 @@ public GenericInfo RemoveTypeParameter(TypeParameterSyntax typeParameter) case SyntaxKind.MethodDeclaration: return new GenericInfo(((MethodDeclarationSyntax)self.Node).WithTypeParameterList(RemoveTypeParameter())); case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return new GenericInfo(((RecordDeclarationSyntax)self.Node).WithTypeParameterList(RemoveTypeParameter())); case SyntaxKind.StructDeclaration: return new GenericInfo(((StructDeclarationSyntax)self.Node).WithTypeParameterList(RemoveTypeParameter())); @@ -320,7 +326,9 @@ public GenericInfo WithConstraintClauses(SyntaxList return new MemberDeclarationListInfo(compilationUnit, compilationUnit.Members); } case SyntaxKind.NamespaceDeclaration: + { + var declaration = (NamespaceDeclarationSyntax)Parent; + declaration = declaration.WithMembers(members); + return new MemberDeclarationListInfo(declaration, declaration.Members); + } +#if ROSLYN_4_0 case SyntaxKind.FileScopedNamespaceDeclaration: { - var declaration = (BaseNamespaceDeclarationSyntax)Parent; + var declaration = (FileScopedNamespaceDeclarationSyntax)Parent; declaration = declaration.WithMembers(members); return new MemberDeclarationListInfo(declaration, declaration.Members); } +#endif case SyntaxKind.ClassDeclaration: { var declaration = (ClassDeclarationSyntax)Parent; @@ -242,7 +259,9 @@ public MemberDeclarationListInfo WithMembers(SyntaxList return new MemberDeclarationListInfo(declaration, declaration.Members); } case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif { var declaration = (RecordDeclarationSyntax)Parent; declaration = declaration.WithMembers(members); @@ -281,12 +300,19 @@ public MemberDeclarationListInfo RemoveNode(SyntaxNode node, SyntaxRemoveOptions return new MemberDeclarationListInfo(compilationUnit, compilationUnit.Members); } case SyntaxKind.NamespaceDeclaration: + { + var declaration = (NamespaceDeclarationSyntax)Parent; + declaration = declaration.RemoveNode(node, options)!; + return new MemberDeclarationListInfo(declaration, declaration.Members); + } +#if ROSLYN_4_0 case SyntaxKind.FileScopedNamespaceDeclaration: { - var declaration = (BaseNamespaceDeclarationSyntax)Parent; + var declaration = (FileScopedNamespaceDeclarationSyntax)Parent; declaration = declaration.RemoveNode(node, options)!; return new MemberDeclarationListInfo(declaration, declaration.Members); } +#endif case SyntaxKind.ClassDeclaration: { var declaration = (ClassDeclarationSyntax)Parent; @@ -294,7 +320,9 @@ public MemberDeclarationListInfo RemoveNode(SyntaxNode node, SyntaxRemoveOptions return new MemberDeclarationListInfo(declaration, declaration.Members); } case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif { var declaration = (RecordDeclarationSyntax)Parent; declaration = declaration.RemoveNode(node, options)!; @@ -333,12 +361,19 @@ public MemberDeclarationListInfo ReplaceNode(SyntaxNode oldNode, SyntaxNode newN return new MemberDeclarationListInfo(compilationUnit, compilationUnit.Members); } case SyntaxKind.NamespaceDeclaration: + { + var declaration = (NamespaceDeclarationSyntax)Parent; + declaration = declaration.ReplaceNode(oldNode, newNode); + return new MemberDeclarationListInfo(declaration, declaration.Members); + } +#if ROSLYN_4_0 case SyntaxKind.FileScopedNamespaceDeclaration: { - var declaration = (BaseNamespaceDeclarationSyntax)Parent; + var declaration = (FileScopedNamespaceDeclarationSyntax)Parent; declaration = declaration.ReplaceNode(oldNode, newNode); return new MemberDeclarationListInfo(declaration, declaration.Members); } +#endif case SyntaxKind.ClassDeclaration: { var declaration = (ClassDeclarationSyntax)Parent; @@ -346,7 +381,9 @@ public MemberDeclarationListInfo ReplaceNode(SyntaxNode oldNode, SyntaxNode newN return new MemberDeclarationListInfo(declaration, declaration.Members); } case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif { var declaration = (RecordDeclarationSyntax)Parent; declaration = declaration.ReplaceNode(oldNode, newNode); diff --git a/src/CSharp/CSharp/Syntax/ModifierListInfo.cs b/src/CSharp/CSharp/Syntax/ModifierListInfo.cs index 8e33ad2005..b076353e70 100644 --- a/src/CSharp/CSharp/Syntax/ModifierListInfo.cs +++ b/src/CSharp/CSharp/Syntax/ModifierListInfo.cs @@ -179,7 +179,9 @@ internal static ModifierListInfo Create(SyntaxNode node) case SyntaxKind.PropertyDeclaration: return new ModifierListInfo(node, ((PropertyDeclarationSyntax)node).Modifiers); case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return new ModifierListInfo(node, ((RecordDeclarationSyntax)node).Modifiers); case SyntaxKind.StructDeclaration: return new ModifierListInfo(node, ((StructDeclarationSyntax)node).Modifiers); @@ -595,7 +597,9 @@ public ModifierListInfo WithModifiers(SyntaxTokenList modifiers) return new ModifierListInfo(newNode, newNode.Modifiers); } case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif { var recordDeclaration = (RecordDeclarationSyntax)Parent; RecordDeclarationSyntax newNode = recordDeclaration.WithModifiers(modifiers); diff --git a/src/CSharp/CSharp/Syntax/TypeParameterConstraintInfo.cs b/src/CSharp/CSharp/Syntax/TypeParameterConstraintInfo.cs index 72b4676213..1e700bb983 100644 --- a/src/CSharp/CSharp/Syntax/TypeParameterConstraintInfo.cs +++ b/src/CSharp/CSharp/Syntax/TypeParameterConstraintInfo.cs @@ -175,7 +175,9 @@ internal static TypeParameterConstraintInfo Create( return new TypeParameterConstraintInfo(constraint, constraintClause); } case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif { var recordDeclaration = (RecordDeclarationSyntax)parent; diff --git a/src/CSharp/CSharp/Syntax/UsingDirectiveListInfo.cs b/src/CSharp/CSharp/Syntax/UsingDirectiveListInfo.cs index 6d7b412cdd..e608c1fe92 100644 --- a/src/CSharp/CSharp/Syntax/UsingDirectiveListInfo.cs +++ b/src/CSharp/CSharp/Syntax/UsingDirectiveListInfo.cs @@ -91,6 +91,7 @@ internal static UsingDirectiveListInfo Create(NamespaceDeclarationSyntax namespa return new UsingDirectiveListInfo(namespaceDeclaration, namespaceDeclaration.Usings); } +#if ROSLYN_4_0 internal static UsingDirectiveListInfo Create(FileScopedNamespaceDeclarationSyntax namespaceDeclaration) { if (namespaceDeclaration is null) @@ -98,6 +99,7 @@ internal static UsingDirectiveListInfo Create(FileScopedNamespaceDeclarationSynt return new UsingDirectiveListInfo(namespaceDeclaration, namespaceDeclaration.Usings); } +#endif internal static UsingDirectiveListInfo Create(CompilationUnitSyntax compilationUnit) { @@ -121,11 +123,13 @@ internal static UsingDirectiveListInfo Create(SyntaxNode declaration) var namespaceDeclaration = (NamespaceDeclarationSyntax)declaration; return new UsingDirectiveListInfo(namespaceDeclaration, namespaceDeclaration.Usings); } +#if ROSLYN_4_0 case SyntaxKind.FileScopedNamespaceDeclaration: { var fileScopedNamespaceDeclaration = (FileScopedNamespaceDeclarationSyntax)declaration; return new UsingDirectiveListInfo(fileScopedNamespaceDeclaration, fileScopedNamespaceDeclaration.Usings); } +#endif } return default; diff --git a/src/CSharp/CSharp/SyntaxAccessibility.cs b/src/CSharp/CSharp/SyntaxAccessibility.cs index 9c94f3da6e..3e91eab963 100644 --- a/src/CSharp/CSharp/SyntaxAccessibility.cs +++ b/src/CSharp/CSharp/SyntaxAccessibility.cs @@ -47,7 +47,9 @@ public static Accessibility GetDefaultAccessibility(SyntaxNode declaration) case SyntaxKind.ClassDeclaration: return SyntaxAccessibility.Instance.GetDefaultAccessibility((ClassDeclarationSyntax)declaration); case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return SyntaxAccessibility.Instance.GetDefaultAccessibility((RecordDeclarationSyntax)declaration); case SyntaxKind.StructDeclaration: return SyntaxAccessibility.Instance.GetDefaultAccessibility((StructDeclarationSyntax)declaration); @@ -61,8 +63,10 @@ public static Accessibility GetDefaultAccessibility(SyntaxNode declaration) return SyntaxAccessibility.Instance.GetDefaultAccessibility((EnumMemberDeclarationSyntax)declaration); case SyntaxKind.NamespaceDeclaration: return SyntaxAccessibility.Instance.GetDefaultAccessibility((NamespaceDeclarationSyntax)declaration); +#if ROSLYN_4_0 case SyntaxKind.FileScopedNamespaceDeclaration: return SyntaxAccessibility.Instance.GetDefaultAccessibility((FileScopedNamespaceDeclarationSyntax)declaration); +#endif case SyntaxKind.GetAccessorDeclaration: case SyntaxKind.SetAccessorDeclaration: case SyntaxKind.AddAccessorDeclaration: @@ -111,7 +115,9 @@ public static Accessibility GetDefaultExplicitAccessibility(SyntaxNode declarati case SyntaxKind.ClassDeclaration: return SyntaxAccessibility.Instance.GetDefaultExplicitAccessibility((ClassDeclarationSyntax)declaration); case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return SyntaxAccessibility.Instance.GetDefaultExplicitAccessibility((RecordDeclarationSyntax)declaration); case SyntaxKind.StructDeclaration: return SyntaxAccessibility.Instance.GetDefaultExplicitAccessibility((StructDeclarationSyntax)declaration); @@ -125,8 +131,10 @@ public static Accessibility GetDefaultExplicitAccessibility(SyntaxNode declarati return SyntaxAccessibility.Instance.GetDefaultExplicitAccessibility((EnumMemberDeclarationSyntax)declaration); case SyntaxKind.NamespaceDeclaration: return SyntaxAccessibility.Instance.GetDefaultExplicitAccessibility((NamespaceDeclarationSyntax)declaration); +#if ROSLYN_4_0 case SyntaxKind.FileScopedNamespaceDeclaration: return SyntaxAccessibility.Instance.GetDefaultExplicitAccessibility((FileScopedNamespaceDeclarationSyntax)declaration); +#endif case SyntaxKind.GetAccessorDeclaration: case SyntaxKind.SetAccessorDeclaration: case SyntaxKind.AddAccessorDeclaration: @@ -175,7 +183,9 @@ public static Accessibility GetAccessibility(SyntaxNode declaration) case SyntaxKind.ClassDeclaration: return SyntaxAccessibility.Instance.GetAccessibility((ClassDeclarationSyntax)declaration); case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return SyntaxAccessibility.Instance.GetAccessibility((RecordDeclarationSyntax)declaration); case SyntaxKind.StructDeclaration: return SyntaxAccessibility.Instance.GetAccessibility((StructDeclarationSyntax)declaration); @@ -189,8 +199,10 @@ public static Accessibility GetAccessibility(SyntaxNode declaration) return SyntaxAccessibility.Instance.GetAccessibility((EnumMemberDeclarationSyntax)declaration); case SyntaxKind.NamespaceDeclaration: return SyntaxAccessibility.Instance.GetAccessibility((NamespaceDeclarationSyntax)declaration); +#if ROSLYN_4_0 case SyntaxKind.FileScopedNamespaceDeclaration: return SyntaxAccessibility.Instance.GetAccessibility((FileScopedNamespaceDeclarationSyntax)declaration); +#endif case SyntaxKind.GetAccessorDeclaration: case SyntaxKind.SetAccessorDeclaration: case SyntaxKind.AddAccessorDeclaration: @@ -239,7 +251,9 @@ public static Accessibility GetExplicitAccessibility(SyntaxNode declaration) case SyntaxKind.ClassDeclaration: return SyntaxAccessibility.Instance.GetExplicitAccessibility((ClassDeclarationSyntax)declaration); case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return SyntaxAccessibility.Instance.GetExplicitAccessibility((RecordDeclarationSyntax)declaration); case SyntaxKind.StructDeclaration: return SyntaxAccessibility.Instance.GetExplicitAccessibility((StructDeclarationSyntax)declaration); @@ -253,8 +267,10 @@ public static Accessibility GetExplicitAccessibility(SyntaxNode declaration) return SyntaxAccessibility.Instance.GetExplicitAccessibility((EnumMemberDeclarationSyntax)declaration); case SyntaxKind.NamespaceDeclaration: return SyntaxAccessibility.Instance.GetExplicitAccessibility((NamespaceDeclarationSyntax)declaration); +#if ROSLYN_4_0 case SyntaxKind.FileScopedNamespaceDeclaration: return SyntaxAccessibility.Instance.GetExplicitAccessibility((FileScopedNamespaceDeclarationSyntax)declaration); +#endif case SyntaxKind.GetAccessorDeclaration: case SyntaxKind.SetAccessorDeclaration: case SyntaxKind.AddAccessorDeclaration: @@ -336,8 +352,13 @@ public static bool IsPubliclyVisible(MemberDeclarationSyntax declaration) do { +#if ROSLYN_4_0 if (declaration.IsKind(SyntaxKind.NamespaceDeclaration, SyntaxKind.FileScopedNamespaceDeclaration)) return true; +#else + if (declaration.IsKind(SyntaxKind.NamespaceDeclaration)) + return true; +#endif if (!GetAccessibility(declaration).Is( Accessibility.Public, @@ -405,13 +426,17 @@ public static bool IsValidAccessibility(SyntaxNode node, Accessibility accessibi switch (node.Parent?.Kind()) { case SyntaxKind.NamespaceDeclaration: +#if ROSLYN_4_0 case SyntaxKind.FileScopedNamespaceDeclaration: +#endif case SyntaxKind.CompilationUnit: { return accessibility.Is(Accessibility.Public, Accessibility.Internal); } case SyntaxKind.StructDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif { if (accessibility.ContainsProtected()) return false; @@ -426,7 +451,9 @@ public static bool IsValidAccessibility(SyntaxNode node, Accessibility accessibi case SyntaxKind.InterfaceDeclaration: case SyntaxKind.RecordDeclaration: case SyntaxKind.StructDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif case SyntaxKind.EnumDeclaration: { return true; diff --git a/src/CSharp/CSharp/SyntaxAccessibility`1.cs b/src/CSharp/CSharp/SyntaxAccessibility`1.cs index 386cddc377..62824c11bc 100644 --- a/src/CSharp/CSharp/SyntaxAccessibility`1.cs +++ b/src/CSharp/CSharp/SyntaxAccessibility`1.cs @@ -60,10 +60,10 @@ private static object GetInstance() if (typeof(TNode) == typeof(NamespaceDeclarationSyntax)) return new NamespaceAccessibility(); - +#if ROSLYN_4_0 if (typeof(TNode) == typeof(FileScopedNamespaceDeclarationSyntax)) return new FileScopedNamespaceAccessibility(); - +#endif if (typeof(TNode) == typeof(OperatorDeclarationSyntax)) return new OperatorAccessibility(); @@ -186,7 +186,11 @@ public static Accessibility GetDefaultAccessibility(BaseTypeDeclarationSyntax de if (declaration is null) throw new ArgumentNullException(nameof(declaration)); +#if ROSLYN_4_0 return (declaration.IsParentKind(SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.RecordDeclaration, SyntaxKind.RecordStructDeclaration)) +#else + return (declaration.IsParentKind(SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.RecordDeclaration)) +#endif ? Accessibility.Private : Accessibility.Internal; } @@ -196,7 +200,11 @@ public static Accessibility GetDefaultExplicitAccessibility(BaseTypeDeclarationS if (declaration is null) throw new ArgumentNullException(nameof(declaration)); +#if ROSLYN_4_0 return (declaration.IsParentKind(SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.RecordDeclaration, SyntaxKind.RecordStructDeclaration)) +#else + return (declaration.IsParentKind(SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.RecordDeclaration)) +#endif ? Accessibility.Private : Accessibility.Internal; } @@ -325,9 +333,20 @@ public override Accessibility GetDefaultAccessibility(DelegateDeclarationSyntax if (declaration is null) throw new ArgumentNullException(nameof(declaration)); - return (declaration.IsParentKind(SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.RecordDeclaration, SyntaxKind.RecordStructDeclaration)) - ? Accessibility.Private - : Accessibility.Internal; + if (declaration.IsParentKind( + SyntaxKind.ClassDeclaration, + SyntaxKind.StructDeclaration, +#if ROSLYN_4_0 + SyntaxKind.RecordStructDeclaration, +#endif + SyntaxKind.RecordDeclaration)) + { + return Accessibility.Private; + } + else + { + return Accessibility.Internal; + } } public override Accessibility GetDefaultExplicitAccessibility(DelegateDeclarationSyntax declaration) @@ -335,9 +354,21 @@ public override Accessibility GetDefaultExplicitAccessibility(DelegateDeclaratio if (declaration is null) throw new ArgumentNullException(nameof(declaration)); - return (declaration.IsParentKind(SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.RecordDeclaration, SyntaxKind.RecordStructDeclaration)) - ? Accessibility.Private - : Accessibility.Internal; + if (declaration.IsParentKind( + SyntaxKind.ClassDeclaration, + SyntaxKind.StructDeclaration, +#if ROSLYN_4_0 + SyntaxKind.RecordStructDeclaration, +#endif + SyntaxKind.RecordDeclaration + )) + { + return Accessibility.Private; + } + else + { + return Accessibility.Internal; + } } public override Accessibility GetAccessibility(DelegateDeclarationSyntax declaration) @@ -771,6 +802,7 @@ public override Accessibility GetExplicitAccessibility(NamespaceDeclarationSynta } } +#if ROSLYN_4_0 private class FileScopedNamespaceAccessibility : SyntaxAccessibility { public override Accessibility GetDefaultAccessibility(FileScopedNamespaceDeclarationSyntax declaration) @@ -802,6 +834,7 @@ public override Accessibility GetExplicitAccessibility(FileScopedNamespaceDeclar return Accessibility.NotApplicable; } } +#endif private class OperatorAccessibility : SyntaxAccessibility { diff --git a/src/CSharp/CSharp/SyntaxInfo.cs b/src/CSharp/CSharp/SyntaxInfo.cs index 25794d4678..121bf429fd 100644 --- a/src/CSharp/CSharp/SyntaxInfo.cs +++ b/src/CSharp/CSharp/SyntaxInfo.cs @@ -300,6 +300,7 @@ public static MemberDeclarationListInfo MemberDeclarationListInfo(NamespaceDecla return Syntax.MemberDeclarationListInfo.Create(declaration); } +#if ROSLYN_4_0 /// /// Creates a new from the specified declaration. /// @@ -307,6 +308,7 @@ public static MemberDeclarationListInfo MemberDeclarationListInfo(BaseNamespaceD { return Syntax.MemberDeclarationListInfo.Create(declaration); } +#endif /// /// Creates a new from the specified declaration. @@ -935,6 +937,7 @@ public static UsingDirectiveListInfo UsingDirectiveListInfo(NamespaceDeclaration return Syntax.UsingDirectiveListInfo.Create(declaration); } +#if ROSLYN_4_0 /// /// Creates a new from the specified declaration. /// @@ -942,6 +945,7 @@ public static UsingDirectiveListInfo UsingDirectiveListInfo(FileScopedNamespaceD { return Syntax.UsingDirectiveListInfo.Create(declaration); } +#endif /// /// Creates a new from the specified xml node. diff --git a/src/CSharp/CSharp/SyntaxRefactorings.cs b/src/CSharp/CSharp/SyntaxRefactorings.cs index e92242db3d..dad16001dd 100644 --- a/src/CSharp/CSharp/SyntaxRefactorings.cs +++ b/src/CSharp/CSharp/SyntaxRefactorings.cs @@ -50,7 +50,9 @@ public static T AddAttributeLists( case SyntaxKind.TypeParameter: return (T)(SyntaxNode)AddAttributeLists((TypeParameterSyntax)(SyntaxNode)node, keepDocumentationCommentOnTop, attributeLists, f => f.AttributeLists.Any(), (f, g) => f.WithAttributeLists(g), (f, g) => f.AddAttributeLists(g)); case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return (T)(SyntaxNode)AddAttributeLists((RecordDeclarationSyntax)(SyntaxNode)node, keepDocumentationCommentOnTop, attributeLists, f => f.AttributeLists.Any(), (f, g) => f.WithAttributeLists(g), (f, g) => f.AddAttributeLists(g)); case SyntaxKind.StructDeclaration: return (T)(SyntaxNode)AddAttributeLists((StructDeclarationSyntax)(SyntaxNode)node, keepDocumentationCommentOnTop, attributeLists, f => f.AttributeLists.Any(), (f, g) => f.WithAttributeLists(g), (f, g) => f.AddAttributeLists(g)); @@ -417,7 +419,11 @@ public static InterfaceDeclarationSyntax RemoveMember(InterfaceDeclarationSyntax return RemoveNode(interfaceDeclaration, f => f.Members, index, GetRemoveOptions(newMember)); } +#if ROSLYN_4_0 public static BaseNamespaceDeclarationSyntax RemoveMember(BaseNamespaceDeclarationSyntax namespaceDeclaration, MemberDeclarationSyntax member) +#else + public static NamespaceDeclarationSyntax RemoveMember(NamespaceDeclarationSyntax namespaceDeclaration, MemberDeclarationSyntax member) +#endif { if (namespaceDeclaration is null) throw new ArgumentNullException(nameof(namespaceDeclaration)); @@ -431,14 +437,18 @@ public static BaseNamespaceDeclarationSyntax RemoveMember(BaseNamespaceDeclarati namespaceDeclaration = namespaceDeclaration.WithMembers(namespaceDeclaration.Members.ReplaceAt(index, newMember)); +#if ROSLYN_4_0 if (namespaceDeclaration.IsKind(SyntaxKind.FileScopedNamespaceDeclaration)) { return namespaceDeclaration.RemoveNode(namespaceDeclaration.Members[index], GetRemoveOptions(newMember))!; } else { +#endif return RemoveNode(namespaceDeclaration, f => f.Members, index, GetRemoveOptions(newMember)); +#if ROSLYN_4_0 } +#endif } public static StructDeclarationSyntax RemoveMember(StructDeclarationSyntax structDeclaration, MemberDeclarationSyntax member) @@ -816,6 +826,7 @@ public static BinaryExpressionSyntax SwapBinaryOperands(BinaryExpressionSyntax b right: left.WithTriviaFrom(right)); } +#if ROSLYN_4_7 public static CollectionExpressionSyntax ConvertInitializerToCollectionExpression(InitializerExpressionSyntax? initializer) { if (initializer is not null) @@ -845,4 +856,5 @@ public static CollectionExpressionSyntax ConvertInitializerToCollectionExpressio return default; } +#endif } diff --git a/src/CSharp/CSharp/SyntaxWalkers/CSharpSyntaxNodeWalker.Roslyn38.cs b/src/CSharp/CSharp/SyntaxWalkers/CSharpSyntaxNodeWalker.Roslyn38.cs new file mode 100644 index 0000000000..dccc212e5c --- /dev/null +++ b/src/CSharp/CSharp/SyntaxWalkers/CSharpSyntaxNodeWalker.Roslyn38.cs @@ -0,0 +1,5391 @@ +#if ROSLYN_3_8_ONLY +// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +// + +using System; +using System.Diagnostics; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace Roslynator.CSharp.SyntaxWalkers +{ + internal abstract class CSharpSyntaxNodeWalker : CSharpSyntaxWalker + { + protected CSharpSyntaxNodeWalker(): base(depth: SyntaxWalkerDepth.Node) + { + } + + protected virtual bool ShouldVisit + { + get + { + return true; + } + } + + public override void Visit(SyntaxNode node) + { + if (!ShouldVisit) + { + return; + } + + base.Visit(node); + } + + public override void VisitAccessorDeclaration(AccessorDeclarationSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + BlockSyntax body = node.Body; + if (body != null) + { + VisitBlock(body); + } + + if (!ShouldVisit) + { + return; + } + + ArrowExpressionClauseSyntax expressionBody = node.ExpressionBody; + if (expressionBody != null) + { + VisitArrowExpressionClause(expressionBody); + } + } + + public override void VisitAccessorList(AccessorListSyntax node) + { + foreach (AccessorDeclarationSyntax accessorDeclaration in node.Accessors) + { + if (!ShouldVisit) + { + return; + } + + VisitAccessorDeclaration(accessorDeclaration); + } + } + + public override void VisitAliasQualifiedName(AliasQualifiedNameSyntax node) + { + if (!ShouldVisit) + { + return; + } + + IdentifierNameSyntax alias = node.Alias; + if (alias != null) + { + VisitIdentifierName(alias); + } + + if (!ShouldVisit) + { + return; + } + + SimpleNameSyntax name = node.Name; + if (name != null) + { + VisitSimpleName(name); + } + } + + public override void VisitAnonymousMethodExpression(AnonymousMethodExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ParameterListSyntax parameterList = node.ParameterList; + if (parameterList != null) + { + VisitParameterList(parameterList); + } + + if (!ShouldVisit) + { + return; + } + + BlockSyntax block = node.Block; + if (block != null) + { + VisitBlock(block); + } + } + + public override void VisitAnonymousObjectCreationExpression(AnonymousObjectCreationExpressionSyntax node) + { + foreach (AnonymousObjectMemberDeclaratorSyntax anonymousObjectMemberDeclarator in node.Initializers) + { + if (!ShouldVisit) + { + return; + } + + VisitAnonymousObjectMemberDeclarator(anonymousObjectMemberDeclarator); + } + } + + public override void VisitAnonymousObjectMemberDeclarator(AnonymousObjectMemberDeclaratorSyntax node) + { + if (!ShouldVisit) + { + return; + } + + NameEqualsSyntax nameEquals = node.NameEquals; + if (nameEquals != null) + { + VisitNameEquals(nameEquals); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitArgument(ArgumentSyntax node) + { + if (!ShouldVisit) + { + return; + } + + NameColonSyntax nameColon = node.NameColon; + if (nameColon != null) + { + VisitNameColon(nameColon); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitArgumentList(ArgumentListSyntax node) + { + foreach (ArgumentSyntax argument in node.Arguments) + { + if (!ShouldVisit) + { + return; + } + + VisitArgument(argument); + } + } + + public override void VisitArrayCreationExpression(ArrayCreationExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ArrayTypeSyntax type = node.Type; + if (type != null) + { + VisitArrayType(type); + } + + if (!ShouldVisit) + { + return; + } + + InitializerExpressionSyntax initializer = node.Initializer; + if (initializer != null) + { + VisitInitializerExpression(initializer); + } + } + + public override void VisitArrayRankSpecifier(ArrayRankSpecifierSyntax node) + { + foreach (ExpressionSyntax expression in node.Sizes) + { + if (!ShouldVisit) + { + return; + } + + VisitExpression(expression); + } + } + + public override void VisitArrayType(ArrayTypeSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax elementType = node.ElementType; + if (elementType != null) + { + VisitType(elementType); + } + + foreach (ArrayRankSpecifierSyntax arrayRankSpecifier in node.RankSpecifiers) + { + if (!ShouldVisit) + { + return; + } + + VisitArrayRankSpecifier(arrayRankSpecifier); + } + } + + public override void VisitArrowExpressionClause(ArrowExpressionClauseSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitAssignmentExpression(AssignmentExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax left = node.Left; + if (left != null) + { + VisitExpression(left); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax right = node.Right; + if (right != null) + { + VisitExpression(right); + } + } + + public override void VisitAttribute(AttributeSyntax node) + { + if (!ShouldVisit) + { + return; + } + + NameSyntax name = node.Name; + if (name != null) + { + VisitType(name); + } + + if (!ShouldVisit) + { + return; + } + + AttributeArgumentListSyntax argumentList = node.ArgumentList; + if (argumentList != null) + { + VisitAttributeArgumentList(argumentList); + } + } + + public override void VisitAttributeArgument(AttributeArgumentSyntax node) + { + if (!ShouldVisit) + { + return; + } + + NameEqualsSyntax nameEquals = node.NameEquals; + if (nameEquals != null) + { + VisitNameEquals(nameEquals); + } + + if (!ShouldVisit) + { + return; + } + + NameColonSyntax nameColon = node.NameColon; + if (nameColon != null) + { + VisitNameColon(nameColon); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitAttributeArgumentList(AttributeArgumentListSyntax node) + { + foreach (AttributeArgumentSyntax attributeArgument in node.Arguments) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeArgument(attributeArgument); + } + } + + public override void VisitAttributeList(AttributeListSyntax node) + { + if (!ShouldVisit) + { + return; + } + + AttributeTargetSpecifierSyntax target = node.Target; + if (target != null) + { + VisitAttributeTargetSpecifier(target); + } + + foreach (AttributeSyntax attribute in node.Attributes) + { + if (!ShouldVisit) + { + return; + } + + VisitAttribute(attribute); + } + } + + public override void VisitAttributeTargetSpecifier(AttributeTargetSpecifierSyntax node) + { + } + + public override void VisitAwaitExpression(AwaitExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitBadDirectiveTrivia(BadDirectiveTriviaSyntax node) + { + } + + public override void VisitBaseExpression(BaseExpressionSyntax node) + { + } + + public override void VisitBaseList(BaseListSyntax node) + { + foreach (BaseTypeSyntax baseType in node.Types) + { + if (!ShouldVisit) + { + return; + } + + VisitBaseType(baseType); + } + } + + public override void VisitBinaryExpression(BinaryExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax left = node.Left; + if (left != null) + { + VisitExpression(left); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax right = node.Right; + if (right != null) + { + VisitExpression(right); + } + } + + public override void VisitBinaryPattern(BinaryPatternSyntax node) + { + if (!ShouldVisit) + { + return; + } + + PatternSyntax left = node.Left; + if (left != null) + { + VisitPattern(left); + } + + if (!ShouldVisit) + { + return; + } + + PatternSyntax right = node.Right; + if (right != null) + { + VisitPattern(right); + } + } + + public override void VisitBlock(BlockSyntax node) + { + foreach (StatementSyntax statement in node.Statements) + { + if (!ShouldVisit) + { + return; + } + + VisitStatement(statement); + } + } + + public override void VisitBracketedArgumentList(BracketedArgumentListSyntax node) + { + foreach (ArgumentSyntax argument in node.Arguments) + { + if (!ShouldVisit) + { + return; + } + + VisitArgument(argument); + } + } + + public override void VisitBracketedParameterList(BracketedParameterListSyntax node) + { + foreach (ParameterSyntax parameter in node.Parameters) + { + if (!ShouldVisit) + { + return; + } + + VisitParameter(parameter); + } + } + + public override void VisitBreakStatement(BreakStatementSyntax node) + { + } + + public override void VisitCasePatternSwitchLabel(CasePatternSwitchLabelSyntax node) + { + if (!ShouldVisit) + { + return; + } + + PatternSyntax pattern = node.Pattern; + if (pattern != null) + { + VisitPattern(pattern); + } + + if (!ShouldVisit) + { + return; + } + + WhenClauseSyntax whenClause = node.WhenClause; + if (whenClause != null) + { + VisitWhenClause(whenClause); + } + } + + public override void VisitCaseSwitchLabel(CaseSwitchLabelSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax value = node.Value; + if (value != null) + { + VisitExpression(value); + } + } + + public override void VisitCastExpression(CastExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitCatchClause(CatchClauseSyntax node) + { + if (!ShouldVisit) + { + return; + } + + CatchDeclarationSyntax declaration = node.Declaration; + if (declaration != null) + { + VisitCatchDeclaration(declaration); + } + + if (!ShouldVisit) + { + return; + } + + CatchFilterClauseSyntax filter = node.Filter; + if (filter != null) + { + VisitCatchFilterClause(filter); + } + + if (!ShouldVisit) + { + return; + } + + BlockSyntax block = node.Block; + if (block != null) + { + VisitBlock(block); + } + } + + public override void VisitCatchDeclaration(CatchDeclarationSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + } + + public override void VisitCatchFilterClause(CatchFilterClauseSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax filterExpression = node.FilterExpression; + if (filterExpression != null) + { + VisitExpression(filterExpression); + } + } + + public override void VisitClassDeclaration(ClassDeclarationSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + TypeParameterListSyntax typeParameterList = node.TypeParameterList; + if (typeParameterList != null) + { + VisitTypeParameterList(typeParameterList); + } + + if (!ShouldVisit) + { + return; + } + + BaseListSyntax baseList = node.BaseList; + if (baseList != null) + { + VisitBaseList(baseList); + } + + foreach (TypeParameterConstraintClauseSyntax typeParameterConstraintClause in node.ConstraintClauses) + { + if (!ShouldVisit) + { + return; + } + + VisitTypeParameterConstraintClause(typeParameterConstraintClause); + } + + foreach (MemberDeclarationSyntax memberDeclaration in node.Members) + { + if (!ShouldVisit) + { + return; + } + + VisitMemberDeclaration(memberDeclaration); + } + } + + public override void VisitClassOrStructConstraint(ClassOrStructConstraintSyntax node) + { + } + + public override void VisitCompilationUnit(CompilationUnitSyntax node) + { + foreach (ExternAliasDirectiveSyntax externAliasDirective in node.Externs) + { + if (!ShouldVisit) + { + return; + } + + VisitExternAliasDirective(externAliasDirective); + } + + foreach (UsingDirectiveSyntax usingDirective in node.Usings) + { + if (!ShouldVisit) + { + return; + } + + VisitUsingDirective(usingDirective); + } + + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + foreach (MemberDeclarationSyntax memberDeclaration in node.Members) + { + if (!ShouldVisit) + { + return; + } + + VisitMemberDeclaration(memberDeclaration); + } + } + + public override void VisitConditionalAccessExpression(ConditionalAccessExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax whenNotNull = node.WhenNotNull; + if (whenNotNull != null) + { + VisitExpression(whenNotNull); + } + } + + public override void VisitConditionalExpression(ConditionalExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax condition = node.Condition; + if (condition != null) + { + VisitExpression(condition); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax whenTrue = node.WhenTrue; + if (whenTrue != null) + { + VisitExpression(whenTrue); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax whenFalse = node.WhenFalse; + if (whenFalse != null) + { + VisitExpression(whenFalse); + } + } + + public override void VisitConstantPattern(ConstantPatternSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitConstructorConstraint(ConstructorConstraintSyntax node) + { + } + + public override void VisitConstructorDeclaration(ConstructorDeclarationSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + ParameterListSyntax parameterList = node.ParameterList; + if (parameterList != null) + { + VisitParameterList(parameterList); + } + + if (!ShouldVisit) + { + return; + } + + ConstructorInitializerSyntax initializer = node.Initializer; + if (initializer != null) + { + VisitConstructorInitializer(initializer); + } + + if (!ShouldVisit) + { + return; + } + + BlockSyntax body = node.Body; + if (body != null) + { + VisitBlock(body); + } + + if (!ShouldVisit) + { + return; + } + + ArrowExpressionClauseSyntax expressionBody = node.ExpressionBody; + if (expressionBody != null) + { + VisitArrowExpressionClause(expressionBody); + } + } + + public override void VisitConstructorInitializer(ConstructorInitializerSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ArgumentListSyntax argumentList = node.ArgumentList; + if (argumentList != null) + { + VisitArgumentList(argumentList); + } + } + + public override void VisitContinueStatement(ContinueStatementSyntax node) + { + } + + public override void VisitConversionOperatorDeclaration(ConversionOperatorDeclarationSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + + if (!ShouldVisit) + { + return; + } + + ParameterListSyntax parameterList = node.ParameterList; + if (parameterList != null) + { + VisitParameterList(parameterList); + } + + if (!ShouldVisit) + { + return; + } + + BlockSyntax body = node.Body; + if (body != null) + { + VisitBlock(body); + } + + if (!ShouldVisit) + { + return; + } + + ArrowExpressionClauseSyntax expressionBody = node.ExpressionBody; + if (expressionBody != null) + { + VisitArrowExpressionClause(expressionBody); + } + } + + public override void VisitConversionOperatorMemberCref(ConversionOperatorMemberCrefSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + + if (!ShouldVisit) + { + return; + } + + CrefParameterListSyntax parameters = node.Parameters; + if (parameters != null) + { + VisitCrefParameterList(parameters); + } + } + + public override void VisitCrefBracketedParameterList(CrefBracketedParameterListSyntax node) + { + foreach (CrefParameterSyntax crefParameter in node.Parameters) + { + if (!ShouldVisit) + { + return; + } + + VisitCrefParameter(crefParameter); + } + } + + public override void VisitCrefParameter(CrefParameterSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + } + + public override void VisitCrefParameterList(CrefParameterListSyntax node) + { + foreach (CrefParameterSyntax crefParameter in node.Parameters) + { + if (!ShouldVisit) + { + return; + } + + VisitCrefParameter(crefParameter); + } + } + + public override void VisitDeclarationExpression(DeclarationExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + + if (!ShouldVisit) + { + return; + } + + VariableDesignationSyntax designation = node.Designation; + if (designation != null) + { + VisitVariableDesignation(designation); + } + } + + public override void VisitDeclarationPattern(DeclarationPatternSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + + if (!ShouldVisit) + { + return; + } + + VariableDesignationSyntax designation = node.Designation; + if (designation != null) + { + VisitVariableDesignation(designation); + } + } + + public override void VisitDefaultConstraint(DefaultConstraintSyntax node) + { + } + + public override void VisitDefaultExpression(DefaultExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + } + + public override void VisitDefaultSwitchLabel(DefaultSwitchLabelSyntax node) + { + } + + public override void VisitDefineDirectiveTrivia(DefineDirectiveTriviaSyntax node) + { + } + + public override void VisitDelegateDeclaration(DelegateDeclarationSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + TypeSyntax returnType = node.ReturnType; + if (returnType != null) + { + VisitType(returnType); + } + + if (!ShouldVisit) + { + return; + } + + TypeParameterListSyntax typeParameterList = node.TypeParameterList; + if (typeParameterList != null) + { + VisitTypeParameterList(typeParameterList); + } + + if (!ShouldVisit) + { + return; + } + + ParameterListSyntax parameterList = node.ParameterList; + if (parameterList != null) + { + VisitParameterList(parameterList); + } + + foreach (TypeParameterConstraintClauseSyntax typeParameterConstraintClause in node.ConstraintClauses) + { + if (!ShouldVisit) + { + return; + } + + VisitTypeParameterConstraintClause(typeParameterConstraintClause); + } + } + + public override void VisitDestructorDeclaration(DestructorDeclarationSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + ParameterListSyntax parameterList = node.ParameterList; + if (parameterList != null) + { + VisitParameterList(parameterList); + } + + if (!ShouldVisit) + { + return; + } + + BlockSyntax body = node.Body; + if (body != null) + { + VisitBlock(body); + } + + if (!ShouldVisit) + { + return; + } + + ArrowExpressionClauseSyntax expressionBody = node.ExpressionBody; + if (expressionBody != null) + { + VisitArrowExpressionClause(expressionBody); + } + } + + public override void VisitDiscardDesignation(DiscardDesignationSyntax node) + { + } + + public override void VisitDiscardPattern(DiscardPatternSyntax node) + { + } + + public override void VisitDocumentationCommentTrivia(DocumentationCommentTriviaSyntax node) + { + foreach (XmlNodeSyntax xmlNode in node.Content) + { + if (!ShouldVisit) + { + return; + } + + VisitXmlNode(xmlNode); + } + } + + public override void VisitDoStatement(DoStatementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + StatementSyntax statement = node.Statement; + if (statement != null) + { + VisitStatement(statement); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax condition = node.Condition; + if (condition != null) + { + VisitExpression(condition); + } + } + + public override void VisitElementAccessExpression(ElementAccessExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + + if (!ShouldVisit) + { + return; + } + + BracketedArgumentListSyntax argumentList = node.ArgumentList; + if (argumentList != null) + { + VisitBracketedArgumentList(argumentList); + } + } + + public override void VisitElementBindingExpression(ElementBindingExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + BracketedArgumentListSyntax argumentList = node.ArgumentList; + if (argumentList != null) + { + VisitBracketedArgumentList(argumentList); + } + } + + public override void VisitElifDirectiveTrivia(ElifDirectiveTriviaSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax condition = node.Condition; + if (condition != null) + { + VisitExpression(condition); + } + } + + public override void VisitElseClause(ElseClauseSyntax node) + { + if (!ShouldVisit) + { + return; + } + + StatementSyntax statement = node.Statement; + if (statement != null) + { + VisitStatement(statement); + } + } + + public override void VisitElseDirectiveTrivia(ElseDirectiveTriviaSyntax node) + { + } + + public override void VisitEmptyStatement(EmptyStatementSyntax node) + { + } + + public override void VisitEndIfDirectiveTrivia(EndIfDirectiveTriviaSyntax node) + { + } + + public override void VisitEndRegionDirectiveTrivia(EndRegionDirectiveTriviaSyntax node) + { + } + + public override void VisitEnumDeclaration(EnumDeclarationSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + BaseListSyntax baseList = node.BaseList; + if (baseList != null) + { + VisitBaseList(baseList); + } + + foreach (EnumMemberDeclarationSyntax enumMemberDeclaration in node.Members) + { + if (!ShouldVisit) + { + return; + } + + VisitEnumMemberDeclaration(enumMemberDeclaration); + } + } + + public override void VisitEnumMemberDeclaration(EnumMemberDeclarationSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + EqualsValueClauseSyntax equalsValue = node.EqualsValue; + if (equalsValue != null) + { + VisitEqualsValueClause(equalsValue); + } + } + + public override void VisitEqualsValueClause(EqualsValueClauseSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax value = node.Value; + if (value != null) + { + VisitExpression(value); + } + } + + public override void VisitErrorDirectiveTrivia(ErrorDirectiveTriviaSyntax node) + { + } + + public override void VisitEventDeclaration(EventDeclarationSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + + if (!ShouldVisit) + { + return; + } + + ExplicitInterfaceSpecifierSyntax explicitInterfaceSpecifier = node.ExplicitInterfaceSpecifier; + if (explicitInterfaceSpecifier != null) + { + VisitExplicitInterfaceSpecifier(explicitInterfaceSpecifier); + } + + if (!ShouldVisit) + { + return; + } + + AccessorListSyntax accessorList = node.AccessorList; + if (accessorList != null) + { + VisitAccessorList(accessorList); + } + } + + public override void VisitEventFieldDeclaration(EventFieldDeclarationSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + VariableDeclarationSyntax declaration = node.Declaration; + if (declaration != null) + { + VisitVariableDeclaration(declaration); + } + } + + public override void VisitExplicitInterfaceSpecifier(ExplicitInterfaceSpecifierSyntax node) + { + if (!ShouldVisit) + { + return; + } + + NameSyntax name = node.Name; + if (name != null) + { + VisitType(name); + } + } + + public override void VisitExpressionStatement(ExpressionStatementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitExternAliasDirective(ExternAliasDirectiveSyntax node) + { + } + + public override void VisitFieldDeclaration(FieldDeclarationSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + VariableDeclarationSyntax declaration = node.Declaration; + if (declaration != null) + { + VisitVariableDeclaration(declaration); + } + } + + public override void VisitFinallyClause(FinallyClauseSyntax node) + { + if (!ShouldVisit) + { + return; + } + + BlockSyntax block = node.Block; + if (block != null) + { + VisitBlock(block); + } + } + + public override void VisitFixedStatement(FixedStatementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + VariableDeclarationSyntax declaration = node.Declaration; + if (declaration != null) + { + VisitVariableDeclaration(declaration); + } + + if (!ShouldVisit) + { + return; + } + + StatementSyntax statement = node.Statement; + if (statement != null) + { + VisitStatement(statement); + } + } + + public override void VisitForEachStatement(ForEachStatementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + + if (!ShouldVisit) + { + return; + } + + StatementSyntax statement = node.Statement; + if (statement != null) + { + VisitStatement(statement); + } + } + + public override void VisitForEachVariableStatement(ForEachVariableStatementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax variable = node.Variable; + if (variable != null) + { + VisitExpression(variable); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + + if (!ShouldVisit) + { + return; + } + + StatementSyntax statement = node.Statement; + if (statement != null) + { + VisitStatement(statement); + } + } + + public override void VisitForStatement(ForStatementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + VariableDeclarationSyntax declaration = node.Declaration; + if (declaration != null) + { + VisitVariableDeclaration(declaration); + } + + foreach (ExpressionSyntax expression in node.Initializers) + { + if (!ShouldVisit) + { + return; + } + + VisitExpression(expression); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax condition = node.Condition; + if (condition != null) + { + VisitExpression(condition); + } + + foreach (ExpressionSyntax expression2 in node.Incrementors) + { + if (!ShouldVisit) + { + return; + } + + VisitExpression(expression2); + } + + if (!ShouldVisit) + { + return; + } + + StatementSyntax statement = node.Statement; + if (statement != null) + { + VisitStatement(statement); + } + } + + public override void VisitFromClause(FromClauseSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitFunctionPointerCallingConvention(FunctionPointerCallingConventionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + FunctionPointerUnmanagedCallingConventionListSyntax unmanagedCallingConventionList = node.UnmanagedCallingConventionList; + if (unmanagedCallingConventionList != null) + { + VisitFunctionPointerUnmanagedCallingConventionList(unmanagedCallingConventionList); + } + } + + public override void VisitFunctionPointerParameter(FunctionPointerParameterSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + } + + public override void VisitFunctionPointerParameterList(FunctionPointerParameterListSyntax node) + { + foreach (FunctionPointerParameterSyntax functionPointerParameter in node.Parameters) + { + if (!ShouldVisit) + { + return; + } + + VisitFunctionPointerParameter(functionPointerParameter); + } + } + + public override void VisitFunctionPointerType(FunctionPointerTypeSyntax node) + { + if (!ShouldVisit) + { + return; + } + + FunctionPointerCallingConventionSyntax callingConvention = node.CallingConvention; + if (callingConvention != null) + { + VisitFunctionPointerCallingConvention(callingConvention); + } + + if (!ShouldVisit) + { + return; + } + + FunctionPointerParameterListSyntax parameterList = node.ParameterList; + if (parameterList != null) + { + VisitFunctionPointerParameterList(parameterList); + } + } + + public override void VisitFunctionPointerUnmanagedCallingConvention(FunctionPointerUnmanagedCallingConventionSyntax node) + { + } + + public override void VisitFunctionPointerUnmanagedCallingConventionList(FunctionPointerUnmanagedCallingConventionListSyntax node) + { + foreach (FunctionPointerUnmanagedCallingConventionSyntax functionPointerUnmanagedCallingConvention in node.CallingConventions) + { + if (!ShouldVisit) + { + return; + } + + VisitFunctionPointerUnmanagedCallingConvention(functionPointerUnmanagedCallingConvention); + } + } + + public override void VisitGenericName(GenericNameSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeArgumentListSyntax typeArgumentList = node.TypeArgumentList; + if (typeArgumentList != null) + { + VisitTypeArgumentList(typeArgumentList); + } + } + + public override void VisitGlobalStatement(GlobalStatementSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + StatementSyntax statement = node.Statement; + if (statement != null) + { + VisitStatement(statement); + } + } + + public override void VisitGotoStatement(GotoStatementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitGroupClause(GroupClauseSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax groupExpression = node.GroupExpression; + if (groupExpression != null) + { + VisitExpression(groupExpression); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax byExpression = node.ByExpression; + if (byExpression != null) + { + VisitExpression(byExpression); + } + } + + public override void VisitCheckedExpression(CheckedExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitCheckedStatement(CheckedStatementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + BlockSyntax block = node.Block; + if (block != null) + { + VisitBlock(block); + } + } + + public override void VisitIdentifierName(IdentifierNameSyntax node) + { + } + + public override void VisitIfDirectiveTrivia(IfDirectiveTriviaSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax condition = node.Condition; + if (condition != null) + { + VisitExpression(condition); + } + } + + public override void VisitIfStatement(IfStatementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax condition = node.Condition; + if (condition != null) + { + VisitExpression(condition); + } + + if (!ShouldVisit) + { + return; + } + + StatementSyntax statement = node.Statement; + if (statement != null) + { + VisitStatement(statement); + } + + if (!ShouldVisit) + { + return; + } + + ElseClauseSyntax @else = node.Else; + if (@else != null) + { + VisitElseClause(@else); + } + } + + public override void VisitImplicitArrayCreationExpression(ImplicitArrayCreationExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + InitializerExpressionSyntax initializer = node.Initializer; + if (initializer != null) + { + VisitInitializerExpression(initializer); + } + } + + public override void VisitImplicitElementAccess(ImplicitElementAccessSyntax node) + { + if (!ShouldVisit) + { + return; + } + + BracketedArgumentListSyntax argumentList = node.ArgumentList; + if (argumentList != null) + { + VisitBracketedArgumentList(argumentList); + } + } + + public override void VisitImplicitObjectCreationExpression(ImplicitObjectCreationExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ArgumentListSyntax argumentList = node.ArgumentList; + if (argumentList != null) + { + VisitArgumentList(argumentList); + } + + if (!ShouldVisit) + { + return; + } + + InitializerExpressionSyntax initializer = node.Initializer; + if (initializer != null) + { + VisitInitializerExpression(initializer); + } + } + + public override void VisitImplicitStackAllocArrayCreationExpression(ImplicitStackAllocArrayCreationExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + InitializerExpressionSyntax initializer = node.Initializer; + if (initializer != null) + { + VisitInitializerExpression(initializer); + } + } + + public override void VisitIncompleteMember(IncompleteMemberSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + } + + public override void VisitIndexerDeclaration(IndexerDeclarationSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + + if (!ShouldVisit) + { + return; + } + + ExplicitInterfaceSpecifierSyntax explicitInterfaceSpecifier = node.ExplicitInterfaceSpecifier; + if (explicitInterfaceSpecifier != null) + { + VisitExplicitInterfaceSpecifier(explicitInterfaceSpecifier); + } + + if (!ShouldVisit) + { + return; + } + + BracketedParameterListSyntax parameterList = node.ParameterList; + if (parameterList != null) + { + VisitBracketedParameterList(parameterList); + } + + if (!ShouldVisit) + { + return; + } + + AccessorListSyntax accessorList = node.AccessorList; + if (accessorList != null) + { + VisitAccessorList(accessorList); + } + + if (!ShouldVisit) + { + return; + } + + ArrowExpressionClauseSyntax expressionBody = node.ExpressionBody; + if (expressionBody != null) + { + VisitArrowExpressionClause(expressionBody); + } + } + + public override void VisitIndexerMemberCref(IndexerMemberCrefSyntax node) + { + if (!ShouldVisit) + { + return; + } + + CrefBracketedParameterListSyntax parameters = node.Parameters; + if (parameters != null) + { + VisitCrefBracketedParameterList(parameters); + } + } + + public override void VisitInitializerExpression(InitializerExpressionSyntax node) + { + foreach (ExpressionSyntax expression in node.Expressions) + { + if (!ShouldVisit) + { + return; + } + + VisitExpression(expression); + } + } + + public override void VisitInterfaceDeclaration(InterfaceDeclarationSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + TypeParameterListSyntax typeParameterList = node.TypeParameterList; + if (typeParameterList != null) + { + VisitTypeParameterList(typeParameterList); + } + + if (!ShouldVisit) + { + return; + } + + BaseListSyntax baseList = node.BaseList; + if (baseList != null) + { + VisitBaseList(baseList); + } + + foreach (TypeParameterConstraintClauseSyntax typeParameterConstraintClause in node.ConstraintClauses) + { + if (!ShouldVisit) + { + return; + } + + VisitTypeParameterConstraintClause(typeParameterConstraintClause); + } + + foreach (MemberDeclarationSyntax memberDeclaration in node.Members) + { + if (!ShouldVisit) + { + return; + } + + VisitMemberDeclaration(memberDeclaration); + } + } + + public override void VisitInterpolatedStringExpression(InterpolatedStringExpressionSyntax node) + { + foreach (InterpolatedStringContentSyntax interpolatedStringContent in node.Contents) + { + if (!ShouldVisit) + { + return; + } + + VisitInterpolatedStringContent(interpolatedStringContent); + } + } + + public override void VisitInterpolatedStringText(InterpolatedStringTextSyntax node) + { + } + + public override void VisitInterpolation(InterpolationSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + + if (!ShouldVisit) + { + return; + } + + InterpolationAlignmentClauseSyntax alignmentClause = node.AlignmentClause; + if (alignmentClause != null) + { + VisitInterpolationAlignmentClause(alignmentClause); + } + + if (!ShouldVisit) + { + return; + } + + InterpolationFormatClauseSyntax formatClause = node.FormatClause; + if (formatClause != null) + { + VisitInterpolationFormatClause(formatClause); + } + } + + public override void VisitInterpolationAlignmentClause(InterpolationAlignmentClauseSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax value = node.Value; + if (value != null) + { + VisitExpression(value); + } + } + + public override void VisitInterpolationFormatClause(InterpolationFormatClauseSyntax node) + { + } + + public override void VisitInvocationExpression(InvocationExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + + if (!ShouldVisit) + { + return; + } + + ArgumentListSyntax argumentList = node.ArgumentList; + if (argumentList != null) + { + VisitArgumentList(argumentList); + } + } + + public override void VisitIsPatternExpression(IsPatternExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + + if (!ShouldVisit) + { + return; + } + + PatternSyntax pattern = node.Pattern; + if (pattern != null) + { + VisitPattern(pattern); + } + } + + public override void VisitJoinClause(JoinClauseSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax inExpression = node.InExpression; + if (inExpression != null) + { + VisitExpression(inExpression); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax leftExpression = node.LeftExpression; + if (leftExpression != null) + { + VisitExpression(leftExpression); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax rightExpression = node.RightExpression; + if (rightExpression != null) + { + VisitExpression(rightExpression); + } + + if (!ShouldVisit) + { + return; + } + + JoinIntoClauseSyntax into = node.Into; + if (into != null) + { + VisitJoinIntoClause(into); + } + } + + public override void VisitJoinIntoClause(JoinIntoClauseSyntax node) + { + } + + public override void VisitLabeledStatement(LabeledStatementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + StatementSyntax statement = node.Statement; + if (statement != null) + { + VisitStatement(statement); + } + } + + public override void VisitLetClause(LetClauseSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitLineDirectiveTrivia(LineDirectiveTriviaSyntax node) + { + } + + public override void VisitLiteralExpression(LiteralExpressionSyntax node) + { + } + + public override void VisitLoadDirectiveTrivia(LoadDirectiveTriviaSyntax node) + { + } + + public override void VisitLocalDeclarationStatement(LocalDeclarationStatementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + VariableDeclarationSyntax declaration = node.Declaration; + if (declaration != null) + { + VisitVariableDeclaration(declaration); + } + } + + public override void VisitLocalFunctionStatement(LocalFunctionStatementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax returnType = node.ReturnType; + if (returnType != null) + { + VisitType(returnType); + } + + if (!ShouldVisit) + { + return; + } + + TypeParameterListSyntax typeParameterList = node.TypeParameterList; + if (typeParameterList != null) + { + VisitTypeParameterList(typeParameterList); + } + + if (!ShouldVisit) + { + return; + } + + ParameterListSyntax parameterList = node.ParameterList; + if (parameterList != null) + { + VisitParameterList(parameterList); + } + + foreach (TypeParameterConstraintClauseSyntax typeParameterConstraintClause in node.ConstraintClauses) + { + if (!ShouldVisit) + { + return; + } + + VisitTypeParameterConstraintClause(typeParameterConstraintClause); + } + + if (!ShouldVisit) + { + return; + } + + BlockSyntax body = node.Body; + if (body != null) + { + VisitBlock(body); + } + + if (!ShouldVisit) + { + return; + } + + ArrowExpressionClauseSyntax expressionBody = node.ExpressionBody; + if (expressionBody != null) + { + VisitArrowExpressionClause(expressionBody); + } + } + + public override void VisitLockStatement(LockStatementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + + if (!ShouldVisit) + { + return; + } + + StatementSyntax statement = node.Statement; + if (statement != null) + { + VisitStatement(statement); + } + } + + public override void VisitMakeRefExpression(MakeRefExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitMemberAccessExpression(MemberAccessExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + + if (!ShouldVisit) + { + return; + } + + SimpleNameSyntax name = node.Name; + if (name != null) + { + VisitSimpleName(name); + } + } + + public override void VisitMemberBindingExpression(MemberBindingExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + SimpleNameSyntax name = node.Name; + if (name != null) + { + VisitSimpleName(name); + } + } + + public override void VisitMethodDeclaration(MethodDeclarationSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + TypeSyntax returnType = node.ReturnType; + if (returnType != null) + { + VisitType(returnType); + } + + if (!ShouldVisit) + { + return; + } + + ExplicitInterfaceSpecifierSyntax explicitInterfaceSpecifier = node.ExplicitInterfaceSpecifier; + if (explicitInterfaceSpecifier != null) + { + VisitExplicitInterfaceSpecifier(explicitInterfaceSpecifier); + } + + if (!ShouldVisit) + { + return; + } + + TypeParameterListSyntax typeParameterList = node.TypeParameterList; + if (typeParameterList != null) + { + VisitTypeParameterList(typeParameterList); + } + + if (!ShouldVisit) + { + return; + } + + ParameterListSyntax parameterList = node.ParameterList; + if (parameterList != null) + { + VisitParameterList(parameterList); + } + + foreach (TypeParameterConstraintClauseSyntax typeParameterConstraintClause in node.ConstraintClauses) + { + if (!ShouldVisit) + { + return; + } + + VisitTypeParameterConstraintClause(typeParameterConstraintClause); + } + + if (!ShouldVisit) + { + return; + } + + BlockSyntax body = node.Body; + if (body != null) + { + VisitBlock(body); + } + + if (!ShouldVisit) + { + return; + } + + ArrowExpressionClauseSyntax expressionBody = node.ExpressionBody; + if (expressionBody != null) + { + VisitArrowExpressionClause(expressionBody); + } + } + + public override void VisitNameColon(NameColonSyntax node) + { + if (!ShouldVisit) + { + return; + } + + IdentifierNameSyntax name = node.Name; + if (name != null) + { + VisitIdentifierName(name); + } + } + + public override void VisitNameEquals(NameEqualsSyntax node) + { + if (!ShouldVisit) + { + return; + } + + IdentifierNameSyntax name = node.Name; + if (name != null) + { + VisitIdentifierName(name); + } + } + + public override void VisitNameMemberCref(NameMemberCrefSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax name = node.Name; + if (name != null) + { + VisitType(name); + } + + if (!ShouldVisit) + { + return; + } + + CrefParameterListSyntax parameters = node.Parameters; + if (parameters != null) + { + VisitCrefParameterList(parameters); + } + } + + public override void VisitNamespaceDeclaration(NamespaceDeclarationSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + NameSyntax name = node.Name; + if (name != null) + { + VisitType(name); + } + + foreach (ExternAliasDirectiveSyntax externAliasDirective in node.Externs) + { + if (!ShouldVisit) + { + return; + } + + VisitExternAliasDirective(externAliasDirective); + } + + foreach (UsingDirectiveSyntax usingDirective in node.Usings) + { + if (!ShouldVisit) + { + return; + } + + VisitUsingDirective(usingDirective); + } + + foreach (MemberDeclarationSyntax memberDeclaration in node.Members) + { + if (!ShouldVisit) + { + return; + } + + VisitMemberDeclaration(memberDeclaration); + } + } + + public override void VisitNullableDirectiveTrivia(NullableDirectiveTriviaSyntax node) + { + } + + public override void VisitNullableType(NullableTypeSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax elementType = node.ElementType; + if (elementType != null) + { + VisitType(elementType); + } + } + + public override void VisitObjectCreationExpression(ObjectCreationExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + + if (!ShouldVisit) + { + return; + } + + ArgumentListSyntax argumentList = node.ArgumentList; + if (argumentList != null) + { + VisitArgumentList(argumentList); + } + + if (!ShouldVisit) + { + return; + } + + InitializerExpressionSyntax initializer = node.Initializer; + if (initializer != null) + { + VisitInitializerExpression(initializer); + } + } + + public override void VisitOmittedArraySizeExpression(OmittedArraySizeExpressionSyntax node) + { + } + + public override void VisitOmittedTypeArgument(OmittedTypeArgumentSyntax node) + { + } + + public override void VisitOperatorDeclaration(OperatorDeclarationSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + TypeSyntax returnType = node.ReturnType; + if (returnType != null) + { + VisitType(returnType); + } + + if (!ShouldVisit) + { + return; + } + + ParameterListSyntax parameterList = node.ParameterList; + if (parameterList != null) + { + VisitParameterList(parameterList); + } + + if (!ShouldVisit) + { + return; + } + + BlockSyntax body = node.Body; + if (body != null) + { + VisitBlock(body); + } + + if (!ShouldVisit) + { + return; + } + + ArrowExpressionClauseSyntax expressionBody = node.ExpressionBody; + if (expressionBody != null) + { + VisitArrowExpressionClause(expressionBody); + } + } + + public override void VisitOperatorMemberCref(OperatorMemberCrefSyntax node) + { + if (!ShouldVisit) + { + return; + } + + CrefParameterListSyntax parameters = node.Parameters; + if (parameters != null) + { + VisitCrefParameterList(parameters); + } + } + + public override void VisitOrderByClause(OrderByClauseSyntax node) + { + foreach (OrderingSyntax ordering in node.Orderings) + { + if (!ShouldVisit) + { + return; + } + + VisitOrdering(ordering); + } + } + + public override void VisitOrdering(OrderingSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitParameter(ParameterSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + + if (!ShouldVisit) + { + return; + } + + EqualsValueClauseSyntax @default = node.Default; + if (@default != null) + { + VisitEqualsValueClause(@default); + } + } + + public override void VisitParameterList(ParameterListSyntax node) + { + foreach (ParameterSyntax parameter in node.Parameters) + { + if (!ShouldVisit) + { + return; + } + + VisitParameter(parameter); + } + } + + public override void VisitParenthesizedExpression(ParenthesizedExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitParenthesizedLambdaExpression(ParenthesizedLambdaExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ParameterListSyntax parameterList = node.ParameterList; + if (parameterList != null) + { + VisitParameterList(parameterList); + } + + if (!ShouldVisit) + { + return; + } + + BlockSyntax block = node.Block; + if (block != null) + { + VisitBlock(block); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expressionBody = node.ExpressionBody; + if (expressionBody != null) + { + VisitExpression(expressionBody); + } + } + + public override void VisitParenthesizedPattern(ParenthesizedPatternSyntax node) + { + if (!ShouldVisit) + { + return; + } + + PatternSyntax pattern = node.Pattern; + if (pattern != null) + { + VisitPattern(pattern); + } + } + + public override void VisitParenthesizedVariableDesignation(ParenthesizedVariableDesignationSyntax node) + { + foreach (VariableDesignationSyntax variableDesignation in node.Variables) + { + if (!ShouldVisit) + { + return; + } + + VisitVariableDesignation(variableDesignation); + } + } + + public override void VisitPointerType(PointerTypeSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax elementType = node.ElementType; + if (elementType != null) + { + VisitType(elementType); + } + } + + public override void VisitPositionalPatternClause(PositionalPatternClauseSyntax node) + { + foreach (SubpatternSyntax subpattern in node.Subpatterns) + { + if (!ShouldVisit) + { + return; + } + + VisitSubpattern(subpattern); + } + } + + public override void VisitPostfixUnaryExpression(PostfixUnaryExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax operand = node.Operand; + if (operand != null) + { + VisitExpression(operand); + } + } + + public override void VisitPragmaChecksumDirectiveTrivia(PragmaChecksumDirectiveTriviaSyntax node) + { + } + + public override void VisitPragmaWarningDirectiveTrivia(PragmaWarningDirectiveTriviaSyntax node) + { + foreach (ExpressionSyntax expression in node.ErrorCodes) + { + if (!ShouldVisit) + { + return; + } + + VisitExpression(expression); + } + } + + public override void VisitPredefinedType(PredefinedTypeSyntax node) + { + } + + public override void VisitPrefixUnaryExpression(PrefixUnaryExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax operand = node.Operand; + if (operand != null) + { + VisitExpression(operand); + } + } + + public override void VisitPrimaryConstructorBaseType(PrimaryConstructorBaseTypeSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + + if (!ShouldVisit) + { + return; + } + + ArgumentListSyntax argumentList = node.ArgumentList; + if (argumentList != null) + { + VisitArgumentList(argumentList); + } + } + + public override void VisitPropertyDeclaration(PropertyDeclarationSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + + if (!ShouldVisit) + { + return; + } + + ExplicitInterfaceSpecifierSyntax explicitInterfaceSpecifier = node.ExplicitInterfaceSpecifier; + if (explicitInterfaceSpecifier != null) + { + VisitExplicitInterfaceSpecifier(explicitInterfaceSpecifier); + } + + if (!ShouldVisit) + { + return; + } + + AccessorListSyntax accessorList = node.AccessorList; + if (accessorList != null) + { + VisitAccessorList(accessorList); + } + + if (!ShouldVisit) + { + return; + } + + ArrowExpressionClauseSyntax expressionBody = node.ExpressionBody; + if (expressionBody != null) + { + VisitArrowExpressionClause(expressionBody); + } + + if (!ShouldVisit) + { + return; + } + + EqualsValueClauseSyntax initializer = node.Initializer; + if (initializer != null) + { + VisitEqualsValueClause(initializer); + } + } + + public override void VisitPropertyPatternClause(PropertyPatternClauseSyntax node) + { + foreach (SubpatternSyntax subpattern in node.Subpatterns) + { + if (!ShouldVisit) + { + return; + } + + VisitSubpattern(subpattern); + } + } + + public override void VisitQualifiedCref(QualifiedCrefSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax container = node.Container; + if (container != null) + { + VisitType(container); + } + + if (!ShouldVisit) + { + return; + } + + MemberCrefSyntax member = node.Member; + if (member != null) + { + VisitMemberCref(member); + } + } + + public override void VisitQualifiedName(QualifiedNameSyntax node) + { + if (!ShouldVisit) + { + return; + } + + NameSyntax left = node.Left; + if (left != null) + { + VisitType(left); + } + + if (!ShouldVisit) + { + return; + } + + SimpleNameSyntax right = node.Right; + if (right != null) + { + VisitSimpleName(right); + } + } + + public override void VisitQueryBody(QueryBodySyntax node) + { + foreach (QueryClauseSyntax queryClause in node.Clauses) + { + if (!ShouldVisit) + { + return; + } + + VisitQueryClause(queryClause); + } + + if (!ShouldVisit) + { + return; + } + + SelectOrGroupClauseSyntax selectOrGroup = node.SelectOrGroup; + if (selectOrGroup != null) + { + VisitSelectOrGroupClause(selectOrGroup); + } + + if (!ShouldVisit) + { + return; + } + + QueryContinuationSyntax continuation = node.Continuation; + if (continuation != null) + { + VisitQueryContinuation(continuation); + } + } + + public override void VisitQueryContinuation(QueryContinuationSyntax node) + { + if (!ShouldVisit) + { + return; + } + + QueryBodySyntax body = node.Body; + if (body != null) + { + VisitQueryBody(body); + } + } + + public override void VisitQueryExpression(QueryExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + FromClauseSyntax fromClause = node.FromClause; + if (fromClause != null) + { + VisitFromClause(fromClause); + } + + if (!ShouldVisit) + { + return; + } + + QueryBodySyntax body = node.Body; + if (body != null) + { + VisitQueryBody(body); + } + } + + public override void VisitRangeExpression(RangeExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax leftOperand = node.LeftOperand; + if (leftOperand != null) + { + VisitExpression(leftOperand); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax rightOperand = node.RightOperand; + if (rightOperand != null) + { + VisitExpression(rightOperand); + } + } + + public override void VisitRecordDeclaration(RecordDeclarationSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + TypeParameterListSyntax typeParameterList = node.TypeParameterList; + if (typeParameterList != null) + { + VisitTypeParameterList(typeParameterList); + } + + if (!ShouldVisit) + { + return; + } + + ParameterListSyntax parameterList = node.ParameterList; + if (parameterList != null) + { + VisitParameterList(parameterList); + } + + if (!ShouldVisit) + { + return; + } + + BaseListSyntax baseList = node.BaseList; + if (baseList != null) + { + VisitBaseList(baseList); + } + + foreach (TypeParameterConstraintClauseSyntax typeParameterConstraintClause in node.ConstraintClauses) + { + if (!ShouldVisit) + { + return; + } + + VisitTypeParameterConstraintClause(typeParameterConstraintClause); + } + + foreach (MemberDeclarationSyntax memberDeclaration in node.Members) + { + if (!ShouldVisit) + { + return; + } + + VisitMemberDeclaration(memberDeclaration); + } + } + + public override void VisitRecursivePattern(RecursivePatternSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + + if (!ShouldVisit) + { + return; + } + + PositionalPatternClauseSyntax positionalPatternClause = node.PositionalPatternClause; + if (positionalPatternClause != null) + { + VisitPositionalPatternClause(positionalPatternClause); + } + + if (!ShouldVisit) + { + return; + } + + PropertyPatternClauseSyntax propertyPatternClause = node.PropertyPatternClause; + if (propertyPatternClause != null) + { + VisitPropertyPatternClause(propertyPatternClause); + } + + if (!ShouldVisit) + { + return; + } + + VariableDesignationSyntax designation = node.Designation; + if (designation != null) + { + VisitVariableDesignation(designation); + } + } + + public override void VisitReferenceDirectiveTrivia(ReferenceDirectiveTriviaSyntax node) + { + } + + public override void VisitRefExpression(RefExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitRefType(RefTypeSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + } + + public override void VisitRefTypeExpression(RefTypeExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitRefValueExpression(RefValueExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + } + + public override void VisitRegionDirectiveTrivia(RegionDirectiveTriviaSyntax node) + { + } + + public override void VisitRelationalPattern(RelationalPatternSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitReturnStatement(ReturnStatementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitSelectClause(SelectClauseSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitShebangDirectiveTrivia(ShebangDirectiveTriviaSyntax node) + { + } + + public override void VisitSimpleBaseType(SimpleBaseTypeSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + } + + public override void VisitSimpleLambdaExpression(SimpleLambdaExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ParameterSyntax parameter = node.Parameter; + if (parameter != null) + { + VisitParameter(parameter); + } + + if (!ShouldVisit) + { + return; + } + + BlockSyntax block = node.Block; + if (block != null) + { + VisitBlock(block); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expressionBody = node.ExpressionBody; + if (expressionBody != null) + { + VisitExpression(expressionBody); + } + } + + public override void VisitSingleVariableDesignation(SingleVariableDesignationSyntax node) + { + } + + public override void VisitSizeOfExpression(SizeOfExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + } + + public override void VisitSkippedTokensTrivia(SkippedTokensTriviaSyntax node) + { + } + + public override void VisitStackAllocArrayCreationExpression(StackAllocArrayCreationExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + + if (!ShouldVisit) + { + return; + } + + InitializerExpressionSyntax initializer = node.Initializer; + if (initializer != null) + { + VisitInitializerExpression(initializer); + } + } + + public override void VisitStructDeclaration(StructDeclarationSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + + if (!ShouldVisit) + { + return; + } + + TypeParameterListSyntax typeParameterList = node.TypeParameterList; + if (typeParameterList != null) + { + VisitTypeParameterList(typeParameterList); + } + + if (!ShouldVisit) + { + return; + } + + BaseListSyntax baseList = node.BaseList; + if (baseList != null) + { + VisitBaseList(baseList); + } + + foreach (TypeParameterConstraintClauseSyntax typeParameterConstraintClause in node.ConstraintClauses) + { + if (!ShouldVisit) + { + return; + } + + VisitTypeParameterConstraintClause(typeParameterConstraintClause); + } + + foreach (MemberDeclarationSyntax memberDeclaration in node.Members) + { + if (!ShouldVisit) + { + return; + } + + VisitMemberDeclaration(memberDeclaration); + } + } + + public override void VisitSubpattern(SubpatternSyntax node) + { + if (!ShouldVisit) + { + return; + } + + NameColonSyntax nameColon = node.NameColon; + if (nameColon != null) + { + VisitNameColon(nameColon); + } + + if (!ShouldVisit) + { + return; + } + + PatternSyntax pattern = node.Pattern; + if (pattern != null) + { + VisitPattern(pattern); + } + } + + public override void VisitSwitchExpression(SwitchExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax governingExpression = node.GoverningExpression; + if (governingExpression != null) + { + VisitExpression(governingExpression); + } + + foreach (SwitchExpressionArmSyntax switchExpressionArm in node.Arms) + { + if (!ShouldVisit) + { + return; + } + + VisitSwitchExpressionArm(switchExpressionArm); + } + } + + public override void VisitSwitchExpressionArm(SwitchExpressionArmSyntax node) + { + if (!ShouldVisit) + { + return; + } + + PatternSyntax pattern = node.Pattern; + if (pattern != null) + { + VisitPattern(pattern); + } + + if (!ShouldVisit) + { + return; + } + + WhenClauseSyntax whenClause = node.WhenClause; + if (whenClause != null) + { + VisitWhenClause(whenClause); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitSwitchSection(SwitchSectionSyntax node) + { + foreach (SwitchLabelSyntax switchLabel in node.Labels) + { + if (!ShouldVisit) + { + return; + } + + VisitSwitchLabel(switchLabel); + } + + foreach (StatementSyntax statement in node.Statements) + { + if (!ShouldVisit) + { + return; + } + + VisitStatement(statement); + } + } + + public override void VisitSwitchStatement(SwitchStatementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + + foreach (SwitchSectionSyntax switchSection in node.Sections) + { + if (!ShouldVisit) + { + return; + } + + VisitSwitchSection(switchSection); + } + } + + public override void VisitThisExpression(ThisExpressionSyntax node) + { + } + + public override void VisitThrowExpression(ThrowExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitThrowStatement(ThrowStatementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + public override void VisitTryStatement(TryStatementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + BlockSyntax block = node.Block; + if (block != null) + { + VisitBlock(block); + } + + foreach (CatchClauseSyntax catchClause in node.Catches) + { + if (!ShouldVisit) + { + return; + } + + VisitCatchClause(catchClause); + } + + if (!ShouldVisit) + { + return; + } + + FinallyClauseSyntax @finally = node.Finally; + if (@finally != null) + { + VisitFinallyClause(@finally); + } + } + + public override void VisitTupleElement(TupleElementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + } + + public override void VisitTupleExpression(TupleExpressionSyntax node) + { + foreach (ArgumentSyntax argument in node.Arguments) + { + if (!ShouldVisit) + { + return; + } + + VisitArgument(argument); + } + } + + public override void VisitTupleType(TupleTypeSyntax node) + { + foreach (TupleElementSyntax tupleElement in node.Elements) + { + if (!ShouldVisit) + { + return; + } + + VisitTupleElement(tupleElement); + } + } + + public override void VisitTypeArgumentList(TypeArgumentListSyntax node) + { + foreach (TypeSyntax type in node.Arguments) + { + if (!ShouldVisit) + { + return; + } + + VisitType(type); + } + } + + public override void VisitTypeConstraint(TypeConstraintSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + } + + public override void VisitTypeCref(TypeCrefSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + } + + public override void VisitTypeOfExpression(TypeOfExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + } + + public override void VisitTypeParameter(TypeParameterSyntax node) + { + foreach (AttributeListSyntax attributeList in node.AttributeLists) + { + if (!ShouldVisit) + { + return; + } + + VisitAttributeList(attributeList); + } + } + + public override void VisitTypeParameterConstraintClause(TypeParameterConstraintClauseSyntax node) + { + if (!ShouldVisit) + { + return; + } + + IdentifierNameSyntax name = node.Name; + if (name != null) + { + VisitIdentifierName(name); + } + + foreach (TypeParameterConstraintSyntax typeParameterConstraint in node.Constraints) + { + if (!ShouldVisit) + { + return; + } + + VisitTypeParameterConstraint(typeParameterConstraint); + } + } + + public override void VisitTypeParameterList(TypeParameterListSyntax node) + { + foreach (TypeParameterSyntax typeParameter in node.Parameters) + { + if (!ShouldVisit) + { + return; + } + + VisitTypeParameter(typeParameter); + } + } + + public override void VisitTypePattern(TypePatternSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + } + + public override void VisitUnaryPattern(UnaryPatternSyntax node) + { + if (!ShouldVisit) + { + return; + } + + PatternSyntax pattern = node.Pattern; + if (pattern != null) + { + VisitPattern(pattern); + } + } + + public override void VisitUndefDirectiveTrivia(UndefDirectiveTriviaSyntax node) + { + } + + public override void VisitUnsafeStatement(UnsafeStatementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + BlockSyntax block = node.Block; + if (block != null) + { + VisitBlock(block); + } + } + + public override void VisitUsingDirective(UsingDirectiveSyntax node) + { + if (!ShouldVisit) + { + return; + } + + NameEqualsSyntax alias = node.Alias; + if (alias != null) + { + VisitNameEquals(alias); + } + + if (!ShouldVisit) + { + return; + } + + NameSyntax name = node.Name; + if (name != null) + { + VisitType(name); + } + } + + public override void VisitUsingStatement(UsingStatementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + VariableDeclarationSyntax declaration = node.Declaration; + if (declaration != null) + { + VisitVariableDeclaration(declaration); + } + + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + + if (!ShouldVisit) + { + return; + } + + StatementSyntax statement = node.Statement; + if (statement != null) + { + VisitStatement(statement); + } + } + + public override void VisitVariableDeclaration(VariableDeclarationSyntax node) + { + if (!ShouldVisit) + { + return; + } + + TypeSyntax type = node.Type; + if (type != null) + { + VisitType(type); + } + + foreach (VariableDeclaratorSyntax variableDeclarator in node.Variables) + { + if (!ShouldVisit) + { + return; + } + + VisitVariableDeclarator(variableDeclarator); + } + } + + public override void VisitVariableDeclarator(VariableDeclaratorSyntax node) + { + if (!ShouldVisit) + { + return; + } + + BracketedArgumentListSyntax argumentList = node.ArgumentList; + if (argumentList != null) + { + VisitBracketedArgumentList(argumentList); + } + + if (!ShouldVisit) + { + return; + } + + EqualsValueClauseSyntax initializer = node.Initializer; + if (initializer != null) + { + VisitEqualsValueClause(initializer); + } + } + + public override void VisitVarPattern(VarPatternSyntax node) + { + if (!ShouldVisit) + { + return; + } + + VariableDesignationSyntax designation = node.Designation; + if (designation != null) + { + VisitVariableDesignation(designation); + } + } + + public override void VisitWarningDirectiveTrivia(WarningDirectiveTriviaSyntax node) + { + } + + public override void VisitWhenClause(WhenClauseSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax condition = node.Condition; + if (condition != null) + { + VisitExpression(condition); + } + } + + public override void VisitWhereClause(WhereClauseSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax condition = node.Condition; + if (condition != null) + { + VisitExpression(condition); + } + } + + public override void VisitWhileStatement(WhileStatementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax condition = node.Condition; + if (condition != null) + { + VisitExpression(condition); + } + + if (!ShouldVisit) + { + return; + } + + StatementSyntax statement = node.Statement; + if (statement != null) + { + VisitStatement(statement); + } + } + + public override void VisitWithExpression(WithExpressionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + + if (!ShouldVisit) + { + return; + } + + InitializerExpressionSyntax initializer = node.Initializer; + if (initializer != null) + { + VisitInitializerExpression(initializer); + } + } + + public override void VisitXmlCDataSection(XmlCDataSectionSyntax node) + { + } + + public override void VisitXmlComment(XmlCommentSyntax node) + { + } + + public override void VisitXmlCrefAttribute(XmlCrefAttributeSyntax node) + { + if (!ShouldVisit) + { + return; + } + + XmlNameSyntax name = node.Name; + if (name != null) + { + VisitXmlName(name); + } + + if (!ShouldVisit) + { + return; + } + + CrefSyntax cref = node.Cref; + if (cref != null) + { + VisitCref(cref); + } + } + + public override void VisitXmlElement(XmlElementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + XmlElementStartTagSyntax startTag = node.StartTag; + if (startTag != null) + { + VisitXmlElementStartTag(startTag); + } + + foreach (XmlNodeSyntax xmlNode in node.Content) + { + if (!ShouldVisit) + { + return; + } + + VisitXmlNode(xmlNode); + } + + if (!ShouldVisit) + { + return; + } + + XmlElementEndTagSyntax endTag = node.EndTag; + if (endTag != null) + { + VisitXmlElementEndTag(endTag); + } + } + + public override void VisitXmlElementEndTag(XmlElementEndTagSyntax node) + { + if (!ShouldVisit) + { + return; + } + + XmlNameSyntax name = node.Name; + if (name != null) + { + VisitXmlName(name); + } + } + + public override void VisitXmlElementStartTag(XmlElementStartTagSyntax node) + { + if (!ShouldVisit) + { + return; + } + + XmlNameSyntax name = node.Name; + if (name != null) + { + VisitXmlName(name); + } + + foreach (XmlAttributeSyntax xmlAttribute in node.Attributes) + { + if (!ShouldVisit) + { + return; + } + + VisitXmlAttribute(xmlAttribute); + } + } + + public override void VisitXmlEmptyElement(XmlEmptyElementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + XmlNameSyntax name = node.Name; + if (name != null) + { + VisitXmlName(name); + } + + foreach (XmlAttributeSyntax xmlAttribute in node.Attributes) + { + if (!ShouldVisit) + { + return; + } + + VisitXmlAttribute(xmlAttribute); + } + } + + public override void VisitXmlName(XmlNameSyntax node) + { + if (!ShouldVisit) + { + return; + } + + XmlPrefixSyntax prefix = node.Prefix; + if (prefix != null) + { + VisitXmlPrefix(prefix); + } + } + + public override void VisitXmlNameAttribute(XmlNameAttributeSyntax node) + { + if (!ShouldVisit) + { + return; + } + + XmlNameSyntax name = node.Name; + if (name != null) + { + VisitXmlName(name); + } + + if (!ShouldVisit) + { + return; + } + + IdentifierNameSyntax identifier = node.Identifier; + if (identifier != null) + { + VisitIdentifierName(identifier); + } + } + + public override void VisitXmlPrefix(XmlPrefixSyntax node) + { + } + + public override void VisitXmlProcessingInstruction(XmlProcessingInstructionSyntax node) + { + if (!ShouldVisit) + { + return; + } + + XmlNameSyntax name = node.Name; + if (name != null) + { + VisitXmlName(name); + } + } + + public override void VisitXmlText(XmlTextSyntax node) + { + } + + public override void VisitXmlTextAttribute(XmlTextAttributeSyntax node) + { + if (!ShouldVisit) + { + return; + } + + XmlNameSyntax name = node.Name; + if (name != null) + { + VisitXmlName(name); + } + } + + public override void VisitYieldStatement(YieldStatementSyntax node) + { + if (!ShouldVisit) + { + return; + } + + ExpressionSyntax expression = node.Expression; + if (expression != null) + { + VisitExpression(expression); + } + } + + protected virtual void VisitBaseType(BaseTypeSyntax node) + { + switch (node.Kind()) + { + case SyntaxKind.PrimaryConstructorBaseType: + VisitPrimaryConstructorBaseType((PrimaryConstructorBaseTypeSyntax)node); + break; + case SyntaxKind.SimpleBaseType: + VisitSimpleBaseType((SimpleBaseTypeSyntax)node); + break; + default: + Debug.Fail($"Unrecognized kind '{node.Kind()}'."); + base.Visit(node); + break; + } + } + + protected virtual void VisitCref(CrefSyntax node) + { + switch (node.Kind()) + { + case SyntaxKind.ConversionOperatorMemberCref: + VisitConversionOperatorMemberCref((ConversionOperatorMemberCrefSyntax)node); + break; + case SyntaxKind.IndexerMemberCref: + VisitIndexerMemberCref((IndexerMemberCrefSyntax)node); + break; + case SyntaxKind.NameMemberCref: + VisitNameMemberCref((NameMemberCrefSyntax)node); + break; + case SyntaxKind.OperatorMemberCref: + VisitOperatorMemberCref((OperatorMemberCrefSyntax)node); + break; + case SyntaxKind.QualifiedCref: + VisitQualifiedCref((QualifiedCrefSyntax)node); + break; + case SyntaxKind.TypeCref: + VisitTypeCref((TypeCrefSyntax)node); + break; + default: + Debug.Fail($"Unrecognized kind '{node.Kind()}'."); + base.Visit(node); + break; + } + } + + protected virtual void VisitExpression(ExpressionSyntax node) + { + switch (node.Kind()) + { + case SyntaxKind.AliasQualifiedName: + VisitAliasQualifiedName((AliasQualifiedNameSyntax)node); + break; + case SyntaxKind.AnonymousMethodExpression: + VisitAnonymousMethodExpression((AnonymousMethodExpressionSyntax)node); + break; + case SyntaxKind.AnonymousObjectCreationExpression: + VisitAnonymousObjectCreationExpression((AnonymousObjectCreationExpressionSyntax)node); + break; + case SyntaxKind.ArrayCreationExpression: + VisitArrayCreationExpression((ArrayCreationExpressionSyntax)node); + break; + case SyntaxKind.ArrayType: + VisitArrayType((ArrayTypeSyntax)node); + break; + case SyntaxKind.SimpleAssignmentExpression: + case SyntaxKind.AddAssignmentExpression: + case SyntaxKind.SubtractAssignmentExpression: + case SyntaxKind.MultiplyAssignmentExpression: + case SyntaxKind.DivideAssignmentExpression: + case SyntaxKind.ModuloAssignmentExpression: + case SyntaxKind.AndAssignmentExpression: + case SyntaxKind.ExclusiveOrAssignmentExpression: + case SyntaxKind.OrAssignmentExpression: + case SyntaxKind.LeftShiftAssignmentExpression: + case SyntaxKind.RightShiftAssignmentExpression: + case SyntaxKind.CoalesceAssignmentExpression: + VisitAssignmentExpression((AssignmentExpressionSyntax)node); + break; + case SyntaxKind.AwaitExpression: + VisitAwaitExpression((AwaitExpressionSyntax)node); + break; + case SyntaxKind.BaseExpression: + VisitBaseExpression((BaseExpressionSyntax)node); + break; + case SyntaxKind.AddExpression: + case SyntaxKind.SubtractExpression: + case SyntaxKind.MultiplyExpression: + case SyntaxKind.DivideExpression: + case SyntaxKind.ModuloExpression: + case SyntaxKind.LeftShiftExpression: + case SyntaxKind.RightShiftExpression: + case SyntaxKind.LogicalOrExpression: + case SyntaxKind.LogicalAndExpression: + case SyntaxKind.BitwiseOrExpression: + case SyntaxKind.BitwiseAndExpression: + case SyntaxKind.ExclusiveOrExpression: + case SyntaxKind.EqualsExpression: + case SyntaxKind.NotEqualsExpression: + case SyntaxKind.LessThanExpression: + case SyntaxKind.LessThanOrEqualExpression: + case SyntaxKind.GreaterThanExpression: + case SyntaxKind.GreaterThanOrEqualExpression: + case SyntaxKind.IsExpression: + case SyntaxKind.AsExpression: + case SyntaxKind.CoalesceExpression: + VisitBinaryExpression((BinaryExpressionSyntax)node); + break; + case SyntaxKind.CastExpression: + VisitCastExpression((CastExpressionSyntax)node); + break; + case SyntaxKind.ConditionalAccessExpression: + VisitConditionalAccessExpression((ConditionalAccessExpressionSyntax)node); + break; + case SyntaxKind.ConditionalExpression: + VisitConditionalExpression((ConditionalExpressionSyntax)node); + break; + case SyntaxKind.DeclarationExpression: + VisitDeclarationExpression((DeclarationExpressionSyntax)node); + break; + case SyntaxKind.DefaultExpression: + VisitDefaultExpression((DefaultExpressionSyntax)node); + break; + case SyntaxKind.ElementAccessExpression: + VisitElementAccessExpression((ElementAccessExpressionSyntax)node); + break; + case SyntaxKind.ElementBindingExpression: + VisitElementBindingExpression((ElementBindingExpressionSyntax)node); + break; + case SyntaxKind.FunctionPointerType: + VisitFunctionPointerType((FunctionPointerTypeSyntax)node); + break; + case SyntaxKind.GenericName: + VisitGenericName((GenericNameSyntax)node); + break; + case SyntaxKind.CheckedExpression: + case SyntaxKind.UncheckedExpression: + VisitCheckedExpression((CheckedExpressionSyntax)node); + break; + case SyntaxKind.IdentifierName: + VisitIdentifierName((IdentifierNameSyntax)node); + break; + case SyntaxKind.ImplicitArrayCreationExpression: + VisitImplicitArrayCreationExpression((ImplicitArrayCreationExpressionSyntax)node); + break; + case SyntaxKind.ImplicitElementAccess: + VisitImplicitElementAccess((ImplicitElementAccessSyntax)node); + break; + case SyntaxKind.ImplicitObjectCreationExpression: + VisitImplicitObjectCreationExpression((ImplicitObjectCreationExpressionSyntax)node); + break; + case SyntaxKind.ImplicitStackAllocArrayCreationExpression: + VisitImplicitStackAllocArrayCreationExpression((ImplicitStackAllocArrayCreationExpressionSyntax)node); + break; + case SyntaxKind.ArrayInitializerExpression: + case SyntaxKind.CollectionInitializerExpression: + case SyntaxKind.ComplexElementInitializerExpression: + case SyntaxKind.ObjectInitializerExpression: + case SyntaxKind.WithInitializerExpression: + VisitInitializerExpression((InitializerExpressionSyntax)node); + break; + case SyntaxKind.InterpolatedStringExpression: + VisitInterpolatedStringExpression((InterpolatedStringExpressionSyntax)node); + break; + case SyntaxKind.InvocationExpression: + VisitInvocationExpression((InvocationExpressionSyntax)node); + break; + case SyntaxKind.IsPatternExpression: + VisitIsPatternExpression((IsPatternExpressionSyntax)node); + break; + case SyntaxKind.ArgListExpression: + case SyntaxKind.NumericLiteralExpression: + case SyntaxKind.StringLiteralExpression: + case SyntaxKind.CharacterLiteralExpression: + case SyntaxKind.TrueLiteralExpression: + case SyntaxKind.FalseLiteralExpression: + case SyntaxKind.NullLiteralExpression: + case SyntaxKind.DefaultLiteralExpression: + VisitLiteralExpression((LiteralExpressionSyntax)node); + break; + case SyntaxKind.MakeRefExpression: + VisitMakeRefExpression((MakeRefExpressionSyntax)node); + break; + case SyntaxKind.PointerMemberAccessExpression: + case SyntaxKind.SimpleMemberAccessExpression: + VisitMemberAccessExpression((MemberAccessExpressionSyntax)node); + break; + case SyntaxKind.MemberBindingExpression: + VisitMemberBindingExpression((MemberBindingExpressionSyntax)node); + break; + case SyntaxKind.NullableType: + VisitNullableType((NullableTypeSyntax)node); + break; + case SyntaxKind.ObjectCreationExpression: + VisitObjectCreationExpression((ObjectCreationExpressionSyntax)node); + break; + case SyntaxKind.OmittedArraySizeExpression: + VisitOmittedArraySizeExpression((OmittedArraySizeExpressionSyntax)node); + break; + case SyntaxKind.OmittedTypeArgument: + VisitOmittedTypeArgument((OmittedTypeArgumentSyntax)node); + break; + case SyntaxKind.ParenthesizedExpression: + VisitParenthesizedExpression((ParenthesizedExpressionSyntax)node); + break; + case SyntaxKind.ParenthesizedLambdaExpression: + VisitParenthesizedLambdaExpression((ParenthesizedLambdaExpressionSyntax)node); + break; + case SyntaxKind.PointerType: + VisitPointerType((PointerTypeSyntax)node); + break; + case SyntaxKind.PostDecrementExpression: + case SyntaxKind.PostIncrementExpression: + case SyntaxKind.SuppressNullableWarningExpression: + VisitPostfixUnaryExpression((PostfixUnaryExpressionSyntax)node); + break; + case SyntaxKind.PredefinedType: + VisitPredefinedType((PredefinedTypeSyntax)node); + break; + case SyntaxKind.UnaryPlusExpression: + case SyntaxKind.UnaryMinusExpression: + case SyntaxKind.BitwiseNotExpression: + case SyntaxKind.LogicalNotExpression: + case SyntaxKind.PreIncrementExpression: + case SyntaxKind.PreDecrementExpression: + case SyntaxKind.AddressOfExpression: + case SyntaxKind.PointerIndirectionExpression: + case SyntaxKind.IndexExpression: + VisitPrefixUnaryExpression((PrefixUnaryExpressionSyntax)node); + break; + case SyntaxKind.QualifiedName: + VisitQualifiedName((QualifiedNameSyntax)node); + break; + case SyntaxKind.QueryExpression: + VisitQueryExpression((QueryExpressionSyntax)node); + break; + case SyntaxKind.RangeExpression: + VisitRangeExpression((RangeExpressionSyntax)node); + break; + case SyntaxKind.RefExpression: + VisitRefExpression((RefExpressionSyntax)node); + break; + case SyntaxKind.RefTypeExpression: + VisitRefTypeExpression((RefTypeExpressionSyntax)node); + break; + case SyntaxKind.RefType: + VisitRefType((RefTypeSyntax)node); + break; + case SyntaxKind.RefValueExpression: + VisitRefValueExpression((RefValueExpressionSyntax)node); + break; + case SyntaxKind.SimpleLambdaExpression: + VisitSimpleLambdaExpression((SimpleLambdaExpressionSyntax)node); + break; + case SyntaxKind.SizeOfExpression: + VisitSizeOfExpression((SizeOfExpressionSyntax)node); + break; + case SyntaxKind.StackAllocArrayCreationExpression: + VisitStackAllocArrayCreationExpression((StackAllocArrayCreationExpressionSyntax)node); + break; + case SyntaxKind.SwitchExpression: + VisitSwitchExpression((SwitchExpressionSyntax)node); + break; + case SyntaxKind.ThisExpression: + VisitThisExpression((ThisExpressionSyntax)node); + break; + case SyntaxKind.ThrowExpression: + VisitThrowExpression((ThrowExpressionSyntax)node); + break; + case SyntaxKind.TupleExpression: + VisitTupleExpression((TupleExpressionSyntax)node); + break; + case SyntaxKind.TupleType: + VisitTupleType((TupleTypeSyntax)node); + break; + case SyntaxKind.TypeOfExpression: + VisitTypeOfExpression((TypeOfExpressionSyntax)node); + break; + case SyntaxKind.WithExpression: + VisitWithExpression((WithExpressionSyntax)node); + break; + default: + Debug.Fail($"Unrecognized kind '{node.Kind()}'."); + base.Visit(node); + break; + } + } + + protected virtual void VisitInterpolatedStringContent(InterpolatedStringContentSyntax node) + { + switch (node.Kind()) + { + case SyntaxKind.InterpolatedStringText: + VisitInterpolatedStringText((InterpolatedStringTextSyntax)node); + break; + case SyntaxKind.Interpolation: + VisitInterpolation((InterpolationSyntax)node); + break; + default: + Debug.Fail($"Unrecognized kind '{node.Kind()}'."); + base.Visit(node); + break; + } + } + + protected virtual void VisitMemberCref(MemberCrefSyntax node) + { + switch (node.Kind()) + { + case SyntaxKind.ConversionOperatorMemberCref: + VisitConversionOperatorMemberCref((ConversionOperatorMemberCrefSyntax)node); + break; + case SyntaxKind.IndexerMemberCref: + VisitIndexerMemberCref((IndexerMemberCrefSyntax)node); + break; + case SyntaxKind.NameMemberCref: + VisitNameMemberCref((NameMemberCrefSyntax)node); + break; + case SyntaxKind.OperatorMemberCref: + VisitOperatorMemberCref((OperatorMemberCrefSyntax)node); + break; + default: + Debug.Fail($"Unrecognized kind '{node.Kind()}'."); + base.Visit(node); + break; + } + } + + protected virtual void VisitMemberDeclaration(MemberDeclarationSyntax node) + { + switch (node.Kind()) + { + case SyntaxKind.ClassDeclaration: + VisitClassDeclaration((ClassDeclarationSyntax)node); + break; + case SyntaxKind.ConstructorDeclaration: + VisitConstructorDeclaration((ConstructorDeclarationSyntax)node); + break; + case SyntaxKind.ConversionOperatorDeclaration: + VisitConversionOperatorDeclaration((ConversionOperatorDeclarationSyntax)node); + break; + case SyntaxKind.DelegateDeclaration: + VisitDelegateDeclaration((DelegateDeclarationSyntax)node); + break; + case SyntaxKind.DestructorDeclaration: + VisitDestructorDeclaration((DestructorDeclarationSyntax)node); + break; + case SyntaxKind.EnumDeclaration: + VisitEnumDeclaration((EnumDeclarationSyntax)node); + break; + case SyntaxKind.EnumMemberDeclaration: + VisitEnumMemberDeclaration((EnumMemberDeclarationSyntax)node); + break; + case SyntaxKind.EventDeclaration: + VisitEventDeclaration((EventDeclarationSyntax)node); + break; + case SyntaxKind.EventFieldDeclaration: + VisitEventFieldDeclaration((EventFieldDeclarationSyntax)node); + break; + case SyntaxKind.FieldDeclaration: + VisitFieldDeclaration((FieldDeclarationSyntax)node); + break; + case SyntaxKind.GlobalStatement: + VisitGlobalStatement((GlobalStatementSyntax)node); + break; + case SyntaxKind.IncompleteMember: + VisitIncompleteMember((IncompleteMemberSyntax)node); + break; + case SyntaxKind.IndexerDeclaration: + VisitIndexerDeclaration((IndexerDeclarationSyntax)node); + break; + case SyntaxKind.InterfaceDeclaration: + VisitInterfaceDeclaration((InterfaceDeclarationSyntax)node); + break; + case SyntaxKind.MethodDeclaration: + VisitMethodDeclaration((MethodDeclarationSyntax)node); + break; + case SyntaxKind.NamespaceDeclaration: + VisitNamespaceDeclaration((NamespaceDeclarationSyntax)node); + break; + case SyntaxKind.OperatorDeclaration: + VisitOperatorDeclaration((OperatorDeclarationSyntax)node); + break; + case SyntaxKind.PropertyDeclaration: + VisitPropertyDeclaration((PropertyDeclarationSyntax)node); + break; + case SyntaxKind.RecordDeclaration: + VisitRecordDeclaration((RecordDeclarationSyntax)node); + break; + case SyntaxKind.StructDeclaration: + VisitStructDeclaration((StructDeclarationSyntax)node); + break; + default: + Debug.Fail($"Unrecognized kind '{node.Kind()}'."); + base.Visit(node); + break; + } + } + + protected virtual void VisitPattern(PatternSyntax node) + { + switch (node.Kind()) + { + case SyntaxKind.AndPattern: + case SyntaxKind.OrPattern: + VisitBinaryPattern((BinaryPatternSyntax)node); + break; + case SyntaxKind.ConstantPattern: + VisitConstantPattern((ConstantPatternSyntax)node); + break; + case SyntaxKind.DeclarationPattern: + VisitDeclarationPattern((DeclarationPatternSyntax)node); + break; + case SyntaxKind.DiscardPattern: + VisitDiscardPattern((DiscardPatternSyntax)node); + break; + case SyntaxKind.ParenthesizedPattern: + VisitParenthesizedPattern((ParenthesizedPatternSyntax)node); + break; + case SyntaxKind.RecursivePattern: + VisitRecursivePattern((RecursivePatternSyntax)node); + break; + case SyntaxKind.RelationalPattern: + VisitRelationalPattern((RelationalPatternSyntax)node); + break; + case SyntaxKind.TypePattern: + VisitTypePattern((TypePatternSyntax)node); + break; + case SyntaxKind.NotPattern: + VisitUnaryPattern((UnaryPatternSyntax)node); + break; + case SyntaxKind.VarPattern: + VisitVarPattern((VarPatternSyntax)node); + break; + default: + Debug.Fail($"Unrecognized kind '{node.Kind()}'."); + base.Visit(node); + break; + } + } + + protected virtual void VisitQueryClause(QueryClauseSyntax node) + { + switch (node.Kind()) + { + case SyntaxKind.FromClause: + VisitFromClause((FromClauseSyntax)node); + break; + case SyntaxKind.JoinClause: + VisitJoinClause((JoinClauseSyntax)node); + break; + case SyntaxKind.LetClause: + VisitLetClause((LetClauseSyntax)node); + break; + case SyntaxKind.OrderByClause: + VisitOrderByClause((OrderByClauseSyntax)node); + break; + case SyntaxKind.WhereClause: + VisitWhereClause((WhereClauseSyntax)node); + break; + default: + Debug.Fail($"Unrecognized kind '{node.Kind()}'."); + base.Visit(node); + break; + } + } + + protected virtual void VisitSelectOrGroupClause(SelectOrGroupClauseSyntax node) + { + switch (node.Kind()) + { + case SyntaxKind.GroupClause: + VisitGroupClause((GroupClauseSyntax)node); + break; + case SyntaxKind.SelectClause: + VisitSelectClause((SelectClauseSyntax)node); + break; + default: + Debug.Fail($"Unrecognized kind '{node.Kind()}'."); + base.Visit(node); + break; + } + } + + protected virtual void VisitSimpleName(SimpleNameSyntax node) + { + switch (node.Kind()) + { + case SyntaxKind.GenericName: + VisitGenericName((GenericNameSyntax)node); + break; + case SyntaxKind.IdentifierName: + VisitIdentifierName((IdentifierNameSyntax)node); + break; + default: + Debug.Fail($"Unrecognized kind '{node.Kind()}'."); + base.Visit(node); + break; + } + } + + protected virtual void VisitStatement(StatementSyntax node) + { + switch (node.Kind()) + { + case SyntaxKind.Block: + VisitBlock((BlockSyntax)node); + break; + case SyntaxKind.BreakStatement: + VisitBreakStatement((BreakStatementSyntax)node); + break; + case SyntaxKind.ContinueStatement: + VisitContinueStatement((ContinueStatementSyntax)node); + break; + case SyntaxKind.DoStatement: + VisitDoStatement((DoStatementSyntax)node); + break; + case SyntaxKind.EmptyStatement: + VisitEmptyStatement((EmptyStatementSyntax)node); + break; + case SyntaxKind.ExpressionStatement: + VisitExpressionStatement((ExpressionStatementSyntax)node); + break; + case SyntaxKind.FixedStatement: + VisitFixedStatement((FixedStatementSyntax)node); + break; + case SyntaxKind.ForEachStatement: + VisitForEachStatement((ForEachStatementSyntax)node); + break; + case SyntaxKind.ForEachVariableStatement: + VisitForEachVariableStatement((ForEachVariableStatementSyntax)node); + break; + case SyntaxKind.ForStatement: + VisitForStatement((ForStatementSyntax)node); + break; + case SyntaxKind.GotoStatement: + case SyntaxKind.GotoCaseStatement: + case SyntaxKind.GotoDefaultStatement: + VisitGotoStatement((GotoStatementSyntax)node); + break; + case SyntaxKind.CheckedStatement: + case SyntaxKind.UncheckedStatement: + VisitCheckedStatement((CheckedStatementSyntax)node); + break; + case SyntaxKind.IfStatement: + VisitIfStatement((IfStatementSyntax)node); + break; + case SyntaxKind.LabeledStatement: + VisitLabeledStatement((LabeledStatementSyntax)node); + break; + case SyntaxKind.LocalDeclarationStatement: + VisitLocalDeclarationStatement((LocalDeclarationStatementSyntax)node); + break; + case SyntaxKind.LocalFunctionStatement: + VisitLocalFunctionStatement((LocalFunctionStatementSyntax)node); + break; + case SyntaxKind.LockStatement: + VisitLockStatement((LockStatementSyntax)node); + break; + case SyntaxKind.ReturnStatement: + VisitReturnStatement((ReturnStatementSyntax)node); + break; + case SyntaxKind.SwitchStatement: + VisitSwitchStatement((SwitchStatementSyntax)node); + break; + case SyntaxKind.ThrowStatement: + VisitThrowStatement((ThrowStatementSyntax)node); + break; + case SyntaxKind.TryStatement: + VisitTryStatement((TryStatementSyntax)node); + break; + case SyntaxKind.UnsafeStatement: + VisitUnsafeStatement((UnsafeStatementSyntax)node); + break; + case SyntaxKind.UsingStatement: + VisitUsingStatement((UsingStatementSyntax)node); + break; + case SyntaxKind.WhileStatement: + VisitWhileStatement((WhileStatementSyntax)node); + break; + case SyntaxKind.YieldBreakStatement: + case SyntaxKind.YieldReturnStatement: + VisitYieldStatement((YieldStatementSyntax)node); + break; + default: + Debug.Fail($"Unrecognized kind '{node.Kind()}'."); + base.Visit(node); + break; + } + } + + protected virtual void VisitSwitchLabel(SwitchLabelSyntax node) + { + switch (node.Kind()) + { + case SyntaxKind.CasePatternSwitchLabel: + VisitCasePatternSwitchLabel((CasePatternSwitchLabelSyntax)node); + break; + case SyntaxKind.CaseSwitchLabel: + VisitCaseSwitchLabel((CaseSwitchLabelSyntax)node); + break; + case SyntaxKind.DefaultSwitchLabel: + VisitDefaultSwitchLabel((DefaultSwitchLabelSyntax)node); + break; + default: + Debug.Fail($"Unrecognized kind '{node.Kind()}'."); + base.Visit(node); + break; + } + } + + protected virtual void VisitTypeParameterConstraint(TypeParameterConstraintSyntax node) + { + switch (node.Kind()) + { + case SyntaxKind.ClassConstraint: + case SyntaxKind.StructConstraint: + VisitClassOrStructConstraint((ClassOrStructConstraintSyntax)node); + break; + case SyntaxKind.ConstructorConstraint: + VisitConstructorConstraint((ConstructorConstraintSyntax)node); + break; + case SyntaxKind.DefaultConstraint: + VisitDefaultConstraint((DefaultConstraintSyntax)node); + break; + case SyntaxKind.TypeConstraint: + VisitTypeConstraint((TypeConstraintSyntax)node); + break; + default: + Debug.Fail($"Unrecognized kind '{node.Kind()}'."); + base.Visit(node); + break; + } + } + + protected virtual void VisitType(TypeSyntax node) + { + switch (node.Kind()) + { + case SyntaxKind.AliasQualifiedName: + VisitAliasQualifiedName((AliasQualifiedNameSyntax)node); + break; + case SyntaxKind.ArrayType: + VisitArrayType((ArrayTypeSyntax)node); + break; + case SyntaxKind.FunctionPointerType: + VisitFunctionPointerType((FunctionPointerTypeSyntax)node); + break; + case SyntaxKind.GenericName: + VisitGenericName((GenericNameSyntax)node); + break; + case SyntaxKind.IdentifierName: + VisitIdentifierName((IdentifierNameSyntax)node); + break; + case SyntaxKind.NullableType: + VisitNullableType((NullableTypeSyntax)node); + break; + case SyntaxKind.OmittedTypeArgument: + VisitOmittedTypeArgument((OmittedTypeArgumentSyntax)node); + break; + case SyntaxKind.PointerType: + VisitPointerType((PointerTypeSyntax)node); + break; + case SyntaxKind.PredefinedType: + VisitPredefinedType((PredefinedTypeSyntax)node); + break; + case SyntaxKind.QualifiedName: + VisitQualifiedName((QualifiedNameSyntax)node); + break; + case SyntaxKind.RefType: + VisitRefType((RefTypeSyntax)node); + break; + case SyntaxKind.TupleType: + VisitTupleType((TupleTypeSyntax)node); + break; + default: + Debug.Fail($"Unrecognized kind '{node.Kind()}'."); + base.Visit(node); + break; + } + } + + protected virtual void VisitVariableDesignation(VariableDesignationSyntax node) + { + switch (node.Kind()) + { + case SyntaxKind.DiscardDesignation: + VisitDiscardDesignation((DiscardDesignationSyntax)node); + break; + case SyntaxKind.ParenthesizedVariableDesignation: + VisitParenthesizedVariableDesignation((ParenthesizedVariableDesignationSyntax)node); + break; + case SyntaxKind.SingleVariableDesignation: + VisitSingleVariableDesignation((SingleVariableDesignationSyntax)node); + break; + default: + Debug.Fail($"Unrecognized kind '{node.Kind()}'."); + base.Visit(node); + break; + } + } + + protected virtual void VisitXmlAttribute(XmlAttributeSyntax node) + { + switch (node.Kind()) + { + case SyntaxKind.XmlCrefAttribute: + VisitXmlCrefAttribute((XmlCrefAttributeSyntax)node); + break; + case SyntaxKind.XmlNameAttribute: + VisitXmlNameAttribute((XmlNameAttributeSyntax)node); + break; + case SyntaxKind.XmlTextAttribute: + VisitXmlTextAttribute((XmlTextAttributeSyntax)node); + break; + default: + Debug.Fail($"Unrecognized kind '{node.Kind()}'."); + base.Visit(node); + break; + } + } + + protected virtual void VisitXmlNode(XmlNodeSyntax node) + { + switch (node.Kind()) + { + case SyntaxKind.XmlCDataSection: + VisitXmlCDataSection((XmlCDataSectionSyntax)node); + break; + case SyntaxKind.XmlComment: + VisitXmlComment((XmlCommentSyntax)node); + break; + case SyntaxKind.XmlElement: + VisitXmlElement((XmlElementSyntax)node); + break; + case SyntaxKind.XmlEmptyElement: + VisitXmlEmptyElement((XmlEmptyElementSyntax)node); + break; + case SyntaxKind.XmlProcessingInstruction: + VisitXmlProcessingInstruction((XmlProcessingInstructionSyntax)node); + break; + case SyntaxKind.XmlText: + VisitXmlText((XmlTextSyntax)node); + break; + default: + Debug.Fail($"Unrecognized kind '{node.Kind()}'."); + base.Visit(node); + break; + } + } + } +} +#endif diff --git a/src/CSharp/CSharp/SyntaxWalkers/CSharpSyntaxNodeWalker.cs b/src/CSharp/CSharp/SyntaxWalkers/CSharpSyntaxNodeWalker.cs index 0e9f6767a0..0b7a0f024c 100644 --- a/src/CSharp/CSharp/SyntaxWalkers/CSharpSyntaxNodeWalker.cs +++ b/src/CSharp/CSharp/SyntaxWalkers/CSharpSyntaxNodeWalker.cs @@ -1,4 +1,5 @@ -// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +#if ROSLYN_4_7_ONLY +// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // @@ -5719,4 +5720,5 @@ protected virtual void VisitCollectionElement(CollectionElementSyntax node) } } } -} \ No newline at end of file +} +#endif diff --git a/src/CodeAnalysis.Analyzers.CodeFixes/CodeAnalysis.Analyzers.CodeFixes.csproj b/src/CodeAnalysis.Analyzers.CodeFixes/CodeAnalysis.Analyzers.CodeFixes.csproj index 15d214f3ad..212396c0ae 100644 --- a/src/CodeAnalysis.Analyzers.CodeFixes/CodeAnalysis.Analyzers.CodeFixes.csproj +++ b/src/CodeAnalysis.Analyzers.CodeFixes/CodeAnalysis.Analyzers.CodeFixes.csproj @@ -4,6 +4,10 @@ netstandard2.0 + + bin\$(RoslynVersion)\ + + $(RoslynatorAnalyzersVersion) Roslynator.CodeAnalysis.Analyzers.CodeFixes diff --git a/src/CodeAnalysis.Analyzers.CodeFixes/Roslynator.CodeAnalysis.Analyzers.nuspec b/src/CodeAnalysis.Analyzers.CodeFixes/Roslynator.CodeAnalysis.Analyzers.nuspec index f35e05336b..ac82e2b871 100644 --- a/src/CodeAnalysis.Analyzers.CodeFixes/Roslynator.CodeAnalysis.Analyzers.nuspec +++ b/src/CodeAnalysis.Analyzers.CodeFixes/Roslynator.CodeAnalysis.Analyzers.nuspec @@ -11,7 +11,7 @@ false A collection of analyzers for Roslyn API. - - This package is dependent on Microsoft.CodeAnalysis.CSharp.Workspaces 4.7.0. + - This package requires Roslyn 3.8 or higher. - This package is applicable for projects that reference Roslyn packages (Microsoft.CodeAnalysis*). A collection of analyzers for Roslyn API. Copyright (c) 2016-2023 Josef Pihrt @@ -21,7 +21,8 @@ docs\README.md - + + diff --git a/src/CodeFixes/CSharp/CodeFixes/MemberDeclarationCodeFixProvider.cs b/src/CodeFixes/CSharp/CodeFixes/MemberDeclarationCodeFixProvider.cs index fad2ddad4c..b4f6e6f62a 100644 --- a/src/CodeFixes/CSharp/CodeFixes/MemberDeclarationCodeFixProvider.cs +++ b/src/CodeFixes/CSharp/CodeFixes/MemberDeclarationCodeFixProvider.cs @@ -188,8 +188,10 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) if (memberDeclaration.IsParentKind( SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, - SyntaxKind.RecordDeclaration, - SyntaxKind.RecordStructDeclaration)) +#if ROSLYN_4_0 + SyntaxKind.RecordStructDeclaration, +#endif + SyntaxKind.RecordDeclaration)) { node = memberDeclaration.Parent; } @@ -198,7 +200,9 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) } case SyntaxKind.ClassDeclaration: case SyntaxKind.StructDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif case SyntaxKind.InterfaceDeclaration: case SyntaxKind.RecordDeclaration: { diff --git a/src/CodeFixes/CSharp/CodeFixes/ModifiersCodeFixProvider.cs b/src/CodeFixes/CSharp/CodeFixes/ModifiersCodeFixProvider.cs index 4d4e615ee6..a8e8950b6c 100644 --- a/src/CodeFixes/CSharp/CodeFixes/ModifiersCodeFixProvider.cs +++ b/src/CodeFixes/CSharp/CodeFixes/ModifiersCodeFixProvider.cs @@ -138,7 +138,11 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) }); } else if (node.IsKind(SyntaxKind.MethodDeclaration, SyntaxKind.PropertyDeclaration, SyntaxKind.IndexerDeclaration, SyntaxKind.EventDeclaration, SyntaxKind.EventFieldDeclaration) - && node.IsParentKind(SyntaxKind.StructDeclaration, SyntaxKind.RecordStructDeclaration) + && node.IsParentKind( +#if ROSLYN_4_0 + SyntaxKind.RecordStructDeclaration, +#endif + SyntaxKind.StructDeclaration) && modifiers.Contains(SyntaxKind.VirtualKeyword)) { ModifiersCodeFixRegistrator.RemoveModifier(context, diagnostic, node, SyntaxKind.VirtualKeyword); @@ -393,7 +397,9 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context) if (!node.IsKind( SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, +#if ROSLYN_4_0 SyntaxKind.RecordStructDeclaration, +#endif SyntaxKind.InterfaceDeclaration, SyntaxKind.MethodDeclaration)) { diff --git a/src/Directory.Build.props b/src/Directory.Build.props index d42a740c76..8d6ccc3c1b 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -11,11 +11,26 @@ false + + + + 3.8.0 + 3.0.0 + $(DefineConstants);ROSLYN_3_8;ROSLYN_3_8_ONLY + $(NoWarn);8600;8604;8625 + + + + + 4.7.0 + 3.3.4 + $(DefineConstants);ROSLYN_3_8;ROSLYN_4_0;ROSLYN_4_2,ROSLYN_4_4;ROSLYN_4_7;ROSLYN_4_7_ONLY + + + + 1.0.0 - - 4.7.0 - 3.3.4 4.8.0 4.8.0 4.8.0 diff --git a/src/Formatting.Analyzers.CodeFixes/Formatting.Analyzers.CodeFixes.csproj b/src/Formatting.Analyzers.CodeFixes/Formatting.Analyzers.CodeFixes.csproj index d7560c8bc3..7d76311a38 100644 --- a/src/Formatting.Analyzers.CodeFixes/Formatting.Analyzers.CodeFixes.csproj +++ b/src/Formatting.Analyzers.CodeFixes/Formatting.Analyzers.CodeFixes.csproj @@ -4,6 +4,10 @@ netstandard2.0 + + bin\$(RoslynVersion)\ + + $(RoslynatorAnalyzersVersion) Roslynator.Formatting.Analyzers.CodeFixes diff --git a/src/Formatting.Analyzers.CodeFixes/Roslynator.Formatting.Analyzers.nuspec b/src/Formatting.Analyzers.CodeFixes/Roslynator.Formatting.Analyzers.nuspec index 632b6aa5fb..2093e29d49 100644 --- a/src/Formatting.Analyzers.CodeFixes/Roslynator.Formatting.Analyzers.nuspec +++ b/src/Formatting.Analyzers.CodeFixes/Roslynator.Formatting.Analyzers.nuspec @@ -11,7 +11,7 @@ false A collection of formatting analyzers, powered by Roslyn. - - This package is dependent on Microsoft.CodeAnalysis.CSharp.Workspaces 4.7.0. + - This package requires Roslyn 3.8 or higher. - All analyzers are disabled by default. A collection of formatting analyzers, powered by Roslyn. Copyright (c) 2016-2023 Josef Pihrt @@ -21,7 +21,8 @@ docs\README.md - + + diff --git a/src/Formatting.Analyzers/CSharp/BlankLineAfterFileScopedNamespaceDeclarationAnalyzer.cs b/src/Formatting.Analyzers/CSharp/BlankLineAfterFileScopedNamespaceDeclarationAnalyzer.cs index 067dde2682..76d39eb577 100644 --- a/src/Formatting.Analyzers/CSharp/BlankLineAfterFileScopedNamespaceDeclarationAnalyzer.cs +++ b/src/Formatting.Analyzers/CSharp/BlankLineAfterFileScopedNamespaceDeclarationAnalyzer.cs @@ -1,4 +1,5 @@ -// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +#if ROSLYN_4_0 +// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Immutable; using Microsoft.CodeAnalysis; @@ -86,3 +87,4 @@ internal static SyntaxNode GetNodeAfterNamespaceDeclaration(FileScopedNamespaceD : memberDeclaration; } } +#endif diff --git a/src/Formatting.Analyzers/CSharp/BlankLineBetweenDeclarationsAnalyzer.cs b/src/Formatting.Analyzers/CSharp/BlankLineBetweenDeclarationsAnalyzer.cs index fb21648dc0..4dd0202af0 100644 --- a/src/Formatting.Analyzers/CSharp/BlankLineBetweenDeclarationsAnalyzer.cs +++ b/src/Formatting.Analyzers/CSharp/BlankLineBetweenDeclarationsAnalyzer.cs @@ -43,7 +43,9 @@ public override void Initialize(AnalysisContext context) f => AnalyzeTypeDeclaration(f), SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, +#if ROSLYN_4_0 SyntaxKind.RecordStructDeclaration, +#endif SyntaxKind.InterfaceDeclaration); context.RegisterSyntaxNodeAction(f => AnalyzeCompilationUnit(f), SyntaxKind.CompilationUnit); diff --git a/src/Formatting.Analyzers/CSharp/FormatTypeDeclarationBracesAnalyzer.cs b/src/Formatting.Analyzers/CSharp/FormatTypeDeclarationBracesAnalyzer.cs index 3e68948870..b15b8b7625 100644 --- a/src/Formatting.Analyzers/CSharp/FormatTypeDeclarationBracesAnalyzer.cs +++ b/src/Formatting.Analyzers/CSharp/FormatTypeDeclarationBracesAnalyzer.cs @@ -33,7 +33,9 @@ public override void Initialize(AnalysisContext context) f => AnalyzeTypeDeclaration(f), SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, +#if ROSLYN_4_0 SyntaxKind.RecordStructDeclaration, +#endif SyntaxKind.InterfaceDeclaration); } diff --git a/src/Formatting.Analyzers/CSharp/PutAttributeListOnItsOwnLineAnalyzer.cs b/src/Formatting.Analyzers/CSharp/PutAttributeListOnItsOwnLineAnalyzer.cs index 1d718b50a3..a0c1bb2a10 100644 --- a/src/Formatting.Analyzers/CSharp/PutAttributeListOnItsOwnLineAnalyzer.cs +++ b/src/Formatting.Analyzers/CSharp/PutAttributeListOnItsOwnLineAnalyzer.cs @@ -33,7 +33,11 @@ public override void Initialize(AnalysisContext context) context.RegisterSyntaxNodeAction(f => AnalyzeEnumDeclaration(f), SyntaxKind.EnumDeclaration); context.RegisterSyntaxNodeAction(f => AnalyzeInterfaceDeclaration(f), SyntaxKind.InterfaceDeclaration); context.RegisterSyntaxNodeAction(f => AnalyzeStructDeclaration(f), SyntaxKind.StructDeclaration); +#if ROSLYN_4_0 context.RegisterSyntaxNodeAction(f => AnalyzeRecordDeclaration(f), SyntaxKind.RecordDeclaration, SyntaxKind.RecordStructDeclaration); +#else + context.RegisterSyntaxNodeAction(f => AnalyzeRecordDeclaration(f), SyntaxKind.RecordDeclaration); +#endif context.RegisterSyntaxNodeAction(f => AnalyzeDelegateDeclaration(f), SyntaxKind.DelegateDeclaration); context.RegisterSyntaxNodeAction(f => AnalyzeEventFieldDeclaration(f), SyntaxKind.EventFieldDeclaration); context.RegisterSyntaxNodeAction(f => AnalyzeFieldDeclaration(f), SyntaxKind.FieldDeclaration); diff --git a/src/Formatting.Analyzers/CSharp/PutTypeParameterConstraintOnItsOwnLineAnalyzer.cs b/src/Formatting.Analyzers/CSharp/PutTypeParameterConstraintOnItsOwnLineAnalyzer.cs index bbd366f316..11ed7d8707 100644 --- a/src/Formatting.Analyzers/CSharp/PutTypeParameterConstraintOnItsOwnLineAnalyzer.cs +++ b/src/Formatting.Analyzers/CSharp/PutTypeParameterConstraintOnItsOwnLineAnalyzer.cs @@ -33,7 +33,9 @@ public override void Initialize(AnalysisContext context) f => AnalyzeTypeDeclaration(f), SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, +#if ROSLYN_4_0 SyntaxKind.RecordStructDeclaration, +#endif SyntaxKind.InterfaceDeclaration); context.RegisterSyntaxNodeAction(f => AnalyzeDelegateDeclaration(f), SyntaxKind.DelegateDeclaration); diff --git a/src/Formatting.Analyzers/CSharp/RemoveNewLineBeforeBaseListAnalyzer.cs b/src/Formatting.Analyzers/CSharp/RemoveNewLineBeforeBaseListAnalyzer.cs index a273509353..aa7ec8eac2 100644 --- a/src/Formatting.Analyzers/CSharp/RemoveNewLineBeforeBaseListAnalyzer.cs +++ b/src/Formatting.Analyzers/CSharp/RemoveNewLineBeforeBaseListAnalyzer.cs @@ -33,7 +33,9 @@ public override void Initialize(AnalysisContext context) f => AnalyzeTypeDeclaration(f), SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, +#if ROSLYN_4_0 SyntaxKind.RecordStructDeclaration, +#endif SyntaxKind.InterfaceDeclaration); context.RegisterSyntaxNodeAction(f => AnalyzeEnumDeclaration(f), SyntaxKind.EnumDeclaration); diff --git a/src/Refactorings/CSharp/Refactorings/AccessModifierRefactoring.cs b/src/Refactorings/CSharp/Refactorings/AccessModifierRefactoring.cs index 639b70bd8a..874b897492 100644 --- a/src/Refactorings/CSharp/Refactorings/AccessModifierRefactoring.cs +++ b/src/Refactorings/CSharp/Refactorings/AccessModifierRefactoring.cs @@ -26,8 +26,10 @@ public static async Task ComputeRefactoringsAsync(RefactoringContext context, Sy if (node.IsKind( SyntaxKind.ClassDeclaration, SyntaxKind.InterfaceDeclaration, - SyntaxKind.StructDeclaration, - SyntaxKind.RecordStructDeclaration)) +#if ROSLYN_4_0 + SyntaxKind.RecordStructDeclaration, +#endif + SyntaxKind.StructDeclaration)) { SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false); diff --git a/src/Refactorings/CSharp/Refactorings/AddGenericParameterToDeclarationRefactoring.cs b/src/Refactorings/CSharp/Refactorings/AddGenericParameterToDeclarationRefactoring.cs index 7097abe8db..5f07b7f7dd 100644 --- a/src/Refactorings/CSharp/Refactorings/AddGenericParameterToDeclarationRefactoring.cs +++ b/src/Refactorings/CSharp/Refactorings/AddGenericParameterToDeclarationRefactoring.cs @@ -260,7 +260,9 @@ private static async Task RefactorAsync( break; } case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif { newNode = GetNewNode((RecordDeclarationSyntax)node, constraint, semanticModel); break; diff --git a/src/Refactorings/CSharp/Refactorings/AddOrRenameParameterRefactoring.cs b/src/Refactorings/CSharp/Refactorings/AddOrRenameParameterRefactoring.cs index 4c5b697d72..3f5a5379e1 100644 --- a/src/Refactorings/CSharp/Refactorings/AddOrRenameParameterRefactoring.cs +++ b/src/Refactorings/CSharp/Refactorings/AddOrRenameParameterRefactoring.cs @@ -40,7 +40,11 @@ public static async Task ComputeRefactoringsAsync(RefactoringContext context, Pa { context.RegisterRefactoring( $"Rename '{oldName}' to '{newName}'", +#if ROSLYN_4_4 ct => Renamer.RenameSymbolAsync(context.Solution, parameterSymbol, default(SymbolRenameOptions), newName, ct), +#else + ct => Renamer.RenameSymbolAsync(context.Solution, parameterSymbol, newName, default(Microsoft.CodeAnalysis.Options.OptionSet), ct), +#endif RefactoringDescriptors.RenameParameterAccordingToTypeName); } } diff --git a/src/Refactorings/CSharp/Refactorings/AddUsingDirectiveRefactoring.cs b/src/Refactorings/CSharp/Refactorings/AddUsingDirectiveRefactoring.cs index 62467cd6cd..e962915e69 100644 --- a/src/Refactorings/CSharp/Refactorings/AddUsingDirectiveRefactoring.cs +++ b/src/Refactorings/CSharp/Refactorings/AddUsingDirectiveRefactoring.cs @@ -54,7 +54,7 @@ public static async Task ComputeRefactoringsAsync(RefactoringContext context, Id { if (ancestor.IsKind(SyntaxKind.UsingDirective)) return; - +#if ROSLYN_4_0 if (ancestor.IsKind(SyntaxKind.FileScopedNamespaceDeclaration)) { if (((FileScopedNamespaceDeclarationSyntax)ancestor).Name.Contains(node)) @@ -62,7 +62,7 @@ public static async Task ComputeRefactoringsAsync(RefactoringContext context, Id break; } - +#endif if (ancestor is StatementSyntax || ancestor is MemberDeclarationSyntax) { diff --git a/src/Refactorings/CSharp/Refactorings/AttributeListRefactoring.cs b/src/Refactorings/CSharp/Refactorings/AttributeListRefactoring.cs index a2ba01dde7..739d444b16 100644 --- a/src/Refactorings/CSharp/Refactorings/AttributeListRefactoring.cs +++ b/src/Refactorings/CSharp/Refactorings/AttributeListRefactoring.cs @@ -18,7 +18,11 @@ public static void ComputeRefactorings(RefactoringContext context, MemberDeclara if (context.IsAnyRefactoringEnabled( RefactoringDescriptors.SplitAttributes, RefactoringDescriptors.MergeAttributes) - && !member.IsKind(SyntaxKind.NamespaceDeclaration, SyntaxKind.FileScopedNamespaceDeclaration) + && !member.IsKind( +#if ROSLYN_4_0 + SyntaxKind.FileScopedNamespaceDeclaration, +#endif + SyntaxKind.NamespaceDeclaration) && SyntaxListSelection.TryCreate(member.GetAttributeLists(), context.Span, out SyntaxListSelection selectedAttributeLists)) { if (context.IsRefactoringEnabled(RefactoringDescriptors.SplitAttributes) @@ -109,7 +113,9 @@ public static SyntaxList GetAttributeLists(this SyntaxNode case SyntaxKind.TypeParameter: return ((TypeParameterSyntax)node).AttributeLists; case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return ((RecordDeclarationSyntax)node).AttributeLists; case SyntaxKind.StructDeclaration: return ((StructDeclarationSyntax)node).AttributeLists; @@ -170,7 +176,9 @@ public static CSharpSyntaxNode WithAttributeLists(this CSharpSyntaxNode node, Sy case SyntaxKind.TypeParameter: return ((TypeParameterSyntax)node).WithAttributeLists(attributeLists); case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return ((RecordDeclarationSyntax)node).WithAttributeLists(attributeLists); case SyntaxKind.StructDeclaration: return ((StructDeclarationSyntax)node).WithAttributeLists(attributeLists); diff --git a/src/Refactorings/CSharp/Refactorings/CheckParameterForNullRefactoring.cs b/src/Refactorings/CSharp/Refactorings/CheckParameterForNullRefactoring.cs index 631374b639..a5c31d5a5d 100644 --- a/src/Refactorings/CSharp/Refactorings/CheckParameterForNullRefactoring.cs +++ b/src/Refactorings/CSharp/Refactorings/CheckParameterForNullRefactoring.cs @@ -229,7 +229,9 @@ private static BlockSyntax GetBody(ParameterSyntax parameter) case SyntaxKind.OperatorDeclaration: case SyntaxKind.ConversionOperatorDeclaration: case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif { break; } diff --git a/src/Refactorings/CSharp/Refactorings/ConvertAutoPropertyToFullPropertyWithoutBackingFieldRefactoring.cs b/src/Refactorings/CSharp/Refactorings/ConvertAutoPropertyToFullPropertyWithoutBackingFieldRefactoring.cs index 7900f87a82..af969b854a 100644 --- a/src/Refactorings/CSharp/Refactorings/ConvertAutoPropertyToFullPropertyWithoutBackingFieldRefactoring.cs +++ b/src/Refactorings/CSharp/Refactorings/ConvertAutoPropertyToFullPropertyWithoutBackingFieldRefactoring.cs @@ -15,7 +15,13 @@ internal static class ConvertAutoPropertyToFullPropertyWithoutBackingFieldRefact { public static bool CanRefactor(PropertyDeclarationSyntax propertyDeclaration) { - return propertyDeclaration.IsParentKind(SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.RecordDeclaration, SyntaxKind.RecordStructDeclaration) + return propertyDeclaration.IsParentKind( + SyntaxKind.ClassDeclaration, + SyntaxKind.StructDeclaration, +#if ROSLYN_4_0 + SyntaxKind.RecordStructDeclaration, +#endif + SyntaxKind.RecordDeclaration) && propertyDeclaration .AccessorList? .Accessors diff --git a/src/Refactorings/CSharp/Refactorings/DeclarationExpressionRefactoring.cs b/src/Refactorings/CSharp/Refactorings/DeclarationExpressionRefactoring.cs index 77fb917055..089e1c0732 100644 --- a/src/Refactorings/CSharp/Refactorings/DeclarationExpressionRefactoring.cs +++ b/src/Refactorings/CSharp/Refactorings/DeclarationExpressionRefactoring.cs @@ -60,7 +60,11 @@ private static async Task RenameVariableAccordingToTypeNameAsync( context.RegisterRefactoring( $"Rename '{oldName}' to '{newName}'", +#if ROSLYN_4_4 ct => Renamer.RenameSymbolAsync(context.Solution, localSymbol, default(SymbolRenameOptions), newName, ct), +#else + ct => Renamer.RenameSymbolAsync(context.Solution, localSymbol, newName, default(Microsoft.CodeAnalysis.Options.OptionSet), ct), +#endif RefactoringDescriptors.RenameIdentifierAccordingToTypeName); } } diff --git a/src/Refactorings/CSharp/Refactorings/DeclarationPatternRefactoring.cs b/src/Refactorings/CSharp/Refactorings/DeclarationPatternRefactoring.cs index 963dbe6e4a..1528973ebe 100644 --- a/src/Refactorings/CSharp/Refactorings/DeclarationPatternRefactoring.cs +++ b/src/Refactorings/CSharp/Refactorings/DeclarationPatternRefactoring.cs @@ -45,7 +45,11 @@ internal static async Task ComputeRefactoringAsync(RefactoringContext context, D { context.RegisterRefactoring( $"Rename '{oldName}' to '{newName}'", +#if ROSLYN_4_4 ct => Renamer.RenameSymbolAsync(context.Solution, symbol, default(SymbolRenameOptions), newName, ct), +#else + ct => Renamer.RenameSymbolAsync(context.Solution, symbol, newName, default(Microsoft.CodeAnalysis.Options.OptionSet), ct), +#endif RefactoringDescriptors.RenameIdentifierAccordingToTypeName); } } diff --git a/src/Refactorings/CSharp/Refactorings/ExpandEventDeclarationRefactoring.cs b/src/Refactorings/CSharp/Refactorings/ExpandEventDeclarationRefactoring.cs index 4b371dc8f6..7bf57bf7c6 100644 --- a/src/Refactorings/CSharp/Refactorings/ExpandEventDeclarationRefactoring.cs +++ b/src/Refactorings/CSharp/Refactorings/ExpandEventDeclarationRefactoring.cs @@ -14,7 +14,13 @@ internal static class ExpandEventDeclarationRefactoring { public static bool CanRefactor(EventFieldDeclarationSyntax eventDeclaration) { - return eventDeclaration.IsParentKind(SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.RecordDeclaration, SyntaxKind.RecordStructDeclaration) + return eventDeclaration.IsParentKind( + SyntaxKind.ClassDeclaration, + SyntaxKind.StructDeclaration, +#if ROSLYN_4_0 + SyntaxKind.RecordStructDeclaration, +#endif + SyntaxKind.RecordDeclaration) && eventDeclaration.Declaration?.Variables.Count == 1; } diff --git a/src/Refactorings/CSharp/Refactorings/ExpandPositionalConstructorRefactoring.cs b/src/Refactorings/CSharp/Refactorings/ExpandPositionalConstructorRefactoring.cs index 4cb7c0a7d1..950948afb5 100644 --- a/src/Refactorings/CSharp/Refactorings/ExpandPositionalConstructorRefactoring.cs +++ b/src/Refactorings/CSharp/Refactorings/ExpandPositionalConstructorRefactoring.cs @@ -59,7 +59,10 @@ private static Task RefactorAsync( } bool isWritable = !recordDeclaration.Modifiers.Contains(SyntaxKind.ReadOnlyKeyword) - && recordDeclaration.ClassOrStructKeyword.IsKind(SyntaxKind.StructKeyword); +#if ROSLYN_4_0 + && recordDeclaration.ClassOrStructKeyword.IsKind(SyntaxKind.StructKeyword) +#endif + ; foreach (ParameterSyntax parameter in parameters) { diff --git a/src/Refactorings/CSharp/Refactorings/ForEachStatementRefactoring.cs b/src/Refactorings/CSharp/Refactorings/ForEachStatementRefactoring.cs index 93844756f5..229fc442ec 100644 --- a/src/Refactorings/CSharp/Refactorings/ForEachStatementRefactoring.cs +++ b/src/Refactorings/CSharp/Refactorings/ForEachStatementRefactoring.cs @@ -162,7 +162,11 @@ internal static async Task RenameIdentifierAccordingToTypeNameAsync( context.RegisterRefactoring( $"Rename '{oldName}' to '{newName}'", +#if ROSLYN_4_4 ct => Renamer.RenameSymbolAsync(context.Solution, symbol, default(SymbolRenameOptions), newName, ct), +#else + ct => Renamer.RenameSymbolAsync(context.Solution, symbol, newName, default(Microsoft.CodeAnalysis.Options.OptionSet), ct), +#endif RefactoringDescriptors.RenameIdentifierAccordingToTypeName); } } diff --git a/src/Refactorings/CSharp/Refactorings/GeneratePropertyForDebuggerDisplayAttributeRefactoring.cs b/src/Refactorings/CSharp/Refactorings/GeneratePropertyForDebuggerDisplayAttributeRefactoring.cs index 2b66f63ad1..d9bd141079 100644 --- a/src/Refactorings/CSharp/Refactorings/GeneratePropertyForDebuggerDisplayAttributeRefactoring.cs +++ b/src/Refactorings/CSharp/Refactorings/GeneratePropertyForDebuggerDisplayAttributeRefactoring.cs @@ -23,8 +23,16 @@ public static async Task ComputeRefactoringAsync(RefactoringContext context, Att if (!attribute.IsParentKind(SyntaxKind.AttributeList)) return; - if (!attribute.Parent.IsParentKind(SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.RecordDeclaration, SyntaxKind.RecordStructDeclaration)) + if (!attribute.Parent.IsParentKind( + SyntaxKind.ClassDeclaration, + SyntaxKind.StructDeclaration, +#if ROSLYN_4_0 + SyntaxKind.RecordStructDeclaration, +#endif + SyntaxKind.RecordDeclaration)) + { return; + } SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false); diff --git a/src/Refactorings/CSharp/Refactorings/IdentifierNameRefactoring.cs b/src/Refactorings/CSharp/Refactorings/IdentifierNameRefactoring.cs index 2887046fc2..109740bf3e 100644 --- a/src/Refactorings/CSharp/Refactorings/IdentifierNameRefactoring.cs +++ b/src/Refactorings/CSharp/Refactorings/IdentifierNameRefactoring.cs @@ -80,7 +80,11 @@ private static async Task SyncPropertyNameAndBackingFieldNameAsync( context.RegisterRefactoring( $"Rename '{fieldSymbol.Name}' to '{newName}'", +#if ROSLYN_4_4 ct => Renamer.RenameSymbolAsync(context.Solution, fieldSymbol, default(SymbolRenameOptions), newName, ct), +#else + ct => Renamer.RenameSymbolAsync(context.Solution, fieldSymbol, newName, default(Microsoft.CodeAnalysis.Options.OptionSet), ct), +#endif RefactoringDescriptors.SyncPropertyNameAndBackingFieldName); } diff --git a/src/Refactorings/CSharp/Refactorings/InitializeFieldFromConstructorRefactoring.cs b/src/Refactorings/CSharp/Refactorings/InitializeFieldFromConstructorRefactoring.cs index 4003c9404e..0cb18f04f7 100644 --- a/src/Refactorings/CSharp/Refactorings/InitializeFieldFromConstructorRefactoring.cs +++ b/src/Refactorings/CSharp/Refactorings/InitializeFieldFromConstructorRefactoring.cs @@ -95,8 +95,16 @@ private static bool CanRefactor(FieldDeclarationSyntax fieldDeclaration) if (fieldDeclaration.Parent is not TypeDeclarationSyntax typeDeclaration) return false; - if (!typeDeclaration.IsKind(SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.RecordDeclaration, SyntaxKind.RecordStructDeclaration)) + if (!typeDeclaration.IsKind( + SyntaxKind.ClassDeclaration, + SyntaxKind.StructDeclaration, +#if ROSLYN_4_0 + SyntaxKind.RecordStructDeclaration, +#endif + SyntaxKind.RecordDeclaration)) + { return false; + } return typeDeclaration .Members diff --git a/src/Refactorings/CSharp/Refactorings/IntroduceConstructorRefactoring.cs b/src/Refactorings/CSharp/Refactorings/IntroduceConstructorRefactoring.cs index 2cdb5dfc6a..717a34a5e4 100644 --- a/src/Refactorings/CSharp/Refactorings/IntroduceConstructorRefactoring.cs +++ b/src/Refactorings/CSharp/Refactorings/IntroduceConstructorRefactoring.cs @@ -37,7 +37,13 @@ public static async Task ComputeRefactoringsAsync(RefactoringContext context, Me } } } - else if (kind.Is(SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.RecordDeclaration, SyntaxKind.RecordStructDeclaration)) + else if (kind.Is( + SyntaxKind.ClassDeclaration, + SyntaxKind.StructDeclaration, +#if ROSLYN_4_0 + SyntaxKind.RecordStructDeclaration, +#endif + SyntaxKind.RecordDeclaration)) { SemanticModel semanticModel = null; @@ -95,8 +101,16 @@ private static bool CanPropertyBeAssignedFromConstructor( if (symbol.IsStatic) return false; - if (!propertyDeclaration.IsParentKind(SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.RecordDeclaration, SyntaxKind.RecordStructDeclaration)) + if (!propertyDeclaration.IsParentKind( + SyntaxKind.ClassDeclaration, + SyntaxKind.StructDeclaration, +#if ROSLYN_4_0 + SyntaxKind.RecordStructDeclaration, +#endif + SyntaxKind.RecordDeclaration)) + { return false; + } ArrowExpressionClauseSyntax expressionBody = propertyDeclaration.ExpressionBody; @@ -311,7 +325,9 @@ private static string GetConstructorIdentifierText(SyntaxNode declaration) case SyntaxKind.ClassDeclaration: return ((ClassDeclarationSyntax)declaration).Identifier.Text; case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return ((RecordDeclarationSyntax)declaration).Identifier.Text; case SyntaxKind.StructDeclaration: return ((StructDeclarationSyntax)declaration).Identifier.Text; @@ -327,7 +343,9 @@ private static MemberDeclarationSyntax GetContainingDeclaration(MemberDeclaratio case SyntaxKind.ClassDeclaration: case SyntaxKind.RecordDeclaration: case SyntaxKind.StructDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif return declaration; default: { diff --git a/src/Refactorings/CSharp/Refactorings/MemberDeclarationRefactoring.cs b/src/Refactorings/CSharp/Refactorings/MemberDeclarationRefactoring.cs index 9c28530158..89a97c4568 100644 --- a/src/Refactorings/CSharp/Refactorings/MemberDeclarationRefactoring.cs +++ b/src/Refactorings/CSharp/Refactorings/MemberDeclarationRefactoring.cs @@ -26,7 +26,9 @@ public static async Task ComputeRefactoringsAsync(RefactoringContext context, Me case SyntaxKind.ClassDeclaration: case SyntaxKind.RecordDeclaration: case SyntaxKind.StructDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif case SyntaxKind.InterfaceDeclaration: case SyntaxKind.EnumDeclaration: { @@ -109,7 +111,9 @@ public static async Task ComputeRefactoringsAsync(RefactoringContext context, Me break; } case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif { var recordDeclaration = (RecordDeclarationSyntax)member; await RecordDeclarationRefactoring.ComputeRefactoringsAsync(context, recordDeclaration).ConfigureAwait(false); @@ -279,7 +283,9 @@ private static (SyntaxToken openBrace, SyntaxToken closeBrace) GetBraces(MemberD return (member2.OpenBraceToken, member2.CloseBraceToken); } case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif { var member3 = ((RecordDeclarationSyntax)member); return (member3.OpenBraceToken, member3.CloseBraceToken); diff --git a/src/Refactorings/CSharp/Refactorings/MethodDeclarationRefactoring.cs b/src/Refactorings/CSharp/Refactorings/MethodDeclarationRefactoring.cs index dcaa15128e..a2d3bf6974 100644 --- a/src/Refactorings/CSharp/Refactorings/MethodDeclarationRefactoring.cs +++ b/src/Refactorings/CSharp/Refactorings/MethodDeclarationRefactoring.cs @@ -142,7 +142,11 @@ private static async Task RenameMethodAccordingToTypeNameAsync( context.RegisterRefactoring( $"Rename '{oldName}' to '{newName}'", +#if ROSLYN_4_4 ct => Renamer.RenameSymbolAsync(context.Solution, methodSymbol, new SymbolRenameOptions(RenameOverloads: true), newName, ct), +#else + ct => Renamer.RenameSymbolAsync(context.Solution, methodSymbol, newName, default(Microsoft.CodeAnalysis.Options.OptionSet), ct), +#endif RefactoringDescriptors.RenameMethodAccordingToTypeName); } diff --git a/src/Refactorings/CSharp/Refactorings/PropertyDeclarationRefactoring.cs b/src/Refactorings/CSharp/Refactorings/PropertyDeclarationRefactoring.cs index 0aadcda283..b4766a0667 100644 --- a/src/Refactorings/CSharp/Refactorings/PropertyDeclarationRefactoring.cs +++ b/src/Refactorings/CSharp/Refactorings/PropertyDeclarationRefactoring.cs @@ -144,7 +144,11 @@ private static async Task RenamePropertyAccordingToTypeName(RefactoringContext c context.RegisterRefactoring( $"Rename '{oldName}' to '{newName}'", +#if ROSLYN_4_4 ct => Renamer.RenameSymbolAsync(context.Solution, symbol, new SymbolRenameOptions(RenameOverloads: true), newName, ct), +#else + ct => Renamer.RenameSymbolAsync(context.Solution, symbol, newName, default(Microsoft.CodeAnalysis.Options.OptionSet), ct), +#endif RefactoringDescriptors.RenamePropertyAccordingToTypeName); } } diff --git a/src/Refactorings/CSharp/Refactorings/SelectedMemberDeclarationsRefactoring.cs b/src/Refactorings/CSharp/Refactorings/SelectedMemberDeclarationsRefactoring.cs index c632e295b0..3dfb241dab 100644 --- a/src/Refactorings/CSharp/Refactorings/SelectedMemberDeclarationsRefactoring.cs +++ b/src/Refactorings/CSharp/Refactorings/SelectedMemberDeclarationsRefactoring.cs @@ -114,7 +114,9 @@ bool CanHaveMultipleDeclarations() break; } case SyntaxKind.RecordDeclaration: +#if ROSLYN_4_0 case SyntaxKind.RecordStructDeclaration: +#endif { if (((RecordDeclarationSyntax)member).Modifiers.Contains(SyntaxKind.PartialKeyword)) return true; diff --git a/src/Refactorings/CSharp/Refactorings/VariableDeclarationRefactoring.cs b/src/Refactorings/CSharp/Refactorings/VariableDeclarationRefactoring.cs index c50ae68b52..11892ab2aa 100644 --- a/src/Refactorings/CSharp/Refactorings/VariableDeclarationRefactoring.cs +++ b/src/Refactorings/CSharp/Refactorings/VariableDeclarationRefactoring.cs @@ -72,7 +72,11 @@ private static async Task RenameVariableAccordingToTypeNameAsync( context.RegisterRefactoring( $"Rename '{oldName}' to '{newName}'", +#if ROSLYN_4_4 ct => Renamer.RenameSymbolAsync(context.Solution, localSymbol, default(SymbolRenameOptions), newName, ct), +#else + ct => Renamer.RenameSymbolAsync(context.Solution, localSymbol, newName, default(Microsoft.CodeAnalysis.Options.OptionSet), ct), +#endif RefactoringDescriptors.RenameIdentifierAccordingToTypeName); } } diff --git a/src/Tests/Analyzers.Tests/RCS1262UnnecessaryRawStringLiteralTests.cs b/src/Tests/Analyzers.Tests/RCS1262UnnecessaryRawStringLiteralTests.cs index 04ad8d8111..b840daeb8b 100644 --- a/src/Tests/Analyzers.Tests/RCS1262UnnecessaryRawStringLiteralTests.cs +++ b/src/Tests/Analyzers.Tests/RCS1262UnnecessaryRawStringLiteralTests.cs @@ -1,4 +1,5 @@ -// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +#if ROSLYN_4_2 +// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; using Microsoft.CodeAnalysis; @@ -155,3 +156,4 @@ void M() "); } } +#endif diff --git a/src/Tests/Formatting.Analyzers.Tests/RCS0060AddEmptyLineAfterFileScopedNamespaceTests.cs b/src/Tests/Formatting.Analyzers.Tests/RCS0060AddEmptyLineAfterFileScopedNamespaceTests.cs index 538cf8d217..7a3a73e46f 100644 --- a/src/Tests/Formatting.Analyzers.Tests/RCS0060AddEmptyLineAfterFileScopedNamespaceTests.cs +++ b/src/Tests/Formatting.Analyzers.Tests/RCS0060AddEmptyLineAfterFileScopedNamespaceTests.cs @@ -1,4 +1,5 @@ -// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +#if ROSLYN_4_0 +// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Threading.Tasks; using Microsoft.CodeAnalysis; @@ -295,3 +296,4 @@ namespace A.B; // x", options: Options.AddConfigOption(ConfigOptionKeys.BlankLineAfterFileScopedNamespaceDeclaration, true)); } } +#endif diff --git a/src/Tools/CodeGeneration/CSharp/CodeFixesOptionsPageGenerator.cs b/src/Tools/CodeGeneration/CSharp/CodeFixesOptionsPageGenerator.cs index 54495f7c76..3e5a9923f8 100644 --- a/src/Tools/CodeGeneration/CSharp/CodeFixesOptionsPageGenerator.cs +++ b/src/Tools/CodeGeneration/CSharp/CodeFixesOptionsPageGenerator.cs @@ -14,10 +14,11 @@ public static CompilationUnitSyntax Generate() return CompilationUnit( UsingDirectives("Roslynator.CSharp"), List(new MemberDeclarationSyntax[] { - FileScopedNamespaceDeclaration(ParseName("Roslynator.VisualStudio")), - ClassDeclaration( - Modifiers.Public_Partial(), - "CodeFixesOptionsPage"), + NamespaceDeclaration( + "Roslynator.VisualStudio", + ClassDeclaration( + Modifiers.Public_Partial(), + "CodeFixesOptionsPage")), })); } } diff --git a/src/Tools/CodeGeneration/CSharp/RefactoringsOptionsPageGenerator.cs b/src/Tools/CodeGeneration/CSharp/RefactoringsOptionsPageGenerator.cs index 5bff3a3b67..a7c5d567d1 100644 --- a/src/Tools/CodeGeneration/CSharp/RefactoringsOptionsPageGenerator.cs +++ b/src/Tools/CodeGeneration/CSharp/RefactoringsOptionsPageGenerator.cs @@ -19,11 +19,12 @@ public static CompilationUnitSyntax Generate(IEnumerable re "System.Collections.Generic", "Roslynator.CSharp.Refactorings"), List(new MemberDeclarationSyntax[] { - FileScopedNamespaceDeclaration(ParseName("Roslynator.VisualStudio")), - ClassDeclaration( - Modifiers.Public_Partial(), - "RefactoringsOptionsPage", - CreateMembers(refactorings, comparer).ToSyntaxList()), + NamespaceDeclaration( + "Roslynator.VisualStudio", + ClassDeclaration( + Modifiers.Public_Partial(), + "RefactoringsOptionsPage", + CreateMembers(refactorings, comparer).ToSyntaxList())), })); } diff --git a/src/Tools/CodeGeneration/CSharp/Symbols.Generated.Roslyn38.cs b/src/Tools/CodeGeneration/CSharp/Symbols.Generated.Roslyn38.cs new file mode 100644 index 0000000000..0e394f5b48 --- /dev/null +++ b/src/Tools/CodeGeneration/CSharp/Symbols.Generated.Roslyn38.cs @@ -0,0 +1,1475 @@ +#if ROSLYN_3_8_ONLY +// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +// + +using System.Collections.Generic; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; + +namespace Roslynator.CodeGeneration.CSharp +{ + internal static partial class Symbols + { + public static IEnumerable GetKinds(INamedTypeSymbol syntaxSymbol) + { + switch (syntaxSymbol.Name) + { + case "AccessorDeclarationSyntax": + { + yield return SyntaxKind.GetAccessorDeclaration; + yield return SyntaxKind.SetAccessorDeclaration; + yield return SyntaxKind.AddAccessorDeclaration; + yield return SyntaxKind.RemoveAccessorDeclaration; + yield return SyntaxKind.UnknownAccessorDeclaration; + yield return SyntaxKind.InitAccessorDeclaration; + break; + } + + case "AccessorListSyntax": + { + yield return SyntaxKind.AccessorList; + break; + } + + case "AliasQualifiedNameSyntax": + { + yield return SyntaxKind.AliasQualifiedName; + break; + } + + case "AnonymousMethodExpressionSyntax": + { + yield return SyntaxKind.AnonymousMethodExpression; + break; + } + + case "AnonymousObjectCreationExpressionSyntax": + { + yield return SyntaxKind.AnonymousObjectCreationExpression; + break; + } + + case "AnonymousObjectMemberDeclaratorSyntax": + { + yield return SyntaxKind.AnonymousObjectMemberDeclarator; + break; + } + + case "ArgumentListSyntax": + { + yield return SyntaxKind.ArgumentList; + break; + } + + case "ArgumentSyntax": + { + yield return SyntaxKind.Argument; + break; + } + + case "ArrayCreationExpressionSyntax": + { + yield return SyntaxKind.ArrayCreationExpression; + break; + } + + case "ArrayRankSpecifierSyntax": + { + yield return SyntaxKind.ArrayRankSpecifier; + break; + } + + case "ArrayTypeSyntax": + { + yield return SyntaxKind.ArrayType; + break; + } + + case "ArrowExpressionClauseSyntax": + { + yield return SyntaxKind.ArrowExpressionClause; + break; + } + + case "AssignmentExpressionSyntax": + { + yield return SyntaxKind.SimpleAssignmentExpression; + yield return SyntaxKind.AddAssignmentExpression; + yield return SyntaxKind.SubtractAssignmentExpression; + yield return SyntaxKind.MultiplyAssignmentExpression; + yield return SyntaxKind.DivideAssignmentExpression; + yield return SyntaxKind.ModuloAssignmentExpression; + yield return SyntaxKind.AndAssignmentExpression; + yield return SyntaxKind.ExclusiveOrAssignmentExpression; + yield return SyntaxKind.OrAssignmentExpression; + yield return SyntaxKind.LeftShiftAssignmentExpression; + yield return SyntaxKind.RightShiftAssignmentExpression; + yield return SyntaxKind.CoalesceAssignmentExpression; + break; + } + + case "AttributeArgumentListSyntax": + { + yield return SyntaxKind.AttributeArgumentList; + break; + } + + case "AttributeArgumentSyntax": + { + yield return SyntaxKind.AttributeArgument; + break; + } + + case "AttributeListSyntax": + { + yield return SyntaxKind.AttributeList; + break; + } + + case "AttributeSyntax": + { + yield return SyntaxKind.Attribute; + break; + } + + case "AttributeTargetSpecifierSyntax": + { + yield return SyntaxKind.AttributeTargetSpecifier; + break; + } + + case "AwaitExpressionSyntax": + { + yield return SyntaxKind.AwaitExpression; + break; + } + + case "BadDirectiveTriviaSyntax": + { + yield return SyntaxKind.BadDirectiveTrivia; + break; + } + + case "BaseExpressionSyntax": + { + yield return SyntaxKind.BaseExpression; + break; + } + + case "BaseListSyntax": + { + yield return SyntaxKind.BaseList; + break; + } + + case "BinaryExpressionSyntax": + { + yield return SyntaxKind.AddExpression; + yield return SyntaxKind.SubtractExpression; + yield return SyntaxKind.MultiplyExpression; + yield return SyntaxKind.DivideExpression; + yield return SyntaxKind.ModuloExpression; + yield return SyntaxKind.LeftShiftExpression; + yield return SyntaxKind.RightShiftExpression; + yield return SyntaxKind.LogicalOrExpression; + yield return SyntaxKind.LogicalAndExpression; + yield return SyntaxKind.BitwiseOrExpression; + yield return SyntaxKind.BitwiseAndExpression; + yield return SyntaxKind.ExclusiveOrExpression; + yield return SyntaxKind.EqualsExpression; + yield return SyntaxKind.NotEqualsExpression; + yield return SyntaxKind.LessThanExpression; + yield return SyntaxKind.LessThanOrEqualExpression; + yield return SyntaxKind.GreaterThanExpression; + yield return SyntaxKind.GreaterThanOrEqualExpression; + yield return SyntaxKind.IsExpression; + yield return SyntaxKind.AsExpression; + yield return SyntaxKind.CoalesceExpression; + break; + } + + case "BinaryPatternSyntax": + { + yield return SyntaxKind.AndPattern; + yield return SyntaxKind.OrPattern; + break; + } + + case "BlockSyntax": + { + yield return SyntaxKind.Block; + break; + } + + case "BracketedArgumentListSyntax": + { + yield return SyntaxKind.BracketedArgumentList; + break; + } + + case "BracketedParameterListSyntax": + { + yield return SyntaxKind.BracketedParameterList; + break; + } + + case "BreakStatementSyntax": + { + yield return SyntaxKind.BreakStatement; + break; + } + + case "CasePatternSwitchLabelSyntax": + { + yield return SyntaxKind.CasePatternSwitchLabel; + break; + } + + case "CaseSwitchLabelSyntax": + { + yield return SyntaxKind.CaseSwitchLabel; + break; + } + + case "CastExpressionSyntax": + { + yield return SyntaxKind.CastExpression; + break; + } + + case "CatchClauseSyntax": + { + yield return SyntaxKind.CatchClause; + break; + } + + case "CatchDeclarationSyntax": + { + yield return SyntaxKind.CatchDeclaration; + break; + } + + case "CatchFilterClauseSyntax": + { + yield return SyntaxKind.CatchFilterClause; + break; + } + + case "ClassDeclarationSyntax": + { + yield return SyntaxKind.ClassDeclaration; + break; + } + + case "ClassOrStructConstraintSyntax": + { + yield return SyntaxKind.ClassConstraint; + yield return SyntaxKind.StructConstraint; + break; + } + + case "CompilationUnitSyntax": + { + yield return SyntaxKind.CompilationUnit; + break; + } + + case "ConditionalAccessExpressionSyntax": + { + yield return SyntaxKind.ConditionalAccessExpression; + break; + } + + case "ConditionalExpressionSyntax": + { + yield return SyntaxKind.ConditionalExpression; + break; + } + + case "ConstantPatternSyntax": + { + yield return SyntaxKind.ConstantPattern; + break; + } + + case "ConstructorConstraintSyntax": + { + yield return SyntaxKind.ConstructorConstraint; + break; + } + + case "ConstructorDeclarationSyntax": + { + yield return SyntaxKind.ConstructorDeclaration; + break; + } + + case "ConstructorInitializerSyntax": + { + yield return SyntaxKind.BaseConstructorInitializer; + yield return SyntaxKind.ThisConstructorInitializer; + break; + } + + case "ContinueStatementSyntax": + { + yield return SyntaxKind.ContinueStatement; + break; + } + + case "ConversionOperatorDeclarationSyntax": + { + yield return SyntaxKind.ConversionOperatorDeclaration; + break; + } + + case "ConversionOperatorMemberCrefSyntax": + { + yield return SyntaxKind.ConversionOperatorMemberCref; + break; + } + + case "CrefBracketedParameterListSyntax": + { + yield return SyntaxKind.CrefBracketedParameterList; + break; + } + + case "CrefParameterListSyntax": + { + yield return SyntaxKind.CrefParameterList; + break; + } + + case "CrefParameterSyntax": + { + yield return SyntaxKind.CrefParameter; + break; + } + + case "DeclarationExpressionSyntax": + { + yield return SyntaxKind.DeclarationExpression; + break; + } + + case "DeclarationPatternSyntax": + { + yield return SyntaxKind.DeclarationPattern; + break; + } + + case "DefaultConstraintSyntax": + { + yield return SyntaxKind.DefaultConstraint; + break; + } + + case "DefaultExpressionSyntax": + { + yield return SyntaxKind.DefaultExpression; + break; + } + + case "DefaultSwitchLabelSyntax": + { + yield return SyntaxKind.DefaultSwitchLabel; + break; + } + + case "DefineDirectiveTriviaSyntax": + { + yield return SyntaxKind.DefineDirectiveTrivia; + break; + } + + case "DelegateDeclarationSyntax": + { + yield return SyntaxKind.DelegateDeclaration; + break; + } + + case "DestructorDeclarationSyntax": + { + yield return SyntaxKind.DestructorDeclaration; + break; + } + + case "DiscardDesignationSyntax": + { + yield return SyntaxKind.DiscardDesignation; + break; + } + + case "DiscardPatternSyntax": + { + yield return SyntaxKind.DiscardPattern; + break; + } + + case "DocumentationCommentTriviaSyntax": + { + yield return SyntaxKind.SingleLineDocumentationCommentTrivia; + yield return SyntaxKind.MultiLineDocumentationCommentTrivia; + break; + } + + case "DoStatementSyntax": + { + yield return SyntaxKind.DoStatement; + break; + } + + case "ElementAccessExpressionSyntax": + { + yield return SyntaxKind.ElementAccessExpression; + break; + } + + case "ElementBindingExpressionSyntax": + { + yield return SyntaxKind.ElementBindingExpression; + break; + } + + case "ElifDirectiveTriviaSyntax": + { + yield return SyntaxKind.ElifDirectiveTrivia; + break; + } + + case "ElseClauseSyntax": + { + yield return SyntaxKind.ElseClause; + break; + } + + case "ElseDirectiveTriviaSyntax": + { + yield return SyntaxKind.ElseDirectiveTrivia; + break; + } + + case "EmptyStatementSyntax": + { + yield return SyntaxKind.EmptyStatement; + break; + } + + case "EndIfDirectiveTriviaSyntax": + { + yield return SyntaxKind.EndIfDirectiveTrivia; + break; + } + + case "EndRegionDirectiveTriviaSyntax": + { + yield return SyntaxKind.EndRegionDirectiveTrivia; + break; + } + + case "EnumDeclarationSyntax": + { + yield return SyntaxKind.EnumDeclaration; + break; + } + + case "EnumMemberDeclarationSyntax": + { + yield return SyntaxKind.EnumMemberDeclaration; + break; + } + + case "EqualsValueClauseSyntax": + { + yield return SyntaxKind.EqualsValueClause; + break; + } + + case "ErrorDirectiveTriviaSyntax": + { + yield return SyntaxKind.ErrorDirectiveTrivia; + break; + } + + case "EventDeclarationSyntax": + { + yield return SyntaxKind.EventDeclaration; + break; + } + + case "EventFieldDeclarationSyntax": + { + yield return SyntaxKind.EventFieldDeclaration; + break; + } + + case "ExplicitInterfaceSpecifierSyntax": + { + yield return SyntaxKind.ExplicitInterfaceSpecifier; + break; + } + + case "ExpressionStatementSyntax": + { + yield return SyntaxKind.ExpressionStatement; + break; + } + + case "ExternAliasDirectiveSyntax": + { + yield return SyntaxKind.ExternAliasDirective; + break; + } + + case "FieldDeclarationSyntax": + { + yield return SyntaxKind.FieldDeclaration; + break; + } + + case "FinallyClauseSyntax": + { + yield return SyntaxKind.FinallyClause; + break; + } + + case "FixedStatementSyntax": + { + yield return SyntaxKind.FixedStatement; + break; + } + + case "ForEachStatementSyntax": + { + yield return SyntaxKind.ForEachStatement; + break; + } + + case "ForEachVariableStatementSyntax": + { + yield return SyntaxKind.ForEachVariableStatement; + break; + } + + case "ForStatementSyntax": + { + yield return SyntaxKind.ForStatement; + break; + } + + case "FromClauseSyntax": + { + yield return SyntaxKind.FromClause; + break; + } + + case "FunctionPointerCallingConventionSyntax": + { + yield return SyntaxKind.FunctionPointerCallingConvention; + break; + } + + case "FunctionPointerParameterListSyntax": + { + yield return SyntaxKind.FunctionPointerParameterList; + break; + } + + case "FunctionPointerParameterSyntax": + { + yield return SyntaxKind.FunctionPointerParameter; + break; + } + + case "FunctionPointerTypeSyntax": + { + yield return SyntaxKind.FunctionPointerType; + break; + } + + case "FunctionPointerUnmanagedCallingConventionListSyntax": + { + yield return SyntaxKind.FunctionPointerUnmanagedCallingConventionList; + break; + } + + case "FunctionPointerUnmanagedCallingConventionSyntax": + { + yield return SyntaxKind.FunctionPointerUnmanagedCallingConvention; + break; + } + + case "GenericNameSyntax": + { + yield return SyntaxKind.GenericName; + break; + } + + case "GlobalStatementSyntax": + { + yield return SyntaxKind.GlobalStatement; + break; + } + + case "GotoStatementSyntax": + { + yield return SyntaxKind.GotoStatement; + yield return SyntaxKind.GotoCaseStatement; + yield return SyntaxKind.GotoDefaultStatement; + break; + } + + case "GroupClauseSyntax": + { + yield return SyntaxKind.GroupClause; + break; + } + + case "CheckedExpressionSyntax": + { + yield return SyntaxKind.CheckedExpression; + yield return SyntaxKind.UncheckedExpression; + break; + } + + case "CheckedStatementSyntax": + { + yield return SyntaxKind.CheckedStatement; + yield return SyntaxKind.UncheckedStatement; + break; + } + + case "IdentifierNameSyntax": + { + yield return SyntaxKind.IdentifierName; + break; + } + + case "IfDirectiveTriviaSyntax": + { + yield return SyntaxKind.IfDirectiveTrivia; + break; + } + + case "IfStatementSyntax": + { + yield return SyntaxKind.IfStatement; + break; + } + + case "ImplicitArrayCreationExpressionSyntax": + { + yield return SyntaxKind.ImplicitArrayCreationExpression; + break; + } + + case "ImplicitElementAccessSyntax": + { + yield return SyntaxKind.ImplicitElementAccess; + break; + } + + case "ImplicitObjectCreationExpressionSyntax": + { + yield return SyntaxKind.ImplicitObjectCreationExpression; + break; + } + + case "ImplicitStackAllocArrayCreationExpressionSyntax": + { + yield return SyntaxKind.ImplicitStackAllocArrayCreationExpression; + break; + } + + case "IncompleteMemberSyntax": + { + yield return SyntaxKind.IncompleteMember; + break; + } + + case "IndexerDeclarationSyntax": + { + yield return SyntaxKind.IndexerDeclaration; + break; + } + + case "IndexerMemberCrefSyntax": + { + yield return SyntaxKind.IndexerMemberCref; + break; + } + + case "InitializerExpressionSyntax": + { + yield return SyntaxKind.ArrayInitializerExpression; + yield return SyntaxKind.CollectionInitializerExpression; + yield return SyntaxKind.ComplexElementInitializerExpression; + yield return SyntaxKind.ObjectInitializerExpression; + yield return SyntaxKind.WithInitializerExpression; + break; + } + + case "InterfaceDeclarationSyntax": + { + yield return SyntaxKind.InterfaceDeclaration; + break; + } + + case "InterpolatedStringExpressionSyntax": + { + yield return SyntaxKind.InterpolatedStringExpression; + break; + } + + case "InterpolatedStringTextSyntax": + { + yield return SyntaxKind.InterpolatedStringText; + break; + } + + case "InterpolationAlignmentClauseSyntax": + { + yield return SyntaxKind.InterpolationAlignmentClause; + break; + } + + case "InterpolationFormatClauseSyntax": + { + yield return SyntaxKind.InterpolationFormatClause; + break; + } + + case "InterpolationSyntax": + { + yield return SyntaxKind.Interpolation; + break; + } + + case "InvocationExpressionSyntax": + { + yield return SyntaxKind.InvocationExpression; + break; + } + + case "IsPatternExpressionSyntax": + { + yield return SyntaxKind.IsPatternExpression; + break; + } + + case "JoinClauseSyntax": + { + yield return SyntaxKind.JoinClause; + break; + } + + case "JoinIntoClauseSyntax": + { + yield return SyntaxKind.JoinIntoClause; + break; + } + + case "LabeledStatementSyntax": + { + yield return SyntaxKind.LabeledStatement; + break; + } + + case "LetClauseSyntax": + { + yield return SyntaxKind.LetClause; + break; + } + + case "LineDirectiveTriviaSyntax": + { + yield return SyntaxKind.LineDirectiveTrivia; + break; + } + + case "LiteralExpressionSyntax": + { + yield return SyntaxKind.ArgListExpression; + yield return SyntaxKind.NumericLiteralExpression; + yield return SyntaxKind.StringLiteralExpression; + yield return SyntaxKind.CharacterLiteralExpression; + yield return SyntaxKind.TrueLiteralExpression; + yield return SyntaxKind.FalseLiteralExpression; + yield return SyntaxKind.NullLiteralExpression; + yield return SyntaxKind.DefaultLiteralExpression; + break; + } + + case "LoadDirectiveTriviaSyntax": + { + yield return SyntaxKind.LoadDirectiveTrivia; + break; + } + + case "LocalDeclarationStatementSyntax": + { + yield return SyntaxKind.LocalDeclarationStatement; + break; + } + + case "LocalFunctionStatementSyntax": + { + yield return SyntaxKind.LocalFunctionStatement; + break; + } + + case "LockStatementSyntax": + { + yield return SyntaxKind.LockStatement; + break; + } + + case "MakeRefExpressionSyntax": + { + yield return SyntaxKind.MakeRefExpression; + break; + } + + case "MemberAccessExpressionSyntax": + { + yield return SyntaxKind.PointerMemberAccessExpression; + yield return SyntaxKind.SimpleMemberAccessExpression; + break; + } + + case "MemberBindingExpressionSyntax": + { + yield return SyntaxKind.MemberBindingExpression; + break; + } + + case "MethodDeclarationSyntax": + { + yield return SyntaxKind.MethodDeclaration; + break; + } + + case "NameColonSyntax": + { + yield return SyntaxKind.NameColon; + break; + } + + case "NameEqualsSyntax": + { + yield return SyntaxKind.NameEquals; + break; + } + + case "NameMemberCrefSyntax": + { + yield return SyntaxKind.NameMemberCref; + break; + } + + case "NamespaceDeclarationSyntax": + { + yield return SyntaxKind.NamespaceDeclaration; + break; + } + + case "NullableDirectiveTriviaSyntax": + { + yield return SyntaxKind.NullableDirectiveTrivia; + break; + } + + case "NullableTypeSyntax": + { + yield return SyntaxKind.NullableType; + break; + } + + case "ObjectCreationExpressionSyntax": + { + yield return SyntaxKind.ObjectCreationExpression; + break; + } + + case "OmittedArraySizeExpressionSyntax": + { + yield return SyntaxKind.OmittedArraySizeExpression; + break; + } + + case "OmittedTypeArgumentSyntax": + { + yield return SyntaxKind.OmittedTypeArgument; + break; + } + + case "OperatorDeclarationSyntax": + { + yield return SyntaxKind.OperatorDeclaration; + break; + } + + case "OperatorMemberCrefSyntax": + { + yield return SyntaxKind.OperatorMemberCref; + break; + } + + case "OrderByClauseSyntax": + { + yield return SyntaxKind.OrderByClause; + break; + } + + case "OrderingSyntax": + { + yield return SyntaxKind.AscendingOrdering; + yield return SyntaxKind.DescendingOrdering; + break; + } + + case "ParameterListSyntax": + { + yield return SyntaxKind.ParameterList; + break; + } + + case "ParameterSyntax": + { + yield return SyntaxKind.Parameter; + break; + } + + case "ParenthesizedExpressionSyntax": + { + yield return SyntaxKind.ParenthesizedExpression; + break; + } + + case "ParenthesizedLambdaExpressionSyntax": + { + yield return SyntaxKind.ParenthesizedLambdaExpression; + break; + } + + case "ParenthesizedPatternSyntax": + { + yield return SyntaxKind.ParenthesizedPattern; + break; + } + + case "ParenthesizedVariableDesignationSyntax": + { + yield return SyntaxKind.ParenthesizedVariableDesignation; + break; + } + + case "PointerTypeSyntax": + { + yield return SyntaxKind.PointerType; + break; + } + + case "PositionalPatternClauseSyntax": + { + yield return SyntaxKind.PositionalPatternClause; + break; + } + + case "PostfixUnaryExpressionSyntax": + { + yield return SyntaxKind.PostDecrementExpression; + yield return SyntaxKind.PostIncrementExpression; + yield return SyntaxKind.SuppressNullableWarningExpression; + break; + } + + case "PragmaChecksumDirectiveTriviaSyntax": + { + yield return SyntaxKind.PragmaChecksumDirectiveTrivia; + break; + } + + case "PragmaWarningDirectiveTriviaSyntax": + { + yield return SyntaxKind.PragmaWarningDirectiveTrivia; + break; + } + + case "PredefinedTypeSyntax": + { + yield return SyntaxKind.PredefinedType; + break; + } + + case "PrefixUnaryExpressionSyntax": + { + yield return SyntaxKind.UnaryPlusExpression; + yield return SyntaxKind.UnaryMinusExpression; + yield return SyntaxKind.BitwiseNotExpression; + yield return SyntaxKind.LogicalNotExpression; + yield return SyntaxKind.PreIncrementExpression; + yield return SyntaxKind.PreDecrementExpression; + yield return SyntaxKind.AddressOfExpression; + yield return SyntaxKind.PointerIndirectionExpression; + yield return SyntaxKind.IndexExpression; + break; + } + + case "PrimaryConstructorBaseTypeSyntax": + { + yield return SyntaxKind.PrimaryConstructorBaseType; + break; + } + + case "PropertyDeclarationSyntax": + { + yield return SyntaxKind.PropertyDeclaration; + break; + } + + case "PropertyPatternClauseSyntax": + { + yield return SyntaxKind.PropertyPatternClause; + break; + } + + case "QualifiedCrefSyntax": + { + yield return SyntaxKind.QualifiedCref; + break; + } + + case "QualifiedNameSyntax": + { + yield return SyntaxKind.QualifiedName; + break; + } + + case "QueryBodySyntax": + { + yield return SyntaxKind.QueryBody; + break; + } + + case "QueryContinuationSyntax": + { + yield return SyntaxKind.QueryContinuation; + break; + } + + case "QueryExpressionSyntax": + { + yield return SyntaxKind.QueryExpression; + break; + } + + case "RangeExpressionSyntax": + { + yield return SyntaxKind.RangeExpression; + break; + } + + case "RecordDeclarationSyntax": + { + yield return SyntaxKind.RecordDeclaration; + break; + } + + case "RecursivePatternSyntax": + { + yield return SyntaxKind.RecursivePattern; + break; + } + + case "ReferenceDirectiveTriviaSyntax": + { + yield return SyntaxKind.ReferenceDirectiveTrivia; + break; + } + + case "RefExpressionSyntax": + { + yield return SyntaxKind.RefExpression; + break; + } + + case "RefTypeExpressionSyntax": + { + yield return SyntaxKind.RefTypeExpression; + break; + } + + case "RefTypeSyntax": + { + yield return SyntaxKind.RefType; + break; + } + + case "RefValueExpressionSyntax": + { + yield return SyntaxKind.RefValueExpression; + break; + } + + case "RegionDirectiveTriviaSyntax": + { + yield return SyntaxKind.RegionDirectiveTrivia; + break; + } + + case "RelationalPatternSyntax": + { + yield return SyntaxKind.RelationalPattern; + break; + } + + case "ReturnStatementSyntax": + { + yield return SyntaxKind.ReturnStatement; + break; + } + + case "SelectClauseSyntax": + { + yield return SyntaxKind.SelectClause; + break; + } + + case "ShebangDirectiveTriviaSyntax": + { + yield return SyntaxKind.ShebangDirectiveTrivia; + break; + } + + case "SimpleBaseTypeSyntax": + { + yield return SyntaxKind.SimpleBaseType; + break; + } + + case "SimpleLambdaExpressionSyntax": + { + yield return SyntaxKind.SimpleLambdaExpression; + break; + } + + case "SingleVariableDesignationSyntax": + { + yield return SyntaxKind.SingleVariableDesignation; + break; + } + + case "SizeOfExpressionSyntax": + { + yield return SyntaxKind.SizeOfExpression; + break; + } + + case "SkippedTokensTriviaSyntax": + { + yield return SyntaxKind.SkippedTokensTrivia; + break; + } + + case "StackAllocArrayCreationExpressionSyntax": + { + yield return SyntaxKind.StackAllocArrayCreationExpression; + break; + } + + case "StructDeclarationSyntax": + { + yield return SyntaxKind.StructDeclaration; + break; + } + + case "SubpatternSyntax": + { + yield return SyntaxKind.Subpattern; + break; + } + + case "SwitchExpressionArmSyntax": + { + yield return SyntaxKind.SwitchExpressionArm; + break; + } + + case "SwitchExpressionSyntax": + { + yield return SyntaxKind.SwitchExpression; + break; + } + + case "SwitchSectionSyntax": + { + yield return SyntaxKind.SwitchSection; + break; + } + + case "SwitchStatementSyntax": + { + yield return SyntaxKind.SwitchStatement; + break; + } + + case "ThisExpressionSyntax": + { + yield return SyntaxKind.ThisExpression; + break; + } + + case "ThrowExpressionSyntax": + { + yield return SyntaxKind.ThrowExpression; + break; + } + + case "ThrowStatementSyntax": + { + yield return SyntaxKind.ThrowStatement; + break; + } + + case "TryStatementSyntax": + { + yield return SyntaxKind.TryStatement; + break; + } + + case "TupleElementSyntax": + { + yield return SyntaxKind.TupleElement; + break; + } + + case "TupleExpressionSyntax": + { + yield return SyntaxKind.TupleExpression; + break; + } + + case "TupleTypeSyntax": + { + yield return SyntaxKind.TupleType; + break; + } + + case "TypeArgumentListSyntax": + { + yield return SyntaxKind.TypeArgumentList; + break; + } + + case "TypeConstraintSyntax": + { + yield return SyntaxKind.TypeConstraint; + break; + } + + case "TypeCrefSyntax": + { + yield return SyntaxKind.TypeCref; + break; + } + + case "TypeOfExpressionSyntax": + { + yield return SyntaxKind.TypeOfExpression; + break; + } + + case "TypeParameterConstraintClauseSyntax": + { + yield return SyntaxKind.TypeParameterConstraintClause; + break; + } + + case "TypeParameterListSyntax": + { + yield return SyntaxKind.TypeParameterList; + break; + } + + case "TypeParameterSyntax": + { + yield return SyntaxKind.TypeParameter; + break; + } + + case "TypePatternSyntax": + { + yield return SyntaxKind.TypePattern; + break; + } + + case "UnaryPatternSyntax": + { + yield return SyntaxKind.NotPattern; + break; + } + + case "UndefDirectiveTriviaSyntax": + { + yield return SyntaxKind.UndefDirectiveTrivia; + break; + } + + case "UnsafeStatementSyntax": + { + yield return SyntaxKind.UnsafeStatement; + break; + } + + case "UsingDirectiveSyntax": + { + yield return SyntaxKind.UsingDirective; + break; + } + + case "UsingStatementSyntax": + { + yield return SyntaxKind.UsingStatement; + break; + } + + case "VariableDeclarationSyntax": + { + yield return SyntaxKind.VariableDeclaration; + break; + } + + case "VariableDeclaratorSyntax": + { + yield return SyntaxKind.VariableDeclarator; + break; + } + + case "VarPatternSyntax": + { + yield return SyntaxKind.VarPattern; + break; + } + + case "WarningDirectiveTriviaSyntax": + { + yield return SyntaxKind.WarningDirectiveTrivia; + break; + } + + case "WhenClauseSyntax": + { + yield return SyntaxKind.WhenClause; + break; + } + + case "WhereClauseSyntax": + { + yield return SyntaxKind.WhereClause; + break; + } + + case "WhileStatementSyntax": + { + yield return SyntaxKind.WhileStatement; + break; + } + + case "WithExpressionSyntax": + { + yield return SyntaxKind.WithExpression; + break; + } + + case "XmlCDataSectionSyntax": + { + yield return SyntaxKind.XmlCDataSection; + break; + } + + case "XmlCommentSyntax": + { + yield return SyntaxKind.XmlComment; + break; + } + + case "XmlCrefAttributeSyntax": + { + yield return SyntaxKind.XmlCrefAttribute; + break; + } + + case "XmlElementEndTagSyntax": + { + yield return SyntaxKind.XmlElementEndTag; + break; + } + + case "XmlElementStartTagSyntax": + { + yield return SyntaxKind.XmlElementStartTag; + break; + } + + case "XmlElementSyntax": + { + yield return SyntaxKind.XmlElement; + break; + } + + case "XmlEmptyElementSyntax": + { + yield return SyntaxKind.XmlEmptyElement; + break; + } + + case "XmlNameAttributeSyntax": + { + yield return SyntaxKind.XmlNameAttribute; + break; + } + + case "XmlNameSyntax": + { + yield return SyntaxKind.XmlName; + break; + } + + case "XmlPrefixSyntax": + { + yield return SyntaxKind.XmlPrefix; + break; + } + + case "XmlProcessingInstructionSyntax": + { + yield return SyntaxKind.XmlProcessingInstruction; + break; + } + + case "XmlTextAttributeSyntax": + { + yield return SyntaxKind.XmlTextAttribute; + break; + } + + case "XmlTextSyntax": + { + yield return SyntaxKind.XmlText; + break; + } + + case "YieldStatementSyntax": + { + yield return SyntaxKind.YieldBreakStatement; + yield return SyntaxKind.YieldReturnStatement; + break; + } + } + } + } +} +#endif diff --git a/src/Tools/CodeGeneration/CSharp/Symbols.Generated.cs b/src/Tools/CodeGeneration/CSharp/Symbols.Generated.cs index de2a7d6147..01c2db74ea 100644 --- a/src/Tools/CodeGeneration/CSharp/Symbols.Generated.cs +++ b/src/Tools/CodeGeneration/CSharp/Symbols.Generated.cs @@ -1,4 +1,5 @@ -// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +#if ROSLYN_4_7_ONLY +// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // @@ -1534,4 +1535,5 @@ public static IEnumerable GetKinds(INamedTypeSymbol syntaxSymbol) } } } -} \ No newline at end of file +} +#endif diff --git a/src/Tools/CodeGeneration/CSharp/SymbolsGetKindsGenerator.Roslyn38.cs b/src/Tools/CodeGeneration/CSharp/SymbolsGetKindsGenerator.Roslyn38.cs new file mode 100644 index 0000000000..a7c7452d1a --- /dev/null +++ b/src/Tools/CodeGeneration/CSharp/SymbolsGetKindsGenerator.Roslyn38.cs @@ -0,0 +1,1319 @@ +#if ROSLYN_3_8_ONLY +// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Roslynator.CSharp; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; +using static Roslynator.CSharp.CSharpFactory; + +namespace Roslynator.CodeGeneration.CSharp +{ + public static class SymbolsGetKindsGenerator + { + public static CompilationUnitSyntax Generate() + { + return CompilationUnit( + UsingDirectives( + "System.Collections.Generic", + "Microsoft.CodeAnalysis", + "Microsoft.CodeAnalysis.CSharp"), + NamespaceDeclaration( + "Roslynator.CodeGeneration.CSharp", + ClassDeclaration( + default(SyntaxList), + Modifiers.Internal_Static_Partial(), + Identifier("Symbols"), + default(TypeParameterListSyntax), + default(BaseListSyntax), + default(SyntaxList), + SingletonList(GenerateMethodDeclaration())))); + } + + private static MethodDeclarationSyntax GenerateMethodDeclaration() + { + var enumNames = new HashSet(); + + foreach (string enumName in Symbols + .Compilation + .GetTypeByMetadataName("Microsoft.CodeAnalysis.CSharp.SyntaxKind") + .GetMembers() + .Where(f => f.DeclaredAccessibility == Accessibility.Public) + .Select(f => f.Name) + .Where(f => f != "None" && !f.EndsWith("Keyword") && !f.EndsWith("Token")) + .OrderBy(f => f)) + { + enumNames.Add(enumName); + } + + MethodDeclarationSyntax methodDeclaration = MethodDeclaration( + Modifiers.Public_Static(), + ParseTypeName("IEnumerable"), + Identifier("GetKinds"), + ParameterList(Parameter(IdentifierName("INamedTypeSymbol"), "syntaxSymbol")), + Block( + SwitchStatement( + SimpleMemberAccessExpression(IdentifierName("syntaxSymbol"), IdentifierName("Name")), + GenerateSections().ToSyntaxList()))); + + foreach (string enumName in enumNames) + { + switch (enumName) + { + case "ConflictMarkerTrivia": + case "DisabledTextTrivia": + case "DocumentationCommentExteriorTrivia": + case "EndOfLineTrivia": + case "MultiLineCommentTrivia": + case "PreprocessingMessageTrivia": + case "SingleLineCommentTrivia": + case "WhitespaceTrivia": + case "value__": + case "List": + break; + default: + throw new InvalidOperationException($"Unrecognized enum value '{enumName}'."); + } + } + + return methodDeclaration; + + IEnumerable GenerateSections() + { + foreach (INamedTypeSymbol symbol in Symbols.SyntaxSymbols) + { + if (symbol.IsAbstract) + continue; + + string name = symbol.Name; + + SyntaxList statements = default; + + foreach (SyntaxKind kind in GetSyntaxKinds(symbol)) + { + statements = statements.Add( + YieldReturnStatement( + SimpleMemberAccessExpression( + IdentifierName("SyntaxKind"), + IdentifierName(kind.ToString())))); + + enumNames.Remove(kind.ToString()); + } + + statements = statements.Add(BreakStatement()); + + yield return SwitchSection( + CaseSwitchLabel(StringLiteralExpression(name)), + Block(statements)); + } + + static IEnumerable GetSyntaxKinds(INamedTypeSymbol syntaxSymbol) + { + switch (syntaxSymbol.Name) + { + case "AccessorDeclarationSyntax": + { + yield return SyntaxKind.GetAccessorDeclaration; + yield return SyntaxKind.SetAccessorDeclaration; + yield return SyntaxKind.AddAccessorDeclaration; + yield return SyntaxKind.RemoveAccessorDeclaration; + yield return SyntaxKind.UnknownAccessorDeclaration; + yield return SyntaxKind.InitAccessorDeclaration; + break; + } + case "AccessorListSyntax": + { + yield return SyntaxKind.AccessorList; + break; + } + case "AliasQualifiedNameSyntax": + { + yield return SyntaxKind.AliasQualifiedName; + break; + } + case "AnonymousMethodExpressionSyntax": + { + yield return SyntaxKind.AnonymousMethodExpression; + break; + } + case "AnonymousObjectCreationExpressionSyntax": + { + yield return SyntaxKind.AnonymousObjectCreationExpression; + break; + } + case "AnonymousObjectMemberDeclaratorSyntax": + { + yield return SyntaxKind.AnonymousObjectMemberDeclarator; + break; + } + case "ArgumentListSyntax": + { + yield return SyntaxKind.ArgumentList; + break; + } + case "ArgumentSyntax": + { + yield return SyntaxKind.Argument; + break; + } + case "ArrayCreationExpressionSyntax": + { + yield return SyntaxKind.ArrayCreationExpression; + break; + } + case "ArrayRankSpecifierSyntax": + { + yield return SyntaxKind.ArrayRankSpecifier; + break; + } + case "ArrayTypeSyntax": + { + yield return SyntaxKind.ArrayType; + break; + } + case "ArrowExpressionClauseSyntax": + { + yield return SyntaxKind.ArrowExpressionClause; + break; + } + case "AssignmentExpressionSyntax": + { + yield return SyntaxKind.SimpleAssignmentExpression; + yield return SyntaxKind.AddAssignmentExpression; + yield return SyntaxKind.SubtractAssignmentExpression; + yield return SyntaxKind.MultiplyAssignmentExpression; + yield return SyntaxKind.DivideAssignmentExpression; + yield return SyntaxKind.ModuloAssignmentExpression; + yield return SyntaxKind.AndAssignmentExpression; + yield return SyntaxKind.ExclusiveOrAssignmentExpression; + yield return SyntaxKind.OrAssignmentExpression; + yield return SyntaxKind.LeftShiftAssignmentExpression; + yield return SyntaxKind.RightShiftAssignmentExpression; + yield return SyntaxKind.CoalesceAssignmentExpression; + break; + } + case "AttributeArgumentListSyntax": + { + yield return SyntaxKind.AttributeArgumentList; + break; + } + case "AttributeArgumentSyntax": + { + yield return SyntaxKind.AttributeArgument; + break; + } + case "AttributeListSyntax": + { + yield return SyntaxKind.AttributeList; + break; + } + case "AttributeSyntax": + { + yield return SyntaxKind.Attribute; + break; + } + case "AttributeTargetSpecifierSyntax": + { + yield return SyntaxKind.AttributeTargetSpecifier; + break; + } + case "AwaitExpressionSyntax": + { + yield return SyntaxKind.AwaitExpression; + break; + } + case "BadDirectiveTriviaSyntax": + { + yield return SyntaxKind.BadDirectiveTrivia; + break; + } + case "BaseExpressionSyntax": + { + yield return SyntaxKind.BaseExpression; + break; + } + case "BaseListSyntax": + { + yield return SyntaxKind.BaseList; + break; + } + case "BinaryExpressionSyntax": + { + yield return SyntaxKind.AddExpression; + yield return SyntaxKind.SubtractExpression; + yield return SyntaxKind.MultiplyExpression; + yield return SyntaxKind.DivideExpression; + yield return SyntaxKind.ModuloExpression; + yield return SyntaxKind.LeftShiftExpression; + yield return SyntaxKind.RightShiftExpression; + yield return SyntaxKind.LogicalOrExpression; + yield return SyntaxKind.LogicalAndExpression; + yield return SyntaxKind.BitwiseOrExpression; + yield return SyntaxKind.BitwiseAndExpression; + yield return SyntaxKind.ExclusiveOrExpression; + yield return SyntaxKind.EqualsExpression; + yield return SyntaxKind.NotEqualsExpression; + yield return SyntaxKind.LessThanExpression; + yield return SyntaxKind.LessThanOrEqualExpression; + yield return SyntaxKind.GreaterThanExpression; + yield return SyntaxKind.GreaterThanOrEqualExpression; + yield return SyntaxKind.IsExpression; + yield return SyntaxKind.AsExpression; + yield return SyntaxKind.CoalesceExpression; + break; + } + case "BlockSyntax": + { + yield return SyntaxKind.Block; + break; + } + case "BracketedArgumentListSyntax": + { + yield return SyntaxKind.BracketedArgumentList; + break; + } + case "BracketedParameterListSyntax": + { + yield return SyntaxKind.BracketedParameterList; + break; + } + case "BreakStatementSyntax": + { + yield return SyntaxKind.BreakStatement; + break; + } + case "CasePatternSwitchLabelSyntax": + { + yield return SyntaxKind.CasePatternSwitchLabel; + break; + } + case "CaseSwitchLabelSyntax": + { + yield return SyntaxKind.CaseSwitchLabel; + break; + } + case "CastExpressionSyntax": + { + yield return SyntaxKind.CastExpression; + break; + } + case "CatchClauseSyntax": + { + yield return SyntaxKind.CatchClause; + break; + } + case "CatchDeclarationSyntax": + { + yield return SyntaxKind.CatchDeclaration; + break; + } + case "CatchFilterClauseSyntax": + { + yield return SyntaxKind.CatchFilterClause; + break; + } + case "ClassDeclarationSyntax": + { + yield return SyntaxKind.ClassDeclaration; + break; + } + case "ClassOrStructConstraintSyntax": + { + yield return SyntaxKind.ClassConstraint; + yield return SyntaxKind.StructConstraint; + break; + } + case "CompilationUnitSyntax": + { + yield return SyntaxKind.CompilationUnit; + break; + } + case "ConditionalAccessExpressionSyntax": + { + yield return SyntaxKind.ConditionalAccessExpression; + break; + } + case "ConditionalExpressionSyntax": + { + yield return SyntaxKind.ConditionalExpression; + break; + } + case "ConstantPatternSyntax": + { + yield return SyntaxKind.ConstantPattern; + break; + } + case "ConstructorConstraintSyntax": + { + yield return SyntaxKind.ConstructorConstraint; + break; + } + case "ConstructorDeclarationSyntax": + { + yield return SyntaxKind.ConstructorDeclaration; + break; + } + case "ConstructorInitializerSyntax": + { + yield return SyntaxKind.BaseConstructorInitializer; + yield return SyntaxKind.ThisConstructorInitializer; + break; + } + case "ContinueStatementSyntax": + { + yield return SyntaxKind.ContinueStatement; + break; + } + case "ConversionOperatorDeclarationSyntax": + { + yield return SyntaxKind.ConversionOperatorDeclaration; + break; + } + case "ConversionOperatorMemberCrefSyntax": + { + yield return SyntaxKind.ConversionOperatorMemberCref; + break; + } + case "CrefBracketedParameterListSyntax": + { + yield return SyntaxKind.CrefBracketedParameterList; + break; + } + case "CrefParameterListSyntax": + { + yield return SyntaxKind.CrefParameterList; + break; + } + case "CrefParameterSyntax": + { + yield return SyntaxKind.CrefParameter; + break; + } + case "DeclarationExpressionSyntax": + { + yield return SyntaxKind.DeclarationExpression; + break; + } + case "DeclarationPatternSyntax": + { + yield return SyntaxKind.DeclarationPattern; + break; + } + case "DefaultExpressionSyntax": + { + yield return SyntaxKind.DefaultExpression; + break; + } + case "DefaultSwitchLabelSyntax": + { + yield return SyntaxKind.DefaultSwitchLabel; + break; + } + case "DefineDirectiveTriviaSyntax": + { + yield return SyntaxKind.DefineDirectiveTrivia; + break; + } + case "DelegateDeclarationSyntax": + { + yield return SyntaxKind.DelegateDeclaration; + break; + } + case "DestructorDeclarationSyntax": + { + yield return SyntaxKind.DestructorDeclaration; + break; + } + case "DiscardDesignationSyntax": + { + yield return SyntaxKind.DiscardDesignation; + break; + } + case "DiscardPatternSyntax": + { + yield return SyntaxKind.DiscardPattern; + break; + } + case "DocumentationCommentTriviaSyntax": + { + yield return SyntaxKind.SingleLineDocumentationCommentTrivia; + yield return SyntaxKind.MultiLineDocumentationCommentTrivia; + break; + } + case "DoStatementSyntax": + { + yield return SyntaxKind.DoStatement; + break; + } + case "ElementAccessExpressionSyntax": + { + yield return SyntaxKind.ElementAccessExpression; + break; + } + case "ElementBindingExpressionSyntax": + { + yield return SyntaxKind.ElementBindingExpression; + break; + } + case "ElifDirectiveTriviaSyntax": + { + yield return SyntaxKind.ElifDirectiveTrivia; + break; + } + case "ElseClauseSyntax": + { + yield return SyntaxKind.ElseClause; + break; + } + case "ElseDirectiveTriviaSyntax": + { + yield return SyntaxKind.ElseDirectiveTrivia; + break; + } + case "EmptyStatementSyntax": + { + yield return SyntaxKind.EmptyStatement; + break; + } + case "EndIfDirectiveTriviaSyntax": + { + yield return SyntaxKind.EndIfDirectiveTrivia; + break; + } + case "EndRegionDirectiveTriviaSyntax": + { + yield return SyntaxKind.EndRegionDirectiveTrivia; + break; + } + case "EnumDeclarationSyntax": + { + yield return SyntaxKind.EnumDeclaration; + break; + } + case "EnumMemberDeclarationSyntax": + { + yield return SyntaxKind.EnumMemberDeclaration; + break; + } + case "EqualsValueClauseSyntax": + { + yield return SyntaxKind.EqualsValueClause; + break; + } + case "ErrorDirectiveTriviaSyntax": + { + yield return SyntaxKind.ErrorDirectiveTrivia; + break; + } + case "EventDeclarationSyntax": + { + yield return SyntaxKind.EventDeclaration; + break; + } + case "EventFieldDeclarationSyntax": + { + yield return SyntaxKind.EventFieldDeclaration; + break; + } + case "ExplicitInterfaceSpecifierSyntax": + { + yield return SyntaxKind.ExplicitInterfaceSpecifier; + break; + } + case "ExpressionStatementSyntax": + { + yield return SyntaxKind.ExpressionStatement; + break; + } + case "ExternAliasDirectiveSyntax": + { + yield return SyntaxKind.ExternAliasDirective; + break; + } + case "FieldDeclarationSyntax": + { + yield return SyntaxKind.FieldDeclaration; + break; + } + case "FinallyClauseSyntax": + { + yield return SyntaxKind.FinallyClause; + break; + } + case "FixedStatementSyntax": + { + yield return SyntaxKind.FixedStatement; + break; + } + case "ForEachStatementSyntax": + { + yield return SyntaxKind.ForEachStatement; + break; + } + case "ForEachVariableStatementSyntax": + { + yield return SyntaxKind.ForEachVariableStatement; + break; + } + case "ForStatementSyntax": + { + yield return SyntaxKind.ForStatement; + break; + } + case "FromClauseSyntax": + { + yield return SyntaxKind.FromClause; + break; + } + case "GenericNameSyntax": + { + yield return SyntaxKind.GenericName; + break; + } + case "GlobalStatementSyntax": + { + yield return SyntaxKind.GlobalStatement; + break; + } + case "GotoStatementSyntax": + { + yield return SyntaxKind.GotoStatement; + yield return SyntaxKind.GotoCaseStatement; + yield return SyntaxKind.GotoDefaultStatement; + break; + } + case "GroupClauseSyntax": + { + yield return SyntaxKind.GroupClause; + break; + } + case "CheckedExpressionSyntax": + { + yield return SyntaxKind.CheckedExpression; + yield return SyntaxKind.UncheckedExpression; + break; + } + case "CheckedStatementSyntax": + { + yield return SyntaxKind.CheckedStatement; + yield return SyntaxKind.UncheckedStatement; + break; + } + case "IdentifierNameSyntax": + { + yield return SyntaxKind.IdentifierName; + break; + } + case "IfDirectiveTriviaSyntax": + { + yield return SyntaxKind.IfDirectiveTrivia; + break; + } + case "IfStatementSyntax": + { + yield return SyntaxKind.IfStatement; + break; + } + case "ImplicitArrayCreationExpressionSyntax": + { + yield return SyntaxKind.ImplicitArrayCreationExpression; + break; + } + case "ImplicitElementAccessSyntax": + { + yield return SyntaxKind.ImplicitElementAccess; + break; + } + case "ImplicitStackAllocArrayCreationExpressionSyntax": + { + yield return SyntaxKind.ImplicitStackAllocArrayCreationExpression; + break; + } + case "IncompleteMemberSyntax": + { + yield return SyntaxKind.IncompleteMember; + break; + } + case "IndexerDeclarationSyntax": + { + yield return SyntaxKind.IndexerDeclaration; + break; + } + case "IndexerMemberCrefSyntax": + { + yield return SyntaxKind.IndexerMemberCref; + break; + } + case "InitializerExpressionSyntax": + { + yield return SyntaxKind.ArrayInitializerExpression; + yield return SyntaxKind.CollectionInitializerExpression; + yield return SyntaxKind.ComplexElementInitializerExpression; + yield return SyntaxKind.ObjectInitializerExpression; + yield return SyntaxKind.WithInitializerExpression; + break; + } + case "InterfaceDeclarationSyntax": + { + yield return SyntaxKind.InterfaceDeclaration; + break; + } + case "InterpolatedStringExpressionSyntax": + { + yield return SyntaxKind.InterpolatedStringExpression; + break; + } + case "InterpolatedStringTextSyntax": + { + yield return SyntaxKind.InterpolatedStringText; + break; + } + case "InterpolationAlignmentClauseSyntax": + { + yield return SyntaxKind.InterpolationAlignmentClause; + break; + } + case "InterpolationFormatClauseSyntax": + { + yield return SyntaxKind.InterpolationFormatClause; + break; + } + case "InterpolationSyntax": + { + yield return SyntaxKind.Interpolation; + break; + } + case "InvocationExpressionSyntax": + { + yield return SyntaxKind.InvocationExpression; + break; + } + case "IsPatternExpressionSyntax": + { + yield return SyntaxKind.IsPatternExpression; + break; + } + case "JoinClauseSyntax": + { + yield return SyntaxKind.JoinClause; + break; + } + case "JoinIntoClauseSyntax": + { + yield return SyntaxKind.JoinIntoClause; + break; + } + case "LabeledStatementSyntax": + { + yield return SyntaxKind.LabeledStatement; + break; + } + case "LetClauseSyntax": + { + yield return SyntaxKind.LetClause; + break; + } + case "LineDirectiveTriviaSyntax": + { + yield return SyntaxKind.LineDirectiveTrivia; + break; + } + case "LiteralExpressionSyntax": + { + yield return SyntaxKind.ArgListExpression; + yield return SyntaxKind.NumericLiteralExpression; + yield return SyntaxKind.StringLiteralExpression; + yield return SyntaxKind.CharacterLiteralExpression; + yield return SyntaxKind.TrueLiteralExpression; + yield return SyntaxKind.FalseLiteralExpression; + yield return SyntaxKind.NullLiteralExpression; + yield return SyntaxKind.DefaultLiteralExpression; + break; + } + case "LoadDirectiveTriviaSyntax": + { + yield return SyntaxKind.LoadDirectiveTrivia; + break; + } + case "LocalDeclarationStatementSyntax": + { + yield return SyntaxKind.LocalDeclarationStatement; + break; + } + case "LocalFunctionStatementSyntax": + { + yield return SyntaxKind.LocalFunctionStatement; + break; + } + case "LockStatementSyntax": + { + yield return SyntaxKind.LockStatement; + break; + } + case "MakeRefExpressionSyntax": + { + yield return SyntaxKind.MakeRefExpression; + break; + } + case "MemberAccessExpressionSyntax": + { + yield return SyntaxKind.PointerMemberAccessExpression; + yield return SyntaxKind.SimpleMemberAccessExpression; + break; + } + case "MemberBindingExpressionSyntax": + { + yield return SyntaxKind.MemberBindingExpression; + break; + } + case "MethodDeclarationSyntax": + { + yield return SyntaxKind.MethodDeclaration; + break; + } + case "NameColonSyntax": + { + yield return SyntaxKind.NameColon; + break; + } + case "NameEqualsSyntax": + { + yield return SyntaxKind.NameEquals; + break; + } + case "NameMemberCrefSyntax": + { + yield return SyntaxKind.NameMemberCref; + break; + } + case "NamespaceDeclarationSyntax": + { + yield return SyntaxKind.NamespaceDeclaration; + break; + } + case "NullableDirectiveTriviaSyntax": + { + yield return SyntaxKind.NullableDirectiveTrivia; + break; + } + case "NullableTypeSyntax": + { + yield return SyntaxKind.NullableType; + break; + } + case "ObjectCreationExpressionSyntax": + { + yield return SyntaxKind.ObjectCreationExpression; + break; + } + case "OmittedArraySizeExpressionSyntax": + { + yield return SyntaxKind.OmittedArraySizeExpression; + break; + } + case "OmittedTypeArgumentSyntax": + { + yield return SyntaxKind.OmittedTypeArgument; + break; + } + case "OperatorDeclarationSyntax": + { + yield return SyntaxKind.OperatorDeclaration; + break; + } + case "OperatorMemberCrefSyntax": + { + yield return SyntaxKind.OperatorMemberCref; + break; + } + case "OrderByClauseSyntax": + { + yield return SyntaxKind.OrderByClause; + break; + } + case "OrderingSyntax": + { + yield return SyntaxKind.AscendingOrdering; + yield return SyntaxKind.DescendingOrdering; + break; + } + case "ParameterListSyntax": + { + yield return SyntaxKind.ParameterList; + break; + } + case "ParameterSyntax": + { + yield return SyntaxKind.Parameter; + break; + } + case "ParenthesizedExpressionSyntax": + { + yield return SyntaxKind.ParenthesizedExpression; + break; + } + case "ParenthesizedLambdaExpressionSyntax": + { + yield return SyntaxKind.ParenthesizedLambdaExpression; + break; + } + case "ParenthesizedVariableDesignationSyntax": + { + yield return SyntaxKind.ParenthesizedVariableDesignation; + break; + } + case "PointerTypeSyntax": + { + yield return SyntaxKind.PointerType; + break; + } + case "PositionalPatternClauseSyntax": + { + yield return SyntaxKind.PositionalPatternClause; + break; + } + case "PostfixUnaryExpressionSyntax": + { + yield return SyntaxKind.PostDecrementExpression; + yield return SyntaxKind.PostIncrementExpression; + yield return SyntaxKind.SuppressNullableWarningExpression; + break; + } + case "PragmaChecksumDirectiveTriviaSyntax": + { + yield return SyntaxKind.PragmaChecksumDirectiveTrivia; + break; + } + case "PragmaWarningDirectiveTriviaSyntax": + { + yield return SyntaxKind.PragmaWarningDirectiveTrivia; + break; + } + case "PredefinedTypeSyntax": + { + yield return SyntaxKind.PredefinedType; + break; + } + case "PrefixUnaryExpressionSyntax": + { + yield return SyntaxKind.UnaryPlusExpression; + yield return SyntaxKind.UnaryMinusExpression; + yield return SyntaxKind.BitwiseNotExpression; + yield return SyntaxKind.LogicalNotExpression; + yield return SyntaxKind.PreIncrementExpression; + yield return SyntaxKind.PreDecrementExpression; + yield return SyntaxKind.AddressOfExpression; + yield return SyntaxKind.PointerIndirectionExpression; + yield return SyntaxKind.IndexExpression; + break; + } + case "PropertyDeclarationSyntax": + { + yield return SyntaxKind.PropertyDeclaration; + break; + } + case "PropertyPatternClauseSyntax": + { + yield return SyntaxKind.PropertyPatternClause; + break; + } + case "QualifiedCrefSyntax": + { + yield return SyntaxKind.QualifiedCref; + break; + } + case "QualifiedNameSyntax": + { + yield return SyntaxKind.QualifiedName; + break; + } + case "QueryBodySyntax": + { + yield return SyntaxKind.QueryBody; + break; + } + case "QueryContinuationSyntax": + { + yield return SyntaxKind.QueryContinuation; + break; + } + case "QueryExpressionSyntax": + { + yield return SyntaxKind.QueryExpression; + break; + } + case "RangeExpressionSyntax": + { + yield return SyntaxKind.RangeExpression; + break; + } + case "RecursivePatternSyntax": + { + yield return SyntaxKind.RecursivePattern; + break; + } + case "ReferenceDirectiveTriviaSyntax": + { + yield return SyntaxKind.ReferenceDirectiveTrivia; + break; + } + case "RefExpressionSyntax": + { + yield return SyntaxKind.RefExpression; + break; + } + case "RefTypeExpressionSyntax": + { + yield return SyntaxKind.RefTypeExpression; + break; + } + case "RefTypeSyntax": + { + yield return SyntaxKind.RefType; + break; + } + case "RefValueExpressionSyntax": + { + yield return SyntaxKind.RefValueExpression; + break; + } + case "RegionDirectiveTriviaSyntax": + { + yield return SyntaxKind.RegionDirectiveTrivia; + break; + } + case "ReturnStatementSyntax": + { + yield return SyntaxKind.ReturnStatement; + break; + } + case "SelectClauseSyntax": + { + yield return SyntaxKind.SelectClause; + break; + } + case "ShebangDirectiveTriviaSyntax": + { + yield return SyntaxKind.ShebangDirectiveTrivia; + break; + } + case "SimpleBaseTypeSyntax": + { + yield return SyntaxKind.SimpleBaseType; + break; + } + case "SimpleLambdaExpressionSyntax": + { + yield return SyntaxKind.SimpleLambdaExpression; + break; + } + case "SingleVariableDesignationSyntax": + { + yield return SyntaxKind.SingleVariableDesignation; + break; + } + case "SizeOfExpressionSyntax": + { + yield return SyntaxKind.SizeOfExpression; + break; + } + case "SkippedTokensTriviaSyntax": + { + yield return SyntaxKind.SkippedTokensTrivia; + break; + } + case "StackAllocArrayCreationExpressionSyntax": + { + yield return SyntaxKind.StackAllocArrayCreationExpression; + break; + } + case "StructDeclarationSyntax": + { + yield return SyntaxKind.StructDeclaration; + break; + } + case "SubpatternSyntax": + { + yield return SyntaxKind.Subpattern; + break; + } + case "SwitchExpressionSyntax": + { + yield return SyntaxKind.SwitchExpression; + break; + } + case "SwitchExpressionArmSyntax": + { + yield return SyntaxKind.SwitchExpressionArm; + break; + } + case "SwitchSectionSyntax": + { + yield return SyntaxKind.SwitchSection; + break; + } + case "SwitchStatementSyntax": + { + yield return SyntaxKind.SwitchStatement; + break; + } + case "ThisExpressionSyntax": + { + yield return SyntaxKind.ThisExpression; + break; + } + case "ThrowExpressionSyntax": + { + yield return SyntaxKind.ThrowExpression; + break; + } + case "ThrowStatementSyntax": + { + yield return SyntaxKind.ThrowStatement; + break; + } + case "TryStatementSyntax": + { + yield return SyntaxKind.TryStatement; + break; + } + case "TupleElementSyntax": + { + yield return SyntaxKind.TupleElement; + break; + } + case "TupleExpressionSyntax": + { + yield return SyntaxKind.TupleExpression; + break; + } + case "TupleTypeSyntax": + { + yield return SyntaxKind.TupleType; + break; + } + case "TypeArgumentListSyntax": + { + yield return SyntaxKind.TypeArgumentList; + break; + } + case "TypeConstraintSyntax": + { + yield return SyntaxKind.TypeConstraint; + break; + } + case "TypeCrefSyntax": + { + yield return SyntaxKind.TypeCref; + break; + } + case "TypeOfExpressionSyntax": + { + yield return SyntaxKind.TypeOfExpression; + break; + } + case "TypeParameterConstraintClauseSyntax": + { + yield return SyntaxKind.TypeParameterConstraintClause; + break; + } + case "TypeParameterListSyntax": + { + yield return SyntaxKind.TypeParameterList; + break; + } + case "TypeParameterSyntax": + { + yield return SyntaxKind.TypeParameter; + break; + } + case "UndefDirectiveTriviaSyntax": + { + yield return SyntaxKind.UndefDirectiveTrivia; + break; + } + case "UnsafeStatementSyntax": + { + yield return SyntaxKind.UnsafeStatement; + break; + } + case "UsingDirectiveSyntax": + { + yield return SyntaxKind.UsingDirective; + break; + } + case "UsingStatementSyntax": + { + yield return SyntaxKind.UsingStatement; + break; + } + case "VariableDeclarationSyntax": + { + yield return SyntaxKind.VariableDeclaration; + break; + } + case "VariableDeclaratorSyntax": + { + yield return SyntaxKind.VariableDeclarator; + break; + } + case "VarPatternSyntax": + { + yield return SyntaxKind.VarPattern; + break; + } + case "WarningDirectiveTriviaSyntax": + { + yield return SyntaxKind.WarningDirectiveTrivia; + break; + } + case "WhenClauseSyntax": + { + yield return SyntaxKind.WhenClause; + break; + } + case "WhereClauseSyntax": + { + yield return SyntaxKind.WhereClause; + break; + } + case "WhileStatementSyntax": + { + yield return SyntaxKind.WhileStatement; + break; + } + case "XmlCDataSectionSyntax": + { + yield return SyntaxKind.XmlCDataSection; + break; + } + case "XmlCommentSyntax": + { + yield return SyntaxKind.XmlComment; + break; + } + case "XmlCrefAttributeSyntax": + { + yield return SyntaxKind.XmlCrefAttribute; + break; + } + case "XmlElementEndTagSyntax": + { + yield return SyntaxKind.XmlElementEndTag; + break; + } + case "XmlElementStartTagSyntax": + { + yield return SyntaxKind.XmlElementStartTag; + break; + } + case "XmlElementSyntax": + { + yield return SyntaxKind.XmlElement; + break; + } + case "XmlEmptyElementSyntax": + { + yield return SyntaxKind.XmlEmptyElement; + break; + } + case "XmlNameAttributeSyntax": + { + yield return SyntaxKind.XmlNameAttribute; + break; + } + case "XmlNameSyntax": + { + yield return SyntaxKind.XmlName; + break; + } + case "XmlPrefixSyntax": + { + yield return SyntaxKind.XmlPrefix; + break; + } + case "XmlProcessingInstructionSyntax": + { + yield return SyntaxKind.XmlProcessingInstruction; + break; + } + case "XmlTextAttributeSyntax": + { + yield return SyntaxKind.XmlTextAttribute; + break; + } + case "XmlTextSyntax": + { + yield return SyntaxKind.XmlText; + break; + } + case "YieldStatementSyntax": + { + yield return SyntaxKind.YieldBreakStatement; + yield return SyntaxKind.YieldReturnStatement; + break; + } + case "UnaryPatternSyntax": + { + yield return SyntaxKind.NotPattern; + break; + } + case "BinaryPatternSyntax": + { + yield return SyntaxKind.AndPattern; + yield return SyntaxKind.OrPattern; + break; + } + case "RelationalPatternSyntax": + case "ParenthesizedPatternSyntax": + case "TypePatternSyntax": + case "RecordDeclarationSyntax": + case "WithExpressionSyntax": + case "ImplicitObjectCreationExpressionSyntax": + case "PrimaryConstructorBaseTypeSyntax": + case "FunctionPointerTypeSyntax": + { + yield return (SyntaxKind)Enum.Parse(typeof(SyntaxKind), syntaxSymbol.Name.Remove(syntaxSymbol.Name.Length - 6)); + break; + } + case "DefaultConstraintSyntax": + { + yield return SyntaxKind.DefaultConstraint; + break; + } + case "FunctionPointerCallingConventionSyntax": + { + yield return SyntaxKind.FunctionPointerCallingConvention; + break; + } + case "FunctionPointerParameterSyntax": + { + yield return SyntaxKind.FunctionPointerParameter; + break; + } + case "FunctionPointerParameterListSyntax": + { + yield return SyntaxKind.FunctionPointerParameterList; + break; + } + case "FunctionPointerUnmanagedCallingConventionSyntax": + { + yield return SyntaxKind.FunctionPointerUnmanagedCallingConvention; + break; + } + case "FunctionPointerUnmanagedCallingConventionListSyntax": + { + yield return SyntaxKind.FunctionPointerUnmanagedCallingConventionList; + break; + } + } + } + } + } + } +} +#endif diff --git a/src/Tools/CodeGeneration/CSharp/SymbolsGetKindsGenerator.cs b/src/Tools/CodeGeneration/CSharp/SymbolsGetKindsGenerator.cs index 51c83a323f..8ec5d1b619 100644 --- a/src/Tools/CodeGeneration/CSharp/SymbolsGetKindsGenerator.cs +++ b/src/Tools/CodeGeneration/CSharp/SymbolsGetKindsGenerator.cs @@ -1,4 +1,5 @@ -// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +#if ROSLYN_4_7_ONLY +// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; @@ -1376,3 +1377,4 @@ static IEnumerable GetSyntaxKinds(INamedTypeSymbol syntaxSymbol) } } } +#endif diff --git a/src/Tools/CodeGeneration/CSharp/SyntaxWalker/CSharpSyntaxWalkerGenerator.Generated.cs b/src/Tools/CodeGeneration/CSharp/SyntaxWalker/CSharpSyntaxWalkerGenerator.Generated.cs index efa24901b9..455bbea381 100644 --- a/src/Tools/CodeGeneration/CSharp/SyntaxWalker/CSharpSyntaxWalkerGenerator.Generated.cs +++ b/src/Tools/CodeGeneration/CSharp/SyntaxWalker/CSharpSyntaxWalkerGenerator.Generated.cs @@ -1,4 +1,5 @@ -// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +#if ROSLYN_4_7_ONLY +// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // @@ -3420,4 +3421,5 @@ protected virtual bool ShouldVisit(IPropertySymbol propertySymbol) } } } -} \ No newline at end of file +} +#endif diff --git a/src/Tools/CodeGeneration/CSharp/SyntaxWalker/CSharpSyntaxWalkerGenerator.Roslyn38.Generated.cs b/src/Tools/CodeGeneration/CSharp/SyntaxWalker/CSharpSyntaxWalkerGenerator.Roslyn38.Generated.cs new file mode 100644 index 0000000000..8986ec054b --- /dev/null +++ b/src/Tools/CodeGeneration/CSharp/SyntaxWalker/CSharpSyntaxWalkerGenerator.Roslyn38.Generated.cs @@ -0,0 +1,3264 @@ +#if ROSLYN_3_8_ONLY +// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +// + +using System; +using Microsoft.CodeAnalysis; + +namespace Roslynator.CodeGeneration.CSharp +{ + public partial class CSharpSyntaxWalkerGenerator + { + protected virtual bool ShouldVisit(IPropertySymbol propertySymbol) + { + switch (propertySymbol.ContainingType.Name) + { + case "AccessorDeclarationSyntax": + { + switch (propertySymbol.Name) + { + case "AttributeLists": + case "Modifiers": + case "Keyword": + case "Body": + case "ExpressionBody": + case "SemicolonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "AccessorListSyntax": + { + switch (propertySymbol.Name) + { + case "OpenBraceToken": + case "Accessors": + case "CloseBraceToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "AliasQualifiedNameSyntax": + { + switch (propertySymbol.Name) + { + case "Alias": + case "ColonColonToken": + case "Name": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "AnonymousMethodExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Modifiers": + case "AsyncKeyword": + case "DelegateKeyword": + case "ParameterList": + case "Block": + return true; + case "Body": + case "ExpressionBody": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "AnonymousObjectCreationExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "NewKeyword": + case "OpenBraceToken": + case "Initializers": + case "CloseBraceToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "AnonymousObjectMemberDeclaratorSyntax": + { + switch (propertySymbol.Name) + { + case "NameEquals": + case "Expression": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ArgumentListSyntax": + { + switch (propertySymbol.Name) + { + case "OpenParenToken": + case "Arguments": + case "CloseParenToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ArgumentSyntax": + { + switch (propertySymbol.Name) + { + case "NameColon": + case "RefKindKeyword": + case "Expression": + return true; + case "RefOrOutKeyword": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ArrayCreationExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "NewKeyword": + case "Type": + case "Initializer": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ArrayRankSpecifierSyntax": + { + switch (propertySymbol.Name) + { + case "Rank": + case "OpenBracketToken": + case "Sizes": + case "CloseBracketToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ArrayTypeSyntax": + { + switch (propertySymbol.Name) + { + case "ElementType": + case "RankSpecifiers": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ArrowExpressionClauseSyntax": + { + switch (propertySymbol.Name) + { + case "ArrowToken": + case "Expression": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "AssignmentExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Left": + case "OperatorToken": + case "Right": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "AttributeArgumentListSyntax": + { + switch (propertySymbol.Name) + { + case "OpenParenToken": + case "Arguments": + case "CloseParenToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "AttributeArgumentSyntax": + { + switch (propertySymbol.Name) + { + case "NameEquals": + case "NameColon": + case "Expression": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "AttributeListSyntax": + { + switch (propertySymbol.Name) + { + case "OpenBracketToken": + case "Target": + case "Attributes": + case "CloseBracketToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "AttributeSyntax": + { + switch (propertySymbol.Name) + { + case "Name": + case "ArgumentList": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "AttributeTargetSpecifierSyntax": + { + switch (propertySymbol.Name) + { + case "Identifier": + case "ColonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "AwaitExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "AwaitKeyword": + case "Expression": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "BadDirectiveTriviaSyntax": + { + switch (propertySymbol.Name) + { + case "HashToken": + case "Identifier": + case "EndOfDirectiveToken": + case "IsActive": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "BaseExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Token": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "BaseListSyntax": + { + switch (propertySymbol.Name) + { + case "ColonToken": + case "Types": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "BinaryExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Left": + case "OperatorToken": + case "Right": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "BlockSyntax": + { + switch (propertySymbol.Name) + { + case "OpenBraceToken": + case "Statements": + case "CloseBraceToken": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "BracketedArgumentListSyntax": + { + switch (propertySymbol.Name) + { + case "OpenBracketToken": + case "Arguments": + case "CloseBracketToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "BracketedParameterListSyntax": + { + switch (propertySymbol.Name) + { + case "OpenBracketToken": + case "Parameters": + case "CloseBracketToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "BreakStatementSyntax": + { + switch (propertySymbol.Name) + { + case "BreakKeyword": + case "SemicolonToken": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "CasePatternSwitchLabelSyntax": + { + switch (propertySymbol.Name) + { + case "Keyword": + case "Pattern": + case "WhenClause": + case "ColonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "CaseSwitchLabelSyntax": + { + switch (propertySymbol.Name) + { + case "Keyword": + case "Value": + case "ColonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "CastExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "OpenParenToken": + case "Type": + case "CloseParenToken": + case "Expression": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "CatchClauseSyntax": + { + switch (propertySymbol.Name) + { + case "CatchKeyword": + case "Declaration": + case "Filter": + case "Block": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "CatchDeclarationSyntax": + { + switch (propertySymbol.Name) + { + case "OpenParenToken": + case "Type": + case "Identifier": + case "CloseParenToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "CatchFilterClauseSyntax": + { + switch (propertySymbol.Name) + { + case "WhenKeyword": + case "OpenParenToken": + case "FilterExpression": + case "CloseParenToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ClassDeclarationSyntax": + { + switch (propertySymbol.Name) + { + case "AttributeLists": + case "Modifiers": + case "Keyword": + case "Identifier": + case "TypeParameterList": + case "BaseList": + case "ConstraintClauses": + case "OpenBraceToken": + case "Members": + case "CloseBraceToken": + case "SemicolonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ClassOrStructConstraintSyntax": + { + switch (propertySymbol.Name) + { + case "ClassOrStructKeyword": + case "QuestionToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "CompilationUnitSyntax": + { + switch (propertySymbol.Name) + { + case "Externs": + case "Usings": + case "AttributeLists": + case "Members": + case "EndOfFileToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ConditionalAccessExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Expression": + case "OperatorToken": + case "WhenNotNull": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ConditionalExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Condition": + case "QuestionToken": + case "WhenTrue": + case "ColonToken": + case "WhenFalse": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ConstantPatternSyntax": + { + switch (propertySymbol.Name) + { + case "Expression": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ConstructorConstraintSyntax": + { + switch (propertySymbol.Name) + { + case "NewKeyword": + case "OpenParenToken": + case "CloseParenToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ConstructorDeclarationSyntax": + { + switch (propertySymbol.Name) + { + case "AttributeLists": + case "Modifiers": + case "Identifier": + case "ParameterList": + case "Initializer": + case "Body": + case "ExpressionBody": + case "SemicolonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ConstructorInitializerSyntax": + { + switch (propertySymbol.Name) + { + case "ColonToken": + case "ThisOrBaseKeyword": + case "ArgumentList": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ContinueStatementSyntax": + { + switch (propertySymbol.Name) + { + case "ContinueKeyword": + case "SemicolonToken": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ConversionOperatorDeclarationSyntax": + { + switch (propertySymbol.Name) + { + case "AttributeLists": + case "Modifiers": + case "ImplicitOrExplicitKeyword": + case "OperatorKeyword": + case "Type": + case "ParameterList": + case "Body": + case "ExpressionBody": + case "SemicolonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ConversionOperatorMemberCrefSyntax": + { + switch (propertySymbol.Name) + { + case "ImplicitOrExplicitKeyword": + case "OperatorKeyword": + case "Type": + case "Parameters": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "CrefBracketedParameterListSyntax": + { + switch (propertySymbol.Name) + { + case "OpenBracketToken": + case "Parameters": + case "CloseBracketToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "CrefParameterListSyntax": + { + switch (propertySymbol.Name) + { + case "OpenParenToken": + case "Parameters": + case "CloseParenToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "CrefParameterSyntax": + { + switch (propertySymbol.Name) + { + case "RefKindKeyword": + case "Type": + return true; + case "RefOrOutKeyword": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "DeclarationExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Type": + case "Designation": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "DeclarationPatternSyntax": + { + switch (propertySymbol.Name) + { + case "Type": + case "Designation": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "DefaultExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Keyword": + case "OpenParenToken": + case "Type": + case "CloseParenToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "DefaultSwitchLabelSyntax": + { + switch (propertySymbol.Name) + { + case "Keyword": + case "ColonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "DefineDirectiveTriviaSyntax": + { + switch (propertySymbol.Name) + { + case "HashToken": + case "DefineKeyword": + case "Name": + case "EndOfDirectiveToken": + case "IsActive": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "DelegateDeclarationSyntax": + { + switch (propertySymbol.Name) + { + case "Arity": + case "AttributeLists": + case "Modifiers": + case "DelegateKeyword": + case "ReturnType": + case "Identifier": + case "TypeParameterList": + case "ParameterList": + case "ConstraintClauses": + case "SemicolonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "DestructorDeclarationSyntax": + { + switch (propertySymbol.Name) + { + case "AttributeLists": + case "Modifiers": + case "TildeToken": + case "Identifier": + case "ParameterList": + case "Body": + case "ExpressionBody": + case "SemicolonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "DiscardDesignationSyntax": + { + switch (propertySymbol.Name) + { + case "UnderscoreToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "DocumentationCommentTriviaSyntax": + { + switch (propertySymbol.Name) + { + case "Content": + case "EndOfComment": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "DoStatementSyntax": + { + switch (propertySymbol.Name) + { + case "DoKeyword": + case "Statement": + case "WhileKeyword": + case "OpenParenToken": + case "Condition": + case "CloseParenToken": + case "SemicolonToken": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ElementAccessExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Expression": + case "ArgumentList": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ElementBindingExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "ArgumentList": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ElifDirectiveTriviaSyntax": + { + switch (propertySymbol.Name) + { + case "HashToken": + case "ElifKeyword": + case "Condition": + case "EndOfDirectiveToken": + case "IsActive": + case "BranchTaken": + case "ConditionValue": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ElseClauseSyntax": + { + switch (propertySymbol.Name) + { + case "ElseKeyword": + case "Statement": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ElseDirectiveTriviaSyntax": + { + switch (propertySymbol.Name) + { + case "HashToken": + case "ElseKeyword": + case "EndOfDirectiveToken": + case "IsActive": + case "BranchTaken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "EmptyStatementSyntax": + { + switch (propertySymbol.Name) + { + case "SemicolonToken": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "EndIfDirectiveTriviaSyntax": + { + switch (propertySymbol.Name) + { + case "HashToken": + case "EndIfKeyword": + case "EndOfDirectiveToken": + case "IsActive": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "EndRegionDirectiveTriviaSyntax": + { + switch (propertySymbol.Name) + { + case "HashToken": + case "EndRegionKeyword": + case "EndOfDirectiveToken": + case "IsActive": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "EnumDeclarationSyntax": + { + switch (propertySymbol.Name) + { + case "AttributeLists": + case "Modifiers": + case "EnumKeyword": + case "Identifier": + case "BaseList": + case "OpenBraceToken": + case "Members": + case "CloseBraceToken": + case "SemicolonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "EnumMemberDeclarationSyntax": + { + switch (propertySymbol.Name) + { + case "AttributeLists": + case "Modifiers": + case "Identifier": + case "EqualsValue": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "EqualsValueClauseSyntax": + { + switch (propertySymbol.Name) + { + case "EqualsToken": + case "Value": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ErrorDirectiveTriviaSyntax": + { + switch (propertySymbol.Name) + { + case "HashToken": + case "ErrorKeyword": + case "EndOfDirectiveToken": + case "IsActive": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "EventDeclarationSyntax": + { + switch (propertySymbol.Name) + { + case "AttributeLists": + case "Modifiers": + case "EventKeyword": + case "Type": + case "ExplicitInterfaceSpecifier": + case "Identifier": + case "AccessorList": + case "SemicolonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "EventFieldDeclarationSyntax": + { + switch (propertySymbol.Name) + { + case "AttributeLists": + case "Modifiers": + case "EventKeyword": + case "Declaration": + case "SemicolonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ExplicitInterfaceSpecifierSyntax": + { + switch (propertySymbol.Name) + { + case "Name": + case "DotToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ExpressionStatementSyntax": + { + switch (propertySymbol.Name) + { + case "AllowsAnyExpression": + case "Expression": + case "SemicolonToken": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ExternAliasDirectiveSyntax": + { + switch (propertySymbol.Name) + { + case "ExternKeyword": + case "AliasKeyword": + case "Identifier": + case "SemicolonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "FieldDeclarationSyntax": + { + switch (propertySymbol.Name) + { + case "AttributeLists": + case "Modifiers": + case "Declaration": + case "SemicolonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "FinallyClauseSyntax": + { + switch (propertySymbol.Name) + { + case "FinallyKeyword": + case "Block": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "FixedStatementSyntax": + { + switch (propertySymbol.Name) + { + case "FixedKeyword": + case "OpenParenToken": + case "Declaration": + case "CloseParenToken": + case "Statement": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ForEachStatementSyntax": + { + switch (propertySymbol.Name) + { + case "ForEachKeyword": + case "OpenParenToken": + case "Type": + case "Identifier": + case "InKeyword": + case "AwaitKeyword": + case "Expression": + case "CloseParenToken": + case "Statement": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ForEachVariableStatementSyntax": + { + switch (propertySymbol.Name) + { + case "ForEachKeyword": + case "OpenParenToken": + case "Variable": + case "InKeyword": + case "AwaitKeyword": + case "Expression": + case "CloseParenToken": + case "Statement": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ForStatementSyntax": + { + switch (propertySymbol.Name) + { + case "ForKeyword": + case "OpenParenToken": + case "Declaration": + case "Initializers": + case "FirstSemicolonToken": + case "Condition": + case "SecondSemicolonToken": + case "Incrementors": + case "CloseParenToken": + case "Statement": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "FromClauseSyntax": + { + switch (propertySymbol.Name) + { + case "FromKeyword": + case "Type": + case "Identifier": + case "InKeyword": + case "Expression": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "GenericNameSyntax": + { + switch (propertySymbol.Name) + { + case "IsUnboundGenericName": + case "Identifier": + case "TypeArgumentList": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "GlobalStatementSyntax": + { + switch (propertySymbol.Name) + { + case "AttributeLists": + case "Modifiers": + case "Statement": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "GotoStatementSyntax": + { + switch (propertySymbol.Name) + { + case "GotoKeyword": + case "CaseOrDefaultKeyword": + case "Expression": + case "SemicolonToken": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "GroupClauseSyntax": + { + switch (propertySymbol.Name) + { + case "GroupKeyword": + case "GroupExpression": + case "ByKeyword": + case "ByExpression": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "CheckedExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Keyword": + case "OpenParenToken": + case "Expression": + case "CloseParenToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "CheckedStatementSyntax": + { + switch (propertySymbol.Name) + { + case "Keyword": + case "Block": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "IdentifierNameSyntax": + { + switch (propertySymbol.Name) + { + case "Identifier": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "IfDirectiveTriviaSyntax": + { + switch (propertySymbol.Name) + { + case "HashToken": + case "IfKeyword": + case "Condition": + case "EndOfDirectiveToken": + case "IsActive": + case "BranchTaken": + case "ConditionValue": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "IfStatementSyntax": + { + switch (propertySymbol.Name) + { + case "IfKeyword": + case "OpenParenToken": + case "Condition": + case "CloseParenToken": + case "Statement": + case "Else": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ImplicitArrayCreationExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "NewKeyword": + case "OpenBracketToken": + case "Commas": + case "CloseBracketToken": + case "Initializer": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ImplicitElementAccessSyntax": + { + switch (propertySymbol.Name) + { + case "ArgumentList": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "IncompleteMemberSyntax": + { + switch (propertySymbol.Name) + { + case "AttributeLists": + case "Modifiers": + case "Type": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "IndexerDeclarationSyntax": + { + switch (propertySymbol.Name) + { + case "AttributeLists": + case "Modifiers": + case "Type": + case "ExplicitInterfaceSpecifier": + case "ThisKeyword": + case "ParameterList": + case "AccessorList": + case "ExpressionBody": + case "SemicolonToken": + return true; + case "Semicolon": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "IndexerMemberCrefSyntax": + { + switch (propertySymbol.Name) + { + case "ThisKeyword": + case "Parameters": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "InitializerExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "OpenBraceToken": + case "Expressions": + case "CloseBraceToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "InterfaceDeclarationSyntax": + { + switch (propertySymbol.Name) + { + case "AttributeLists": + case "Modifiers": + case "Keyword": + case "Identifier": + case "TypeParameterList": + case "BaseList": + case "ConstraintClauses": + case "OpenBraceToken": + case "Members": + case "CloseBraceToken": + case "SemicolonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "InterpolatedStringExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "StringStartToken": + case "Contents": + case "StringEndToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "InterpolatedStringTextSyntax": + { + switch (propertySymbol.Name) + { + case "TextToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "InterpolationAlignmentClauseSyntax": + { + switch (propertySymbol.Name) + { + case "CommaToken": + case "Value": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "InterpolationFormatClauseSyntax": + { + switch (propertySymbol.Name) + { + case "ColonToken": + case "FormatStringToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "InterpolationSyntax": + { + switch (propertySymbol.Name) + { + case "OpenBraceToken": + case "Expression": + case "AlignmentClause": + case "FormatClause": + case "CloseBraceToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "InvocationExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Expression": + case "ArgumentList": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "IsPatternExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Expression": + case "IsKeyword": + case "Pattern": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "JoinClauseSyntax": + { + switch (propertySymbol.Name) + { + case "JoinKeyword": + case "Type": + case "Identifier": + case "InKeyword": + case "InExpression": + case "OnKeyword": + case "LeftExpression": + case "EqualsKeyword": + case "RightExpression": + case "Into": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "JoinIntoClauseSyntax": + { + switch (propertySymbol.Name) + { + case "IntoKeyword": + case "Identifier": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "LabeledStatementSyntax": + { + switch (propertySymbol.Name) + { + case "Identifier": + case "ColonToken": + case "Statement": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "LetClauseSyntax": + { + switch (propertySymbol.Name) + { + case "LetKeyword": + case "Identifier": + case "EqualsToken": + case "Expression": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "LineDirectiveTriviaSyntax": + { + switch (propertySymbol.Name) + { + case "HashToken": + case "LineKeyword": + case "Line": + case "File": + case "EndOfDirectiveToken": + case "IsActive": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "LiteralExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Token": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "LoadDirectiveTriviaSyntax": + { + switch (propertySymbol.Name) + { + case "HashToken": + case "LoadKeyword": + case "File": + case "EndOfDirectiveToken": + case "IsActive": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "LocalDeclarationStatementSyntax": + { + switch (propertySymbol.Name) + { + case "AwaitKeyword": + case "UsingKeyword": + case "IsConst": + case "Modifiers": + case "Declaration": + case "SemicolonToken": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "LocalFunctionStatementSyntax": + { + switch (propertySymbol.Name) + { + case "Modifiers": + case "ReturnType": + case "Identifier": + case "TypeParameterList": + case "ParameterList": + case "ConstraintClauses": + case "Body": + case "ExpressionBody": + case "SemicolonToken": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "LockStatementSyntax": + { + switch (propertySymbol.Name) + { + case "LockKeyword": + case "OpenParenToken": + case "Expression": + case "CloseParenToken": + case "Statement": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "MakeRefExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Keyword": + case "OpenParenToken": + case "Expression": + case "CloseParenToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "MemberAccessExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Expression": + case "OperatorToken": + case "Name": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "MemberBindingExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "OperatorToken": + case "Name": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "MethodDeclarationSyntax": + { + switch (propertySymbol.Name) + { + case "Arity": + case "AttributeLists": + case "Modifiers": + case "ReturnType": + case "ExplicitInterfaceSpecifier": + case "Identifier": + case "TypeParameterList": + case "ParameterList": + case "ConstraintClauses": + case "Body": + case "ExpressionBody": + case "SemicolonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "NameColonSyntax": + { + switch (propertySymbol.Name) + { + case "Name": + case "ColonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "NameEqualsSyntax": + { + switch (propertySymbol.Name) + { + case "Name": + case "EqualsToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "NameMemberCrefSyntax": + { + switch (propertySymbol.Name) + { + case "Name": + case "Parameters": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "NamespaceDeclarationSyntax": + { + switch (propertySymbol.Name) + { + case "AttributeLists": + case "Modifiers": + case "NamespaceKeyword": + case "Name": + case "OpenBraceToken": + case "Externs": + case "Usings": + case "Members": + case "CloseBraceToken": + case "SemicolonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "NullableTypeSyntax": + { + switch (propertySymbol.Name) + { + case "ElementType": + case "QuestionToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ObjectCreationExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "NewKeyword": + case "Type": + case "ArgumentList": + case "Initializer": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "OmittedArraySizeExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "OmittedArraySizeExpressionToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "OmittedTypeArgumentSyntax": + { + switch (propertySymbol.Name) + { + case "OmittedTypeArgumentToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "OperatorDeclarationSyntax": + { + switch (propertySymbol.Name) + { + case "AttributeLists": + case "Modifiers": + case "ReturnType": + case "OperatorKeyword": + case "OperatorToken": + case "ParameterList": + case "Body": + case "ExpressionBody": + case "SemicolonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "OperatorMemberCrefSyntax": + { + switch (propertySymbol.Name) + { + case "OperatorKeyword": + case "OperatorToken": + case "Parameters": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "OrderByClauseSyntax": + { + switch (propertySymbol.Name) + { + case "OrderByKeyword": + case "Orderings": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "OrderingSyntax": + { + switch (propertySymbol.Name) + { + case "Expression": + case "AscendingOrDescendingKeyword": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ParameterListSyntax": + { + switch (propertySymbol.Name) + { + case "OpenParenToken": + case "Parameters": + case "CloseParenToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ParameterSyntax": + { + switch (propertySymbol.Name) + { + case "AttributeLists": + case "Modifiers": + case "Type": + case "Identifier": + case "Default": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ParenthesizedExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "OpenParenToken": + case "Expression": + case "CloseParenToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ParenthesizedLambdaExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Modifiers": + case "AsyncKeyword": + case "ParameterList": + case "ArrowToken": + case "ExpressionBody": + case "Block": + return true; + case "Body": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ParenthesizedVariableDesignationSyntax": + { + switch (propertySymbol.Name) + { + case "OpenParenToken": + case "Variables": + case "CloseParenToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "PointerTypeSyntax": + { + switch (propertySymbol.Name) + { + case "ElementType": + case "AsteriskToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "PostfixUnaryExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Operand": + case "OperatorToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "PragmaChecksumDirectiveTriviaSyntax": + { + switch (propertySymbol.Name) + { + case "HashToken": + case "PragmaKeyword": + case "ChecksumKeyword": + case "File": + case "Guid": + case "Bytes": + case "EndOfDirectiveToken": + case "IsActive": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "PragmaWarningDirectiveTriviaSyntax": + { + switch (propertySymbol.Name) + { + case "HashToken": + case "PragmaKeyword": + case "WarningKeyword": + case "DisableOrRestoreKeyword": + case "NullableKeyword": + case "ErrorCodes": + case "EndOfDirectiveToken": + case "IsActive": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "PredefinedTypeSyntax": + { + switch (propertySymbol.Name) + { + case "Keyword": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "PrefixUnaryExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "OperatorToken": + case "Operand": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "PropertyDeclarationSyntax": + { + switch (propertySymbol.Name) + { + case "AttributeLists": + case "Modifiers": + case "Type": + case "ExplicitInterfaceSpecifier": + case "Identifier": + case "AccessorList": + case "ExpressionBody": + case "Initializer": + case "SemicolonToken": + return true; + case "Semicolon": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "QualifiedCrefSyntax": + { + switch (propertySymbol.Name) + { + case "Container": + case "DotToken": + case "Member": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "QualifiedNameSyntax": + { + switch (propertySymbol.Name) + { + case "Left": + case "DotToken": + case "Right": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "QueryBodySyntax": + { + switch (propertySymbol.Name) + { + case "Clauses": + case "SelectOrGroup": + case "Continuation": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "QueryContinuationSyntax": + { + switch (propertySymbol.Name) + { + case "IntoKeyword": + case "Identifier": + case "Body": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "QueryExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "FromClause": + case "Body": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ReferenceDirectiveTriviaSyntax": + { + switch (propertySymbol.Name) + { + case "HashToken": + case "ReferenceKeyword": + case "File": + case "EndOfDirectiveToken": + case "IsActive": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "RefExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "RefKeyword": + case "Expression": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "RefTypeExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Keyword": + case "OpenParenToken": + case "Expression": + case "CloseParenToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "RefTypeSyntax": + { + switch (propertySymbol.Name) + { + case "RefKeyword": + case "ReadOnlyKeyword": + case "Type": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "RefValueExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Keyword": + case "OpenParenToken": + case "Expression": + case "Comma": + case "Type": + case "CloseParenToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "RegionDirectiveTriviaSyntax": + { + switch (propertySymbol.Name) + { + case "HashToken": + case "RegionKeyword": + case "EndOfDirectiveToken": + case "IsActive": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ReturnStatementSyntax": + { + switch (propertySymbol.Name) + { + case "ReturnKeyword": + case "Expression": + case "SemicolonToken": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "SelectClauseSyntax": + { + switch (propertySymbol.Name) + { + case "SelectKeyword": + case "Expression": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ShebangDirectiveTriviaSyntax": + { + switch (propertySymbol.Name) + { + case "HashToken": + case "ExclamationToken": + case "EndOfDirectiveToken": + case "IsActive": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "SimpleBaseTypeSyntax": + { + switch (propertySymbol.Name) + { + case "Type": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "SimpleLambdaExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Modifiers": + case "AsyncKeyword": + case "Parameter": + case "ArrowToken": + case "ExpressionBody": + case "Block": + return true; + case "Body": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "SingleVariableDesignationSyntax": + { + switch (propertySymbol.Name) + { + case "Identifier": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "SizeOfExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Keyword": + case "OpenParenToken": + case "Type": + case "CloseParenToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "SkippedTokensTriviaSyntax": + { + switch (propertySymbol.Name) + { + case "Tokens": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "StackAllocArrayCreationExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "StackAllocKeyword": + case "Type": + case "Initializer": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "StructDeclarationSyntax": + { + switch (propertySymbol.Name) + { + case "AttributeLists": + case "Modifiers": + case "Keyword": + case "Identifier": + case "TypeParameterList": + case "BaseList": + case "ConstraintClauses": + case "OpenBraceToken": + case "Members": + case "CloseBraceToken": + case "SemicolonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "SwitchSectionSyntax": + { + switch (propertySymbol.Name) + { + case "Labels": + case "Statements": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "SwitchStatementSyntax": + { + switch (propertySymbol.Name) + { + case "SwitchKeyword": + case "OpenParenToken": + case "Expression": + case "CloseParenToken": + case "OpenBraceToken": + case "Sections": + case "CloseBraceToken": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ThisExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Token": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ThrowExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "ThrowKeyword": + case "Expression": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ThrowStatementSyntax": + { + switch (propertySymbol.Name) + { + case "ThrowKeyword": + case "Expression": + case "SemicolonToken": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "TryStatementSyntax": + { + switch (propertySymbol.Name) + { + case "TryKeyword": + case "Block": + case "Catches": + case "Finally": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "TupleElementSyntax": + { + switch (propertySymbol.Name) + { + case "Type": + case "Identifier": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "TupleExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "OpenParenToken": + case "Arguments": + case "CloseParenToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "TupleTypeSyntax": + { + switch (propertySymbol.Name) + { + case "OpenParenToken": + case "Elements": + case "CloseParenToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "TypeArgumentListSyntax": + { + switch (propertySymbol.Name) + { + case "LessThanToken": + case "Arguments": + case "GreaterThanToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "TypeConstraintSyntax": + { + switch (propertySymbol.Name) + { + case "Type": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "TypeCrefSyntax": + { + switch (propertySymbol.Name) + { + case "Type": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "TypeOfExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Keyword": + case "OpenParenToken": + case "Type": + case "CloseParenToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "TypeParameterConstraintClauseSyntax": + { + switch (propertySymbol.Name) + { + case "WhereKeyword": + case "Name": + case "ColonToken": + case "Constraints": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "TypeParameterListSyntax": + { + switch (propertySymbol.Name) + { + case "LessThanToken": + case "Parameters": + case "GreaterThanToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "TypeParameterSyntax": + { + switch (propertySymbol.Name) + { + case "AttributeLists": + case "VarianceKeyword": + case "Identifier": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "UndefDirectiveTriviaSyntax": + { + switch (propertySymbol.Name) + { + case "HashToken": + case "UndefKeyword": + case "Name": + case "EndOfDirectiveToken": + case "IsActive": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "UnsafeStatementSyntax": + { + switch (propertySymbol.Name) + { + case "UnsafeKeyword": + case "Block": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "UsingDirectiveSyntax": + { + switch (propertySymbol.Name) + { + case "UsingKeyword": + case "StaticKeyword": + case "Alias": + case "Name": + case "SemicolonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "UsingStatementSyntax": + { + switch (propertySymbol.Name) + { + case "UsingKeyword": + case "AwaitKeyword": + case "OpenParenToken": + case "Declaration": + case "Expression": + case "CloseParenToken": + case "Statement": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "VariableDeclarationSyntax": + { + switch (propertySymbol.Name) + { + case "Type": + case "Variables": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "VariableDeclaratorSyntax": + { + switch (propertySymbol.Name) + { + case "Identifier": + case "ArgumentList": + case "Initializer": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "WarningDirectiveTriviaSyntax": + { + switch (propertySymbol.Name) + { + case "HashToken": + case "WarningKeyword": + case "EndOfDirectiveToken": + case "IsActive": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "WhenClauseSyntax": + { + switch (propertySymbol.Name) + { + case "WhenKeyword": + case "Condition": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "WhereClauseSyntax": + { + switch (propertySymbol.Name) + { + case "WhereKeyword": + case "Condition": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "WhileStatementSyntax": + { + switch (propertySymbol.Name) + { + case "WhileKeyword": + case "OpenParenToken": + case "Condition": + case "CloseParenToken": + case "Statement": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "XmlCDataSectionSyntax": + { + switch (propertySymbol.Name) + { + case "StartCDataToken": + case "TextTokens": + case "EndCDataToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "XmlCommentSyntax": + { + switch (propertySymbol.Name) + { + case "LessThanExclamationMinusMinusToken": + case "TextTokens": + case "MinusMinusGreaterThanToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "XmlCrefAttributeSyntax": + { + switch (propertySymbol.Name) + { + case "Name": + case "EqualsToken": + case "StartQuoteToken": + case "Cref": + case "EndQuoteToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "XmlElementEndTagSyntax": + { + switch (propertySymbol.Name) + { + case "LessThanSlashToken": + case "Name": + case "GreaterThanToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "XmlElementStartTagSyntax": + { + switch (propertySymbol.Name) + { + case "LessThanToken": + case "Name": + case "Attributes": + case "GreaterThanToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "XmlElementSyntax": + { + switch (propertySymbol.Name) + { + case "StartTag": + case "Content": + case "EndTag": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "XmlEmptyElementSyntax": + { + switch (propertySymbol.Name) + { + case "LessThanToken": + case "Name": + case "Attributes": + case "SlashGreaterThanToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "XmlNameAttributeSyntax": + { + switch (propertySymbol.Name) + { + case "Name": + case "EqualsToken": + case "StartQuoteToken": + case "Identifier": + case "EndQuoteToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "XmlNameSyntax": + { + switch (propertySymbol.Name) + { + case "Prefix": + case "LocalName": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "XmlPrefixSyntax": + { + switch (propertySymbol.Name) + { + case "Prefix": + case "ColonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "XmlProcessingInstructionSyntax": + { + switch (propertySymbol.Name) + { + case "StartProcessingInstructionToken": + case "Name": + case "TextTokens": + case "EndProcessingInstructionToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "XmlTextAttributeSyntax": + { + switch (propertySymbol.Name) + { + case "Name": + case "EqualsToken": + case "StartQuoteToken": + case "TextTokens": + case "EndQuoteToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "XmlTextSyntax": + { + switch (propertySymbol.Name) + { + case "TextTokens": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "YieldStatementSyntax": + { + switch (propertySymbol.Name) + { + case "YieldKeyword": + case "ReturnOrBreakKeyword": + case "Expression": + case "SemicolonToken": + return true; + case "AttributeLists": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ImplicitStackAllocArrayCreationExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "StackAllocKeyword": + case "OpenBracketToken": + case "CloseBracketToken": + case "Initializer": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "DiscardPatternSyntax": + { + switch (propertySymbol.Name) + { + case "UnderscoreToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "NullableDirectiveTriviaSyntax": + { + switch (propertySymbol.Name) + { + case "HashToken": + case "NullableKeyword": + case "SettingToken": + case "TargetToken": + case "EndOfDirectiveToken": + case "IsActive": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "PositionalPatternClauseSyntax": + { + switch (propertySymbol.Name) + { + case "OpenParenToken": + case "Subpatterns": + case "CloseParenToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "PropertyPatternClauseSyntax": + { + switch (propertySymbol.Name) + { + case "OpenBraceToken": + case "Subpatterns": + case "CloseBraceToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "RangeExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "LeftOperand": + case "OperatorToken": + case "RightOperand": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "RecursivePatternSyntax": + { + switch (propertySymbol.Name) + { + case "Type": + case "PositionalPatternClause": + case "PropertyPatternClause": + case "Designation": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "SubpatternSyntax": + { + switch (propertySymbol.Name) + { + case "NameColon": + case "Pattern": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "SwitchExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "GoverningExpression": + case "SwitchKeyword": + case "OpenBraceToken": + case "Arms": + case "CloseBraceToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "SwitchExpressionArmSyntax": + { + switch (propertySymbol.Name) + { + case "Pattern": + case "WhenClause": + case "EqualsGreaterThanToken": + case "Expression": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "VarPatternSyntax": + { + switch (propertySymbol.Name) + { + case "VarKeyword": + case "Designation": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "UnaryPatternSyntax": + { + switch (propertySymbol.Name) + { + case "OperatorToken": + case "Pattern": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "BinaryPatternSyntax": + { + switch (propertySymbol.Name) + { + case "Left": + case "OperatorToken": + case "Right": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "RelationalPatternSyntax": + { + switch (propertySymbol.Name) + { + case "OperatorToken": + case "Expression": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ParenthesizedPatternSyntax": + { + switch (propertySymbol.Name) + { + case "OpenParenToken": + case "Pattern": + case "CloseParenToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "TypePatternSyntax": + { + switch (propertySymbol.Name) + { + case "Type": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "RecordDeclarationSyntax": + { + switch (propertySymbol.Name) + { + case "AttributeLists": + case "Modifiers": + case "Keyword": + case "Identifier": + case "ParameterList": + case "TypeParameterList": + case "BaseList": + case "ConstraintClauses": + case "OpenBraceToken": + case "Members": + case "CloseBraceToken": + case "SemicolonToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "WithExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "Expression": + case "WithKeyword": + case "Initializer": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "ImplicitObjectCreationExpressionSyntax": + { + switch (propertySymbol.Name) + { + case "NewKeyword": + case "ArgumentList": + case "Initializer": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "PrimaryConstructorBaseTypeSyntax": + { + switch (propertySymbol.Name) + { + case "Type": + case "ArgumentList": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "FunctionPointerTypeSyntax": + { + switch (propertySymbol.Name) + { + case "DelegateKeyword": + case "AsteriskToken": + case "CallingConvention": + case "ParameterList": + return true; + case "LessThanToken": + case "Parameters": + case "GreaterThanToken": + return false; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "DefaultConstraintSyntax": + { + switch (propertySymbol.Name) + { + case "DefaultKeyword": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "FunctionPointerCallingConventionSyntax": + { + switch (propertySymbol.Name) + { + case "ManagedOrUnmanagedKeyword": + case "UnmanagedCallingConventionList": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "FunctionPointerParameterSyntax": + { + switch (propertySymbol.Name) + { + case "AttributeLists": + case "Modifiers": + case "Type": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "FunctionPointerParameterListSyntax": + { + switch (propertySymbol.Name) + { + case "LessThanToken": + case "Parameters": + case "GreaterThanToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "FunctionPointerUnmanagedCallingConventionSyntax": + { + switch (propertySymbol.Name) + { + case "Name": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + case "FunctionPointerUnmanagedCallingConventionListSyntax": + { + switch (propertySymbol.Name) + { + case "OpenBracketToken": + case "CallingConventions": + case "CloseBracketToken": + return true; + default: + throw new InvalidOperationException($"Unrecognized property '{propertySymbol.ToDisplayString(SymbolDisplayFormats.Test)}'"); + } + } + + default: + { + throw new InvalidOperationException($"Unrecognized type '{propertySymbol.ContainingType.Name}'"); + } + } + } + } +} +#endif diff --git a/src/Tools/CodeGeneration/CSharp/SyntaxWalker/CSharpSyntaxWalkerGenerator.Roslyn38.cs b/src/Tools/CodeGeneration/CSharp/SyntaxWalker/CSharpSyntaxWalkerGenerator.Roslyn38.cs new file mode 100644 index 0000000000..d029bc9301 --- /dev/null +++ b/src/Tools/CodeGeneration/CSharp/SyntaxWalker/CSharpSyntaxWalkerGenerator.Roslyn38.cs @@ -0,0 +1,632 @@ +#if ROSLYN_3_8_ONLY +// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Roslynator.CSharp; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; +using static Roslynator.CodeGeneration.CSharp.CSharpFactory2; +using static Roslynator.RoslynMetadataNames; +using static Roslynator.CodeGeneration.CSharp.Symbols; +using static Roslynator.CSharp.CSharpFactory; + +namespace Roslynator.CodeGeneration.CSharp +{ + public partial class CSharpSyntaxWalkerGenerator + { + private static readonly SymbolDisplayFormat _parameterSymbolDisplayFormat = SymbolDisplayFormats.DisplayName_WithoutNullableReferenceTypeModifier.WithParameterOptions( + SymbolDisplayParameterOptions.IncludeDefaultValue + | SymbolDisplayParameterOptions.IncludeExtensionThis + | SymbolDisplayParameterOptions.IncludeName + | SymbolDisplayParameterOptions.IncludeParamsRefOut + | SymbolDisplayParameterOptions.IncludeType); + + public CSharpSyntaxWalkerGenerator( + SyntaxWalkerDepth depth = SyntaxWalkerDepth.Node, + bool useCustomVisitMethod = false, + bool eliminateDefaultVisit = false) + { + Depth = depth; + UseCustomVisitMethod = useCustomVisitMethod; + EliminateDefaultVisit = eliminateDefaultVisit; + } + + public SyntaxWalkerDepth Depth { get; } + + public bool UseCustomVisitMethod { get; } + + public bool EliminateDefaultVisit { get; } + + public List CreateMemberDeclarations() + { + var members = new List(); + + AddIfNotNull(CreateConstructorDeclaration(Depth)); + AddIfNotNull(CreateShouldVisitPropertyDeclaration()); + AddIfNotNull(CreateVisitNodeMethodDeclaration()); + + if (!EliminateDefaultVisit + && Depth >= SyntaxWalkerDepth.Node) + { + AddIfNotNull(CreateVisitListMethodDeclaration()); + AddIfNotNull(CreateVisitSeparatedListMethodDeclaration()); + } + + if (Depth >= SyntaxWalkerDepth.Token) + AddIfNotNull(CreateVisitTokenListMethodDeclaration()); + + var context = new MethodGenerationContext(); + + foreach (ISymbol symbol in VisitMethodSymbols) + { + context.MethodSymbol = (IMethodSymbol)symbol; + + AddIfNotNull(CreateVisitMethodDeclaration(context)); + + context.MethodSymbol = null; + context.Statements.Clear(); + context.LocalNames.Clear(); + } + + if (EliminateDefaultVisit) + { + AddIfNotNull(CreateVisitAbstractSyntaxMethodDeclaration(Microsoft_CodeAnalysis_CSharp_Syntax_BaseTypeSyntax)); + AddIfNotNull(CreateVisitAbstractSyntaxMethodDeclaration(Microsoft_CodeAnalysis_CSharp_Syntax_CrefSyntax)); + AddIfNotNull(CreateVisitAbstractSyntaxMethodDeclaration(Microsoft_CodeAnalysis_CSharp_Syntax_ExpressionSyntax)); + AddIfNotNull(CreateVisitAbstractSyntaxMethodDeclaration(Microsoft_CodeAnalysis_CSharp_Syntax_InterpolatedStringContentSyntax)); + AddIfNotNull(CreateVisitAbstractSyntaxMethodDeclaration(Microsoft_CodeAnalysis_CSharp_Syntax_MemberCrefSyntax)); + AddIfNotNull(CreateVisitAbstractSyntaxMethodDeclaration(Microsoft_CodeAnalysis_CSharp_Syntax_MemberDeclarationSyntax)); + AddIfNotNull(CreateVisitAbstractSyntaxMethodDeclaration(Microsoft_CodeAnalysis_CSharp_Syntax_PatternSyntax)); + AddIfNotNull(CreateVisitAbstractSyntaxMethodDeclaration(Microsoft_CodeAnalysis_CSharp_Syntax_QueryClauseSyntax)); + AddIfNotNull(CreateVisitAbstractSyntaxMethodDeclaration(Microsoft_CodeAnalysis_CSharp_Syntax_SelectOrGroupClauseSyntax)); + AddIfNotNull(CreateVisitAbstractSyntaxMethodDeclaration(Microsoft_CodeAnalysis_CSharp_Syntax_SimpleNameSyntax)); + AddIfNotNull(CreateVisitAbstractSyntaxMethodDeclaration(Microsoft_CodeAnalysis_CSharp_Syntax_StatementSyntax)); + AddIfNotNull(CreateVisitAbstractSyntaxMethodDeclaration(Microsoft_CodeAnalysis_CSharp_Syntax_SwitchLabelSyntax)); + AddIfNotNull(CreateVisitAbstractSyntaxMethodDeclaration(Microsoft_CodeAnalysis_CSharp_Syntax_TypeParameterConstraintSyntax)); + AddIfNotNull(CreateVisitAbstractSyntaxMethodDeclaration(Microsoft_CodeAnalysis_CSharp_Syntax_TypeSyntax)); + AddIfNotNull(CreateVisitAbstractSyntaxMethodDeclaration(Microsoft_CodeAnalysis_CSharp_Syntax_VariableDesignationSyntax)); + AddIfNotNull(CreateVisitAbstractSyntaxMethodDeclaration(Microsoft_CodeAnalysis_CSharp_Syntax_XmlAttributeSyntax)); + AddIfNotNull(CreateVisitAbstractSyntaxMethodDeclaration(Microsoft_CodeAnalysis_CSharp_Syntax_XmlNodeSyntax)); + } + + return members; + + void AddIfNotNull(MemberDeclarationSyntax memberDeclaration) + { + if (memberDeclaration != null) + members.Add(memberDeclaration); + } + } + + protected virtual MethodDeclarationSyntax CreateVisitMethodDeclaration(MethodGenerationContext context) + { + CreateMethodStatements(context); + + return MethodDeclaration( + Modifiers.Public_Override(), + VoidType(), + Identifier(context.MethodName), + ParseParameterList($"({context.ParameterSymbol.ToDisplayString(_parameterSymbolDisplayFormat)})"), + Block(context.Statements)); + } + + protected virtual void CreateMethodStatements(MethodGenerationContext context) + { + foreach (IPropertySymbol propertySymbol in GetPropertySymbols(context.ParameterType)) + { + if (ShouldVisit(propertySymbol)) + { + context.PropertySymbol = propertySymbol; + + CreateVisitStatements(context); + + context.PropertySymbol = null; + } + } + } + + protected virtual void CreateVisitStatements(MethodGenerationContext context) + { + string parameterName = context.ParameterName; + ITypeSymbol propertyType = context.PropertyType; + string propertyName = context.PropertyName; + + if (SymbolEqualityComparer.Default.Equals(propertyType.OriginalDefinition, SyntaxListSymbol)) + { + if (UseCustomVisitMethod) + { + CreateVisitListStatements(context, isSeparatedList: false); + } + else + { + context.AddStatement(VisitStatement("VisitList", parameterName, propertyName)); + } + } + else if (SymbolEqualityComparer.Default.Equals(propertyType.OriginalDefinition, SeparatedSyntaxListSymbol)) + { + if (UseCustomVisitMethod) + { + CreateVisitListStatements(context, isSeparatedList: true); + } + else + { + context.AddStatement(VisitStatement("VisitSeparatedList", parameterName, propertyName)); + } + } + else if (SymbolEqualityComparer.Default.Equals(propertyType, SyntaxTokenListSymbol)) + { + if (Depth >= SyntaxWalkerDepth.Token) + { + context.AddStatement(VisitStatement("VisitTokenList", parameterName, propertyName)); + } + } + else if (SymbolEqualityComparer.Default.Equals(propertyType, SyntaxTokenSymbol)) + { + if (Depth >= SyntaxWalkerDepth.Token) + { + context.AddStatement(VisitStatement("VisitToken", parameterName, propertyName)); + } + } + else if (propertyType.EqualsOrInheritsFrom(SyntaxNodeSymbol)) + { + switch (propertyType.Name) + { + case "AccessorListSyntax": + case "ArgumentListSyntax": + case "ArrayTypeSyntax": + case "ArrowExpressionClauseSyntax": + case "AttributeArgumentListSyntax": + case "AttributeTargetSpecifierSyntax": + case "BaseListSyntax": + case "BlockSyntax": + case "BracketedArgumentListSyntax": + case "BracketedParameterListSyntax": + case "CatchDeclarationSyntax": + case "CatchFilterClauseSyntax": + case "ConstructorInitializerSyntax": + case "CrefBracketedParameterListSyntax": + case "CrefParameterListSyntax": + case "CrefSyntax": + case "ElseClauseSyntax": + case "EqualsValueClauseSyntax": + case "ExplicitInterfaceSpecifierSyntax": + case "ExpressionSyntax": + case "FinallyClauseSyntax": + case "FromClauseSyntax": + case "IdentifierNameSyntax": + case "InitializerExpressionSyntax": + case "InterpolationAlignmentClauseSyntax": + case "InterpolationFormatClauseSyntax": + case "JoinIntoClauseSyntax": + case "MemberCrefSyntax": + case "NameColonSyntax": + case "NameEqualsSyntax": + case "NameSyntax": + case "ParameterListSyntax": + case "ParameterSyntax": + case "PatternSyntax": + case "QueryBodySyntax": + case "QueryContinuationSyntax": + case "SelectOrGroupClauseSyntax": + case "SimpleNameSyntax": + case "StatementSyntax": + case "TypeArgumentListSyntax": + case "TypeParameterListSyntax": + case "TypeSyntax": + case "VariableDeclarationSyntax": + case "VariableDesignationSyntax": + case "WhenClauseSyntax": + case "XmlElementEndTagSyntax": + case "XmlElementStartTagSyntax": + case "XmlNameSyntax": + case "XmlPrefixSyntax": + case "PositionalPatternClauseSyntax": + case "PropertyPatternClauseSyntax": + case "SubpatternSyntax": + case "FunctionPointerParameterListSyntax": + case "FunctionPointerCallingConventionSyntax": + case "FunctionPointerCallingConventionListSyntax": + case "FunctionPointerUnmanagedCallingConventionSyntax": + case "FunctionPointerUnmanagedCallingConventionListSyntax": + { + if (UseCustomVisitMethod) + { + CreateTypeVisitStatements(context); + } + else + { + context.AddStatement(VisitStatement("Visit", parameterName, propertyName)); + } + + break; + } + case "CSharpSyntaxNode": + { + if (!UseCustomVisitMethod) + { + context.AddStatement(VisitStatement("Visit", parameterName, propertyName)); + break; + } + + if (EliminateDefaultVisit + && propertyName == "Body" + && context.ParameterType.InheritsFrom(Microsoft_CodeAnalysis_CSharp_Syntax_AnonymousFunctionExpressionSyntax)) + { + CreateVisitAnonymousFunctionStatements(context); + } + else + { + CreateTypeVisitStatements(context); + } + + break; + } + default: + { + throw new InvalidOperationException($"Unrecognized property type '{propertyType.ToDisplayString()}'."); + } + } + } + else if (!propertyType.SpecialType.Is(SpecialType.System_Int32, SpecialType.System_Boolean)) + { + throw new InvalidOperationException(); + } + } + + private static void CreateVisitAnonymousFunctionStatements(MethodGenerationContext context) + { + string variableName = context.CreateVariableName(context.PropertyName); + + context.AddStatement(LocalDeclarationStatement(context.PropertyType, variableName, context.ParameterName, context.PropertyName)); + + IfStatementSyntax ifStatement = IfStatement( + IsPatternExpression( + IdentifierName(variableName), + DeclarationPattern(IdentifierName("ExpressionSyntax"), SingleVariableDesignation(Identifier("expression")))), + Block(VisitStatement("VisitExpression", "expression")), + ElseClause( + IfStatement( + IsPatternExpression( + IdentifierName(variableName), + DeclarationPattern(IdentifierName("StatementSyntax"), SingleVariableDesignation(Identifier("statement")))), + Block(VisitStatement("VisitStatement", "statement")), + ElseClause(Block(VisitStatement("Visit", variableName)))))); + + context.AddStatement(ifStatement); + } + + protected virtual void CreateVisitListStatements(MethodGenerationContext context, bool isSeparatedList) + { + ITypeSymbol typeSymbol = ((INamedTypeSymbol)context.PropertyType).TypeArguments.Single(); + + IMethodSymbol methodSymbol = FindVisitMethod(typeSymbol); + + string methodName = null; + + if (methodSymbol != null) + { + methodName = methodSymbol.Name; + } + else if (EliminateDefaultVisit) + { + methodName = GetMethodName(typeSymbol); + } + + if (methodName != null) + { + string typeName = typeSymbol.Name; + + string variableName = context.CreateVariableName(typeName.Remove(typeName.Length - 6)); + + ForEachStatementSyntax forEachStatement = ForEachVisitStatement( + typeName, + variableName, + SimpleMemberAccessExpression(IdentifierName(context.ParameterName), IdentifierName(context.PropertyName)), + VisitStatement(methodName, variableName), + checkShouldVisit: true); + + context.AddStatement(forEachStatement); + } + else + { + methodName = (isSeparatedList) ? "VisitSeparatedList" : "VisitList"; + + context.AddStatement(VisitStatement(methodName, context.ParameterName, context.PropertyName)); + } + } + + protected virtual void CreateTypeVisitStatements(MethodGenerationContext context) + { + ITypeSymbol propertyType = context.PropertyType; + string propertyName = context.PropertyName; + string parameterName = context.ParameterName; + + IMethodSymbol methodSymbol = FindVisitMethod(propertyType); + + if (methodSymbol == null) + { + if (EliminateDefaultVisit) + { + context.AddStatement(IfNotShouldVisitReturnStatement()); + + string variableName = context.CreateVariableName(propertyName); + + context.AddStatement(LocalDeclarationStatement(propertyType, variableName, parameterName, propertyName)); + + string methodName = GetMethodName(propertyType); + + IfStatementSyntax ifStatement = IfNotEqualsToNullStatement( + variableName, + VisitStatement(methodName, variableName)); + + context.AddStatement(ifStatement); + } + else + { + context.AddStatement(VisitStatement("Visit", parameterName, propertyName)); + } + } + else + { + string variableName = context.CreateVariableName(propertyName); + + context.AddStatement(IfNotShouldVisitReturnStatement()); + + context.AddStatement(LocalDeclarationStatement(propertyType, variableName, parameterName, propertyName)); + + context.AddStatement(IfNotEqualsToNullStatement(variableName, VisitStatement(methodSymbol.Name, variableName))); + } + } + + private void CreateVisitListSyntaxStatements(MethodGenerationContext context) + { + string variableName = context.CreateVariableName(context.PropertyName); + + context.AddStatement(LocalDeclarationStatement(context.PropertyType, variableName, context.ParameterName, context.PropertyName)); + + IPropertySymbol listPropertySymbol = FindListPropertySymbol(context.PropertySymbol); + + ITypeSymbol typeSymbol = ((INamedTypeSymbol)listPropertySymbol.Type).TypeArguments.Single(); + + IMethodSymbol methodSymbol = FindVisitMethod(typeSymbol); + + string methodName = null; + + if (methodSymbol != null) + { + methodName = methodSymbol.Name; + } + else if (EliminateDefaultVisit) + { + methodName = GetMethodName(typeSymbol); + } + + StatementSyntax statement; + + if (methodName != null) + { + string forEachVariableName = context.CreateVariableName(typeSymbol.Name.Remove(typeSymbol.Name.Length - 6)); + + statement = ForEachVisitStatement( + typeSymbol.Name, + forEachVariableName, + SimpleMemberAccessExpression( + IdentifierName(variableName), + IdentifierName(listPropertySymbol.Name)), + VisitStatement(methodName, forEachVariableName), + checkShouldVisit: true); + } + else + { + methodName = (SymbolEqualityComparer.Default.Equals(listPropertySymbol.Type.OriginalDefinition, SyntaxListSymbol)) ? "VisitList" : "VisitSeparatedList"; + + statement = VisitStatement(methodName, variableName, listPropertySymbol.Name); + } + + context.AddStatement(IfNotEqualsToNullStatement(variableName, statement)); + } + + private static string GetMethodName(ITypeSymbol typeSymbol) + { + do + { + string name = typeSymbol.MetadataName; + + switch (name) + { + case "BaseTypeSyntax": + case "CrefSyntax": + case "ExpressionSyntax": + case "InterpolatedStringContentSyntax": + case "MemberCrefSyntax": + case "MemberDeclarationSyntax": + case "PatternSyntax": + case "QueryClauseSyntax": + case "SelectOrGroupClauseSyntax": + case "SimpleNameSyntax": + case "StatementSyntax": + case "SwitchLabelSyntax": + case "TypeSyntax": + case "TypeParameterConstraintSyntax": + case "VariableDesignationSyntax": + case "XmlAttributeSyntax": + case "XmlNodeSyntax": + { + if (typeSymbol + .ContainingNamespace + .HasMetadataName(Microsoft_CodeAnalysis_CSharp_Syntax)) + { + return "Visit" + name.Remove(name.Length - 6); + } + + break; + } + } + + typeSymbol = typeSymbol.BaseType; + + } while (typeSymbol != null); + + throw new ArgumentException("", nameof(typeSymbol)); + } + + public virtual ConstructorDeclarationSyntax CreateConstructorDeclaration(SyntaxWalkerDepth depth) + { + return ConstructorDeclaration( + default(SyntaxList), + Modifiers.Protected(), + Identifier("CSharpSyntaxNodeWalker"), + ParameterList(), + BaseConstructorInitializer( + ArgumentList( + Argument( + NameColon("depth"), + SimpleMemberAccessExpression(IdentifierName("SyntaxWalkerDepth"), IdentifierName(depth.ToString()))))), + Block()); + } + + public virtual PropertyDeclarationSyntax CreateShouldVisitPropertyDeclaration() + { + return PropertyDeclaration( + Modifiers.Protected_Virtual(), + PredefinedBoolType(), + Identifier("ShouldVisit"), + AccessorList(GetAccessorDeclaration(Block(ReturnStatement(TrueLiteralExpression()))))); + } + + public virtual MethodDeclarationSyntax CreateVisitNodeMethodDeclaration() + { + return MethodDeclaration( + Modifiers.Public_Override(), + VoidType(), + Identifier("Visit"), + ParameterList(Parameter(IdentifierName("SyntaxNode"), "node")), + Block( + IfNotShouldVisitReturnStatement(), + ExpressionStatement( + SimpleMemberInvocationExpression( + BaseExpression(), + IdentifierName("Visit"), + ArgumentList(Argument(IdentifierName("node"))))))); + } + + public virtual MethodDeclarationSyntax CreateVisitListMethodDeclaration() + { + return MethodDeclaration( + default(SyntaxList), + Modifiers.Private(), + VoidType(), + default(ExplicitInterfaceSpecifierSyntax), + Identifier("VisitList"), + TypeParameterList(TypeParameter("TNode")), + ParameterList(Parameter(GenericName("SyntaxList", IdentifierName("TNode")), "list")), + SingletonList(TypeParameterConstraintClause("TNode", TypeConstraint(IdentifierName("SyntaxNode")))), + Block(ForEachVisitStatement( + "TNode", + "node", + IdentifierName("list"), + VisitStatement("Visit", "node"), + checkShouldVisit: true)), + default(ArrowExpressionClauseSyntax)); + } + + public virtual MethodDeclarationSyntax CreateVisitSeparatedListMethodDeclaration() + { + return MethodDeclaration( + default(SyntaxList), + Modifiers.Private(), + VoidType(), + default(ExplicitInterfaceSpecifierSyntax), + Identifier("VisitSeparatedList"), + TypeParameterList(TypeParameter("TNode")), + ParameterList(Parameter(GenericName("SeparatedSyntaxList", IdentifierName("TNode")), "list")), + SingletonList(TypeParameterConstraintClause("TNode", TypeConstraint(IdentifierName("SyntaxNode")))), + Block(ForEachVisitStatement( + "TNode", + "node", + IdentifierName("list"), + VisitStatement("Visit", "node"), + checkShouldVisit: true)), + default(ArrowExpressionClauseSyntax)); + } + + public virtual MethodDeclarationSyntax CreateVisitTokenListMethodDeclaration() + { + return MethodDeclaration( + Modifiers.Private(), + VoidType(), + Identifier("VisitTokenList"), + ParameterList(Parameter(IdentifierName("SyntaxTokenList"), "list")), + Block( + IfStatement( + SimpleMemberInvocationExpression(IdentifierName("list"), IdentifierName("Any")), + Block( + ForEachVisitStatement( + "SyntaxToken", + "token", + IdentifierName("list"), + VisitStatement("VisitToken", "token"), + checkShouldVisit: true))))); + } + + internal virtual MethodDeclarationSyntax CreateVisitAbstractSyntaxMethodDeclaration(MetadataName metadataName) + { + string name = metadataName.Name; + + return MethodDeclaration( + Modifiers.Protected_Virtual(), + VoidType(), + Identifier($"Visit{name.Remove(name.Length - 6)}"), + ParameterList(Parameter(IdentifierName(name), "node")), + Block( + SwitchStatement( + SimpleMemberInvocationExpression(IdentifierName("node"), IdentifierName("Kind")), + CreateSections().ToSyntaxList()))); + + IEnumerable CreateSections() + { + foreach (INamedTypeSymbol typeSymbol2 in SyntaxSymbols.Where(f => !f.IsAbstract && f.InheritsFrom(metadataName))) + { + string name2 = typeSymbol2.Name; + + SyntaxList labels = GetKinds(typeSymbol2) + .Select(f => CaseSwitchLabel(SimpleMemberAccessExpression(IdentifierName("SyntaxKind"), IdentifierName(f.ToString())))) + .ToSyntaxList(); + + yield return SwitchSection( + labels, + List(new StatementSyntax[] + { + ExpressionStatement( + InvocationExpression( + IdentifierName("Visit" + name2.Remove(name2.Length - 6)), + ArgumentList(Argument(CastExpression(IdentifierName(name2), IdentifierName("node")))))), + BreakStatement() + })); + } + + yield return DefaultSwitchSection( + List(new StatementSyntax[] + { + ExpressionStatement( + SimpleMemberInvocationExpression( + IdentifierName("Debug"), + IdentifierName("Fail"), + ArgumentList( + Argument( + ParseExpression(@"$""Unrecognized kind '{node.Kind()}'."""))))), + ExpressionStatement( + SimpleMemberInvocationExpression( + BaseExpression(), + IdentifierName("Visit"), + ArgumentList(Argument(IdentifierName("node"))))), + BreakStatement() + })); + } + } + } +} +#endif diff --git a/src/Tools/CodeGeneration/CSharp/SyntaxWalker/CSharpSyntaxWalkerGenerator.cs b/src/Tools/CodeGeneration/CSharp/SyntaxWalker/CSharpSyntaxWalkerGenerator.cs index 7490a79a65..0f7dd813e8 100644 --- a/src/Tools/CodeGeneration/CSharp/SyntaxWalker/CSharpSyntaxWalkerGenerator.cs +++ b/src/Tools/CodeGeneration/CSharp/SyntaxWalker/CSharpSyntaxWalkerGenerator.cs @@ -1,4 +1,5 @@ -// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +#if ROSLYN_4_7_ONLY +// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; @@ -586,3 +587,4 @@ IEnumerable CreateSections() } } } +#endif diff --git a/src/VisualStudio/CodeFixesOptionsPage.Generated.cs b/src/VisualStudio/CodeFixesOptionsPage.Generated.cs index ddf2689cf8..3063a7ca4f 100644 --- a/src/VisualStudio/CodeFixesOptionsPage.Generated.cs +++ b/src/VisualStudio/CodeFixesOptionsPage.Generated.cs @@ -4,7 +4,9 @@ using Roslynator.CSharp; -namespace Roslynator.VisualStudio; -public partial class CodeFixesOptionsPage +namespace Roslynator.VisualStudio { + public partial class CodeFixesOptionsPage + { + } } \ No newline at end of file diff --git a/src/VisualStudio/RefactoringsOptionsPage.Generated.cs b/src/VisualStudio/RefactoringsOptionsPage.Generated.cs index 56e690db33..8d44764c4b 100644 --- a/src/VisualStudio/RefactoringsOptionsPage.Generated.cs +++ b/src/VisualStudio/RefactoringsOptionsPage.Generated.cs @@ -5,209 +5,211 @@ using System.Collections.Generic; using Roslynator.CSharp.Refactorings; -namespace Roslynator.VisualStudio; -public partial class RefactoringsOptionsPage +namespace Roslynator.VisualStudio { - protected override void Fill(ICollection refactorings) + public partial class RefactoringsOptionsPage { - refactorings.Clear(); - refactorings.Add(new BaseModel(RefactoringIdentifiers.AddBraces, "Add braces", IsEnabled(RefactoringIdentifiers.AddBraces))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.AddBracesToIfElse, "Add braces to if-else", IsEnabled(RefactoringIdentifiers.AddBracesToIfElse))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.AddBracesToSwitchSection, "Add braces to switch section", IsEnabled(RefactoringIdentifiers.AddBracesToSwitchSection))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.AddBracesToSwitchSections, "Add braces to switch sections", IsEnabled(RefactoringIdentifiers.AddBracesToSwitchSections))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.AddDefaultValueToParameter, "Add default value to parameter", IsEnabled(RefactoringIdentifiers.AddDefaultValueToParameter))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.AddExceptionElementToDocumentationComment, "Add 'exception' element to documentation comment", IsEnabled(RefactoringIdentifiers.AddExceptionElementToDocumentationComment))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.AddArgumentName, "Add argument name", IsEnabled(RefactoringIdentifiers.AddArgumentName))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.AddUsingDirective, "Add using directive", IsEnabled(RefactoringIdentifiers.AddUsingDirective))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.AddUsingStaticDirective, "Add using static directive", IsEnabled(RefactoringIdentifiers.AddUsingStaticDirective))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.CallExtensionMethodAsInstanceMethod, "Call extension method as instance method", IsEnabled(RefactoringIdentifiers.CallExtensionMethodAsInstanceMethod))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.UseImplicitType, "Use implicit type", IsEnabled(RefactoringIdentifiers.UseImplicitType))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ChangeMethodReturnTypeToVoid, "Change method return type to 'void'", IsEnabled(RefactoringIdentifiers.ChangeMethodReturnTypeToVoid))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ChangeTypeAccordingToExpression, "Change type according to expression", IsEnabled(RefactoringIdentifiers.ChangeTypeAccordingToExpression))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.UseExplicitType, "Use explicit type", IsEnabled(RefactoringIdentifiers.UseExplicitType))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.CheckExpressionForNull, "Check expression for null", IsEnabled(RefactoringIdentifiers.CheckExpressionForNull))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.CheckParameterForNull, "Check parameter for null", IsEnabled(RefactoringIdentifiers.CheckParameterForNull))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.UseObjectInitializer, "Use object initializer", IsEnabled(RefactoringIdentifiers.UseObjectInitializer))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.CommentOutMemberDeclaration, "Comment out member declaration", IsEnabled(RefactoringIdentifiers.CommentOutMemberDeclaration))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.CommentOutStatement, "Comment out statement", IsEnabled(RefactoringIdentifiers.CommentOutStatement))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.CopyDocumentationCommentFromBaseMember, "Copy documentation comment from base member", IsEnabled(RefactoringIdentifiers.CopyDocumentationCommentFromBaseMember))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.CopyArgument, "Copy argument", IsEnabled(RefactoringIdentifiers.CopyArgument))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.CopyMemberDeclaration, "Copy member declaration", IsEnabled(RefactoringIdentifiers.CopyMemberDeclaration))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.CopyParameter, "Copy parameter", IsEnabled(RefactoringIdentifiers.CopyParameter))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.CopyStatement, "Copy statement", IsEnabled(RefactoringIdentifiers.CopyStatement))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ExpandCompoundAssignment, "Expand compound assignment", IsEnabled(RefactoringIdentifiers.ExpandCompoundAssignment))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ExpandCoalesceExpression, "Expand coalesce expression", IsEnabled(RefactoringIdentifiers.ExpandCoalesceExpression))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ExpandEventDeclaration, "Expand event declaration", IsEnabled(RefactoringIdentifiers.ExpandEventDeclaration))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertExpressionBodyToBlockBody, "Convert expression body to block body", IsEnabled(RefactoringIdentifiers.ConvertExpressionBodyToBlockBody))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ExpandInitializer, "Expand initializer", IsEnabled(RefactoringIdentifiers.ExpandInitializer))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertLambdaExpressionBodyToBlockBody, "Convert lambda expression body to block body", IsEnabled(RefactoringIdentifiers.ConvertLambdaExpressionBodyToBlockBody))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertAutoPropertyToFullPropertyWithoutBackingField, "Convert auto-property to full property (without backing field)", IsEnabled(RefactoringIdentifiers.ConvertAutoPropertyToFullPropertyWithoutBackingField))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertAutoPropertyToFullProperty, "Convert auto-property to full property", IsEnabled(RefactoringIdentifiers.ConvertAutoPropertyToFullProperty))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ExtractExpressionFromCondition, "Extract expression from condition", IsEnabled(RefactoringIdentifiers.ExtractExpressionFromCondition))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveContainingStatement, "Remove containing statement", IsEnabled(RefactoringIdentifiers.RemoveContainingStatement))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ExtractTypeDeclarationToNewFile, "Extract type declaration to a new file", IsEnabled(RefactoringIdentifiers.ExtractTypeDeclarationToNewFile))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapArguments, "Wrap arguments", IsEnabled(RefactoringIdentifiers.WrapArguments))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapBinaryExpression, "Wrap binary expression", IsEnabled(RefactoringIdentifiers.WrapBinaryExpression))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapConditionalExpression, "Wrap conditional expression", IsEnabled(RefactoringIdentifiers.WrapConditionalExpression))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapCallChain, "Wrap call chain", IsEnabled(RefactoringIdentifiers.WrapCallChain))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapInitializerExpressions, "Wrap initializer expressions", IsEnabled(RefactoringIdentifiers.WrapInitializerExpressions))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapParameters, "Wrap parameters", IsEnabled(RefactoringIdentifiers.WrapParameters))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.GenerateBaseConstructors, "Generate base constructors", IsEnabled(RefactoringIdentifiers.GenerateBaseConstructors))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.GenerateCombinedEnumMember, "Generate combined enum member", IsEnabled(RefactoringIdentifiers.GenerateCombinedEnumMember))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.GenerateEnumMember, "Generate enum member", IsEnabled(RefactoringIdentifiers.GenerateEnumMember))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.GenerateEnumValues, "Generate enum values", IsEnabled(RefactoringIdentifiers.GenerateEnumValues))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.GenerateEventInvokingMethod, "Generate event invoking method", IsEnabled(RefactoringIdentifiers.GenerateEventInvokingMethod))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.AddMissingCasesToSwitchStatement, "Add missing cases to switch statement", IsEnabled(RefactoringIdentifiers.AddMissingCasesToSwitchStatement))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.InitializeLocalVariableWithDefaultValue, "Initialize local variable with default value", IsEnabled(RefactoringIdentifiers.InitializeLocalVariableWithDefaultValue))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.InlineAliasExpression, "Inline alias expression", IsEnabled(RefactoringIdentifiers.InlineAliasExpression))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.InlineMethod, "Inline method", IsEnabled(RefactoringIdentifiers.InlineMethod))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.InsertStringInterpolation, "Insert string interpolation", IsEnabled(RefactoringIdentifiers.InsertStringInterpolation))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.IntroduceAndInitializeField, "Introduce and initialize field", IsEnabled(RefactoringIdentifiers.IntroduceAndInitializeField))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.IntroduceAndInitializeProperty, "Introduce and initialize property", IsEnabled(RefactoringIdentifiers.IntroduceAndInitializeProperty))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.IntroduceConstructor, "Introduce constructor", IsEnabled(RefactoringIdentifiers.IntroduceConstructor))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.IntroduceFieldToLockOn, "Introduce field to lock on", IsEnabled(RefactoringIdentifiers.IntroduceFieldToLockOn))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.IntroduceLocalVariable, "Introduce local variable", IsEnabled(RefactoringIdentifiers.IntroduceLocalVariable))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.MakeMemberAbstract, "Make member abstract", IsEnabled(RefactoringIdentifiers.MakeMemberAbstract))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.MakeMemberVirtual, "Make member virtual", IsEnabled(RefactoringIdentifiers.MakeMemberVirtual))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveUnnecessaryAssignment, "Remove unnecessary assignment", IsEnabled(RefactoringIdentifiers.RemoveUnnecessaryAssignment))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.MergeAttributes, "Merge attributes", IsEnabled(RefactoringIdentifiers.MergeAttributes))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.MergeIfStatements, "Merge 'if' statements", IsEnabled(RefactoringIdentifiers.MergeIfStatements))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.MergeLocalDeclarations, "Merge local declarations", IsEnabled(RefactoringIdentifiers.MergeLocalDeclarations))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.JoinStringExpressions, "Join string expressions", IsEnabled(RefactoringIdentifiers.JoinStringExpressions))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.InvertBinaryExpression, "Invert binary expression", IsEnabled(RefactoringIdentifiers.InvertBinaryExpression))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.InvertBooleanLiteral, "Invert boolean literal", IsEnabled(RefactoringIdentifiers.InvertBooleanLiteral))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.InvertIsExpression, "Invert is expression", IsEnabled(RefactoringIdentifiers.InvertIsExpression))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.InvertOperator, "Invert operator", IsEnabled(RefactoringIdentifiers.InvertOperator))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.NotifyWhenPropertyChanges, "Notify when property changes", IsEnabled(RefactoringIdentifiers.NotifyWhenPropertyChanges))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ParenthesizeExpression, "Parenthesize expression", IsEnabled(RefactoringIdentifiers.ParenthesizeExpression))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.PromoteLocalVariableToParameter, "Promote local variable to parameter", IsEnabled(RefactoringIdentifiers.PromoteLocalVariableToParameter))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveAllComments, "Remove all comments", IsEnabled(RefactoringIdentifiers.RemoveAllComments))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveAllCommentsExceptDocumentationComments, "Remove all comments (except documentation comments)", IsEnabled(RefactoringIdentifiers.RemoveAllCommentsExceptDocumentationComments))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveAllDocumentationComments, "Remove all documentation comments", IsEnabled(RefactoringIdentifiers.RemoveAllDocumentationComments))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveAllMemberDeclarations, "Remove all member declarations", IsEnabled(RefactoringIdentifiers.RemoveAllMemberDeclarations))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveAllPreprocessorDirectives, "Remove all preprocessor directives", IsEnabled(RefactoringIdentifiers.RemoveAllPreprocessorDirectives))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveAllRegionDirectives, "Remove all region directives", IsEnabled(RefactoringIdentifiers.RemoveAllRegionDirectives))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveAllStatements, "Remove all statements", IsEnabled(RefactoringIdentifiers.RemoveAllStatements))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveAllSwitchSections, "Remove all switch sections", IsEnabled(RefactoringIdentifiers.RemoveAllSwitchSections))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveBraces, "Remove braces", IsEnabled(RefactoringIdentifiers.RemoveBraces))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveBracesFromIfElse, "Remove braces from if-else", IsEnabled(RefactoringIdentifiers.RemoveBracesFromIfElse))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveBracesFromSwitchSection, "Remove braces from switch section", IsEnabled(RefactoringIdentifiers.RemoveBracesFromSwitchSection))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveBracesFromSwitchSections, "Remove braces from switch sections", IsEnabled(RefactoringIdentifiers.RemoveBracesFromSwitchSections))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveComment, "Remove comment", IsEnabled(RefactoringIdentifiers.RemoveComment))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveConditionFromLastElse, "Remove condition from last else clause", IsEnabled(RefactoringIdentifiers.RemoveConditionFromLastElse))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemovePreprocessorDirective, "Remove preprocessor directive", IsEnabled(RefactoringIdentifiers.RemovePreprocessorDirective))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveEmptyLines, "Remove empty lines", IsEnabled(RefactoringIdentifiers.RemoveEmptyLines))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveInterpolation, "Remove interpolation", IsEnabled(RefactoringIdentifiers.RemoveInterpolation))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveMemberDeclaration, "Remove member declaration", IsEnabled(RefactoringIdentifiers.RemoveMemberDeclaration))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveMemberDeclarations, "Remove member declarations above/below", IsEnabled(RefactoringIdentifiers.RemoveMemberDeclarations))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveArgumentName, "Remove argument name", IsEnabled(RefactoringIdentifiers.RemoveArgumentName))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveParentheses, "Remove parentheses", IsEnabled(RefactoringIdentifiers.RemoveParentheses))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemovePropertyInitializer, "Remove property initializer", IsEnabled(RefactoringIdentifiers.RemovePropertyInitializer))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveRegion, "Remove region", IsEnabled(RefactoringIdentifiers.RemoveRegion))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveStatement, "Remove statement", IsEnabled(RefactoringIdentifiers.RemoveStatement))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.MergeSwitchSections, "Merge switch sections", IsEnabled(RefactoringIdentifiers.MergeSwitchSections))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.SyncPropertyNameAndBackingFieldName, "Synchronize property name and backing field name", IsEnabled(RefactoringIdentifiers.SyncPropertyNameAndBackingFieldName))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RenameIdentifierAccordingToTypeName, "Rename identifier according to type name", IsEnabled(RefactoringIdentifiers.RenameIdentifierAccordingToTypeName))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RenameMethodAccordingToTypeName, "Rename method according to type name", IsEnabled(RefactoringIdentifiers.RenameMethodAccordingToTypeName))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RenameParameterAccordingToTypeName, "Rename parameter according to its type name", IsEnabled(RefactoringIdentifiers.RenameParameterAccordingToTypeName))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RenamePropertyAccordingToTypeName, "Rename property according to type name", IsEnabled(RefactoringIdentifiers.RenamePropertyAccordingToTypeName))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.InvertLinqMethodCall, "Invert LINQ method call", IsEnabled(RefactoringIdentifiers.InvertLinqMethodCall))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ReplaceAsExpressionWithExplicitCast, "Replace 'as' expression with explicit cast", IsEnabled(RefactoringIdentifiers.ReplaceAsExpressionWithExplicitCast))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ReplaceExplicitCastWithAsExpression, "Replace explicit cast expression 'as' expression", IsEnabled(RefactoringIdentifiers.ReplaceExplicitCastWithAsExpression))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ReplaceConditionalExpressionWithTrueOrFalseBranch, "Replace conditional expression with true/false branch", IsEnabled(RefactoringIdentifiers.ReplaceConditionalExpressionWithTrueOrFalseBranch))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertConditionalExpressionToIfElse, "Convert ?: to if-else", IsEnabled(RefactoringIdentifiers.ConvertConditionalExpressionToIfElse))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.UseReadOnlyFieldInsteadOfConstant, "Use read-only field instead of constant", IsEnabled(RefactoringIdentifiers.UseReadOnlyFieldInsteadOfConstant))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertDoToWhile, "Convert 'do' to 'while'", IsEnabled(RefactoringIdentifiers.ConvertDoToWhile))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ReplaceEqualityOperatorWithStringEquals, "Replace equality operator with string.Equals", IsEnabled(RefactoringIdentifiers.ReplaceEqualityOperatorWithStringEquals))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ReplaceEqualityOperatorWithStringIsNullOrEmpty, "Replace equality operator with string.IsNullOrEmpty", IsEnabled(RefactoringIdentifiers.ReplaceEqualityOperatorWithStringIsNullOrEmpty))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ReplaceEqualityOperatorWithStringIsNullOrWhiteSpace, "Replace equality operator with string.IsNullOrWhiteSpace", IsEnabled(RefactoringIdentifiers.ReplaceEqualityOperatorWithStringIsNullOrWhiteSpace))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.InlineConstantValue, "Inline constant value", IsEnabled(RefactoringIdentifiers.InlineConstantValue))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.UseConstantInsteadOfReadOnlyField, "Use constant instead of read-only field", IsEnabled(RefactoringIdentifiers.UseConstantInsteadOfReadOnlyField))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertForEachToFor, "Convert 'foreach' to 'for'", IsEnabled(RefactoringIdentifiers.ConvertForEachToFor))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertForToForEach, "Convert 'for' to 'foreach'", IsEnabled(RefactoringIdentifiers.ConvertForToForEach))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertForToWhile, "Convert 'for' to 'while'", IsEnabled(RefactoringIdentifiers.ConvertForToWhile))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertHexadecimalLiteralToDecimalLiteral, "Convert hexadecimal literal to decimal literal", IsEnabled(RefactoringIdentifiers.ConvertHexadecimalLiteralToDecimalLiteral))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertIfToSwitch, "Convert 'if' to 'switch'", IsEnabled(RefactoringIdentifiers.ConvertIfToSwitch))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.InvertPrefixOrPostfixUnaryOperator, "Invert prefix/postfix unary operator", IsEnabled(RefactoringIdentifiers.InvertPrefixOrPostfixUnaryOperator))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ReplaceInterpolatedStringWithInterpolationExpression, "Replace interpolated string with interpolation expression", IsEnabled(RefactoringIdentifiers.ReplaceInterpolatedStringWithInterpolationExpression))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertInterpolatedStringToStringLiteral, "Convert interpolated string to string literal", IsEnabled(RefactoringIdentifiers.ConvertInterpolatedStringToStringLiteral))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertMethodGroupToLambda, "Convert method group to lambda", IsEnabled(RefactoringIdentifiers.ConvertMethodGroupToLambda))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ReplaceMethodWithProperty, "Replace method with property", IsEnabled(RefactoringIdentifiers.ReplaceMethodWithProperty))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ReplaceNullLiteralWithDefaultExpression, "Replace 'null' with 'default(...)'", IsEnabled(RefactoringIdentifiers.ReplaceNullLiteralWithDefaultExpression))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ReplacePrefixOperatorWithPostfixOperator, "Replace prefix operator to postfix operator", IsEnabled(RefactoringIdentifiers.ReplacePrefixOperatorWithPostfixOperator))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ReplacePropertyWithMethod, "Replace property with method", IsEnabled(RefactoringIdentifiers.ReplacePropertyWithMethod))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertRegularStringLiteralToVerbatimStringLiteral, "Convert regular string literal to verbatim string literal", IsEnabled(RefactoringIdentifiers.ConvertRegularStringLiteralToVerbatimStringLiteral))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertReturnStatementToIf, "Convert 'return' statement to 'if'", IsEnabled(RefactoringIdentifiers.ConvertReturnStatementToIf))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.CallIndexOfInsteadOfContains, "Call string.IndexOf instead of string.Contains", IsEnabled(RefactoringIdentifiers.CallIndexOfInsteadOfContains))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertStringFormatToInterpolatedString, "Convert 'string.Format' to interpolated string", IsEnabled(RefactoringIdentifiers.ConvertStringFormatToInterpolatedString))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertSwitchToIf, "Convert 'switch' to 'if'", IsEnabled(RefactoringIdentifiers.ConvertSwitchToIf))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertVerbatimStringLiteralToRegularStringLiteral, "Convert verbatim string literal to regular string literal", IsEnabled(RefactoringIdentifiers.ConvertVerbatimStringLiteralToRegularStringLiteral))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertVerbatimStringLiteralToRegularStringLiterals, "Convert verbatim string literal to regular string literals", IsEnabled(RefactoringIdentifiers.ConvertVerbatimStringLiteralToRegularStringLiterals))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertWhileToDo, "Convert 'while' statement to 'do' statement", IsEnabled(RefactoringIdentifiers.ConvertWhileToDo))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertWhileToFor, "Convert 'while' statement to 'for' statement", IsEnabled(RefactoringIdentifiers.ConvertWhileToFor))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ReverseForStatement, "Reverse 'for' statement", IsEnabled(RefactoringIdentifiers.ReverseForStatement))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.SimplifyIf, "Simplify if", IsEnabled(RefactoringIdentifiers.SimplifyIf))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertLambdaBlockBodyToExpressionBody, "Convert lambda block body to expression body", IsEnabled(RefactoringIdentifiers.ConvertLambdaBlockBodyToExpressionBody))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.SortMemberDeclarations, "Sort member declarations", IsEnabled(RefactoringIdentifiers.SortMemberDeclarations))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.SplitAttributes, "Split attributes", IsEnabled(RefactoringIdentifiers.SplitAttributes))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.SplitSwitchLabels, "Split switch labels", IsEnabled(RefactoringIdentifiers.SplitSwitchLabels))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.SplitVariableDeclaration, "Split variable declaration", IsEnabled(RefactoringIdentifiers.SplitVariableDeclaration))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.SwapBinaryOperands, "Swap binary operands", IsEnabled(RefactoringIdentifiers.SwapBinaryOperands))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.InvertConditionalExpression, "Invert conditional expression", IsEnabled(RefactoringIdentifiers.InvertConditionalExpression))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.SwapMemberDeclarations, "Swap member declarations", IsEnabled(RefactoringIdentifiers.SwapMemberDeclarations))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.InvertIfElse, "Invert if-else", IsEnabled(RefactoringIdentifiers.InvertIfElse))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.UncommentSingleLineComment, "Uncomment single-line comment", IsEnabled(RefactoringIdentifiers.UncommentSingleLineComment))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertHasFlagCallToBitwiseOperation, "Convert 'HasFlag' call to bitwise operation", IsEnabled(RefactoringIdentifiers.ConvertHasFlagCallToBitwiseOperation))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.UseCoalesceExpressionInsteadOfIf, "Use coalesce expression instead of if", IsEnabled(RefactoringIdentifiers.UseCoalesceExpressionInsteadOfIf))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertIfToConditionalExpression, "Convert 'if' to ?:", IsEnabled(RefactoringIdentifiers.ConvertIfToConditionalExpression))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.UseElementAccessInsteadOfLinqMethod, "Use element access instead of LINQ method", IsEnabled(RefactoringIdentifiers.UseElementAccessInsteadOfLinqMethod))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertBlockBodyToExpressionBody, "Convert block body to expression body", IsEnabled(RefactoringIdentifiers.ConvertBlockBodyToExpressionBody))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.UseLambdaInsteadOfAnonymousMethod, "Use lambda instead of anonymous method", IsEnabled(RefactoringIdentifiers.UseLambdaInsteadOfAnonymousMethod))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.UseStringEmptyInsteadOfEmptyStringLiteral, "Convert \"\" to string.Empty", IsEnabled(RefactoringIdentifiers.UseStringEmptyInsteadOfEmptyStringLiteral))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapStatementsInCondition, "Wrap statements in condition", IsEnabled(RefactoringIdentifiers.WrapStatementsInCondition))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapLinesInPreprocessorDirective, "Wrap lines in preprocessor directive", IsEnabled(RefactoringIdentifiers.WrapLinesInPreprocessorDirective))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapLinesInRegion, "Wrap lines in #region directive", IsEnabled(RefactoringIdentifiers.WrapLinesInRegion))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapLinesInTryCatch, "Wrap lines in try-catch", IsEnabled(RefactoringIdentifiers.WrapLinesInTryCatch))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapStatementsInUsingStatement, "Wrap statements in 'using' statement", IsEnabled(RefactoringIdentifiers.WrapStatementsInUsingStatement))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.AddGenericParameterToDeclaration, "Add generic parameter to a declaration", IsEnabled(RefactoringIdentifiers.AddGenericParameterToDeclaration))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ImplementIEquatableOfT, "Implement IEquatable", IsEnabled(RefactoringIdentifiers.ImplementIEquatableOfT))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.InlineUsingStaticDirective, "Inline using static directive", IsEnabled(RefactoringIdentifiers.InlineUsingStaticDirective))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.InlineConstantDeclaration, "Inline constant declaration", IsEnabled(RefactoringIdentifiers.InlineConstantDeclaration))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.UseStringBuilderInsteadOfConcatenation, "Use StringBuilder instead of concatenation", IsEnabled(RefactoringIdentifiers.UseStringBuilderInsteadOfConcatenation))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.UseListInsteadOfYield, "Use List instead of yield", IsEnabled(RefactoringIdentifiers.UseListInsteadOfYield))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.SplitIf, "Split if", IsEnabled(RefactoringIdentifiers.SplitIf))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveInstantiationOfLocalVariable, "Remove instantiation of a local variable", IsEnabled(RefactoringIdentifiers.RemoveInstantiationOfLocalVariable))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ChangeAccessibility, "Change accessibility", IsEnabled(RefactoringIdentifiers.ChangeAccessibility))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapConstraintClauses, "Wrap constraint clauses", IsEnabled(RefactoringIdentifiers.WrapConstraintClauses))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertForEachToForAndReverseLoop, "Convert 'foreach' to 'for' and reverse loop", IsEnabled(RefactoringIdentifiers.ConvertForEachToForAndReverseLoop))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.InvertIf, "Invert if", IsEnabled(RefactoringIdentifiers.InvertIf))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.SplitIfElse, "Split if-else", IsEnabled(RefactoringIdentifiers.SplitIfElse))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.UseIndexInitializer, "Use index initializer", IsEnabled(RefactoringIdentifiers.UseIndexInitializer))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertCommentToDocumentationComment, "Convert comment to documentation comment", IsEnabled(RefactoringIdentifiers.ConvertCommentToDocumentationComment))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertInterpolatedStringToConcatenation, "Convert interpolated string to concatenation", IsEnabled(RefactoringIdentifiers.ConvertInterpolatedStringToConcatenation))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.SplitLocalDeclarationAndAssignment, "Split local declaration and assignment", IsEnabled(RefactoringIdentifiers.SplitLocalDeclarationAndAssignment))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.AddMemberToInterface, "Add member to interface", IsEnabled(RefactoringIdentifiers.AddMemberToInterface))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.MergeIfWithParentIf, "Merge if with parent if", IsEnabled(RefactoringIdentifiers.MergeIfWithParentIf))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.InitializeFieldFromConstructor, "Initialize field from constructor", IsEnabled(RefactoringIdentifiers.InitializeFieldFromConstructor))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.InlineProperty, "Inline property", IsEnabled(RefactoringIdentifiers.InlineProperty))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveEnumMemberValue, "Remove enum member value(s)", IsEnabled(RefactoringIdentifiers.RemoveEnumMemberValue))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.UncommentMultiLineComment, "Uncomment multi-line comment", IsEnabled(RefactoringIdentifiers.UncommentMultiLineComment))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertInterpolatedStringToStringFormat, "Convert interpolated string to 'string.Format'", IsEnabled(RefactoringIdentifiers.ConvertInterpolatedStringToStringFormat))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.MoveUnsafeContextToContainingDeclaration, "Move unsafe context to containing declaration", IsEnabled(RefactoringIdentifiers.MoveUnsafeContextToContainingDeclaration))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ExtractEventHandlerMethod, "Extract event handler method", IsEnabled(RefactoringIdentifiers.ExtractEventHandlerMethod))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.GeneratePropertyForDebuggerDisplayAttribute, "Generate property for DebuggerDisplay attribute", IsEnabled(RefactoringIdentifiers.GeneratePropertyForDebuggerDisplayAttribute))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.AddEmptyLineBetweenDeclarations, "Add empty line between declarations", IsEnabled(RefactoringIdentifiers.AddEmptyLineBetweenDeclarations))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.UseEnumeratorExplicitly, "Use enumerator explicitly", IsEnabled(RefactoringIdentifiers.UseEnumeratorExplicitly))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.SortCaseLabels, "Sort case labels", IsEnabled(RefactoringIdentifiers.SortCaseLabels))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.AddTagToDocumentationComment, "Add tag to documentation comment", IsEnabled(RefactoringIdentifiers.AddTagToDocumentationComment))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveAsyncAwait, "Remove async/await", IsEnabled(RefactoringIdentifiers.RemoveAsyncAwait))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ImplementCustomEnumerator, "Implement custom enumerator", IsEnabled(RefactoringIdentifiers.ImplementCustomEnumerator))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertStatementsToIfElse, "Convert statements to if-else", IsEnabled(RefactoringIdentifiers.ConvertStatementsToIfElse))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.CopySwitchSection, "Copy switch section", IsEnabled(RefactoringIdentifiers.CopySwitchSection))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.AddParameterToInterfaceMember, "Add parameter to interface member", IsEnabled(RefactoringIdentifiers.AddParameterToInterfaceMember))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertSwitchExpressionToSwitchStatement, "Convert 'switch' expression to 'switch' statement", IsEnabled(RefactoringIdentifiers.ConvertSwitchExpressionToSwitchStatement))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.ExpandPositionalConstructor, "Expand positional constructor", IsEnabled(RefactoringIdentifiers.ExpandPositionalConstructor))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.AddAllPropertiesToInitializer, "Add all properties to initializer", IsEnabled(RefactoringIdentifiers.AddAllPropertiesToInitializer))); - refactorings.Add(new BaseModel(RefactoringIdentifiers.DeconstructForeachVariable, "Deconstruct foreach variable", IsEnabled(RefactoringIdentifiers.DeconstructForeachVariable))); + protected override void Fill(ICollection refactorings) + { + refactorings.Clear(); + refactorings.Add(new BaseModel(RefactoringIdentifiers.AddBraces, "Add braces", IsEnabled(RefactoringIdentifiers.AddBraces))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.AddBracesToIfElse, "Add braces to if-else", IsEnabled(RefactoringIdentifiers.AddBracesToIfElse))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.AddBracesToSwitchSection, "Add braces to switch section", IsEnabled(RefactoringIdentifiers.AddBracesToSwitchSection))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.AddBracesToSwitchSections, "Add braces to switch sections", IsEnabled(RefactoringIdentifiers.AddBracesToSwitchSections))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.AddDefaultValueToParameter, "Add default value to parameter", IsEnabled(RefactoringIdentifiers.AddDefaultValueToParameter))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.AddExceptionElementToDocumentationComment, "Add 'exception' element to documentation comment", IsEnabled(RefactoringIdentifiers.AddExceptionElementToDocumentationComment))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.AddArgumentName, "Add argument name", IsEnabled(RefactoringIdentifiers.AddArgumentName))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.AddUsingDirective, "Add using directive", IsEnabled(RefactoringIdentifiers.AddUsingDirective))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.AddUsingStaticDirective, "Add using static directive", IsEnabled(RefactoringIdentifiers.AddUsingStaticDirective))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.CallExtensionMethodAsInstanceMethod, "Call extension method as instance method", IsEnabled(RefactoringIdentifiers.CallExtensionMethodAsInstanceMethod))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.UseImplicitType, "Use implicit type", IsEnabled(RefactoringIdentifiers.UseImplicitType))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ChangeMethodReturnTypeToVoid, "Change method return type to 'void'", IsEnabled(RefactoringIdentifiers.ChangeMethodReturnTypeToVoid))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ChangeTypeAccordingToExpression, "Change type according to expression", IsEnabled(RefactoringIdentifiers.ChangeTypeAccordingToExpression))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.UseExplicitType, "Use explicit type", IsEnabled(RefactoringIdentifiers.UseExplicitType))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.CheckExpressionForNull, "Check expression for null", IsEnabled(RefactoringIdentifiers.CheckExpressionForNull))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.CheckParameterForNull, "Check parameter for null", IsEnabled(RefactoringIdentifiers.CheckParameterForNull))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.UseObjectInitializer, "Use object initializer", IsEnabled(RefactoringIdentifiers.UseObjectInitializer))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.CommentOutMemberDeclaration, "Comment out member declaration", IsEnabled(RefactoringIdentifiers.CommentOutMemberDeclaration))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.CommentOutStatement, "Comment out statement", IsEnabled(RefactoringIdentifiers.CommentOutStatement))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.CopyDocumentationCommentFromBaseMember, "Copy documentation comment from base member", IsEnabled(RefactoringIdentifiers.CopyDocumentationCommentFromBaseMember))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.CopyArgument, "Copy argument", IsEnabled(RefactoringIdentifiers.CopyArgument))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.CopyMemberDeclaration, "Copy member declaration", IsEnabled(RefactoringIdentifiers.CopyMemberDeclaration))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.CopyParameter, "Copy parameter", IsEnabled(RefactoringIdentifiers.CopyParameter))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.CopyStatement, "Copy statement", IsEnabled(RefactoringIdentifiers.CopyStatement))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ExpandCompoundAssignment, "Expand compound assignment", IsEnabled(RefactoringIdentifiers.ExpandCompoundAssignment))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ExpandCoalesceExpression, "Expand coalesce expression", IsEnabled(RefactoringIdentifiers.ExpandCoalesceExpression))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ExpandEventDeclaration, "Expand event declaration", IsEnabled(RefactoringIdentifiers.ExpandEventDeclaration))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertExpressionBodyToBlockBody, "Convert expression body to block body", IsEnabled(RefactoringIdentifiers.ConvertExpressionBodyToBlockBody))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ExpandInitializer, "Expand initializer", IsEnabled(RefactoringIdentifiers.ExpandInitializer))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertLambdaExpressionBodyToBlockBody, "Convert lambda expression body to block body", IsEnabled(RefactoringIdentifiers.ConvertLambdaExpressionBodyToBlockBody))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertAutoPropertyToFullPropertyWithoutBackingField, "Convert auto-property to full property (without backing field)", IsEnabled(RefactoringIdentifiers.ConvertAutoPropertyToFullPropertyWithoutBackingField))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertAutoPropertyToFullProperty, "Convert auto-property to full property", IsEnabled(RefactoringIdentifiers.ConvertAutoPropertyToFullProperty))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ExtractExpressionFromCondition, "Extract expression from condition", IsEnabled(RefactoringIdentifiers.ExtractExpressionFromCondition))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveContainingStatement, "Remove containing statement", IsEnabled(RefactoringIdentifiers.RemoveContainingStatement))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ExtractTypeDeclarationToNewFile, "Extract type declaration to a new file", IsEnabled(RefactoringIdentifiers.ExtractTypeDeclarationToNewFile))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapArguments, "Wrap arguments", IsEnabled(RefactoringIdentifiers.WrapArguments))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapBinaryExpression, "Wrap binary expression", IsEnabled(RefactoringIdentifiers.WrapBinaryExpression))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapConditionalExpression, "Wrap conditional expression", IsEnabled(RefactoringIdentifiers.WrapConditionalExpression))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapCallChain, "Wrap call chain", IsEnabled(RefactoringIdentifiers.WrapCallChain))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapInitializerExpressions, "Wrap initializer expressions", IsEnabled(RefactoringIdentifiers.WrapInitializerExpressions))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapParameters, "Wrap parameters", IsEnabled(RefactoringIdentifiers.WrapParameters))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.GenerateBaseConstructors, "Generate base constructors", IsEnabled(RefactoringIdentifiers.GenerateBaseConstructors))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.GenerateCombinedEnumMember, "Generate combined enum member", IsEnabled(RefactoringIdentifiers.GenerateCombinedEnumMember))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.GenerateEnumMember, "Generate enum member", IsEnabled(RefactoringIdentifiers.GenerateEnumMember))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.GenerateEnumValues, "Generate enum values", IsEnabled(RefactoringIdentifiers.GenerateEnumValues))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.GenerateEventInvokingMethod, "Generate event invoking method", IsEnabled(RefactoringIdentifiers.GenerateEventInvokingMethod))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.AddMissingCasesToSwitchStatement, "Add missing cases to switch statement", IsEnabled(RefactoringIdentifiers.AddMissingCasesToSwitchStatement))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.InitializeLocalVariableWithDefaultValue, "Initialize local variable with default value", IsEnabled(RefactoringIdentifiers.InitializeLocalVariableWithDefaultValue))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.InlineAliasExpression, "Inline alias expression", IsEnabled(RefactoringIdentifiers.InlineAliasExpression))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.InlineMethod, "Inline method", IsEnabled(RefactoringIdentifiers.InlineMethod))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.InsertStringInterpolation, "Insert string interpolation", IsEnabled(RefactoringIdentifiers.InsertStringInterpolation))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.IntroduceAndInitializeField, "Introduce and initialize field", IsEnabled(RefactoringIdentifiers.IntroduceAndInitializeField))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.IntroduceAndInitializeProperty, "Introduce and initialize property", IsEnabled(RefactoringIdentifiers.IntroduceAndInitializeProperty))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.IntroduceConstructor, "Introduce constructor", IsEnabled(RefactoringIdentifiers.IntroduceConstructor))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.IntroduceFieldToLockOn, "Introduce field to lock on", IsEnabled(RefactoringIdentifiers.IntroduceFieldToLockOn))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.IntroduceLocalVariable, "Introduce local variable", IsEnabled(RefactoringIdentifiers.IntroduceLocalVariable))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.MakeMemberAbstract, "Make member abstract", IsEnabled(RefactoringIdentifiers.MakeMemberAbstract))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.MakeMemberVirtual, "Make member virtual", IsEnabled(RefactoringIdentifiers.MakeMemberVirtual))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveUnnecessaryAssignment, "Remove unnecessary assignment", IsEnabled(RefactoringIdentifiers.RemoveUnnecessaryAssignment))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.MergeAttributes, "Merge attributes", IsEnabled(RefactoringIdentifiers.MergeAttributes))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.MergeIfStatements, "Merge 'if' statements", IsEnabled(RefactoringIdentifiers.MergeIfStatements))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.MergeLocalDeclarations, "Merge local declarations", IsEnabled(RefactoringIdentifiers.MergeLocalDeclarations))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.JoinStringExpressions, "Join string expressions", IsEnabled(RefactoringIdentifiers.JoinStringExpressions))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.InvertBinaryExpression, "Invert binary expression", IsEnabled(RefactoringIdentifiers.InvertBinaryExpression))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.InvertBooleanLiteral, "Invert boolean literal", IsEnabled(RefactoringIdentifiers.InvertBooleanLiteral))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.InvertIsExpression, "Invert is expression", IsEnabled(RefactoringIdentifiers.InvertIsExpression))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.InvertOperator, "Invert operator", IsEnabled(RefactoringIdentifiers.InvertOperator))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.NotifyWhenPropertyChanges, "Notify when property changes", IsEnabled(RefactoringIdentifiers.NotifyWhenPropertyChanges))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ParenthesizeExpression, "Parenthesize expression", IsEnabled(RefactoringIdentifiers.ParenthesizeExpression))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.PromoteLocalVariableToParameter, "Promote local variable to parameter", IsEnabled(RefactoringIdentifiers.PromoteLocalVariableToParameter))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveAllComments, "Remove all comments", IsEnabled(RefactoringIdentifiers.RemoveAllComments))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveAllCommentsExceptDocumentationComments, "Remove all comments (except documentation comments)", IsEnabled(RefactoringIdentifiers.RemoveAllCommentsExceptDocumentationComments))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveAllDocumentationComments, "Remove all documentation comments", IsEnabled(RefactoringIdentifiers.RemoveAllDocumentationComments))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveAllMemberDeclarations, "Remove all member declarations", IsEnabled(RefactoringIdentifiers.RemoveAllMemberDeclarations))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveAllPreprocessorDirectives, "Remove all preprocessor directives", IsEnabled(RefactoringIdentifiers.RemoveAllPreprocessorDirectives))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveAllRegionDirectives, "Remove all region directives", IsEnabled(RefactoringIdentifiers.RemoveAllRegionDirectives))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveAllStatements, "Remove all statements", IsEnabled(RefactoringIdentifiers.RemoveAllStatements))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveAllSwitchSections, "Remove all switch sections", IsEnabled(RefactoringIdentifiers.RemoveAllSwitchSections))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveBraces, "Remove braces", IsEnabled(RefactoringIdentifiers.RemoveBraces))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveBracesFromIfElse, "Remove braces from if-else", IsEnabled(RefactoringIdentifiers.RemoveBracesFromIfElse))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveBracesFromSwitchSection, "Remove braces from switch section", IsEnabled(RefactoringIdentifiers.RemoveBracesFromSwitchSection))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveBracesFromSwitchSections, "Remove braces from switch sections", IsEnabled(RefactoringIdentifiers.RemoveBracesFromSwitchSections))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveComment, "Remove comment", IsEnabled(RefactoringIdentifiers.RemoveComment))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveConditionFromLastElse, "Remove condition from last else clause", IsEnabled(RefactoringIdentifiers.RemoveConditionFromLastElse))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemovePreprocessorDirective, "Remove preprocessor directive", IsEnabled(RefactoringIdentifiers.RemovePreprocessorDirective))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveEmptyLines, "Remove empty lines", IsEnabled(RefactoringIdentifiers.RemoveEmptyLines))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveInterpolation, "Remove interpolation", IsEnabled(RefactoringIdentifiers.RemoveInterpolation))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveMemberDeclaration, "Remove member declaration", IsEnabled(RefactoringIdentifiers.RemoveMemberDeclaration))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveMemberDeclarations, "Remove member declarations above/below", IsEnabled(RefactoringIdentifiers.RemoveMemberDeclarations))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveArgumentName, "Remove argument name", IsEnabled(RefactoringIdentifiers.RemoveArgumentName))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveParentheses, "Remove parentheses", IsEnabled(RefactoringIdentifiers.RemoveParentheses))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemovePropertyInitializer, "Remove property initializer", IsEnabled(RefactoringIdentifiers.RemovePropertyInitializer))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveRegion, "Remove region", IsEnabled(RefactoringIdentifiers.RemoveRegion))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveStatement, "Remove statement", IsEnabled(RefactoringIdentifiers.RemoveStatement))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.MergeSwitchSections, "Merge switch sections", IsEnabled(RefactoringIdentifiers.MergeSwitchSections))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.SyncPropertyNameAndBackingFieldName, "Synchronize property name and backing field name", IsEnabled(RefactoringIdentifiers.SyncPropertyNameAndBackingFieldName))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RenameIdentifierAccordingToTypeName, "Rename identifier according to type name", IsEnabled(RefactoringIdentifiers.RenameIdentifierAccordingToTypeName))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RenameMethodAccordingToTypeName, "Rename method according to type name", IsEnabled(RefactoringIdentifiers.RenameMethodAccordingToTypeName))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RenameParameterAccordingToTypeName, "Rename parameter according to its type name", IsEnabled(RefactoringIdentifiers.RenameParameterAccordingToTypeName))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RenamePropertyAccordingToTypeName, "Rename property according to type name", IsEnabled(RefactoringIdentifiers.RenamePropertyAccordingToTypeName))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.InvertLinqMethodCall, "Invert LINQ method call", IsEnabled(RefactoringIdentifiers.InvertLinqMethodCall))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ReplaceAsExpressionWithExplicitCast, "Replace 'as' expression with explicit cast", IsEnabled(RefactoringIdentifiers.ReplaceAsExpressionWithExplicitCast))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ReplaceExplicitCastWithAsExpression, "Replace explicit cast expression 'as' expression", IsEnabled(RefactoringIdentifiers.ReplaceExplicitCastWithAsExpression))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ReplaceConditionalExpressionWithTrueOrFalseBranch, "Replace conditional expression with true/false branch", IsEnabled(RefactoringIdentifiers.ReplaceConditionalExpressionWithTrueOrFalseBranch))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertConditionalExpressionToIfElse, "Convert ?: to if-else", IsEnabled(RefactoringIdentifiers.ConvertConditionalExpressionToIfElse))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.UseReadOnlyFieldInsteadOfConstant, "Use read-only field instead of constant", IsEnabled(RefactoringIdentifiers.UseReadOnlyFieldInsteadOfConstant))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertDoToWhile, "Convert 'do' to 'while'", IsEnabled(RefactoringIdentifiers.ConvertDoToWhile))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ReplaceEqualityOperatorWithStringEquals, "Replace equality operator with string.Equals", IsEnabled(RefactoringIdentifiers.ReplaceEqualityOperatorWithStringEquals))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ReplaceEqualityOperatorWithStringIsNullOrEmpty, "Replace equality operator with string.IsNullOrEmpty", IsEnabled(RefactoringIdentifiers.ReplaceEqualityOperatorWithStringIsNullOrEmpty))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ReplaceEqualityOperatorWithStringIsNullOrWhiteSpace, "Replace equality operator with string.IsNullOrWhiteSpace", IsEnabled(RefactoringIdentifiers.ReplaceEqualityOperatorWithStringIsNullOrWhiteSpace))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.InlineConstantValue, "Inline constant value", IsEnabled(RefactoringIdentifiers.InlineConstantValue))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.UseConstantInsteadOfReadOnlyField, "Use constant instead of read-only field", IsEnabled(RefactoringIdentifiers.UseConstantInsteadOfReadOnlyField))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertForEachToFor, "Convert 'foreach' to 'for'", IsEnabled(RefactoringIdentifiers.ConvertForEachToFor))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertForToForEach, "Convert 'for' to 'foreach'", IsEnabled(RefactoringIdentifiers.ConvertForToForEach))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertForToWhile, "Convert 'for' to 'while'", IsEnabled(RefactoringIdentifiers.ConvertForToWhile))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertHexadecimalLiteralToDecimalLiteral, "Convert hexadecimal literal to decimal literal", IsEnabled(RefactoringIdentifiers.ConvertHexadecimalLiteralToDecimalLiteral))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertIfToSwitch, "Convert 'if' to 'switch'", IsEnabled(RefactoringIdentifiers.ConvertIfToSwitch))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.InvertPrefixOrPostfixUnaryOperator, "Invert prefix/postfix unary operator", IsEnabled(RefactoringIdentifiers.InvertPrefixOrPostfixUnaryOperator))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ReplaceInterpolatedStringWithInterpolationExpression, "Replace interpolated string with interpolation expression", IsEnabled(RefactoringIdentifiers.ReplaceInterpolatedStringWithInterpolationExpression))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertInterpolatedStringToStringLiteral, "Convert interpolated string to string literal", IsEnabled(RefactoringIdentifiers.ConvertInterpolatedStringToStringLiteral))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertMethodGroupToLambda, "Convert method group to lambda", IsEnabled(RefactoringIdentifiers.ConvertMethodGroupToLambda))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ReplaceMethodWithProperty, "Replace method with property", IsEnabled(RefactoringIdentifiers.ReplaceMethodWithProperty))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ReplaceNullLiteralWithDefaultExpression, "Replace 'null' with 'default(...)'", IsEnabled(RefactoringIdentifiers.ReplaceNullLiteralWithDefaultExpression))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ReplacePrefixOperatorWithPostfixOperator, "Replace prefix operator to postfix operator", IsEnabled(RefactoringIdentifiers.ReplacePrefixOperatorWithPostfixOperator))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ReplacePropertyWithMethod, "Replace property with method", IsEnabled(RefactoringIdentifiers.ReplacePropertyWithMethod))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertRegularStringLiteralToVerbatimStringLiteral, "Convert regular string literal to verbatim string literal", IsEnabled(RefactoringIdentifiers.ConvertRegularStringLiteralToVerbatimStringLiteral))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertReturnStatementToIf, "Convert 'return' statement to 'if'", IsEnabled(RefactoringIdentifiers.ConvertReturnStatementToIf))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.CallIndexOfInsteadOfContains, "Call string.IndexOf instead of string.Contains", IsEnabled(RefactoringIdentifiers.CallIndexOfInsteadOfContains))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertStringFormatToInterpolatedString, "Convert 'string.Format' to interpolated string", IsEnabled(RefactoringIdentifiers.ConvertStringFormatToInterpolatedString))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertSwitchToIf, "Convert 'switch' to 'if'", IsEnabled(RefactoringIdentifiers.ConvertSwitchToIf))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertVerbatimStringLiteralToRegularStringLiteral, "Convert verbatim string literal to regular string literal", IsEnabled(RefactoringIdentifiers.ConvertVerbatimStringLiteralToRegularStringLiteral))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertVerbatimStringLiteralToRegularStringLiterals, "Convert verbatim string literal to regular string literals", IsEnabled(RefactoringIdentifiers.ConvertVerbatimStringLiteralToRegularStringLiterals))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertWhileToDo, "Convert 'while' statement to 'do' statement", IsEnabled(RefactoringIdentifiers.ConvertWhileToDo))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertWhileToFor, "Convert 'while' statement to 'for' statement", IsEnabled(RefactoringIdentifiers.ConvertWhileToFor))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ReverseForStatement, "Reverse 'for' statement", IsEnabled(RefactoringIdentifiers.ReverseForStatement))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.SimplifyIf, "Simplify if", IsEnabled(RefactoringIdentifiers.SimplifyIf))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertLambdaBlockBodyToExpressionBody, "Convert lambda block body to expression body", IsEnabled(RefactoringIdentifiers.ConvertLambdaBlockBodyToExpressionBody))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.SortMemberDeclarations, "Sort member declarations", IsEnabled(RefactoringIdentifiers.SortMemberDeclarations))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.SplitAttributes, "Split attributes", IsEnabled(RefactoringIdentifiers.SplitAttributes))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.SplitSwitchLabels, "Split switch labels", IsEnabled(RefactoringIdentifiers.SplitSwitchLabels))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.SplitVariableDeclaration, "Split variable declaration", IsEnabled(RefactoringIdentifiers.SplitVariableDeclaration))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.SwapBinaryOperands, "Swap binary operands", IsEnabled(RefactoringIdentifiers.SwapBinaryOperands))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.InvertConditionalExpression, "Invert conditional expression", IsEnabled(RefactoringIdentifiers.InvertConditionalExpression))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.SwapMemberDeclarations, "Swap member declarations", IsEnabled(RefactoringIdentifiers.SwapMemberDeclarations))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.InvertIfElse, "Invert if-else", IsEnabled(RefactoringIdentifiers.InvertIfElse))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.UncommentSingleLineComment, "Uncomment single-line comment", IsEnabled(RefactoringIdentifiers.UncommentSingleLineComment))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertHasFlagCallToBitwiseOperation, "Convert 'HasFlag' call to bitwise operation", IsEnabled(RefactoringIdentifiers.ConvertHasFlagCallToBitwiseOperation))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.UseCoalesceExpressionInsteadOfIf, "Use coalesce expression instead of if", IsEnabled(RefactoringIdentifiers.UseCoalesceExpressionInsteadOfIf))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertIfToConditionalExpression, "Convert 'if' to ?:", IsEnabled(RefactoringIdentifiers.ConvertIfToConditionalExpression))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.UseElementAccessInsteadOfLinqMethod, "Use element access instead of LINQ method", IsEnabled(RefactoringIdentifiers.UseElementAccessInsteadOfLinqMethod))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertBlockBodyToExpressionBody, "Convert block body to expression body", IsEnabled(RefactoringIdentifiers.ConvertBlockBodyToExpressionBody))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.UseLambdaInsteadOfAnonymousMethod, "Use lambda instead of anonymous method", IsEnabled(RefactoringIdentifiers.UseLambdaInsteadOfAnonymousMethod))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.UseStringEmptyInsteadOfEmptyStringLiteral, "Convert \"\" to string.Empty", IsEnabled(RefactoringIdentifiers.UseStringEmptyInsteadOfEmptyStringLiteral))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapStatementsInCondition, "Wrap statements in condition", IsEnabled(RefactoringIdentifiers.WrapStatementsInCondition))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapLinesInPreprocessorDirective, "Wrap lines in preprocessor directive", IsEnabled(RefactoringIdentifiers.WrapLinesInPreprocessorDirective))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapLinesInRegion, "Wrap lines in #region directive", IsEnabled(RefactoringIdentifiers.WrapLinesInRegion))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapLinesInTryCatch, "Wrap lines in try-catch", IsEnabled(RefactoringIdentifiers.WrapLinesInTryCatch))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapStatementsInUsingStatement, "Wrap statements in 'using' statement", IsEnabled(RefactoringIdentifiers.WrapStatementsInUsingStatement))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.AddGenericParameterToDeclaration, "Add generic parameter to a declaration", IsEnabled(RefactoringIdentifiers.AddGenericParameterToDeclaration))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ImplementIEquatableOfT, "Implement IEquatable", IsEnabled(RefactoringIdentifiers.ImplementIEquatableOfT))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.InlineUsingStaticDirective, "Inline using static directive", IsEnabled(RefactoringIdentifiers.InlineUsingStaticDirective))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.InlineConstantDeclaration, "Inline constant declaration", IsEnabled(RefactoringIdentifiers.InlineConstantDeclaration))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.UseStringBuilderInsteadOfConcatenation, "Use StringBuilder instead of concatenation", IsEnabled(RefactoringIdentifiers.UseStringBuilderInsteadOfConcatenation))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.UseListInsteadOfYield, "Use List instead of yield", IsEnabled(RefactoringIdentifiers.UseListInsteadOfYield))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.SplitIf, "Split if", IsEnabled(RefactoringIdentifiers.SplitIf))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveInstantiationOfLocalVariable, "Remove instantiation of a local variable", IsEnabled(RefactoringIdentifiers.RemoveInstantiationOfLocalVariable))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ChangeAccessibility, "Change accessibility", IsEnabled(RefactoringIdentifiers.ChangeAccessibility))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.WrapConstraintClauses, "Wrap constraint clauses", IsEnabled(RefactoringIdentifiers.WrapConstraintClauses))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertForEachToForAndReverseLoop, "Convert 'foreach' to 'for' and reverse loop", IsEnabled(RefactoringIdentifiers.ConvertForEachToForAndReverseLoop))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.InvertIf, "Invert if", IsEnabled(RefactoringIdentifiers.InvertIf))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.SplitIfElse, "Split if-else", IsEnabled(RefactoringIdentifiers.SplitIfElse))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.UseIndexInitializer, "Use index initializer", IsEnabled(RefactoringIdentifiers.UseIndexInitializer))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertCommentToDocumentationComment, "Convert comment to documentation comment", IsEnabled(RefactoringIdentifiers.ConvertCommentToDocumentationComment))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertInterpolatedStringToConcatenation, "Convert interpolated string to concatenation", IsEnabled(RefactoringIdentifiers.ConvertInterpolatedStringToConcatenation))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.SplitLocalDeclarationAndAssignment, "Split local declaration and assignment", IsEnabled(RefactoringIdentifiers.SplitLocalDeclarationAndAssignment))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.AddMemberToInterface, "Add member to interface", IsEnabled(RefactoringIdentifiers.AddMemberToInterface))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.MergeIfWithParentIf, "Merge if with parent if", IsEnabled(RefactoringIdentifiers.MergeIfWithParentIf))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.InitializeFieldFromConstructor, "Initialize field from constructor", IsEnabled(RefactoringIdentifiers.InitializeFieldFromConstructor))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.InlineProperty, "Inline property", IsEnabled(RefactoringIdentifiers.InlineProperty))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveEnumMemberValue, "Remove enum member value(s)", IsEnabled(RefactoringIdentifiers.RemoveEnumMemberValue))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.UncommentMultiLineComment, "Uncomment multi-line comment", IsEnabled(RefactoringIdentifiers.UncommentMultiLineComment))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertInterpolatedStringToStringFormat, "Convert interpolated string to 'string.Format'", IsEnabled(RefactoringIdentifiers.ConvertInterpolatedStringToStringFormat))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.MoveUnsafeContextToContainingDeclaration, "Move unsafe context to containing declaration", IsEnabled(RefactoringIdentifiers.MoveUnsafeContextToContainingDeclaration))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ExtractEventHandlerMethod, "Extract event handler method", IsEnabled(RefactoringIdentifiers.ExtractEventHandlerMethod))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.GeneratePropertyForDebuggerDisplayAttribute, "Generate property for DebuggerDisplay attribute", IsEnabled(RefactoringIdentifiers.GeneratePropertyForDebuggerDisplayAttribute))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.AddEmptyLineBetweenDeclarations, "Add empty line between declarations", IsEnabled(RefactoringIdentifiers.AddEmptyLineBetweenDeclarations))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.UseEnumeratorExplicitly, "Use enumerator explicitly", IsEnabled(RefactoringIdentifiers.UseEnumeratorExplicitly))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.SortCaseLabels, "Sort case labels", IsEnabled(RefactoringIdentifiers.SortCaseLabels))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.AddTagToDocumentationComment, "Add tag to documentation comment", IsEnabled(RefactoringIdentifiers.AddTagToDocumentationComment))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.RemoveAsyncAwait, "Remove async/await", IsEnabled(RefactoringIdentifiers.RemoveAsyncAwait))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ImplementCustomEnumerator, "Implement custom enumerator", IsEnabled(RefactoringIdentifiers.ImplementCustomEnumerator))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertStatementsToIfElse, "Convert statements to if-else", IsEnabled(RefactoringIdentifiers.ConvertStatementsToIfElse))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.CopySwitchSection, "Copy switch section", IsEnabled(RefactoringIdentifiers.CopySwitchSection))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.AddParameterToInterfaceMember, "Add parameter to interface member", IsEnabled(RefactoringIdentifiers.AddParameterToInterfaceMember))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ConvertSwitchExpressionToSwitchStatement, "Convert 'switch' expression to 'switch' statement", IsEnabled(RefactoringIdentifiers.ConvertSwitchExpressionToSwitchStatement))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.ExpandPositionalConstructor, "Expand positional constructor", IsEnabled(RefactoringIdentifiers.ExpandPositionalConstructor))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.AddAllPropertiesToInitializer, "Add all properties to initializer", IsEnabled(RefactoringIdentifiers.AddAllPropertiesToInitializer))); + refactorings.Add(new BaseModel(RefactoringIdentifiers.DeconstructForeachVariable, "Deconstruct foreach variable", IsEnabled(RefactoringIdentifiers.DeconstructForeachVariable))); + } } } \ No newline at end of file diff --git a/src/Workspaces.Common/CSharp/Refactorings/ConvertInterpolatedStringToStringBuilderMethodRefactoring.cs b/src/Workspaces.Common/CSharp/Refactorings/ConvertInterpolatedStringToStringBuilderMethodRefactoring.cs index d3ae5e834e..bcc98d10bb 100644 --- a/src/Workspaces.Common/CSharp/Refactorings/ConvertInterpolatedStringToStringBuilderMethodRefactoring.cs +++ b/src/Workspaces.Common/CSharp/Refactorings/ConvertInterpolatedStringToStringBuilderMethodRefactoring.cs @@ -71,6 +71,8 @@ public static (SyntaxKind contentKind, string methodName, ImmutableArray RefactorAsync( SyntaxNode parent = usingDirective.Parent; +#if ROSLYN_4_0 Debug.Assert(parent.IsKind(SyntaxKind.CompilationUnit, SyntaxKind.NamespaceDeclaration, SyntaxKind.FileScopedNamespaceDeclaration), ""); +#else + Debug.Assert(parent.IsKind(SyntaxKind.CompilationUnit, SyntaxKind.NamespaceDeclaration), ""); +#endif int index = SyntaxInfo.UsingDirectiveListInfo(parent).IndexOf(usingDirective); @@ -43,8 +47,10 @@ private static SyntaxNode RemoveUsingDirective(SyntaxNode node, int index) return compilationUnit.RemoveNode(compilationUnit.Usings[index]); case NamespaceDeclarationSyntax namespaceDeclaration: return namespaceDeclaration.RemoveNode(namespaceDeclaration.Usings[index]); +#if ROSLYN_4_0 case FileScopedNamespaceDeclarationSyntax fileScopedNamespaceDeclaration: return fileScopedNamespaceDeclaration.RemoveNode(fileScopedNamespaceDeclaration.Usings[index]); +#endif } return node; diff --git a/src/Workspaces.Core/Rename/SymbolRenameState.cs b/src/Workspaces.Core/Rename/SymbolRenameState.cs index 35550c9208..c79932f84c 100644 --- a/src/Workspaces.Core/Rename/SymbolRenameState.cs +++ b/src/Workspaces.Core/Rename/SymbolRenameState.cs @@ -756,6 +756,7 @@ IEnumerable GetLocations() try { +#if ROSLYN_4_4 var options = new Microsoft.CodeAnalysis.Rename.SymbolRenameOptions( RenameOverloads: Options.RenameOverloads, RenameInStrings: Options.RenameInStrings, @@ -769,6 +770,15 @@ IEnumerable GetLocations() newName, cancellationToken) .ConfigureAwait(false); +#else + newSolution = await Microsoft.CodeAnalysis.Rename.Renamer.RenameSymbolAsync( + CurrentSolution, + symbol, + newName, + default(Microsoft.CodeAnalysis.Options.OptionSet)!, + cancellationToken) + .ConfigureAwait(false); +#endif } catch (InvalidOperationException ex) { diff --git a/src/Workspaces.Core/Spelling/SpellcheckAnalyzer.cs b/src/Workspaces.Core/Spelling/SpellcheckAnalyzer.cs index 0ca1463b11..940e3c342c 100644 --- a/src/Workspaces.Core/Spelling/SpellcheckAnalyzer.cs +++ b/src/Workspaces.Core/Spelling/SpellcheckAnalyzer.cs @@ -486,6 +486,7 @@ private async Task> FixCommentsAsync( try { //TODO: detect naming conflict +#if ROSLYN_4_4 newSolution = await Microsoft.CodeAnalysis.Rename.Renamer.RenameSymbolAsync( CurrentSolution, symbol, @@ -494,6 +495,15 @@ private async Task> FixCommentsAsync( newName, cancellationToken) .ConfigureAwait(false); +#else + newSolution = await Microsoft.CodeAnalysis.Rename.Renamer.RenameSymbolAsync( + CurrentSolution, + symbol, + newName, + default(Microsoft.CodeAnalysis.Options.OptionSet), + cancellationToken) + .ConfigureAwait(false); +#endif } catch (InvalidOperationException #if DEBUG